Q: Gradient text is not working in safari browser.It is showing white color instead of gradient text Below is the code.Gradient not working in safari after using webkits also.

.gradientText{
  background: -webkit-linear-gradient(#862AA5, #CE3E81);
  background: -moz-linear-gradient(#862AA5, #CE3E81);
  background: -webkit-gradient(#862AA5, #CE3E81);
  background: -o-linear-gradient(#862AA5, #CE3E81);
  background:  -ms-linear-gradient(#862AA5, #CE3E81);
  background: linear-gradient(#862AA5, #CE3E81);
  //-webkit-mask-image: linear-gradient(#862AA5, #CE3E81);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  //border: 3px solid #fff;

}
<p class='gradientText'>text
</p>


Q: How to properly inline for static libraries I'm re-writing a small C math library of mine that will end up as a static library for the user and would like to benefit from inlining for my vector math interface.
I have the following:
[ mymath.h ]
...
...
extern float clampf( float v, float min, float max );
...
...

[ mymath.c ]
inline float clampf( float v, float min, float max )
{
    if( v < min ) v = min;
    if( v > max ) v = max;

   return v;
}

Since my library will be static and I'm only going to provide the .h (and the .lib) to the user, will the clampf function be inlined in their program when compiled?
Am I doing the right thing but declaring the function extern in the .h and inline in the .c?

A: You should define your function as static inline in the .h file:
static inline float clampf( float v, float min, float max )
{
    if( v < min ) v = min;
    if( v > max ) v = max;

    return v;
}

The function must be absent in the .c file.
The compiler may decide not to inline the function but make it a proper function call. So every generated .o file may contain a copy of the function.

A: You have it almost correct.  You actually have it backwards; for inline functions you must put the inline definition in the header file and the extern declaration in the C file.
// mymath.h
inline float clampf( float v, float min, float max )
{
    if( v < min ) v = min;
    if( v > max ) v = max;

    return v;
}

// mymath.c
#include "mymath.h"
extern float clampf( float v, float min, float max );

You have to put the definition (full body) in the header file, this will allow any file which includes the header file to be able to use the inline definition if the compiler chooses to do so.
You have to put the extern declaration (prototype) in the source file to tell the compiler to emit an extern version of the function in the library.  This provides one place in your library for the non-inline version, so the compiler can choose between inlining the function or using the common version.
Note that this may not work well with the MSVC compiler, which has very poor support in general for C (and has almost zero support for C99).  For GCC, you will have to enable C99 support for old versions.  Modern C compilers support this syntax by default.
Alternative:
You can change the header to have a static inline version,
// mymath.h
static inline float clampf(float v, float min, float max)
{
    ...
}

However, this doesn't provide a non-inline version of the function, so the compiler may be forced to create a copy of this function for each translation unit.
Notes:

*

*The C99 inlining rules are not exactly intuitive.  The article "Inline functions in C" (mirror) describes them in detail.  In particular, skip to the bottom and look at "Strategies for using inline functions".  I prefer method #3, since GCC has been defaulting to the C99 method for a while now.

*Technically, you never need to put extern on a function declaration (or definition), since extern is the default.  I put it there for emphasis.


Q: How to set order of the nodes in Sankey Diagram Plotly So i am traying to make a cycle that gives different sankey diagram the thing is due to the plotly optimization the node are in different positions. I will like to set the standard order to be [Formal, Informal, Unemployed, Inactive]
import matplotlib.pyplot as plt
import pandas as pd
import plotly.graph_objects as go

df = pd.read_csv(path, delimiter=",")

Lista_Paises = df["code"].unique().tolist()

Lista_DF = []

for x in Lista_Paises:
    DF_x = df[df["code"] == x]
    Lista_DF.append(DF_x)

def grafico(df):
    df = df.astype({"Source": "category", "Value": "float", "Target": "category"})

    def category(i):
        if i == "Formal":
            return 0
        if i == "Informal":
            return 1
        if i == "Unemployed":
            return 2
        if i == "Inactive":
            return 3

    def color(i):
        if i == "Formal":
            return "#9FB5D5"
        if i == "Informal":
            return "#E3EEF9"
        if i == "Unemployed":
            return "#E298AE"
        if i == "Inactive":
            return "#FCEFBC"

    df['Source_cat'] = df["Source"].apply(category).astype("int")
    df['Target_cat'] = df["Target"].apply(category).astype("int")

    #    df['Source_cat'] = LabelEncoder().fit_transform(df.Source)
    #    df['Target_cat'] = LabelEncoder().fit_transform(df.Target)
    df["Color"] = df["Source"].apply(color).astype("str")
    df = df.sort_values(by=["Source_cat", "Target_cat"])
    Lista_Para_Sumar = df["Source_cat"].nunique()
    Lista_Para_Tags = df["Source"].unique().tolist()
    Suma = Lista_Para_Sumar
    df["out"] = df["Target_cat"] + Suma
    TAGS = Lista_Para_Tags + Lista_Para_Tags
    Origen = df['Source_cat'].tolist()
    Destino = df["out"].tolist()
    Valor = df["Value"].tolist()
    Color = df["Color"].tolist()

    return (TAGS, Origen, Destino, Valor, Color)

def Sankey(TAGS: object, Origen: object, Destino: object, Valor: object, Color: object, titulo: str) -> object:
    label = TAGS
    source = Origen
    target = Destino
    value = Valor
    link = dict(source=source, target=target, value=value,
                color=Color)
    node = dict(x=[0, 0, 0, 0, 1, 1, 1, 1], y=[1, 0.75, 0.5, 0.25, 0, 1, 0.75, 0.5, 0.25, 0], label=label, pad=35,
                thickness=10,
                color=["#305CA3", "#C1DAF1", "#C9304E", "#F7DC70", "#305CA3", "#C1DAF1", "#C9304E", "#F7DC70"])
    data = go.Sankey(link=link, node=node, arrangement='snap')
    fig = go.Figure(data)
    fig.update_layout(title_text=titulo + "-" + "Mujeres", font_size=10, )
    plt.plot(alpha=0.01)
    titulo_guardar = (str(titulo) + ".png")
    fig.write_image("/Users/agudelo/Desktop/GRAFICOS PNUD/Graficas/MUJERES/" + titulo_guardar, engine="kaleido")

for y in Lista_DF:
    TAGS, Origen, Destino, Valor, Color = grafico(y)
    titulo = str(y["code"].unique())
    titulo = titulo.replace("[", "")
    titulo = titulo.replace("]", "")
    titulo = titulo.replace("'", "")
    Sankey(TAGS, Origen, Destino, Valor, Color, titulo)

The expected result should be.
The expected result due to the correct order:

The real result i am getting is:

A: I had a similar problem earlier. I hope this will work for you. As I did not have your data, I created some dummy data. Sorry about the looooong explanation. Here are the steps that should help you reach your goal...
This is what I did:

*

*Order the data and sort it - used pd.Categorical to set the order and then df.sort to sort the data so that the input is sorted by source and then destination.

*For the sankey node, you need to set the x and y positions. x=0, y=0 starts at top left. This is important as you are telling plotly the order you want the nodes. One weird thing is that it sometimes errors if x or y is at 0 or 1. Keep it very close, but not the same number... wish I knew why

*For the other x and y entries, I used ratios as my total adds up to 285. For eg. Source-Informal starts at x = 0.001 and y = 75/285 as Source-Formal = 75 and this will start right after that

*Based on step 1, the link -> source and destination should also be sorted. But, pls do check.

Note: I didn't color the links, but think you already have achieved that...
Hope this helps resolve your issue...
My data - sankey.csv
source,destination,value
Formal,Formal,20
Formal,Informal, 10
Formal,Unemployed,30
Formal,Inactive,15
Informal,Formal,20
Informal,Informal,15
Informal,Unemployed,25
Informal,Inactive,25
Unemployed,Formal,5
Unemployed,Informal,10
Unemployed,Unemployed,10
Unemployed,Inactive,5
Inactive,Formal,30
Inactive,Informal,20
Inactive,Unemployed,20
Inactive,Inactive,25

The code
import plotly.graph_objects as go
import pandas as pd
df = pd.read_csv('sankey.csv') #Read above CSV

#Sort by Source and then Destination
df['source'] = pd.Categorical(df['source'], ['Formal','Informal', 'Unemployed', 'Inactive'])
df['destination'] = pd.Categorical(df['destination'], ['Formal','Informal', 'Unemployed', 'Inactive'])
df.sort_values(['source', 'destination'], inplace = True)
df.reset_index(drop=True)

mynode = dict(
      pad = 15,
      thickness = 20,
      line = dict(color = "black", width = 0.5),
      label = ['Formal', 'Informal', 'Unemployed', 'Inactive', 'Formal', 'Informal', 'Unemployed', 'Inactive'],
      x = [0.001, 0.001, 0.001, 0.001, 0.999, 0.999, 0.999, 0.999],
      y = [0.001, 75/285, 160/285, 190/285, 0.001, 75/285, 130/285, 215/285],
      color = ["#305CA3", "#C1DAF1", "#C9304E", "#F7DC70", "#305CA3", "#C1DAF1", "#C9304E", "#F7DC70"])

mylink = dict(
    source = [ 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3 ],
    target = [ 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7 ],
    value = df.value.to_list())

fig = go.Figure(data=[go.Sankey(
    arrangement='snap',
    node = mynode,
    link = mylink
)])

fig.update_layout(title_text="Basic Sankey Diagram", font_size=20)
fig.show()

The output


Q: Bug in VBA in MSProject how to check if sub project is loaded in master project? If I place watch on the tmp variable and stop on the line If Not tmp Then both show up as true, I.e. tmp is True and Not tmp is True.
Dim subProj As Subproject
For Each subProj In prj.Subprojects
    Dim tmp As Boolean
    tmp = subProj.IsLoaded
    If Not tmp Then
        ExportTaskToExcel subProj.SourceProject, StartDate, EndDate
    End If
Next

What should I do to check if the subproject is not loaded (not expanded) in master project?
Look at image under this link which is showing that in the same time: True = not True

A: There is a chance you have tmp declared somewhere else that can be seen from here causing this issue (i.e. it is declared public in another module). Try changing the name to isolate it, also, I've never declared a variable in a loop before, While I'm not sure of the implications, I would not recommend it.
Dim subProj As Subproject
Dim tmp10 As Boolean
For Each subProj In prj.Subprojects
    tmp10 = subProj.IsLoaded
    If Not tmp10 Then
        ExportTaskToExcel subProj.SourceProject, StartDate, EndDate
    End If
Next

You may have done it for a specific reason but you could omit the variable altogether: -
Dim subProj As Subproject
For Each subProj In prj.Subprojects
    If Not subProj.IsLoaded Then
        ExportTaskToExcel subProj.SourceProject, StartDate, EndDate
    End If
Next


Q: Porting QT application from Linux to Windows? Greetings all,
We are developing a QT application (QT 4.6 LGPL version) in Linux platform.All the libraries we use are cross-platform.
Now we want to port it into Windows and continue develop in Windows.
My questions are:

*

*Which compiler should we use ,Can we use MinGW or Visual C++ compiler?

2.If its Visual C++ compiler, which Visual Studio version should be used ,can we use 'Visual C++ Studio 2010 express' ?
thanks in advance.

A: The easiest, by far, is to install QtCreator.  it includes MinGW and simply opens the same project files as on linux.  compile, and go!
A huge advantage of MinGW over VC++ is that it doesn't make you chase circles around getting the right vcredist library for the exact version of the compiler, nor it cares too much about debug/release builds.  To deploy, just be sure to copy the same one or two DLLs you have on the development machine.  A few more for Qt, but these are well-documented on Qt docs.  No hidden surprises.


Q: Citing a Web Page with no author For my thesis, I need to cite a lot of web-sources with no specific author. I'd like them to appear in the bibliography in the following format
<title> <year>, accessed <date accessed>,
<url>

and as (<title> <year>) within the text.
(as described in this guidelines http://www.lc.unsw.edu.au/onlib/ref_elec1.html#elec3 )
Is there an easy way how to achieve this?
I was looking into biblatex, but it seems to be rather complicated to create a custom source type...

A: See the biblatex manual, § 2.3.2:

2.3.2 Missing and Omissible Data
The fields marked as ‘required’ in § 2.1.1 are not strictly
  required in all cases. The bibliography styles which ship with
  this package can get by with as little as a title field for most
  entry types. A book published anonymously, a periodical without
  an explicit editor, or a software manual without an explicit
  author should pose no problem as far as the bibliography is
  concerned. Citation styles, however, may have different
  requirements. For example, an author-year citation scheme obviously requires an author/editor and a year field.
You may generally use the label field to provide a substitute for
  any missing data required for citations. How the label field is
  employed depends on the citation style. The author-year
  citation styles which come with this package use the label field
  as a fallback if either the author/editor or the year is
  missing. The numeric styles, on the other hand, do not use it at
  all since the numeric scheme is independent of the available
  data. The author-title styles ignore it as well, be- cause the
  bare title is usually suƿcient to form a unique citation and a
  title is expected to be available in any case. The label field
  may also be used to override the non-numeric portion of the
  automatically generated labelalpha field used by alphabetic
  citation styles. See § 4.2.4 for details.

So, depending on the citation style you choose, you might just go with something like this:
@online{question64352,
  title = {Citing a Web Page with no author},
  url = {http://tex.stackexchange.com/questions/64352/citing-a-web-page-with-no-author},
  urldate = {2012-07-23}}


Q: sIFR 3 - sifr-config.js possibly not running? Not sure what's wrong I've been messing with this for a few hours, and I just can't get the text to be replaced at all.  I really can't believe it's taking so long, especially because I did this a few months ago and got it to work in minutes.
Anyway, here is my site I'm working on:
http://www.moreheadplanetarium.org/regeneration/test/vision.php
and I want to replace the h1 tag (Morehead's Vision).  I don't know what's wrong, since I've done everything I know to do. I'm jumping back into web design and using Firebug, and when I check the scripts it only has sifr.js and sifr-debug.js in the list, so I'm assuming the config isn't loading but I have no idea what could be the hold up...
How do you get the debug to work btw?
thanks!

A: There's a syntax error at the end of sifr-config.js.


Q: Asp.net MVC binding ajax data to a submit button I have ajax code that gets data from a radio button.
  $("input[name='SelectedCG']").on('change', function () {
        $.ajax({
            url: '@Url.Action("FilterReports", "Reports")',
            data: { cgName: $("input[name='SelectedCG']:checked").val() },
            type: 'POST',
            success: function (data) {
                $('#reportTable').html(data);
                $('#reportTable').show();
            },
            error: function(xhr, status, error)
            {
                alert(xhr.responseText);
            }
        })
    });

I want to bind this data to a submit button which can pass this information to a method in a controller.
<input type="submit" value="Export" class="btn btn-primary btn-large" onclick="location.href='@Url.Action("Export", "Reports")'">

Any help would be appreciated!

A: It is better to pass the value of the radioButton to the Export method and get the data again. In any case you might need to do some more work on that data before you export it any way.
Also you might want to check the user's permissions to export such data.
Also you might not want to transfer such data over the network back and forth. It is easier (faster) to send the value of a button than it is to send a collection of data which has to be exported.
Not to mention that there are also security concerns depending on how you will handle the data you receive and if it is correct or not? What If a user changes it manually in the browser before hitting the export button? Would that hurt your application's logic in some way and would you want to protect yourself against that?
Best is to use an HttpPost, to include AntiForgeryToken, to submit the radio button value and check the user's permissions.


Q: How to read my String correctly in html and mvc? I'm using MVC, getting a certain message this way
[HttpGet]
    public virtual ActionResult Message(int ID)
    {
        Models.Userr.Message model = new Models.User.Message();

        String getMessage = userService.getMessage(ID);
        model.Message = getMessage;
        return View(model);
    }

Then in the view I'm writting in the View:
@Model.Message

And it is writting in my screen, for example:
Hello Google.

yet, it is being read as string. So my problem and question is:
what can I use in either MVC (in the controller) or Html (in the View) in order to detect the link.
Also
I'm using the userservce.getMessage(int ID) to get a message related to a certain ID from a table of errors.

A: I think what you're looking for is Raw
@Html.Raw(Model.Message)

This will write Model.Message's contents as html instead of text.


Q: How to delete more than one relationship in neo4j using cypher? I want to remove more than one relationship but not all relationship for specific node,
I can delete single relationship or every relationship but not more than one specific relationship
match(n:Student{id:2),
(n)-[r1:STUDENT_CLASS]->(b:Class),
(n)-[r2:STUDENT_RANK]->(m:Rank)
delete r1,r2
return n.name

I connected Student node with 3 common nodes(School,Class,Rank) with different relationship.
I want to delete 2 relationship(Class,Rank) for particular student in same query without affecting another node's(School) relationship with Student node.

A: Your query is logically correct but syntactically wrong:
match(n:Student{id:2), <--- missed a closing curly brace here
(n)-[r1:STUDENT_CLASS]->(b:Class),
(n)-[r2:STUDENT_RANK]->(m:Rank)
delete r1,r2
return n.name

Try this:
match(n:Student{id:2}),
(n)-[r1:STUDENT_CLASS]->(b:Class),
(n)-[r2:STUDENT_RANK]->(m:Rank)
delete r1,r2
return n.name

A: The vertical stroke | acts as an OR operator when selecting relationships:
match (n:Student {id:2})-[r:STUDENT_CLASS|STUDENT_RANK]->(b)
where b:Class or b:Rank
delete r


Q: The electric current discharging in a R-C circuit is given by $i=i_0e^{\frac{-t}{RC}}$, where are $i_0, R, C$ are constant parameters. t is time. Let $i_0=2.00 units$, $R=(6.00)10^5 unit$ and $C=(0.500)10^{-6}$. Find the rate of change of current at t=0.3s
The answer need to be obtained by differentiating wrt t
$$\frac{di}{dt}=[i_0][e^{\frac{-t}{RC}}][\frac{-1}{RC}$$
Inputting the values
$$-[2][e^{\frac{-0.3}{0.3}}][\frac{1}{0.3}]$$
Since $RC=(30)10^{-2}$
$$\frac{2}{0.3e}$$
I don’t think it can be simplified further. The right answer is, however, $\frac{2}{3e}$. Either I am wrong or the solution is wrong. Who is right?
(Derivative calculators don’t give a meaningful answer, please dont send me links, I have already tried them.)

A: I don't see any mistakes in your calculations (apart from not including a negative sign at the end as discussed below). Based on
$$i = i_0 e^{-t/(RC)} \tag{1}\label{eq1}$$
then with $i_0$ and $RC$ being constant, differentiating gives what you stated, i.e.,
$$\frac{di}{dt} = i_0 e^{-t/(RC)}\left(\frac{-1}{RC}\right) \tag{2}\label{eq2}$$
Thus, based on your provided values, $i_0 = 2$, $R = 6 \times 10^5$, $C = 0.5 \times 10^{-6}$ and $t = 0.3$, we get $RC = (6 \times 10^5) \times (0.5 \times 10^{-6}) = 3 \times 10^{-1} = 0.3$. Thus, $e^{-t/(RC)} = e^{-0.3/0.3} = e^{-1} = \frac{1}{e}$ and $\frac{-1}{RC} = \frac{-1}{0.3}$.
As such, the answer you gave of $\frac{2}{0.3e}$ should be $\frac{-2}{0.3e}$ (I assume you are just focusing on the absolute value part, i.e., by how much the current is decreasing). The "right" answer of $\frac{2}{3e}$ is $\frac{1}{10}$ of your answer and is incorrect.


Q: Appgyver Steroids Simulator Build Submit to Facebook My app is nearing completion (HECK YEAH!) and we are needing some extended Facebook permissions.   Following Facebook's instructions for submitting an app, it requires that I do a Simulator build.   However, the Appgyver Facebook plugin doesn't work on the simulator so I have to use their build service to even test the Facebook functionality.
Does anyone have any clue as to how to build an Appgyver Steroids app for iOS so that I can submit it to Facebook for review?
Thanks!

A: There's currently no support for custom simulator builds. That's something that we've considered but there has not been a real use case yet. Since Facebook now wants to review iOS builds using a Simulator build, we'll need to add support for that at some point soon.
We can continue over email to get your application submitted for review before we can offer custom simulator builds from the Build Service.

Edit: Custom Simulator builds have now been available since spring 2015.


Q: how to set the required validator for an input field in jquery? I have a page which has a GridView placed in an update panel. Each row in the GridView has a update button, when clicked, a modal dialog will pop up, where you could edit the corresponding row and save the record to the database through a web service call.  Following is the aspx and jquery code. My question is I want to make the txtName and txtDescription required. As you can see, the Save button in the modal dialog gets created in the jquery function. How should I add required field validator to those fields? And when the user clicking the Save button, if the txtName or txtDescription is empty, a red label with text “required!” will should next to it, the focus will set to the first field that is empty.

        <asp:UpdatePanel ID="upMainPanel" runat="server" RenderMode="Inline" UpdateMode="Conditional">
            <ContentTemplate>

                            <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
                                AllowSorting="false" AutoGenerateColumns="False" PageSize="20"
                                onpageindexchanging="GridView1_PageIndexChanging">
                            <Columns>
                                <asp:TemplateField >
                                    <ItemTemplate>

<input type="button" value="update" />

                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField >
                                    <HeaderTemplate>Vendor

                                        <asp:DropDownList ID="ddlVendor" runat="server" AutoPostBack="true" AppendDataBoundItems="true" OnSelectedIndexChanged="OnVendorChanged">
                                            <asp:ListItem Text="- Select a Vendor -" Value=""></asp:ListItem>
                                        </asp:DropDownList>
                                    </HeaderTemplate>
                                    <ItemTemplate><%#Eval("Vendor") %></ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Name" >
                                    <ItemTemplate><%#Eval("Name")%></ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Description" >
                                    <ItemTemplate><%#Eval("Description")%></ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            </asp:GridView>

            </ContentTemplate>
        </asp:UpdatePanel>

                Vendor:
                <select name="VendorList" id="VendorList"></select>

                Name:
                <input type="text" id="txtName"/>

                Description:
                <input type="text" id="txtDescription"/>

    this.BindEvents = function () {
        var myself = this;

        $(myself.get_element()).find("input[value='update']").each(
            function () {
                var input = $(this);

                if (input.closest('tr').find('td')[1].innerText.replace(' ', '') != '') {
                    input.click(
                        function () {
                            myself.UpdateButtonClicked(this);
                        }
                    );
                }
                else {
                    input.attr('disabled', 'disabled');
                }
            }
        );
    }
    this.UpdateButtonClicked = function (button) {
        var myself = this;
        var btns = {};
        var Vendor = "";
        var Name = "";
        var Description = "";

        …
        btns["Save"] = function () {
            myself.UpdateVendor(button);
        };

        btns["Cancel"] = function () { $("#dvUpdatePrompt").dialog('close'); };

        …
        $("#dvUpdatePrompt").dialog({
            modal: true,
            buttons: btns,
            width: 500,
            height: 300
        });
    }

    this.UpdateVendor = function (button) {
        var myself = this;

        …
        var parmIn = "…";

        myself.Utilities.CallWebService('WebService.asmx/UpateVendor', parmIn,
            function (result) {
                $("#dvUpdatePrompt").dialog('close');
                ...
            }
        );
    }

Update: I added following code to the this.BindEvents function: But it is not working?
$("#txtName").blur(function () {
            if (!$(this).val()) {
                $(this).parents('p').addClass('warning');
            }
        });


Q: Making a copy of an own object instead of a reference (updated post, different Q) solution
I am still getting the hang of it, and its probally logic for a lot of you. But I've updated the post with how I got it working, might some one come here by search.
declare:
var test=Element({"id" : 1, "name" : "wrapper"}).
      append(Element({"id" : 2, "name" : "elm A"}),
             Element({"id" : 3, "name" : "elm b"})
      );

alert(test.getInfo("name"));
alert(test.aArguments["children"][1].getInfo("name"));

'class':
var Element = function ($aPassArguments) {
    aArguments: {
            "id" : false,
            "name" : false,
            "type" : false,
            "title" : false,
            "style" : false,
            "action" : [],
            "parent" : false,
            "children" : []
        };
    for (var prop in this.aArguments)
            if (prop in $aPassArguments)
                this.aArguments[prop] = $aPassArguments[prop];
    return {
        append: function () {
            $argList = arguments;
            for ($i = 0; $i < $argList.length; $i++)
                if (typeof $argList[$i]=="string")
                    this.setChild(this.importDB($argList[$i],true));
                else
                    this.setChild($argList[$i]);
        },
         setChild: function($oChild) {
            this.aArguments["children"][this.aArguments["children"].length]=$oChild;
        }
    };
};

.............................................................
Previous edit
I wasnt aware a new object instance in javascript is a reference instead of a copy. Now I want to have a copy of my own object Element. Apperantly (thanks @blurd) I want it to be a factory hybrid:
 http://javascript.info/tutorial/factory-constructor-pattern
Thanks to the help of @blurd and me defining some problems, I came up with a sollution like the following:
(but I am not happying with my usage declaration below)
In which I finaly got copies of my Element object instead of references. The good answers below didnt completly solve my problem. But this is due to my poor clarification and understanding of the problems
Sort of solution
var Element = function (initialConfig) {

    return {
        aArguments: {
            "id" : false,
            "name" : false,
            "type" : false,
            "title" : false,
            "style" : false,
            "action" : [],
            "parent" : false,
            "children" : [],
        },

        create:function ($aPassArguments) {
            for (var prop in this.aArguments)
                if (prop in $aPassArguments)
                    this.aArguments[prop] = $aPassArguments[prop];
        },
        append: function () {
            $argList = arguments;
            for ($i = 0; $i < $argList.length; $i++)
                if (typeof $argList[$i]=="string")
                    this.setChild(this.importDB($argList[$i],true));
                else
                    this.setChild($argList[$i]);
        },
         setChild: function($oChild) {
            this.aArguments["children"][this.aArguments["children"].length]=$oChild;
        }
    };
};

usage
var test=Element();
test.create({"id" : 1, "name" : "wrapper"});
var test2=Element();
test2.create({"id" : 2, "name" : "elm A"});
test3.create({"id" : 3, "name" : "elm B"});
test.append(test2,test3);

alert(test.aArguments["name"]);
alert(test.aArguments["children"][0].aArguments["name"]);

Now I am very unhappy about the usage,I would like it be one line and use a constructor again. And this is probally possible, and... after some more selfschooling I will probally solve it. But for now I am done with it :P just updated my post with this. When I get to it again and have a beter declaration I will update it again. And perhaps someone might share a way (beter way) to do this.  To eventually have something like this:
var test=new Element({"id" : 3, "name" : "wrapper"})
           .append( new Element{"id" : 3, "name" : "elm A"}),
                    new Element({"id" : 3, "name" : "elm B"})
                  );

.............................................................................................
old post
I am pulling my hair outs here, everything I search about javascript and objects tells me the same, which is not enough, because I cant figure out why the following code isnt working propaly:
For example I am making an object like this:
var Element = {
    aArguments: {                                                       //set Default arguments
        "id" : false,
        "name" : false,
        "type" : false,
        "title" : false,
        "style" : false,
        "action" : [],
        "parent" : false,
        "children" : {},
    },
    create:function ($aPassArguments) {
        for (var prop in this.aArguments)
            if (prop in $aPassArguments)
                this.aArguments[prop] = $aPassArguments[prop];
        return this;
    },
    append: function () {
        $argList = arguments;
        for ($i = 0; $i < $argList.length-1; $i++)
            if (typeof $argList[$i]=="string")
                this.setChild(this.importDB($argList[$i],true));
            else
                this.setChild($argList[$i]);
        return this;
    },
    setChild: function($oChild) {
        this.aArguments["children"][this.aArguments["children"].length-1]=$oChild;
    },
    getInfo: function($sKey) {
        return this.aArguments[$sKey];
    }
};

Which merges $aPassArguments with this.Arguments on calling of .create() (I cant figureif its possible to use a '__constructor'). To replace given proparties in aArguments.
And add passed object(s) with .append to aArguments["childeren"].
But when I call the object like this:
$set=(Element.create({"id": 1, "name" : "wrapper"})).
     append(Element.create({"id" : 3, "name" : "elm A"}));
alert($set.getInfo("name"));

It will alert me "Elm A" and not "wrapper".
I assume that this is because I am not creating a new object of Element, but are working on the same object. Now to me the logical solution and start would be to write:
$set=(new Element.create({"id": 1, "name" : "wrapper"})).
     append(new Element.create({"id" : 3, "name" : "elm A"}));
alert($set.getInfo("name"));

but I get the error:
TypeError: (intermediate value).append is not a function
Why isnt my code not working as supposed by me?
And is it possible and if so how do I add a constructor to an object? So I could skip calling .create and use:
 $set=new Element({"id": 1, "name" : "wrapper"}).
     append(new Element({"id" : 3, "name" : "elm A"}));

A: You are right, you should be using the new operator.  Aside from that, it looks like you're trying to make this some type of factory hybrid.  I suggest the following.
Use a Constructor Function
Include an optional configuration that you can use when creating the object.
var Element = function (initialConfig) {
    if (initialConfig) {
        this.create(initialConfig);
    }
};

Add to the Prototype
All your shared Element members should be part of the prototype.
Element.prototype = {
    aArguments: {
        "id" : false,
        "name" : false,
        "type" : false,
        "title" : false,
        "style" : false,
        "action" : [],
        "parent" : false,
        "children" : {},
    },
    create:function ($aPassArguments) {
        for (var prop in this.aArguments)
            if (prop in $aPassArguments)
                this.aArguments[prop] = $aPassArguments[prop];
        return this;
    },
    append: function () {
        $argList = arguments;
        for ($i = 0; $i < $argList.length-1; $i++)
            if (typeof $argList[$i]=="string")
                this.setChild(this.importDB($argList[$i],true));
            else
                this.setChild($argList[$i]);
        return this;
    },
    setChild: function($oChild) {
        this.aArguments["children"][this.aArguments["children"].length-1]=$oChild;
    },
    getInfo: function($sKey) {
        return this.aArguments[$sKey];
    }
};

Examples
Your examples should now work as you expected.  Notice that you can't call new Element.create() as that would treat Element.create as a constructor.  Instead, pass your initial values into the constructor.
$set = new Element({"id": 1, "name" : "wrapper"}).
     append(new Element({"id" : 3, "name" : "elm A"}));

alert($set.getInfo("name"));

Be Careful
You're not checking for own properties in your loops, omitting {}, and I spotted at least one implied global.  JavaScript will bite you if you're not careful.  Consider using JSLint or JSHint to help you spot these problems.

A: Your create function does not create any object, but rather changes on place the Element. aArguments object.  Any strange thing might follow.
Anyway, just go for a clean and simple prototypal inheritance scheme, do not use $, remember to always declare your vars, and keep things simple :
function Element(initialValues) {
    this.id = this.prototype.id++;
    this.name = null;
    this.type = null;
    this.title = null;
    this.style = null;
    this.action = [];
    this.parent = null;
    this.children = [];
    for (var prop in initialValues)
        if (this[prop] != undefined) this[prop] = initialValues[prop];
}

Element.prototype = {
    append: function () {
        for (var i = 0; i < arguments.length - 1; i++) {
            var thisElement = arguments[i];
            if (typeof thisElement == "string") this.setChild(this.importDB(thisElement, true));
            else this.setChild(thisElement);
        }
        return this;
    },
    setChild: function (child) {
        this.children.push(child);
        return this;
    },
    getInfo: function (key) {
        return this[Key];
    },
    id: 0
};


Q: How to define n-th parent element by pure JavaScript? As in the title,
how can i define nth parentElement in js in other way than:
var theComment = e.target.parentElement.parentElement.parentElement.parentElement;

A: You can write a loop for it:
const n = 4
let elem = e.target
for(let i = 0; i < n; i++)
  elem = elem.parentElement
console.log(elem)

However, as mentioned in the comments, if you're looking for a specific element, it might be better to just write a selector for the element you're looking for.
This applies to your case even more, as event.target can return  child nodes of the watched element (if the event bubbles), making your parent count shift around a bit.

A: You might define a function which ascends up in the parent hierarchy with a loop, e.g.:
function nthParent(n, el) {
  while (n--) {
    el = el.parentElement;
    if (!el) return null;
  }
  return el;
}


Q: Laravel 5.7 and ExtJS 5 app configuration I am trying for the first time to create an application with Laravel 5.7 and ExtJS 5.
There is a lot of information for Laravel / Vue and Laravel / Angular applications, but for Laravel / ExtJS it is practically non-existent (unfortunately).
I created an ExtJS app called extjs_app with cmd that I put in the public folder of the Laravel project.
In the Laravel views folder I created a view named index_extjs.blade.php containing the index.html code of the ExtJS app with the following change:
<script id="microloader" type="text/javascript" src="bootstrap.js"></script>

replaced for
<script id="microloader" type="text/javascript" src="extjs_app/bootstrap.js"></script>

And in the bootstrap.js file (I probably should not edit this file):
Ext.manifest = Ext.manifest || "bootstrap.json";

replaced for
Ext.manifest = Ext.manifest || "extjs_app / bootstrap.json"

And in the app.json file
indexHtmlPath": "index.html"

replaced for
"indexHtmlPath": "../../../resources/views/index_extjs.php"

However, despite several attempts, the files required for the ExtJS application are not loaded.
How to properly configure Laravel and ExtJS to work together?

A: You need to set the root route for the entire application to be served with your blade view, in your case index_extjs.blade.php.
Why? Because when anyone opens up your site, you are loading up that page and hence, loading extjs too. After that page is loaded, you can handle page changes through extjs.
So to achieve this, you need to declare your root route to server this index file:
Route::get('/', function() {
    return view('index_extjs');
});

Also you need to revert all extjs config changes back to default, because everything will be relative to your extjs app inside public folder and not relative to the project itself. I hope this makes sense


Q: Hazelcast management center - Membres unable to communicate I have this config to connect:
config.getManagementCenterConfig().setEnabled(true);
config.getManagementCenterConfig().setUrl("http://localhost:8096/hazelcast-mancenter");

Error on management center console :
2019-05-29 12:44:27 [qtp873415566-15] WARN  org.eclipse.jetty.server.HttpChannel - /hazelcast-mancenter/collector.do
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.hazelcast.webmonitor.model.DeserializationException: nodeState field is null
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1655)
        at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:208)
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:347)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:263)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1634)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1317)

Error on Client springboot app console:
2019-05-29 12:54:27.059  INFO [-,,,] 12068 --- [           main] c.h.i.m.ManagementCenterService          : [10.1.204.138]:5701 [dev] [3.7.7] Hazelcast will connect to Hazelcast Management Center on address:
http://localhost:8096/hazelcast-mancenter
2019-05-29 12:54:27.090  INFO [-,,,] 12068 --- [           main] com.hazelcast.core.LifecycleService      : [10.1.204.138]:5701 [dev] [3.7.7] [10.1.204.138]:5701 is STARTED
2019-05-29 12:54:27.090  INFO [-,,,] 12068 --- [MC.State.Sender] c.h.i.p.impl.PartitionStateManager       : [10.1.204.138]:5701 [dev] [3.7.7] Initializing cluster partition table arrangement...
2019-05-29 12:54:27.115  INFO [-,,,] 12068 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'hazelcastInstance' of type [com.hazelcast.instance.HazelcastInstanceProxy] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-05-29 12:54:27.197  INFO [-,,,] 12068 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'cacheManager' of type [com.hazelcast.spring.cache.HazelcastCacheManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-05-29 12:54:27.205  INFO [-,,,] 12068 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'cacheAutoConfigurationValidator' of type [org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration$CacheManagerValidator] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-05-29 12:54:27.292  INFO [-,,,] 12068 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$a3818d32] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-05-29 12:54:27.342  INFO [-,,,] 12068 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.sleuth.instrument.web.client.feign.TraceFeignClientAutoConfiguration$FeignBeanPostProcessorConfiguration' of type [org.springframework.cloud.sleuth.instrument.web.client.feign.TraceFeignClientAutoConfiguration$FeignBeanPostProcessorConfiguration$$EnhancerBySpringCGLIB$$c6f962fb] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-05-29 12:54:27.385  INFO [-,,,] 12068 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.sleuth.instrument.async.AsyncDefaultAutoConfiguration' of type [org.springframework.cloud.sleuth.instrument.async.AsyncDefaultAutoConfiguration$$EnhancerBySpringCGLIB$$6f4b3654] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-05-29 12:54:28.645  INFO [-,,,] 12068 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8090 (http)
2019-05-29 12:54:28.667  INFO [-,,,] 12068 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-05-29 12:54:28.669  INFO [-,,,] 12068 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.15
2019-05-29 12:54:28.799  WARN [-,,,] 12068 --- [MulticastThread] c.h.i.cluster.impl.MulticastService      : [10.1.204.138]:5701 [dev] [3.7.7] Received a JoinRequest with a different packet version! This -> 4, Incoming -> -84, Sender -> /10.1.204.123
2019-05-29 12:54:29.260  INFO [-,,,] 12068 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-05-29 12:54:29.260  INFO [-,,,] 12068 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 12542 ms
2019-05-29 12:54:30.158  WARN [-,,,] 12068 --- [MC.State.Sender] c.h.i.m.ManagementCenterService          : [10.1.204.138]:5701 [dev] [3.7.7] Failed to send response, responseCode:405 url:http://localhost:8096/hazelcast-mancenter/collector.do

I don't see any configuration to be made to set the nodeStatus as described in errorstack trace.
Kindly let know what config to be made. Thanks!

A: As stated by @emre in comments, there is official text about it:

... the Management Center is compatible with Hazelcast IMDG cluster members having the same or the previous minor version. For example, Hazelcast Management Center version 3.12.x works with Hazelcast IMDG cluster members having version 3.11.x or 3.12.x.

from Hazelcast Management Center Documentation.
The Exception message (DeserializationException: nodeState field is null) is not really helpful to realize that.
The same happend to me, I was using Spring boot parent in version 1.5.9.RELEASE and therefore it had old the dependency of hazelcast (3.7.8). You can always check for versions of spring autoconfigured dependencies in spring-boot-dependencies projects's pom.xml file. There you can see hazelcast version in properties section defined like this:
<hazelcast.version>3.7.8</hazelcast.version>
You can

*

*change the spring-boot-starter-parent version to newer (e.g. 2.2.0.RELEASE) and the issue should dissapear or

*overwrite only the properties in your own pom.xml with newer hazelcast version.


Q: CS-CART Themeing I have been looking into using CS-CART as a shopping cart and started looking through the themes and it appears to me the only way to build a theme is to extend a default theme and use the theme editor and visual designer to construct themes. Is this the only way or is there a way to code custom themes without being limited to designing in the administration section?

A: The theme editor is intended to be used as a customization tool for the site administrator, not for the theme developer.
A theme may provide configuration for the theme editor - what colors can be changed, etc.
For the deep customization of how the site looks you can create you own theme with your own CSS code.
Check out this guide on how to create your custom theme - http://docs.cs-cart.com/4.3.x/designer_guide/theme_tutorial/index.html
Also there is an official Bootstrap 3 theme for CS-Cart which can be easily customized - https://github.com/cscart/cscart-boilerplate#the-cs-cart-boilerplate-theme

A: You are not limited, you have all the tools that you need to develop as you desire, the responsive theme is the base because this theme was tested enough so far and have good feedback and for somebody to start from scratch will take to much time and until you finish CS-Cart will do a big change and you will need to do another work ;)
Please check https://www.ambientlounge.ie and let me know if you find any limitations here :D

A: It's very easy modift cs-cart theme, cs-cart theme base on bootstrap and and smarty engine, firt you need looking for "index.tpl", "common/script.tpl", "common/style.tpl", "view/block_manager/render/grid.tpl || container.tpl || block.tpl || location.tpl. and you will understand cs-cart theme structure
You need to know smarty engine syntax here http://www.smarty.net/documentation
and cs-cart developer doc here http://docs.cs-cart.com/4.3.x/#designer-guide


Q: Android Webview Javascript window.location and checked problems I am having 2 related problem with javascript in webview.
The first is that when I check a checkbox in the html page it will sometimes but not always display the checkbox as checked. So, to help the user I also use a label and also set the onclick event to document.getElementById('checkbox')=checked and still it only sometimes works:
<input type="checkbox" class="big" id="checkbox' + (i-1) +'" name="activities" value="' + (i-1) + '">' + questionsTexts[i-1] + '

The second is that when I try to open a new page i use
function clickNextPage(url) {
        //write to cookies here

        //end write to cookies
        var HtmlStr = "ict4d_198_19815d.html?num_questions="+num_questions+"&";

        for(i=1; i<=num_questions; i++) {

            if (document.getElementById("checkbox" + (i-1)).checked)HtmlStr+="arrId"+(i-1)+"="+(i-1)+"&";
        }
        window.location=""+HtmlStr;
        return false;
    }

Originally I passed it to the activity and used loadUrl(url) but this did not work as i could not get the webview to loadUrl. I tried this.loadUrl webview.loadUrl super.loadUrl but nothing would work so I went back to doing it in the javascript code with window.location. Again, it only works sometimes. Tried window.location.href also to no avail.
All these issues don't exist in the HTC Desire but do in the Samsung Galaxy S.
Does anyone have a workaround that is foolproof?
Thanks.


Q: Sort-Object - differences when using console vs .ps1 file When running .ps1 file the sizes are sorted alphabetically (mixing MB and KB).
But when running in the console directly, it correctly sorts by folder size.
Both running on the same server.
Get-MailboxFolderStatistics -identity mailbox@domain.org | Sort-Object Foldersize -Descending | Format-Table folderpath, foldersize

Solution: turns out it had to do with using a Remote shell. Remote shell returns FolderSize as System.String rather than Microsoft.Exchange.Data.ByteQuantifiedSize


Q: Authorize to Apple Music via Facebook Messenger In-App Browser We're using https://developer.apple.com/documentation/musickitjs to authorize Apple music, on Desktop it opens a new window to authorize to apple.
But It's NOT working on mobile In-App Browser (both iOS & Android), probably because on mobile messenger, it's not possible to allow the opening of multiple windows.
Are we missing something here? Any workaround for it?
Has anyone done that?
Ref: https://developer.apple.com/forums/thread/117058


Q: Standard deviation of normal distribution density curve in Excel I have been ripping my worksheet around for a few hours now and I could not find related problems out here.
I want to see how the Excel normal distribution density curve shows the 68-95-99 rule.
I made two columns:
In A: -5 to 5, Inc. 0,02
In B: =NORM.DIST(A2;0;1;FALSE)

where A2 is X, $0$ is the mean value, $1$ is Stdev, false to show density.

When I am trying to calculate the Stdev using =Stdev.P(B2:B502) or =Stdev.S(B2:B502), it shows a different number ($=0.135$), even though in B, the parameter is $1$.
IMO, the density curve shows the distributions where $63\%$ of all situations are mapped within $1$ sigma. After my parameters in function Norm.Dist from Column B, this should be reflected in function =Stdev…
Glad if somebody could help!
Best regards,
Nicola

A: You are taking the standard deviation of the $y$ values of the PDF. This has nothing to do with the standard deviation of the normal distribution. The PDF values tell you the probability density at that value of $x$; they are not random variables from that distribution.
To create random variables with the standard normal distribution, first create a column of (say 1000) uniform random variables with Rand(). Then make a new column where you apply the function Norm.S.Inv to the column of uniform variable. (Or you can use Norm.Inv with some extra arguments if you want a different mean and variance than $0$ and $1$.) This is called inverse transform sampling and is the easiest way I know of to make normal RVs in Excel (though I'm not sure, they may have a built in now).
If you take the stddev of your normals, you should get something close to one. If you want to plot the empirical distribution, I know of no other way than to make a histogram (again, take my statement that this is the only way with a grain of salt).

A: The normal density curve is not the same as a normal random variable. You plotted 500 points along the normal density curve and then found the sample standard deviation of these values. But the graph only takes on values between 0 and 0.4, while a normal random variable can take on any positive or negative number, so the standard deviation of the density graph is not the standard deviation of the random variable. When you specify that your normal distribution has standard deviation 1, you mean that if you generated a lot of these random variables, their standard deviation would be close to 1. To get the probability that the random variable takes on values between two numbers, you have to look at the $\textit{area under the curve}$ between those two points on the density graph.
To show the 68-95-99 rule, use the cumulative distribution functions (which gives the probability that the random variable is less than a particular value, this is equivalent to the area under the density curve to the left of that same value). Then the cumulative function at 1 minus the cumulative function at -1 gives 0.68, i.e, 68% of the time the random variable will take on a value between -1 and 1.


Q: slapd.d missing after installation I am following the instructions on https://www.openldap.org/doc/admin24/quickstart.html to install OpenLDAP on RedHat. Everything goes fine until step 9:

Import the configuration database
You are now ready to import your configration database for use by slapd(8), by running the command:
su root -c /usr/local/sbin/slapadd -n 0 -F /usr/local/etc/slapd.d -l /usr
/local/etc/openldap/slapd.ldif

Then I get the error: su: invalid option -- 'n'
Then I tried only running /usr/local/sbin/slapadd -n 0 -F /usr/local/etc/slapd.d -l /usr/local/etc/openldap/slapd.ldif since I already logged in as the root user, then I get this error:
 5bcca422 invalid config directory /usr/local/etc/slapd.d, error 2
 slapadd: bad configuration directory!

My installation prefix is the default /usr/local/
I find there is no slapd.d under /usr/local/etc directory. What's the problem? Thanks!
Additional Information: When I ranmake in step 5, I got an error: fatal error:ltdl.h: No such file or directory, then I installed it with yum install libtool-ltdl-devel, and repeated step 5. When I ran make test in step 6, there is no error. I don't know if this piece of additional information could help.

A: The default location of configuration files is specified as build configuration option --sysconfdir. The default depends on value used for --prefix.
$ ./configure --help
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]

So what's actually used in your case depends on the build configuration.
When starting slapd you can also specify the configuration to be used with command-line options -f for static config or -F for directory holding the dynamic config. This is very handy for using a local test-bed config or to stay away completely from what OS packages mess around during package installation.
The man-page slapd(8) locally installed on your system will show you the actual default values of your build. Bear in mind that man-pages provided by OS packages are different from your local builds from source.
Also I'd recommend not to use the RHEL/CentOS packages. You should use pre-built RPMs provided by LDAP Toolbox project. They use build option --prefix=/usr/local/openldap and therefore dynamic config DB would be in default location /usr/local/openldap/etc/openldap/slapd.d/.
See also: slapd(8)

A: To avoid su: invalid option -- 'n' error, you can put quotes as the below:
su root -c '/usr/local/sbin/slapadd -n 0 -F /usr/local/etc/slapd.d -l /usr
/local/etc/openldap/slapd.ldif'

Notice that I have put the part after -c inside the quotes.
As far as slapd.d is concerned, creating the directory helped me:
sudo mkdir /usr/local/etc/slapd.d

The cli will promptly ask for password. After that, this is what looks like on my console,
_#################### 100.00% eta   none elapsed            none fast!

A: Maybe you can try:mkdir /usr/local/etc/slapd.d


Q: HTML/Javascript/CSS GUI for the development of desktop applications with python? I wonder if there's a python GUI like pyqt etc. which works purely with html and javascript for layouting desktop applications...
Do you know if there are projects like this? Does this make sense at all ;-) Or it it just me finding that a nice tool...

A: Since you mention PyQt yourself, you could perhaps just create a simple GUI using these tools, with your entire application made up of a QtWebKit module. Then just point to some files you created locally, and browse them using your appliction? But, this would not be any different compared to using a normal browser, so there's not really any point in doing this in my opinion...

A: If it were Python-based but had nothing to do with Python, would you really care if it wasn't Python based?
Anyways, yes, a project exists. A pretty big one too. It's called XULRunner. The project is maintained by Mozilla and is used for the GUI of every Mozilla program.
It features an XML-based syntax (XUL):
<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window id="main" title="My App" width="300" height="300" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <script type="application/javascript" src="chrome://myapp/content/main.js"/>

  <caption label="Hello World"/>
  <separator/>
  <button label="More >>" oncommand="showMore();"/>
  <separator/>
  <description id="more-text" hidden="true">This is a simple XULRunner application. XUL is simple to use and quite powerful and can even be used on mobile devices.</description>

</window>

And JavaScript:
function showMore() {
  document.getElementById("more-text").hidden = false;
}

You can even embed Python scripts, it seems, into your code: http://pyxpcomext.mozdev.org/no_wrap/tutorials/pyxulrunner/python_xulrunner_about.html

A: you could always use django, django templates support html, js, css, php etc.


Q: Best way to make object hash in Ruby? So I have a class wherein I need to override the equality operators. This is not so hard. But the custom equality operators aren't used unless my_obj.hash is equal for two objects being compared. so we need to override hash()
I'm kind of stuck on the best way to do this. My object embeds three other object instances. I see by example that for simple instance vars you can just take a hash of the vars themselves:
[var1, var2, var3].hash

More specifically, my class has instance vars for three embedded objects, let's call them:
A
B1
B2
Two instances of my object are equal if
object1.B1 == object2.B1 && object1.B2 == object2.B2 ||
      object1.B1 == object2.B2 && object1.B2 == object2.B1

In other words, the collection of B1 and B2 has the same two objects in it, regardless of which specific vars they're assigned to.
B1 and B2 have a custom equality mechanism as well.
I'm just not clear on the best strategy for overriding hash() here.
Sorry if the example is abstract, I'm trying to avoid posting a lot of code.

A: Try using a Set instead of an array so the order doesn't matter.  You have to have this line at the top:
require 'set'

Then make a Set containing both objects and use it to help implement the equality operator and hash method.  I assume Set#hash behaves correctly and your can use it in your hash method.  Set#== can be used to simplify your equality operator.
http://www.ruby-doc.org/stdlib-2.1.4/libdoc/set/rdoc/Set.html

A: Are your B1 and B2 objects sortable? If so, here's an easy implementation of your hash method:
class MyClass
  def hash
    return [self.B1, self.B2].sort.hash
  end
end

If they aren't currently sortable and it makes no sense to sort them by any inherent value, you could always just sort by object_id:
class BClass
  include Comparable

  def <=> (other)
    case other
    when BClass then return (self.object_id <=> other.object_id)
    else return nil
    end
  end
end

This enables your B1 and B2 objects to sort themselves versus each other, while throwing "ArgumentError: comparison of X with Y failed" versus instances of any other class.
If you're going the route of using object_id, though, it may just be easier to implement your hash method using that to begin with:
class MyClass
  def hash
    return [self.B1.object_id, self.B2.object_id].sort.hash
  end
end

but this will mean only self-same objects will correctly turn up as equal, and not just objects that "look" alike. To understand what I mean, compare the following:
# Comparison of look-alike objects
"a".object_id == "a".object_id  # => false

# Comparison of self-same objects
a = "a"
a.object_id == a.object_id      # => true

A: I assume the hash value can be any object as long as it is unique in each object in your case.  If that assumption is correct, how about defining the object hash() method returns as an array, for example?
I am not 100% clear what you are trying to achieve.  But I have interpreted the order of self.B1 and self.B2 does not matter.  Then this is a possibility:
def hash
  [self.B1.hash, self.B2.hash].sort
end

Then you can compare hash() of two objects with
(my_obj1.hash == my_obj2.hash)


Q: Problem applying Cauchy's estimate in proof Let $f$ is an analytic map from the unit disk to itself.
Taylor series of $f$ centered at 0: $f=\sum_n a_n z^n$ ).
Prove that: $|a_n|\leq 1 \; \forall n$
I've started using Cauchy's estimate:
$|a_n|=\frac{f^{(n)}(0)}{n!}\leq \frac{M_r}{r^n}$ with $M_r=\max\{|f(z)|: |z|=r\}$
We see that: $M_r\leq 1 $ and $r=1$. But why is this ($M_r\leq 1 $ and $r=1$) the case ?

A: You have $M_r \leqslant 1$ because by assumption $f$ maps the unit disk to itself, so $\lvert f(z)\rvert < 1$ for all $z$ with $\lvert z\rvert < 1$.
The assumptions don't allow you to set $r = 1$, since $f$ need not be defined, let alone continuous, on the boundary of the disk, the circle $\lvert z\rvert = 1$. But you have
$$\lvert a_n \rvert \leqslant \frac{M_r}{r^n} \leqslant \frac{1}{r^n}$$
for all $r < 1$, so you can take the limit $r \to 1$ to conclude $\lvert a_n\rvert \leqslant 1$.


Q: How would it be possible that adaptive cards in Microsoft Teams for Android never be cropped (using c#)? In Microsoft Teams for Windows the Adaptive Cards look like this:

And in Microsoft Teams for Android the same Adaptive Cards look this way:

I'm using LG-files (Microsoft Language Generation files) and Microsoft.Bot.Builder.Dialogs.
Is there a solution to prevent that adaptive cards were being cropped in Microsoft Teams for Android?
Here is the code of the first part:
{
"type": "AdaptiveCard",
"body": [
    {
        "type": "ColumnSet",
        "columns": [
            {
                "type": "Column",
                "width": "auto",
                "items": [
                    {
                        "type": "ActionSet",
                        "actions": [
                            {
                                "type": "Action.Submit",
                                "title": "Ja, einverstanden.",
                                "data": {
                                    "msteams": {
                                        "type": "messageBack",
                                        "text": "Ja, einverstanden.",
                                        "displayText": "Ja, einverstanden."
                                    }
                                }
                            }
                        ]
                    }
                ]
            },
            {
                "type": "Column",
                "width": "auto",
                "items": [
                    {
                        "type": "ActionSet",
                        "actions": [
                            {
                                "type": "Action.Submit",
                                "title": "Nein",
                                "data": {
                                    "msteams": {
                                        "type": "messageBack",
                                        "text": "Nein",
                                        "displayText": "Nein"
                                    }
                                }
                            }
                        ]
                    }
                ]
            },
            {
                "type": "Column",
                "width": "auto",
                "items": [
                    {
                        "type": "ActionSet",
                        "actions": [
                            {
                                "type": "Action.Submit",
                                "title": "Weitere Infos",
                                "data": {
                                    "msteams": {
                                        "type": "messageBack",
                                        "text": "Weitere Infos",
                                        "displayText": "Weitere Infos"
                                    }
                                }
                            }
                        ]
                    }
                ]
            }
        ]
    }
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}

Thank you Tim Cadenbach. Your example looks like this on Android:

This means that only the first button was displayed and it was cropped.
On Windows, it Looks like this:

The first and second buttons have been cropped.
All buttons are located one above the other and not side by side.
I considered adding a case distinction and programming other adaptive cards for mobile devices. How can I find out what device it is? With channels from Microsoft.Bot.Connector I can find out that the channel is MS Teams. But how the device?

A: This is the default behaviour of Mobile adaptive card actions. Adaptive card renders the buttons according to the width of the screens and provides you a scroll bar below to scroll through the buttons.

A: Updated Answer:
This is a known issue in the MS Teams Mobile App already raised with the team here:
https://github.com/microsoft/AdaptiveCards/issues/3919
Someone is working on it and it should be solved in the next month.


Q: flask-sqlalchemy - change lazy in different situations Take the example in document
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), nullable=False)
    addresses = db.relationship('Address', lazy='dynamic',
        backref=db.backref('person', lazy='select'))

We can only set the lazy parameter to relationship when we build the models. But I found no document show how to change it after  instantiated it.
In most of my situation like
user = User.query.first()
addresses = user.addresses.filter(is_del=0).all()

which is One-to-Many or
wallet = user.wallet

which is One-to-One Model, I just set the lazy to dynamic or select to let the model only get data what I need.
However recently I want to export the data in database using Admin Front-end page.
user_list = UserModel.query.all()
for x in user_list:
    item = {
        "ID": x.id if x.id else ''
    }
    if 'basic' in fields or is_all_field == 1:
        ex_item = {
            "Email": x.base.account,
            "Full Name": x.base.full_name,
            "Display Name": x.display_name if x.display_name else '',
            "Phone Number": x.base.phone_number if x.base.phone_number else '',
            "Status": status_map(x.is_sharer,x.is_block,x.status_id)
            "Register Time": x.create_date.strftime('%Y-%m-%d %H:%M:%S') if x.create_date else ''
        }
        item = {**item, **ex_item}
    if ......
    ........

If I continue to use select and dynamic as lazy. It will be very very slow cause every loop the parent query will access database every time when it use subquery.
I test the speed between select and joined using single field like "Full Name": x.base.full_name to export all user data. Select got 53s and joined got 0.02s.
Is there a way to change the lazy parameter based on not changing the original Model?

A: According to the documentation you can use options to define the type of loading you want. I believe it will override your default value defined in your relationship
Useful links
Joined Loads
Select Loads
Lazy Load

A: So, basically, if you are using lazy=' select', lazy load, and want to switch to joinedload to optimize your query, use the following:
from sqlalchemy.orm import joinedload  # import the joinedload
user_list = db.session.query(UserModel).options(joinedload("person"))  # running a joinedload which will give you access to all attributes in parent and child class
for x in user_list:
    # now use x.account directly


Q: "binding" between factory and controller I'm trying to return a scope for binding from a factory to a controller. it would be ideal if i could pass the name so it could be dynamic. Here's what I have so far
.factory('urlWatch', function (urlFactory) {
    var _this = this;
    return {
        listenToUrl: function (scope, moduleName, stateName) {
          scope.$on('$locationChangeSuccess', function (event) {
            console.log(scope.bind);
            scope = urlFactory.parseState(moduleName, stateName);

          });
        }
    };
    return _this;
});

and in the controller I have
$scope.mod1m3 = urlWatch.listenToUrl($scope, "module1", "mod1");

So this does not work but if I change the factory to look like this
 listenToUrl: function (scope, moduleName, stateName) {
          scope.$on('$locationChangeSuccess', function (event) {
            console.log(scope.bind);
            scope.mod1m3 = urlFactory.parseState(moduleName, stateName);

          });
        }

What i was trying to do is change it to
  listenToUrl: function (scope, moduleName, stateName, bind) {
          scope.$on('$locationChangeSuccess', function (event) {

            scope.bind = urlFactory.parseState(moduleName, stateName);

          });
        }

and
  $scope.mod1m3 = urlWatch.listenToUrl($scope, "module1", "mod1", "mod1m3");

however it doesn't seem to want to connect the 2, I'm getting :
 TypeError: Cannot read property '$on' of undefined

Unsure how i can get it to connect to get it to work as intended. Thanks!

A: As the $scope attributre should be dynamic and saved in variable bind use:
listenToUrl: function (scope, moduleName, stateName, bind) {
  scope.$on('$locationChangeSuccess', function (event) {

    // use scope like an associative array
    scope[bind] = urlFactory.parseState(moduleName, stateName);
  });
}

In the controller it is sufficient, if you use.
urlWatch.listenToUrl($scope, "module1", "mod1", "mod1m3");

$scope.mod1m3 will then be whatever parseState returns


Q: Is the matrix norm $\mu(A)=n\max_{i,j}|a_{ij}|$ for $A\in\mathbb R^{n\times n}$ NOT compatible with any vector norm on $\mathbb R^n$? Define $\mu(A)=n\max_{i,j}|a_{ij}|$ for $A\in\mathbb R^{n\times n}$. We can easily verify it is a matrix norm:
\begin{align}
\mu(AB) &=n\max_{i,j}|\sum_{k}a_{ik}b_{kj}| \\
& \leq n\max_{i,j}\sum_{k=1}^n|a_{ik}||b_{kj}|\\
&\leq n(n\max_{i,j,k,k'}|a_{ik}||b_{k'j}|)\\
&=(n\max_{i,k}|a_{ik}|)(n\max_{k',j}|b_{k'j}|)\\
&\leq\mu(A)\mu(B)
\end{align}
Is this matrix norm NOT compatible with any vector norm? I am trying to construct a counter example as follows: $A$ is a square matrix consisting of all ones, and $x$ is a column vector consisting of all ones. Then $Ax=(n,\cdots,n)^T$. However, if we use any $p$-norm, then we have
$$||Ax||_p=n^{1+1/p},\quad ||x||_p=n^{1/p},\quad \mu(A)=n$$
but this satisfies $||Ax||_p\leq\mu(A)||x||_p$ and is not a counterexample. Any help is appreciated.

A: There are no counterexamples, because the inequality holds for all $1\le p\le\infty$.
For $p\ge1$, (letting $\|A\|_\infty=\max_{ij}|A_{ij}|$)
\begin{align}
\|Ax\|_p&=\left(\sum_i|\sum_jA_{ij}x_j|^p\right)^{1/p}\\
&\le\|A\|_\infty\left(\sum_i\sum_j|x_j|^p\right)^{1/p}\\
&=\|A\|_\infty\ n^{1/p}\|x\|_p\le \mu(A)\|x\|_p
\end{align}
For $p=\infty$,
\begin{align}
\|Ax\|_\infty&=\max_i|\sum_jA_{ij}x_j|\\
&\le\max_i\sum_j|A_{ij}x_j|\\
&\le\|A\|_\infty\sum_j|x_j|\\
&\le\|A\|_\infty\ n\|x\|_\infty=\mu(A)\|x\|_\infty
\end{align}
Any other norm is equivalent to the standard norms, $$c\|x\|_2\le\|x\|\le d\|x\|_2$$ so continuity of $A$ is assured: $$\|Ax\|\le d\|Ax\|_2\le dn^{1/2}\|A\|_\infty\|x\|_2\le\frac{d}{c n^{1/2}}\mu(A)\|x\|$$
If the question is specifically about the inequality $\|Ax\|\le\mu(A)\|x\|$, then one must choose, for a counterexample, a norm such that $d>>c$. For example, take $\|(x_1,x_2)\|:=\sqrt{9x_1^2+x_2^2}$, $A=\begin{pmatrix}0&1\\1&0\end{pmatrix}$, $x=(0,1)$, to get $\|Ax\|=3$, $\mu(A)=2$, $\|x\|=1$.


Q: Graphic problem with Ubuntu 20.04 - random pixelated areas I am experiencing a problem since I installed Ubuntu 20.04 on a Dell XPS 13. Often the screen shows pixelated areas as the one in the figures below.

On the website I saw people experiencing similar problems, but couldn't find a solution.
The details of my graphic card are the following:
  *-display
   description: VGA compatible controller
   product: Intel Corporation
   vendor: Intel Corporation
   physical id: 2
   bus info: pci@0000:00:02.0
   logical name: /dev/fb0
   version: 01
   width: 64 bits
   clock: 33MHz
   capabilities: pciexpress msi pm vga_controller bus_master cap_list rom fb
   configuration: depth=32 driver=i915 latency=0 mode=3840x2400 visual=truecolor xres=3840 yres=2400
   resources: iomemory:600-5ff iomemory:400-3ff irq:206 memory:603e000000-603effffff memory:4000000000-400fffffff ioport:3000(size=64) memory:c0000-dffff memory:4010000000-4016ffffff memory:4020000000-40ffffffff

Any help is greatly appreciated!


Q: How to hide and show an object on scene in three.js I have an object which is composed of spheres on my scene. And I have a hide and show button.
The flow of my program is like that. For example, when I select one of the spheres (I used raycasting for select a sphere) then click the hide button, this sphere will be hidden. And after then click the show button it will be shown. But I don't know how can I do it.
I used three.js for creating my scene.
And I don't find any example for my question. How can I do it?
Thanks for your help.

A: Try this:
object.visible = false; //Invisible
object.visible = true;  //Visible

A: simply use the object traverse method to hide the mesh in three.js.
In my code hide the object based on its name
object.traverse ( function (child) {
    if (child instanceof THREE.Mesh) {
        child.visible = true;
    }
});

Here is the working sample for Object show/hide option
http://jsfiddle.net/ddbTy/287/
I think it should be helpful,..


Q: Ms dynamics crm 2013 subgrid overlap with its add button In Ms dynamics crm 2013 when we hide and show a subgrid using JavaScript visible function then subgrid's add button overlap with subgrid. Is there any way to resolve this issue.

A: You want to find the schema name of the sub grid.  You can do this by opening the form editor and then double clicking on the specific sub-grid.
To hide the sub-grid, you want to make sure to use supported JavaScript. To hide:
Xrm.Page.ui.controls.get('ProjectRisks').setVisible(false);

To show:
Xrm.Page.ui.controls.get('ProjectRisks').setVisible(false);

When testing, these worked fine for me.


Q: What are these GCC/G++ parameters? I've been using the UVa Online Judge to solve some programming challenges, and, when submitting my solutions, I'm told the judge will compile my code using the following parameters to GCC/G++ that I don't know: -lm -lcrypt -pipe -DONLINE_JUDGE.
What do they do? Thank you very much in advance!

A: "-lm -lcrypt" specifies to link with the math and cryptography libraries - useful if you're going to use the functions defined in math.h and crypt.h.  "-pipe" just means it won't create intermediate files but will use pipes instead.  "-DONLINE_JUDGE" defines a macro called "ONLINE_JUDGE", just as if you'd put a "#define" in your code.  I guess that's so you can put something specific to the judging in your code in an "#ifdef"/"#endif" block.


Q: What is the default working directory for a jar launched from Windows Explorer? I have created a jar file of my application so that users can run it from Windows Explorer. It loads a JSON file in its own working directory for some settings (using the path ".\config.json"). However, when I run it from the jar file from Windows Explorer, it cannot find the config file, while running the same jar from the command line works. I'm assuming this is because explorer sets the working directory to something other than the jar's folder. What does it set it to? (And how can I find the jar's own folder?)

A: Why not try printing out System.getProperty("user.dir"); and finding out what the application thinks?
user.dir    User's current working directory

use the following to get the PARENT of where you .jar is loading from, which is what it sounds like you want
import java.io.*;

public class Main
{
    public static void main(final String[] args) throws IOException
    {
        final File file = new File(".");
        System.out.println("file = " + file.getAbsoluteFile().getParent());
    }
}

The output when I run it from the command line or double clicking from Windows Explorer is:
file = c:\Users\Jarrod Roberson\Projects\SwingJarFinder

A: Looks like a duplicate of:
How to get the path of a running JAR file?
If your jar file is in your file system start here to get the current path:
ClassLoader.getSystemClassLoader().getResource(".").getPath();


Q: Extjs Set dirty false for form after saving I need to reset the form's dirty status to false after saving the form.
Form is configured for trackresetonload so that not set dirty for setvalue function.
I tried calling reset() but it resets the data in the form fields to its previous state(ie initial value).
Is there a way to do this,
Thanks.

A: formpanel.setValues(formpanel.getValues());

Aafter you call this, the form has not longer the dirty status


Q: TypeScript: add more data to enum In TypeScript, is it possible to add more stuff (properties, methods, etc.) to enum constants, like in Java?
Java example demonstrating adding of fields, methods and constructor:
public enum Planet {
    MERCURY (3.303e+23, 2.4397e6),
    VENUS   (4.869e+24, 6.0518e6),
    EARTH   (5.976e+24, 6.37814e6),
    MARS    (6.421e+23, 3.3972e6),
    JUPITER (1.9e+27,   7.1492e7),
    SATURN  (5.688e+26, 6.0268e7),
    URANUS  (8.686e+25, 2.5559e7),
    NEPTUNE (1.024e+26, 2.4746e7);

    private final double mass;   // in kilograms
    private final double radius; // in meters

    Planet(double mass, double radius) {
        this.mass = mass;
        this.radius = radius;
    }
    private double mass() { return mass; }
    private double radius() { return radius; }

    // universal gravitational constant  (m3 kg-1 s-2)
    public static final double G = 6.67300E-11;

    double surfaceGravity() {
        return G * mass / (radius * radius);
    }
    double surfaceWeight(double otherMass) {
        return otherMass * surfaceGravity();
    }
    // ...
}

A: Not using an enum, but you can get the same exact thing using a class and a few static members:
class Planet {
    public static MERCURY = new Planet(3.303e+23, 2.4397e6);
    public static VENUS = new Planet(4.869e+24, 6.0518e6);
    public static EARTH = new Planet(5.976e+24, 6.37814e6);
    public static MARS = new Planet(6.421e+23, 3.3972e6);
    public static JUPITER = new Planet(1.9e+27, 7.1492e7);
    public static SATURN = new Planet(5.688e+26, 6.0268e7);
    public static URANUS = new Planet(8.686e+25, 2.5559e7);
    public static NEPTUNE = new Planet(1.024e+26, 2.4746e7);

    private mass: number;
    private radius: number;

    private constructor(mass: number, radius: number) {
        this.mass = mass;
        this.radius = radius;
    }

    public static G = 6.67300E-11;

    public surfaceGravity(): number {
        return Planet.G * this.mass / (this.radius * this.radius);
    }

    public surfaceWeight(otherMass: number) {
        return otherMass * this.surfaceGravity();
    }
}

console.log(Planet.MERCURY.surfaceGravity());

(code in playground)
In java for each item in the enum a static instance is created, which means that this indeed does the same thing, it's just that java has a nicer syntax for defining enums.

Edit
Here's a version with the equivalent Planet.values() which java will generate:
class Planet {
    public static MERCURY = new Planet(3.303e+23, 2.4397e6);
    public static VENUS = new Planet(4.869e+24, 6.0518e6);
    ...

    private static VALUES: Planet[] = [];

    private mass: number;
    private radius: number;

    private constructor(mass: number, radius: number) {
        this.mass = mass;
        this.radius = radius;

        Planet.VALUES.push(this);
    }

    public static values() {
        return Planet.VALUES;
    }

    ...
}

2nd edit
Here's a way to implement the valueOf:
   public static valueOf(name: string): Planet | null {
        const names = Object.keys(this);
        for (let i = 0; i < names.length; i++) {
            if (this[names[i]] instanceof Planet && name.toLowerCase() === names[i].toLowerCase()) {
                return this[names[i]];
            }
        }

        return null;
    }

A: Unfortunately it's not possible. You can just assign property names

See this reference for the TypeScript spec https://github.com/microsoft/TypeScript/blob/30cb20434a6b117e007a4959b2a7c16489f86069/doc/spec-ARCHIVED.md#a7-enums

A: You can get the 'same thing' using a const.
Obviously this solution isn't exactly like enumerations, it's just a different use of the keys of a const object instead of an actual enumeration value.
export const OrderStateEnum = {
    WAITING_SCORING: { key: 1, value: "WAITING for SCORING" },
    WAITING_ACCEPTANCE: { key: 2, value: "Waiting for acceptance" },
    ORDER_ACCEPTED: { key: 3, value: "Order accepted" },
 } as const

export type OrderStateEnum = keyof typeof OrderStateEnum

export function valueOf(value: string): OrderStateEnum{
    for(var key in OrderStateEnum) {
        if(value.toLowerCase()=== OrderStateEnum[key].value.toLowerCase()){
            return OrderStateEnum[key];
        }
    }
}

To receive all the values of the false enum:
  states = OrderStateEnum;

To receive a certain value of the false enum:
  OrderStateEnum.WAITING_SCORING.value;

Below is a usage via *ngFor
<select formControlName="statoOrdine" [(ngModel)]="stato">
    <option *ngFor="let item of states | keyvalue" [value]="item.value.key">
      {{item.value.value}}</option>
</select>


Q: Many-to-many relationship using @EmbeddedId produces null id generated for:class I have two tables that have a many to many relationship between them:

*

*Table one: Competition

*Relationship table: Entry

*Table two: User

The entry table is using an @EmbeddedId:
@Getter @Setter
@AllArgsConstructor
@NoArgsConstructor
public class Entry {

    @EmbeddedId
    EntryKey id;

    @ManyToOne
    @MapsId("competition_id")
    @JoinColumn(name = "competition_id")
    private Competition competition;

    @ManyToOne
    @MapsId("user_id")
    @JoinColumn(name = "user_id")
    private User user;

    private Integer number;
}

where EntryKey is implemented as:
@EqualsAndHashCode
@Getter @Setter
@AllArgsConstructor
@NoArgsConstructor
public class EntryKey implements Serializable {
    @Column(name = "competition_id")
    Integer competitionId;

    @Column(name = "user_id")
    Integer userId;
}

The Competition and User entities also contain the inverse references:
Competition
@OneToMany(mappedBy = "competition")
private Set<Entry> entries;

User
@OneToMany(mappedBy = "user")
private Set<Entry> entries;

The issue is when executing the following post request (maybe this is wrong?):
{
    "user_id": 1,
    "competition_id": 2,
    "number": 1
}

...which is being picked up in this controller:
@PostMapping
public Entry create(@RequestBody Entry entry) {
    return entryRepo.save(entry);
}

A IdentifierGenerationException is thrown: org.hibernate.id.IdentifierGenerationException: null id generated for:class com.mw.API.Entities.Entry. I'm not sure where I'm going wrong here.
There is a very similar question here however none of the answers seemed to help.

A: It seems that the EntryKey is not getting bound by the request.Sending this
{
    "competition":{
            "competitionId":6
    },
    "user":{
        "userId":5
    },
    "number": 1
}

instead of this
{
    "user_id": 1,
    "competition_id": 2,
    "number": 1
}

Should bind the values properly.


Q: Mysql order by field with given values which has NULL in between I'm trying to sort a query by given values like this:
ORDER BY FIELD(items.stock_id, 1, 5, NULL, 3, 6)
But it seems it doesn't work and null comes first or last depending on it being descending or not.
The order is not always the same hence [1,5,NULL,3,6] changes every time and is dynamic.

A: FIELD-function does not match the NULL-stock_id as NULL value (NULL does not have any value).
You could use a magic number:
ORDER BY FIELD(IFNULL(items.stock_id,-1), 1, 5, -1, 3, 6)


Q: ksh: How to pass arguments containing white space between scripts? I have two scripts (one ksh and other Perl) and one calls the other. I have to handle a scenario when someone accidentally enters a white space in file name and report it as an error (only when the file does not exist). It looks like p.sh which uses $* to pass/forward all arguments to p.pl doesn't handle quoted arguments the way they should be? Any ideas how to fix this? Let's just say one could enter multiple spaces in the filename too.
p.sh:
#!/usr/bin/env ksh
/tmp/p.pl $* 1>/tmp/chk.out 2>&1
print "Script exited with value $?"
print "P.PL OUTPUT:"
cat /tmp/chk.out
exit 0

p.pl:
#!/usr/bin/perl -w
use Getopt::Std;

getopts ("i:", \ %options);

if ($options{i} && -e $options{i}) {
  print "File $options{i} Exists!\n";
}
else {
  print "File $options{i} DOES NOT exist!\n";
}

Test cases (when there is an actual file '/tmp/a b.txt' (with a space in it) on the system):
[test] /tmp $ p.pl -i /tmp/a b.txt
File /tmp/a DOES NOT exist!
[test] /tmp $ p.pl -i "/tmp/a b.txt"
File /tmp/a b.txt Exists!
[test] /tmp $ ./p.sh -i "/tmp/a b.txt"
Script exited with value 0
P.PL Check OUTPUT:
File /tmp/a DOES NOT exist!
[test] /tmp $ ./p.sh -i "/tmp/ a b.txt"
Script exited with value 0
P.PL Check OUTPUT:
File /tmp/ Exists!

It's the last two scenarios I'm trying to fix. Thank you.

A: To preserve whitespace that was passed into the script, use the $@ parameter:
/tmp/p.pl "$@" 1>/tmp/chk.out 2>&1

The quotation marks are necessary to make sure that quoted whitespace is seen by p.pl.


Q: Identifying SMD motherboard component My motherboard (Gigabyte b450) died after a power outage. I found out that an SMD 5-pin IC with the code VA8qE was burned. I tried to identify it myself, with no luck.
I searched for the code online, but no result, even on pages like:

*

*https://alltransistors.com/smd-search.php

*https://smd.yooneed.one/
Any idea what it is?

A: I think it says "VAB", in which case it's probably a S-1135 Series voltage regulator.
More specifically the "S-1135C11-M5T1y", according to the datasheet.

A: Doing some reading with the multimer on the same 5 pin not burned VA8qE next to the chipset, it looks like it a voltage regulator, 5 V input 3.3 V output. I found (different code) in an old motherboard I had around, measure, and the MOBO is live again, booted to BIOS so far.


Q: cannot find protocol declaration custom protocol delegate iphone Slowly but surely getting this delegation and protocol stuff on iphone but I cannot understand this error.
I have declared my protocol in my first viewcontroller.
In the second viewcontroller i try to add it at the top after i have imported it into the header file and it cannot find it. see my code below.
//SendSMS
#import <UIKit/UIKit.h>
#import "LoginPage.h"
#import "MessageOptions.h"

@protocol SMSProtocol <NSObject>

-(NSString *)postbackType;

@end

@interface SendSMS : UIViewController <UITextViewDelegate, UITextFieldDelegate> {

    id<SMSProtocol> delegate;

    MessageOptions *messageOptions;
    LoginPage *loginPage;
    IBOutlet UITextField *phonenumber;
    IBOutlet UITextView *smsBody;
    IBOutlet UIScrollView *scrollview;

}

@property (nonatomic, retain) id<SMSProtocol> delegate;

-(IBAction)LoadMessageOptions;

@end

Then my second view
#import <UIKit/UIKit.h>
#import "SendSMS.h"

@interface ScheduledSMS : UIViewController <SMSProtocol>{

}

-(IBAction)popBack;

@end

A: That is surely strange. Have you tried restarting Xcode? Xcode has a habit of not indexing symbols for me when I add new files.
You should also look into how your naming conventions. SendSMS is not really a good class name, more of a action method name. I would go for SendSMSViewController, since that is what it is.
By that it would follow that SMSProtocol should be named SendSMSViewControllerDelegate, since that is what it is.
Methods in a delegate protocol should contain the sender and one of the three words will, did, or should. If not at the very least it should name what it expects to return. -(NSString *)postbackType; should probably be -(NSString *)postbackTypeForSendSMSViewController:(SendSMSViewController*)controller;.


Q: Powershell command SCCM 2012 - Get all Resource Names from device collection? I'm still learning about PowerShell and SCCM.
At the moment i'm trying to get all resource names of a device collection into an array variable. I don't know if this is possible?
Example:
Computers: Win7, Win8, CM02,....

into a variable like:
$computers = COMPUTERNAMEWIN7.local.domain.lo, COMPUTERNAMEWIN8.local.domain.lo, COMPUTERNAMECM02.local.domain.lo

This is what i'm trying to achieve:
I'm trying to deploy LibreOffice to all computers i have under my control in SCCM 2012.
So i have a Device Collection: "All Systems" with all these computers in it.
and then use aForeach-Object command to copy and install the .Msi file of LibreOffice.
Is there a PowerShell command to get these into an array like the example, when specifying the device collection name ?
thank you :)


Q: Calling JS function from external file give error in yii2 I'm trying to call a JS function in a yii2 project but got function not define,
the JS function is inside a file named main.js which is included to the layout of the homepage, and in site/index in have another internal JS code that calls the function in main.js file. if i put this function in site/index everything works fine as expected but if i separate it to call it from outside it says function not define.
My action page site/index:
<?php
 $getcatUrl = Yii::$app->UrlManager->createUrl(['site/getcategories']);

$script = <<< JS

 $(document).ready(function(){

       $(".sideBarNav").mouseenter(function(){
          id = $(this).attr('href');
          getCategories(id);
           $('.cat-container').css('display', 'block');
       });
  });
JS;
$this->registerJs($script);
?>

Now in my main JS file i have the following:
  function getCategories(id){
           $.ajax({
                        url: '{$getcatUrl}',
            type: 'POST',
            data: {category_id: id},
            success: function (data) {
                         data = jQuery.parseJSON(data);
                         //console.log(data); return;
                      if (data.length > 0) {
                        $("#dl-cat").html("");
                        var content = $("#dl-cat");
                        firstdata = data[0];
                        secdata = data[1];

                        for (var i = 0; i < firstdata.length; i++) {
                         // var d =  $( document.createElement('dl') );
                          var dl = $("

");
                          dl.append("
"+firstdata[i].name+"
");

                              for (var j = 0; j < secdata.length; j++) {
                            if (secdata[i][j] !== undefined) {
                              dl.append("
"+secdata[i][j].name+"
");
                            }

                          }
                        content.append(dl);
                        }

                      } else {
                        console.log('no item for this categories');
                      }
                   },
                error: function(jqXHR, errMsg) {
                 // handle error
                    console.log(errMsg);
                }
            });
       }

Note other codes from the JS file works expect from functions that needed to be called from external source
This how do i solve this problem any help will be appreciated thanks

A: I bet, the script is before the jquery all, so the function "disappears". Try placing the script in a external file and making sure that
try «I hope it helps»
    $this->registerJsFile(
        '@web/js/your_file.js',
        ['depends' => [\yii\web\JqueryAsset::class]]
    );

If it's not exactly this, but probably the function is being placed after the call, so it will be undefined, so try to be sure that the function gets rendered before the call.


Q: How to use CircleImageView with Volley's NetworkImageView? I need to get circle images from rectangular/square images taken from network. In my application I get images with Volley's NetworkImageView. I found that fantastic library https://github.com/hdodenhof/CircleImageView but I don't understand how I can use it with NetworkImageView.
Can someone help me?

A: Check this Class
public class CirculaireNetworkImageView extends NetworkImageView {
    private int borderWidth;
    private int canvasSize;
    private Bitmap image;
    private Paint paint;
    private Paint paintBorder;

    public CirculaireNetworkImageView(final Context context) {
        this(context, null);
    }

    public CirculaireNetworkImageView(Context context, AttributeSet attrs) {
        this(context, attrs, R.attr.actionButtonStyle);
    }

    public CirculaireNetworkImageView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        paint = new Paint();
        paint.setAntiAlias(true);

        paintBorder = new Paint();
        paintBorder.setAntiAlias(true);
    }

    public void setBorderWidth(int borderWidth) {
        this.borderWidth = borderWidth;
        this.requestLayout();
        this.invalidate();
    }

    public void setBorderColor(int borderColor) {
        if (paintBorder != null)
            paintBorder.setColor(borderColor);
        this.invalidate();
    }

    public void addShadow() {
        setLayerType(LAYER_TYPE_SOFTWARE, paintBorder);
        paintBorder.setShadowLayer(4.0f, 0.0f, 2.0f, Color.BLACK);
    }

    @SuppressLint("DrawAllocation")
    @Override
    public void onDraw(Canvas canvas) {
        // load the bitmap
        image = drawableToBitmap(getDrawable());

        // init shader
        if (image != null) {

            canvasSize = canvas.getWidth();
            if(canvas.getHeight()<canvasSize)
                canvasSize = canvas.getHeight();

            BitmapShader shader = new BitmapShader(Bitmap.createScaledBitmap(image, canvasSize, canvasSize, false), Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
            paint.setShader(shader);

            // circleCenter is the x or y of the view's center
            // radius is the radius in pixels of the cirle to be drawn
            // paint contains the shader that will texture the shape
            int circleCenter = (canvasSize - (borderWidth * 2)) / 2;
            canvas.drawCircle(circleCenter + borderWidth, circleCenter + borderWidth, ((canvasSize - (borderWidth * 2)) / 2) + borderWidth - 4.0f, paintBorder);
            canvas.drawCircle(circleCenter + borderWidth, circleCenter + borderWidth, ((canvasSize - (borderWidth * 2)) / 2) - 4.0f, paint);
        }
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int width = measureWidth(widthMeasureSpec);
        int height = measureHeight(heightMeasureSpec);
        setMeasuredDimension(width, height);
    }

    private int measureWidth(int measureSpec) {
        int result = 0;
        int specMode = MeasureSpec.getMode(measureSpec);
        int specSize = MeasureSpec.getSize(measureSpec);

        if (specMode == MeasureSpec.EXACTLY) {
            // The parent has determined an exact size for the child.
            result = specSize;
        } else if (specMode == MeasureSpec.AT_MOST) {
            // The child can be as large as it wants up to the specified size.
            result = specSize;
        } else {
            // The parent has not imposed any constraint on the child.
            result = canvasSize;
        }

        return result;
    }

    private int measureHeight(int measureSpecHeight) {
        int result = 0;
        int specMode = MeasureSpec.getMode(measureSpecHeight);
        int specSize = MeasureSpec.getSize(measureSpecHeight);

        if (specMode == MeasureSpec.EXACTLY) {
            // We were told how big to be
            result = specSize;
        } else if (specMode == MeasureSpec.AT_MOST) {
            // The child can be as large as it wants up to the specified size.
            result = specSize;
        } else {
            // Measure the text (beware: ascent is a negative number)
            result = canvasSize;
        }

        return (result + 2);
    }

    public Bitmap drawableToBitmap(Drawable drawable) {
        if (drawable == null) {
            return null;
        } else if (drawable instanceof BitmapDrawable) {
            return ((BitmapDrawable) drawable).getBitmap();
        }

        Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);

        return bitmap;
    }
}

A: Check the source code of the NetworkImageView here. Modify it to extend your "CircleImageView" instead of the normal ImageView and you are done.