Nosql design - tags and mvc

Question: I'm using Rails and Mongoid. I'm trying to come up with a tagging feature (similar to stackoverflow in that each user can have "favorite" tags).
From the design articles I've read about mongodb, I've understood that I need to stop thinking in "4th normal" form. I keep thinking to have a many to many table with tag_id and user_id and another many to many table with tag_id and item_id. But from reading about nosql, it seems like it'd be much better to embed the tags (either as tags or even an array of strings) within each user or item.
There's going to be a list of tags in the "tags" collection and the application will control whether a user can add a tag to their favorites or not.
I'm trying to figure out how to do this. Do I have the tag model have a key on the title and just store an array of those keys in a user model? Would "linking" or "embedding" be better in this situation? I'm trying to think of how I'll retrieve the tags since they have a key such as foo-bar and the title is Foo Bar. If I need to retrieve the user's tags then do I need to loop through the array and fetch each tag model to get the titles?
Answer: I can't help you on the Ruby aspects of this, but here are some options on the MongoDB side..
You could create a tags collection with entries looking a bit like this: {_id: ObjectId(), title: "Foo Bar"}. Each user could then have an array of id values of the tags he subscribes too:
{ username: ...,
  tags: [ObjectId(), ObjectId(), ... ]}

You could then retrieve the the titles of a users tags using the $in operator:
db.tags.find({_id: { $in: [array from user] }});

Nosql design - tags and mvc


XSLT - unmapped fields at bottom of html

Question: I have an XML document which references a XSL file for the output of HTML.
In the XSL file I have put in various "<xsl:value-of select="fieldname" />" tags referencing items in my XML File.
However for the items I have not mapped they just appear as a long string at the bottom of the html page?
Do I really need to omit all my xml data items not referenced in the XSL file for them to go away or is there a trick to this or a bug in my XSL file?
j
Answer: This is result of the XSLT Processing Model.
XSLT uses its *built-in templates` if a node should be processed and no template in the XSLT code is matching it. The built-in template that matches a text node copies it.
Solution:
Add this template that overrides the XSLT built-in template for text nodes:
<xsl:template match="text()"/>

This causes any text node not matched by a more specific template in the code (and not copied with xsl:copy-of or xsl:value-of) to be ignored ("deleted").
Comment: The alternative is to avoid processing the items you don't want output, by being selective about which you select in your xsl:apply-templates instructions.
Comment: @MichaelKay: Yes, definitely. In conditions where no XML document or XSLT code, or wanted result is provided, one cannot be more specific.


MariaDB reviews a lot of rows when using index on uuid with null values

Question: We got a database with a card table
CREATE TABLE `card` (
  `id` char(36) NOT NULL,
  `parent_card_id` char(36) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `table_parent_card_id_idx` (`parent_card_id`) USING BTREE,
  CONSTRAINT `card_collection_id_foreign` FOREIGN KEY (`collection_id`) REFERENCES `collection` (`id`) ON DELETE CASCADE ON UPDATE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

The card can have a reference to its parent, if the field is null its means that the row is the main object.
In the current database we 20838 row, and only 5 of the cards are having a parent_card_id.
When i look a the explain of both queries, it looks like the first one don't uses the index correctly. The real table and query are larger and different, but made it simpeler for this question.
EXPLAIN
 SELECT
    card.id,
    (
        SELECT COUNT(`child`.`id`)
        FROM `card` AS `child`
        WHERE `child`.`parent_card_id` = `card`.`id`
    )
FROM card
WHERE card.id IN  ('0a4f5e08-496f-4a43-994a-1ed1bc28f8fb', '51d755a6-74ef-4c36-bc5b-a3a313d340f4')

id
select_type
table
type
possible_keys
key
key_len
ref
rows
Extra

1
PRIMARY
card
range
PRIMARY
PRIMARY
144
2

Using where; Using index

2
DEPENDENT SUBQUERY
child
ref
card_parent_card_id_idx
card_parent_card_id_idx
145
card.id
10269
Using index

EXPLAIN
 SELECT
    card.id,
    (
        SELECT COUNT(`child`.`id`)
        FROM `card` AS `child`
        WHERE `child`.`parent_card_id` = `card`.`id`
    )
FROM card
WHERE card.id IN  ('0a4f5e08-496f-4a43-994a-1ed1bc28f8fb')

id
select_type
table
type
possible_keys
key
key_len
ref
rows
Extra

1
PRIMARY
card
range
PRIMARY
PRIMARY
144
const
1
Using index

2
SUBQUERY
child
ref
card_parent_card_id_idx
card_parent_card_id_idx
145
const
1
Using index

Is the result in te rows column incorrect on the first query, or does he looks in alle the card items in the subquery. Is there a way to get maybe a better index for the parent child relation.
EDIT 23 feb
Added a extra line in the subquery, both cards (parent/ child) always have the same collection id, this give me a better result in total rows examined in the explain
EXPLAIN
 SELECT
    parent.id,
    (
        SELECT COUNT(`child`.`id`)
        FROM `card` AS `child`
        WHERE `child`.`parent_card_id` = `parent`.`id`
            AND child.collection_id = parent.collection_id
    )
FROM card as parent
WHERE parent.id IN  ('0a4f5e08-496f-4a43-994a-1ed1bc28f8fb', '51d755a6-74ef-4c36-bc5b-a3a313d340f4')

id
select_type
table
type
possible_keys
key
key_len
ref
rows
Extra

1
PRIMARY
card
range
PRIMARY
PRIMARY
144
2

Using where

2
DEPENDENT SUBQUERY
child
ref|filter
card_collection_id_foreign,card_parent_card_id_idx
card_collection_id_foreign|card_parent_card_id_idx
144|145
parent.collection_id
2 (0%)
Using where; Using rowid filter
Comment: `card.id` is ambiguous.  Please give the outer `card` and alias of `parent`.  Also change `COUNT(...)` to simply `COUNT(*)`.
Comment: Count is only a shorter version of the original sum(...), card.id in the subquery is the same as the outer card.id. It would also give a error if it was ambigous, tried to give outer card a alias but did not give a change in te rows examed
Comment: `COUNT` and `SUM` may be optimized differently.  Please don't simplify things; we could give you the "wrong" answer.
Answer: Try refactoring your dependent subquery to be independent.
SELECT card.id, children.child_count
  FROM card
  LEFT JOIN (
               SELECT COUNT(id) child_count
                      parent_card_id
                 FROM card
                GROUP BY parent_card_id
            ) children ON card.id = children.parent_card_id
 WHERE card.id IN  (
      '0a4f5e08-496f-4a43-994a-1ed1bc28f8fb',
      '51d755a6-74ef-4c36-bc5b-a3a313d340f4')

And, if you can change your table definition so those VARCHAR UUIDs have CHARACTER SET ascii you'll save space and time.
Comment: Thanks for the answer, only makes its slower. Using index; Using temporary; Using filesort. Also the subquery is not the original subquery, but only a sorter one to make the question simpeler.
Answer: From my understanding, you're trying to get the number of children cards for each card. I think a GROUP BY on the parent_card_id should do the trick
SELECT parent_card_id, COUNT(*)
FROM card
WHERE parent_card_id IN ('0a4f5e08-496f-4a43-994a-1ed1bc28f8fb', '51d755a6-74ef-4c36-bc5b-a3a313d340f4')
GROUP BY parent_card_id

The caveat is that if a card has no children, it will just not appear in the query. It's probably easier and cheaper to deal with that case in the code rather than trying to perfect the query.


How to increment column value during on_conflict_do_update?

Question: I would like to insert a row if it does not break unique values across product_id and date columns (not added as a unique constraint), and if it does I just want to increment the column value in the existing row.
I think i have to use:
on_conflict_do_update()
But I cannot find out what should I type for the index/constraint and set_arguments.
Can you guys point me the direction? :)
Model:
class MyModel(db.Model):
    __tablename__ = 'my_model'

    id = Column(Integer, primary_key=True)
    date = Column(Date)
    product_id = Column(Integer, ForeignKey('product.id'))
    counter = Column(Integer)

Thanks in advance!
Answer: This worked for me, using Postgresql:
from sqlalchemy.dialects.postgresql import insert

class my_table(Base):
    __tablename__ = 'foo'
    id = Column(Integer, primary_key=True)
    counter = Column(Integer)

insert_stmt = insert(my_table).\
    values(id=42).\
    on_conflict_do_update(index_elements=[my_table.id],
                          set_=dict(counter=my_table.counter+1)).\
    returning(my_table.id)

results = session.execute(insert_stmt)

https://docs.sqlalchemy.org/en/13/dialects/postgresql.html?highlight=conflict#sqlalchemy.dialects.postgresql.dml.Insert.on_conflict_do_nothing
Answer: According to the doc here here, you can give it a try:
from sqlalchemy.dialects.mysql import insert

insert_stmt = insert(my_table). \
    values(id='some_id', data='some data to insert')

on_conflict_stmt = insert_stmt.on_duplicate_key_update(
    data=insert_stmt.inserted.data,
    status='U'
)

conn.execute(on_conflict_stmt)


Terraform: Passing variable from one module to another

Question: I am creating a Terraform module for AWS VPC creation.
Here is my directory structure
➢  tree -L 3
.
├── main.tf
├── modules
│   ├── subnets
│   │   ├── main.tf
│   │   ├── outputs.tf
│   │   └── variables.tf
│   └── vpc
│       ├── main.tf
│       ├── outputs.tf
│       └── variables.tf
└── variables.tf

3 directories, 12 files

In the subnets module, I want to grab the vpc id of the vpc (sub)module.
In modules/vpc/outputs.tf I use:
output "my_vpc_id" {
  value = "${aws_vpc.my_vpc.id}"
}

Will this be enough for me doing the following in modules/subnets/main.tf ?
resource "aws_subnet" "env_vpc_sn" {
   ...
   vpc_id                  = "${aws_vpc.my_vpc.id}"
}

Answer: Your main.tf (or wherever you use the subnet module) would need to pass this in from the output of the VPC module and your subnet module needs to take is a required variable.
To access a module's output you need to reference it as module.<MODULE NAME>.<OUTPUT NAME>:

In a parent module, outputs of child modules are available in expressions as module... For example, if a child module named web_server declared an output named instance_ip_addr, you could access that value as module.web_server.instance_ip_addr.

So your main.tf would look something like this:
module "vpc" {
  # ...
}

module "subnets" {
  vpc_id = "${module.vpc.my_vpc_id}"
  # ...
}

and subnets/variables.tf would look like this:
variable "vpc_id" {}


Protected object inside the final class

Question: Considering following class definition.
public final class engine{
protected Object _obj=new Object();
}

My question is, as final classes are not allowed to be inherited in java, so the protected access specifier rules like private here.
Why doesn't java raise error for this definition while code compilation?
Is it possible to inherit from Engine using reflection, native codes, anything?
Comment: You can also access a protected variable from within the package (in this case protected is the same as default). Also; raising an error in this case would be a massive overreaction, a warning maybe
Comment: Read more about it here [Why are protected members allowed in final java classes?](http://stackoverflow.com/questions/3661270/why-are-protected-members-allowed-in-final-java-classes)
Answer: Protected means that you can reach that variable from the same package or subclass. Private means that you can only reach that variable from the class it is declared in..
See the reference: http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html

Protected object inside the final class


Should I use a UITableView or UICollectionView to create this

Question: I would like to create the following, but not absolutely sure which one is the best to use: UITableView or UICollectionView?
Answer: Table views only do a single vertical list of cells. If you need a grid with rows and columns then you need a collection view.
If the 3 parts of your A-G rows are separate sections of single items then you might use a table view. (Say the left column contains an image, the middle column contains a title and subheading, and the right column contains a description of the item.)


Text at the top of all contents

Question: I have a question ....
In my webpage here
But when you scroll how can i do so the fixed header is on top of all content ?
Answer: Use the z-index CSS property on the element you want to put over the others.

The z-index property specifies the stack order of an element.
  An element with greater stack order is always in front of an element
  with a lower stack order.

#sticky {
   z-index: 1;
}

Use 1 or more, depending on the value of the other z-indexed elements.
Answer: Use z-index to place your header on top:
#sticky{
   z-index: 1;
}

Answer: Add this CSS
#sticky {
    background-color: #FFFFFF;
    display: inline;
    margin-top: -15px;
    position: fixed;
    width: 1200px;
    z-index: 1;
}

Answer: add z-index with a large number like this:
#sticky {
position: fixed;
background-color: white;
width: 1200px;
margin-top: -15px;
display: inline;
z-index: 99999;  /* added */
}

z-index reference

Text at the top of all contents


as3 How to use swap with array list?

Question: I have Array list, and in this array have 4 url and port, i want when user connect from index[0] then connection lose i show button when click user this button i want to connect same port but second url like index[1].
How i solve and how can i do please help thanks. This is my List
<code>private static var urisToTry:Array = [
            new SocketUri("123.net", 123),
            new SocketUri("1234.net", 123),
            new SocketUri("123.net", 321),
            new SocketUri("1234.net", 321)
        ];
</code>
Any help would be great i need pseudo code
Comment: Um, yeah:
`when connection lost:`
`getNextUrl;`
`connect using new url;`
Comment: 1) Keep index of currently selected one and every time you lost connection, increase it. Check if index is less than array length.

2) Keep using index 0, but every time you lost connection, move 1st element from the list to the end. `urisToTry.push(urisToTry.shift())`
Comment: thanks for answering do you have any pseudo code ? @3vilguy
Answer: Something like this:
<code>// current array index
private var connIndex:int = 0;

public function connect():void
{
    var mySocketURI:SocketUri = urisToTry[connIndex];

    // do your connection here
}

private function onConnectionLost():void
{
    // increase index and check if it is within array length
    if(connIndex >= urisToTry.length -1)
        connIndex = 0;
    else
        connIndex++;

    connect();
}
</code>

as3 How to use swap with array list?


ODE Proof - Intersection of the family of solutions and the line $t = k$

Question: Prove that if the family of solutions of the differential equation
$$y′+p(t)y=q(t), p(t)q(t) \neq 0$$ is cut by the line $t=k$, the tangent lines to each member of the family at the points of intersection all intersect at one point.
This is for homework and I would really appreciate a hint. I get the general solution $$y = e^{- \int p(t) dt}(\int q(t) e^{\int p(t) dt} dt + C)$$ which is just the general solution for first order linear equation. But then I'm confused what the question is asking. Any clarifications on the question would be much appreciated.
The only thing I can think of right now is differentiating the solution but that's definitely not the right idea.
Answer: Wow!  Cool problem!  Sorry if I got carried away and presented a complete solution, but once I had explained wassup here, I was just too close to the end to not conclude.  Anyway, hope this helps!
So here's what I think is going on: envision with the mind's eye, if you will, a cartesian coordinate system in $\Bbb R^2$, with the $t$-axis horizontal and the $y$-axis vertical; the graphs of functions $y(t): \Bbb R \to \Bbb R$ are the sets
$\{(t, y(t)) \mid t \in \Bbb R\} \subset \Bbb R^2, \tag 1$
and any line of the form
$t = k \tag 2$
passes through the point $(k, 0)$ and is parallel to the $y$-axis; as such, it is the set
$\{ (k, y) \mid y \in \Bbb R \}. \tag 3$
I assume that
$p(t), q(t) \in C(\Bbb R, \Bbb R); \tag 4$
that is, $p, q: \Bbb R \to \Bbb R$ are everywhere continuous functions of $t$; then through any point $(k, y_1)$ of the line (3) there exists precisely one solution $y(t)$ to
$y'(t) + p(t)y(t) = q(t), \; y(k) = y_1, \tag 5$
as follows from the standard Picard-Lindeloef theorem; since the function $q(t) - p(t)y$ is both jointly continuous in $t$ and $y$ and Lipschitz continuous in $y$ (an easily-verified result I leave to my myriad readers), it meets the hypothesis of the theorem and hence we establish existence and uniqueness for (5).
Now the slope of the line tangent to such a solution at $(k, y(k))$ is in fact
$y'(k) = q(k) - p(k)y(k) = q(k) - p(k) y_1; \tag 6$
therefore the equation of the line tangent to such a $y(t)$ at $(k, y(k)) = (k, y_1)$ is
$y - y_1 = (q(k) - p(k) y_1)(t - k); \tag 7$
likewise the tangent line at $(k, y_2)$ is
$y - y_2 = (q(k) - p(k) y_2)(t - k); \tag 8$
we see that for $y_2 \ne y_1$ these two lines have different slopes, hence are not parallel, hence they intersect at a unique point which may be found by equating their $y$-values for some as yet to be determined $t$:
$ (q(k) - p(k) y_1)(t - k) + y_1 = (q(k) - p(k) y_2)(t - k) + y_2; \tag 9$
thus,
$y_1 - y_2 = ((q(k) - p(k)y_2) - (q(k) - p(k) y_1))(t - k) = p(k)(y_1 - y_2)(t - k), \tag{10}$
or
$p(k)(t - k) = 1, \tag{11}$
or
$t = \dfrac{1}{p(k)} + k; \tag{12}$
observe that (12) is legitimized by the given hypothesis $p(t)q(t) \ne 0$, which implies $p(k) \ne 0$; furthermore, we may determine the corresponding $y$-value from (7) or (8):
$y = (q(k) - p(k) y_1)(t - k) + y_1 = \dfrac{(q(k) - p(k) y_1)}{p(k)} + y_1 = \dfrac{q(k)}{p(k)}; \tag{13}$
we thus see that the intersection point $(1/p(k) + k, q(k)/p(k))$ depends only on $k$,$p(k)$ and $q(k)$ and is thus completely independent of the value $y(k)$; therefore all such tangent lines pass through $(1/p(k) + k, q(k)/p(k))$, intersecting there, and we are done. $OE\Delta$
Comment: I know I'm suppose to reserve this for useful comments, but WOW just WOW. Thank you sensei.
Comment: You are most welcome my friend!


VBA checkbox name length limit

Question: i have just simple question. Is here some limit in excel VBA to checkbox name?
i have code like this, and when im using name longer than 33 characters, i have error Unable to set the Name property of the checkbox class (its only a test code)
So is here some way to bypass this?
<code> Sub createTestBox()

    Dim shimSheet As Worksheet
    Set shimSheet = Sheets("ShimSheet")

    Dim chkbox As checkBox

    Dim i As Long

    Dim name As String
    name = ""

    For i = 1 To 50
        name = name & "a"
        With shimSheet.Cells(12 + i, 3)

            shimSheet.CheckBoxes.Add(.Left, .Top, .Width, .Height).name = name
            shimSheet.CheckBoxes(name).Delete
        End With
    Next i

End Sub
</code>
Comment: you can see it directly in Excel UI, where my Excel 2013 limits it to 31 characters. You could use alphanumeric names: "a1", "a2",...
Comment: @PartyHatPanda its not about repeating A. This was just my testcase to figure out why is excel failing :) My thought was to have some checkbox tree structure, with parent<>child reference. But names was too long...
Comment: I saw the same problem here: https://social.msdn.microsoft.com/Forums/office/en-US/72201c7c-81e6-4f6a-b109-ddad86dc8e59/bug-naming-activex-checkbox-in-excel-2010?forum=exceldev . Apparently it is the limit.
Comment: The Microsoft Documentation doesn't have any information regarding max name length, but I cannot find a work around to get more than 33 characters. If it is not necessary to use "a" repeatedly, @user3598756 has a great suggestion!
Answer: Whenever you face such kind of limits, simply use the inbuilt office help. However to make the best use of help in your case, manually try to change the name of the control and you will see an error as shown below

Simply click on help and it will take you to the relevant MSDN page in you have internet connectivity :)
Please refer to the link Not a legal object name
In case the link dies

Not a legal object name: 'item
Office 2013 and later Other Versions
Form and control names must start with a letter and can be a maximum
  of 40 characters — including letters, numbers, and underscores (_).
  Note that the Name property of a form or control is different from the
  Label properties — Caption, Text, and Value — that label or display
  the contents of a control at run time. These properties can be
  restricted keywords, can begin with a number, and can contain
  nonalphanumeric characters.
Comment: Good point, i was just trying to type longer name in Excel manualy (and everything was okay). Checkbox was even created with that name, but after that i cannot acces him.

VBA checkbox name length limit


Difference between $R^\infty$ and $R^\omega$

Question: I know $R^\omega$ is the set of functions from $\omega$ to $R$. I would think $R^\infty$ as the limit of $R^n$, but isn't that $R^\omega$?
The seem to be used differently, but I can't tell exactly how.
Comment: Notations mean what their users want. Without context, it is impossible to decide what either of these notatins you mention mean. (Limit in what sense?)
Comment: This will manifest itself in people answering completely different things, due to their familiarity with different conventions. It does not helpthat each answer appears to think that their answer is authoritative :-(
Comment: See also https://math.stackexchange.com/questions/616815/what-are-default-topologies-on-r%e2%88%9e-and-r%cf%89
Answer: In a context where one makes a distiction between $R^\infty$ and $R^\omega$,
$R^\infty$ denotes the set of sequences with finite support whereas $R^\omega$ denotes the set of unrestricted sequences.
In this context, $R^\infty$ is the limit of $R^n$ when $n \to \infty$, in the sense that $R^\infty = \bigcup_{n=0}^{\infty} R^n$, with the convention that $R^n$ are all seen as subsets of $R^\omega$.
Comment: To extend the original question: What are default topologies on $R^∞$ and $R^ω$? I would think that we take product topology on $R^ω$ and limit topology on $R^∞$ (in the sense of direct limit in category of topological spaces, if I remeber in this case it corresponds to subspace topology of box product).


Doctrine2 returns returns fields with wrong data type

Question: I'm working on a mid-size Symfony2 project. While using several doctrine entities I stucked on the following "error".
I've got an entity with 3 fields:
<entity name="xxx\yyyBundle\Entity\ABTexte" table="ABTexte">
    <id name="Nr" type="integer" />
    <field name="OID" type="integer" />
    <field name="Text" type="string" />
    <many-to-one target-entity="xxx\yyyBundle\Entity\ABKopf" field="ABKopf" inversed-by="ABTexte">
        <join-column name="OID" referenced-column-name="OID" on-delete="CASCADE" />
    </many-to-one>
</entity>

After loading one or more entities using $repo->findBy() I receive an entities with wrong datatypes. My result is:
$ABKopf->Nr (int)
$ABKopf->Text (string)
$ABKopf->OID (string)     <===== !!!!!!!!!

It's very important for my application to get this value as an integer. Do you have any ideas what causes this behaviour?
PS: All values are filled with data of the correct data type. e. g. OID = 999000
I verified that, when I use an integer column as a foreign key (many-to-one relationship...) doctrine always returns it as a string
Relationship in ABKopf:
<entity name="xxx\yyyBundle\Entity\ABKopf" table="ABKopf">
    <id name="OID" column="OID" type="integer" />
    <field name="ABNr" column="ABNr" type="integer" />

    <one-to-many target-entity="xxx\yyyBundle\Entity\ABTexte" field="ABTexte" mapped-by="ABKopf" />
</entity>

ABTexte-Entity: https://gist.github.com/715f3881a57cdd8a7d23
Comment: Did you create the table with doctrine or did you map an existing table? What datatype is the OID-column in your table?
Comment: @mahok I created the table using doctrine. The datatypes of the fields in my datatable are corresponding to the doctrine-XML: OID int(11), Nr int(11), Text varchar(255).
When var_dumping the entity after a call of $repo->findBy(), $entity->Nr is correctly dumped as an integer, OID is dumped as a string...
Comment: PS: At first I didn't define a datatype for column OID so it was a varchar(255) / string. Later I changed the datatype to integer, and used doctrine:generate:schema command to update the column in the database...
Comment: PPS: Even after deleting and recreating the datatable there's the same problem.
Answer: Based on your comment

PS: At first I didn't define a datatype for column OID so it was a
varchar(255) / string. Later I changed the datatype to integer, and
used doctrine:generate:schema command to update the column in the
database...

I'll explain you the entire "doctrine process" for generate entities.
At first you write a PHP class with some annotation or a yml,xml,ecc that tells doctrine how to create entities, link each other, and so on.
Second step is about generating getters and setter in an automated way doctrine:generate:entities
IMPORTANT
The third step is, when you want to change something about your schema, use the following command doctrine:schema:update --force
END IMPORTANT
I suppose that doctrine:generate:schema doesn't do what you're expecting that it to do.

Try with command that I've wrote on the third step
Comment: Thx for your answer.

I know that I have to use the force-Flag to write the schema changes into DB. I've done it. And I checked the settings in my DB, so I'm sure that the database-tables have the same type settings as my doctrine-definitions.

**I've tried removing the foreign-key (many-to-one-relationship) from my entity, and then findBy returns the values with the correct data-types. After re-enabling the foreign-key, OID is returned as a string again.**
Comment: @RenePöpperl this is kind of strange because keys have to be of the same type. Have you checked at the other side of your association for understand what's goin' on?
Comment: I've tried some approaches:

    `$ABKopf = $repoABKopf->findOneBy(...);`
    `$OID    = $ABKopf->getABTexte()[0]->getOID();`

Here I get OID as integer. If I call

    `$ABTexte = $repoABTexte->findBy(...);`
    `$OID = $ABTexte[0]->getOID();`

... I receive a string. From this point on, even if I call

    `$ABKopf->getABTexte()[0]->getOID();`

I receive a string...

In each table OID is used, datatype is integer.
Comment: @RenePöpperl looks strange
Comment: I verified that, when I use an integer column as a foreign key (many-to-one relationship...) doctrine always returns it as a string... but I need an integer... :-(
Comment: @RenePöpperl could you provide the section of code where you define that relationship? Please, update your question


JPA+Swing is there a way to use a single Connection?

Question: I'm in a process of rewriting a part of Oracle Forms code to Java Swing as a demo (just a showcase for Oracle people to see how it looks and feels). I'd rather use JPA than play directly with JDBC.
The problem is, (as with any Oracle Forms apllication, I guess) that each application user has a separate Oracle account/schema, and the program relies heavily on keeping track of stuff via Oracle session-tied package variables. When they decide whether they want a web app or a desktop one, they will probably have to make a hard decision and switch to a different model, but for now I have to play the cards I've been dealt.
So - is there a way to configure Hibernate (or any other) JPA so that it works with a single Connection object (and try to reconnect in case it's dropped)?
Answer: In you use EclipseLink you have a few options.  One is using Oracle proxy authentication, the other is to connect each EntityManager with a user id.
See,
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Auditing


Htaccess rewrite with optional parameters

Question: I have little understanding of HTACCESS, even though I have spent a long time looking into it. I think the real reason is because regular expressions go above and beyond my capacity.
Currently, in HTACCESS, I have use this line:
RewriteRule ^website/([^/]+)(/([^/]+))?$ controller/url.php?method=$1&param=$3

This will allow users to have a nice url that looks like www.website.com/website/method/optional_parameter
How could I add a second and third optional parameter to the HTACCESS rewrite line?
Comment: Provide some examples of your pretty URLs and their actual rewritten URLs on your server side.
Answer: The easiest way would be to allow the second group to contain the rest of the URL after your "method" group.
RewriteRule ^website\/([^/]+)\/(.*)$ controller/url.php?method=$1&params=$2

Then use PHP to split params at each /
Hope that helps.
Comment: www.website.com/website/method/optional_parameter returns a 404 error. www.website.com/website/method/optional_parameter/param works, but param needs to be optional.
Comment: Ah, then you can use a rule more similar to your original: `RewriteRule ^website\/([^/]+)(/([^/]+))?$ controller/url.php?method=$1&params=$3`


Powershell - exclude last record from array from getting join

Question: i was wondering if anyone could help me with my issue. i have this code:
$test = ForEach ($file from $folder){
        join-path -path $path -childpath $file
{
$test -join ","

if i have for example 12 records on the array, i need the first 11 to have ","
path\file1.txt,
path\file2.txt,
...
path\file11.txt,
path\file12.txt (should be the result) but what i'm getting is path\file12.txt,
how can i have the last record not contain ","?
any help is much appreciated.
thank you
Comment: As a workaround, you can do `$test = $test -replace ',[^,]*$'`. But I would advise finding the root cause. Using `-join` on an array actually joins all elements together as a single string with the delimiter provided. It won't append the delimiter to the end of the string. You likely have a blank space or invisible character as the last element of your array.
Comment: Did you try the code? Do you really get a comma in the end? How do you fill in your variable `$folder`? ... what you descibe should not happen ...
Comment: If `path\file12.txt` is truly the only thing in `$test[-1]`, then this would not happen.
Comment: the output gives me
path\text1.txt,
path\text2.txt,
...
path\text11.txt,
path\text12.txt,
Comment: @adminofthings so on the $test[-1] -join "," ?
Comment: Try to run this code: `1,2,3,4,5,6,7 -join ' + '`  is there a ` + ` in the end then?
Comment: No. What is just the output of `$test[-1]`
Answer: As a workaround, you can do the following:
$test = $test -replace ',[^,]*$'

However, I would investigate the root cause of the issue as there could be a number of issues (or nonissues) with your data. See below for how this could happen if your final $folder element contains an ending comma:
# Example 1
# The $folder final element contains a comma in its string
# The -join does not add the comma because it is part of the string already
$folder = 'one','two','three','four,'
$path = 'c:\temp'
$test = foreach ($file in $folder) {
    Join-Path -Path $path -ChildPath $file
}
$test -join ','

#output
c:\temp\one,c:\temp\two,c:\temp\three,c:\temp\four,

In the example above, we should be able to look at the last element ([-1]) of $test and find the trailing comma:
$test[-1]
#output
c:\temp\four,

See below if $test is manipulated to have a blank (or $null) element added to the end of it:
# Example 2
# $test gets a space added as the final element
$folder = 'one','two','three','four'
$path = 'c:\temp'
$test = foreach ($file in $folder) {
    Join-Path -Path $path -ChildPath $file
}
$test += ' '
$test -join ','

#output
c:\temp\one,c:\temp\two,c:\temp\three,c:\temp\four,

The last element of $test here will be a blank line:
PS > $test[-1]

PS >

Edit Based on Comments:
You can use the format operator -f to format each query string. Then use the -join operator to combine all your string elements together.
$query = ForEach ($file in $test) {
    $sqlquery = Join-Path -Path $path -ChildPath $file
    "file='{0}'" -f $sqlquery
}
$query -join ",`n"

Comment: $path = 'c:\folder'
cd $path
#dir

$test = Get-ChildItem -path $path  -Exclude lite* -Recurse -File -Name

#write-host $test

$query = ForEach ($file in $test) {

   $sqlquery = join-path -path $path -ChildPath $file
   "file='"+$sqlquery+"',`n"
}

#output $query content
write-output $query
output is below:
file='C:\Folder\202007104.txt',
file='C:\Folder\202007104.txt',
file='C:\Folder\202007105.txt',
file='C:\Folder\202007106.txt',
....
file="C:\Folder\202007112.txt',

hope it makes sense?
Comment: You are not using `-join` there at all. Let `-join` do the work. If you want newline characters, then use ```$pathArray -join ",`n"```.
Comment: @Ralph, I added an edit at the end of my post that should help.


How to setup multiple domains on AEM as a cloud service on dispatcher

Question: I want to set up a multiple domain in aem as a cloud service how can i achieve this.
I  have create a two vhost and two rewrite files but only one vhost is get accesible
Is any one have done this configuration please provide support for this
Answer: For AEMaaCS, you define vhost settings in src/conf.d/available_vhosts and create a symlink under src/conf.d/enabled_vhosts
There is then default.vhost which is catch all configurations i.e if you dont have domain based vhost defined, it will be rendered by default.vhost.
These files are included in alphabetical order, so if for example you name your files as asite.vhost and siteb.vhost, the order in which the files will be included is asite.vhost, default.vhost and last siteb.vhost. In this case any request for siteb will be handled by default.vhost.
In most of mine multisite dispatcher configurations, I use 00_<site 1>.vhost, 00_<site2>.vhost to ensure that my sites are loaded before default.vhost.
In case this is not the case for you, can you share your configurations.


Ajax not loading

Question: I am dynamically adding options to a drop down list with ajax jquery and PHP from my DB but for some reason it is not working. Please check my code:
AJAX
$("#course").change(function() {
    var id = $(this).val();
    $.ajax({
        type: "POST",
        url: "../ajax-select.php",
        data: id,
        cache: false,
        success: function(html)
        {
            $("#sub").html(html);
        }
    });
});

ajax-select.php
<?php
if($_POST['id'])
{
    $id=$_POST['id'];
    $sql=mysql_query("SELECT * FROM `subjects` WHERE `course_id`='$id'");
    while($row=mysql_fetch_array($sql))
    {
        $id=$row['sub_id'];
        $data=$row['sub_name'];
        echo '<option value="'.$id.'">'.$data.'</option>';
    }
}
?>

HTML
<select class="form-control" name="course" id="course">
        <option value="notselectedyear" selected>Select the Course</option>
              <?select_course();?>
        </select>

    Subject
        <select class="form-control" name="sub" id="sub">
              <option value="notselectedsubject" selected>Select the subject</option>
        </select>

Additional info:

Ids assigned to the select options are correct
ajax code is in a folder called js whereas all other files are on the root
Jquery is included before the closing of the body

Where am i going wrong?
Comment: try `data: "id="+id,` or `data: {id:id},`
Comment: Have you tried making the url an absolute path, i.e. `url: "/ajax-select.php"`
Comment: Your SQL is open to SQL injection.
Comment: Are the "`" in your SQL query necessary? Also as user3558931 has stated, you are open to SQL injection. You should be using somethign like this http://php.net/manual/en/pdo.prepare.php but figure your error out first.
Answer: Concept Verification
Change:
data: id,

To:
data: {id: id},

If your content is dynamically generated (added after DOM ready) use the following:
$(document).on('change', '#course', function()
{
    //your code here
});

Comment: I tried this. I am checking the console, no request is being sent to the server
Comment: Please post your HTML or create a jsfiddle.
Comment: @HetuNandu is your `$("#course").change(function() {` wrapped in a `$(document).ready(function(){` or `$(function(){`?
Comment: @Sean $(function(){ because it is at the end of the html
Comment: Are you getting any errors? Can we take a look at your live page?
Comment: Live page is protected but there are no errors of any sorts. There is nothing on the console at all! why would it not even send a xhr request??
Comment: Ok, take a look at the demo. You'll notice that I am using your exact code with the change suggested. The code attempts an ajax request each time the select is changed. The data being sent (via POST) is `id = n`. Compare the demo and your code; if you're running your code from a local drive please move it to a server.
Comment: @user3558931 Thanks. I am seeing the demo and my code matches yours exactly. Still i am not being able to send any xhr request. JS is working. All other functions working except this which is of AJAX
Comment: Okay i have drilled down the situation to this part: It is not listening to the change of drop down, thus the function is not working. how can i rectify that?

Ajax not loading


Matplotlib "Cannot Determine Home Directory" Issue Using PyInstaller in MSYS2/MinGW

Question: This is a bit more complex than the title of the post might imply. The problem stems from me having a large GTK application written in C that spawns a Python matplotlib process that is embedded in a GTK window using the Python GTK libraries. The matplotlib script is compiled into an executable using PyInstaller. Everything works fine in a Linux environment (Ubuntu 16.04/18.04), but that is not the case when trying to compile the application for Windows using MSYS2/MinGW. When I compile the application in Windows, the plot fails with the following error:
Traceback (most recent call last):
  File "plotter.py", line 6, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "PyInstaller/loader/pyimod03_importers.py", line 531, in exec_module
  File "matplotlib/__init__.py", line 921, in <module>
  File "matplotlib/__init__.py", line 602, in matplotlib_fname
  File "matplotlib/__init__.py", line 599, in gen_candidates
  File "matplotlib/__init__.py", line 239, in wrapper
  File "matplotlib/__init__.py", line 502, in get_configdir
  File "matplotlib/__init__.py", line 444, in _get_xdg_config_dir
  File "pathlib.py", line 1104, in home
  File "pathlib.py", line 267, in gethomedir
RuntimeError: Can't determine home directory

It comes from the import of matplotlib in the script. I am not sure if this is a simple PATH issue, or if there is some other subtlety stemming from a mix of MSYS and MinGW being used to compile everything.
I created a minimal working example that replicates the problem from my larger GTK application. Since this requires some DLL's and a makefile to run, rather than simply post the code here I created a GitHub repository with a README that walks through what needs to be done to show the issue and what I did that resolved the issue. You can clone it using:
git clone https://github.com/LeighKorbel/pyinstaller_msys2_issue.git

The problem resides in the fact that I am not sure what exactly resolved the issue, and whatever it is that happened, I cannot reproduce the same resolution in my actual GTK program. The questions I have are outlined in the README, so I will post that here for additional clarity:
(1) Download and install MSYS2 from "https://www.msys2.org/".

(2) This will install both MSYS2 and MinGW to the msys2 directory on your local disk. Go into the msys2 folder and
open a MinGW64 shell as administrator.

(3) In the MinGW shell, type in the following commands to install the required packages using the Pacman package manager:

    pacman -Syu     (NOTE: You will have to perform this call and close the shell several times for it to complete!)
    pacman -S mingw-w64-x86_64-python-pip
    pacman -S mingw-w64-x86_64-python-matplotlib
    pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-gtk3 mingw-w64-x86_64-python3 mingw-w64-x86_64-python3-gobject
    pacman -S git make nano pkg-config gcc

(4) Clone the GitHub repository with the example showing the error in question:

    mkdir testing
    cd testing
    git clone https://github.com/LeighKorbel/pyinstaller_msys2_issue.git
    cd pyinstaller_msys2_issue

(5) Download PyInstaller using Python's pip package manager:

    pip install pyinstaller

(6) Now we are ready to start compiling. The first thing we need to do is run PyInstaller on the python script. This
    script is just a simple matplotlib plot that is embedded within a GTK window. Run the following commands:

    cd gtk_simple_plot
    pyinstaller plot.py

(7) After PyInstaller finishes, an executable file will now be located in "/dist/plot". This can be run from the
    command line by:

    ./dist/plot/plot.exe

(8) Now that we have verified that this works, we want to compile a very basic GTK application in C that only has a
    button that will spawn the script using GLib's g_spawn() function. However, this needs to be done in a MSYS2 shell
    because MinGW does not have the system headers needed in it. So you need to open an MSYS2 shell now as an administrator.
    After this is done, we will need to set an environment variable for pkg_config, which is used by GTK. I would
    recommend adding the following line to the .bashrc file and then closing and reopening the MSYS2 shell, but it is
    not required (you will just need to remember to export again in the case that you close and reopen the shell). Once
    the MSYS2 shell is open type in:

    nano .bashrc

(9) Scroll to the bottom of the file and type in the following:

    export PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:$PKG_CONFIG_PATH"

(10) Now exit and save by pressing "Ctrl-x", then "y", then "enter". Close and reopen the shell. Now enter the following commands:

    cd testing/call_gtk_plot_from_C
    make

(11) The GTK program will now be compiled and can be executed by running:

    ./launch.exe

(12) Press the button on the UI to launch the PyInstaller compiled matplotlib script. The following error should
     appear in the MSYS2 shell:

    Traceback (most recent call last):
      File "plotter.py", line 6, in <module>
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
      File "PyInstaller/loader/pyimod03_importers.py", line 531, in exec_module
      File "matplotlib/__init__.py", line 921, in <module>
      File "matplotlib/__init__.py", line 602, in matplotlib_fname
      File "matplotlib/__init__.py", line 599, in gen_candidates
      File "matplotlib/__init__.py", line 239, in wrapper
      File "matplotlib/__init__.py", line 502, in get_configdir
      File "matplotlib/__init__.py", line 444, in _get_xdg_config_dir
      File "pathlib.py", line 1104, in home
      File "pathlib.py", line 267, in gethomedir
    RuntimeError: Can't determine home directory

********************************************************************************************************************
QUESTION 1: WHAT IS THE CAUSE OF THIS ERROR? IS THIS FROM THE DUAL USE OF MinGW FOR PYINSTALLER AND MSYS2 FOR MAKE?
            IS IT A PATH ISSUE?
********************************************************************************************************************

(13) This error can be eliminated by performing the following: In the "call_gtk_plot_from_C" folder, edit both the
     makefile and the launch.c code (in src/) to remove all instances of "../gtk_simple_plot/" and then copy and move
     the plot.py script from the gtk_simple_plot directory into the call_gtk_plot_from_C directory. From a MinGW shell
     run make.

     NOW IT WILL MAKE EVERYTHING, EVEN THE C CODE.

(14) Run the program:

     ./launch.exe

     When you run this time it errors out with a gdk_pixbuf error. For some reason, in /dist/plot/lib/gdk-pixbuf there
     is no longer the folder "loaders" which does exist on the previous run of PyInstaller. Copy it from the dist/
     folder in gtk_simple_plot over to the dist/ folder in call_gtk_plot_from_C. Run the program again.

     NOW IT WORKS WITHOUT THE PREVIOUS HOME DIRECTORY ERROR.

********************************************************************************************************************
QUESTION 2: WHAT CAUSED IT TO WORK NOW? WAS IT THE FULL COMPILE IN MinGW? IS THERE A PATH THAT IS DIFFERENT NOW WITH
            THE PYTHON SCRIPT BEING MOVED INTO THE NEW DIRECTORY? WHY WAS THE PIXBUF MISSING?
********************************************************************************************************************

********************************************************************************************************************
QUESTION 3: WHY DOES THE C CODE COMPILE IN MinGW NOW? IT DOES NOT CONTAIN THE SYSTEM HEADERS REQUIRED FOR IT COMPILE?
********************************************************************************************************************

You can see that there are three questions that I have outlined that remain mysterious to me. If anyone could assist me with any of them, it would be greatly appreciated.
Answer: The problem is using gcc in different environments. This problem is a little complex since I had a GTK program written in C (dependent on POSIX system headers, so MSYS2 is needed), but this program is spawning a child process of a frozen Python script using PyInstaller (which is also using GTK to embed the matplotlib plot into a GTK window). The PyGobject library (which contains GLib and GTK) requires the use of a MinGW shell in order to compile it. So on one hand I have something that requires MSYS2 and on the other I have something that requires MinGW.
So the answer to Question 1 is:
It is sort of caused by the use of both MSYS2 and MinGW, but really the cause is the use of MSYS2 gcc to compile the C code and MinGW gcc to run PyInstaller on the Python script. The problem is indeed a PATH issue.
This is because the Python script inherits environment variables from MinGW, while the C GTK code inherits environment variables from MSYS2. When the Python script can't determine the home directory, this is due to the fact that they simply do not exist, so when the g_spawn() from the C code occurs, the python script errors out with HOMEPATH error.
The answer to Question 2 is:
It works now because of the simple fact that everything was compiled in the MinGW environment, so now the C code has the missing environment variable that it didn't have before.
The answer to Question 3 is:
The C code compiles in MinGW normally. This ended up being a bad minimal example because it is not dependent on any system headers. In my actual code, this is not the case. I have to ensure that everything compiles in MinGW, which requires the use of the MSYS2 gcc to compile so that it gets both the system headers it needs and is able to compile the python script using PyGobject. In order for me to get it to work, I needed to set the environment variables in the C code using g_setenv() and g_get_home_dir(). This then allowed the g_spawn() to have the environment variable that it was previously missing.


Android emulator not running with my React Native App

Question: Trying to run my React Native app in Android emulator but it keeps throwing error:
"Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error spawnSync ./gradlew EACCES. Run CLI with --verbose flag for more details."
Tried react-native run-android, npm start, react-native start... nothing worked!!!

Am I missing out something here?? struggling with this since morning. Please help....
Update:
Ran "adb devices" in terminal. Still its not working :/ Same error!!!
Comment: Import the project in Android Studio, let gradle configure all dependencies and start the app again using react-native run-android.
Answer: Check the permission on android/gradew. It should be 755 and not 644.
Run the following command inside your app root folder:
chmod 755 android/gradlew

The run: react-native run-android. If you are on Windows, make sure to run react-native run-android in CMD as administrator.
Hope it helps :)
EDIT for the new problem in the comments:
The following are a few ways you can try to fix the error you mentioned in the comments:
1) Go to FILE -> sync project with gradle files.
If no.1 doesn't work for you. Try no.2
2) Go to .gradle\caches\2.0\scripts\build_7l4t45nbnsvdcl79ol8u0beli4\ProjectScript and remove the cache.properties.lock file. If you are on windows try this as: C:\Users\<username>\.gradle\caches\<gradle version such as 2.4 or something else>\scripts>del /S *.lock
Hope this solves your problem :)
EDIT 2:
You can downgrade from your Java 13 to Java 8. It may solve your problems. However, if you are unwilling to downgrade go to build.gradle and do the following:
compileJava.options.fork = true
compileJava.options.forkOptions.executable = /path_to_javac

If you do the following above instead of downgrading you will set a concrete path which will hinder your project if you are sharing it with other developers.
This was the best I could come up with from simulating the same problem on one of my test projects in my computer. Hope it helps :)
Comment: Now its throwing error       "FAILURE: Build failed with an exception.
* What went wrong:
Could not open settings remapped class cache for 76mds5z5o9jvw4bf22hb4vayu (/Users/raksha/.gradle/caches/5.1.1/scripts-remapped/settings_dxh59uz6potz1i95k939u6umk/76mds5z5o9jvw4bf22hb4vayu/settings13bba240a07c562d578336deed5b2fbf).
> Could not open settings generic class cache for settings file '/Users/raksha/update/notif-center-app/android/settings.gradle' (/Users/raksha/.gradle/caches/5.1.1/scripts/76mds5z5o9jvw4bf22hb4vayu/settings/settings13bba240a07c562d578336deed5b2fbf)
Comment: Thanks a lot Mahir. I tried this. Deleted the lock file. But It still throws the same damn error "Could not open settings generic class cache for settings file '/Users/raksha/update/notif-center-app/android/settings.gradle' (/Users/raksha/.gradle/caches/5.1.1/scripts/76mds5z5o9jvw4bf22hb4vayu/settings/settings13bba240a07c562d578336deed5b2fbf)." "error Command failed: ./gradlew app:installDebug."
Comment: @RakshaHegde what java version are you using?
Comment: openjdk version "13.0.1" 2019-10-15
OpenJDK Runtime Environment AdoptOpenJDK (build 13.0.1+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 13.0.1+9, mixed mode, sharing)
Comment: @RakshaHegde check the edit 2 if it solves your problem.
Answer: Check if you actually have a device connected by typing this in terminal
adb devices

If there is no device detected.
Try typing this in terminal
adb kill-server
adb connect 127.0.0.1:62001
adb devices

If it looks like this

Then you have no problem with Android devices.
Try running the app again with
react-native run-android

If it's not working, try
cd android
./gradlew clean
cd ..
react-native run-android

Comment: check my updated question please. still did not work. I can see my emulator in the list of devices. But when I run "react-native run-android" it shows the same old error "Make sure you have an Android emulator running or a device connected and have set up your Android development environment". Any other way??
Answer: please add you skds path in windows or mac path environment


How to Fully customize GrapesJs UI

Question: I am using Grapesjs in my web Application for creating web pages. As I am new to GrapesJS I am not sure how to customize the UI from GrapesJs .
I just use this code.
<code>      const editor = grapes.init({
        container: '#gjs',
        fromElement: true,
        plugins: ["gjs-blocks-basic", "gjs-plugin-ckeditor",
          editor => gjsForms(editor, { /* options */ }),
          editor => gjsnavbar(editor, { /* options */ }),
          editor => styleFilter(editor, { /* options */ }),
          editor => plugin(editor, { /* options */ }),
          editor => flexbox(editor, { /* options */ }),
          editor => slider(editor, { /* options */ }),
          editor => tabs(editor, { /* options */ }),
          editor => customcode(editor, { /* options */ }),
          editor => tooltip(editor, { /* options */ }),
          editor => gjstouch(editor, { /* options */ }),
          editor => thePlugin(editor, { /* options */ }),
        ],
        pluginsOpts: {
          "gjs-blocks-basic": {
            /* ...options */
          },
          'gjs-plugin-ckeditor': {
            options: {
              language: 'en',
              startupFocus: true,
              extraAllowedContent: '*(*);*{*}', // Allows any class and any inline style
              allowedContent: true, // Disable auto-formatting, class removing, etc.
              enterMode: CKEDITOR.ENTER_BR,
              uiColor: '#0000001a', // Inline editor color
              extraPlugins: 'justify,colorbutton,panelbutton,font,sourcedialog,showblocks',
              toolbar: [
                ["Format", "-", "Bold", "Italic", "Strike", "Underline", "Subscript", "Superscript", "RemoveFormat", "-", "NumberedList", "BulletedList", "-", "Outdent", "Indent", "-", "JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock", "-", "Link", "Unlink", "Anchor", "TextColor", "BGColor", "-", "ShowBlocks", "-", "Image", "Table", "-", "Sourcedialog"]
              ]
            },
            position: 'left',
          }
        },
        fromElement: false,
        components: LandingPage.components || LandingPage.html,
        style: LandingPage.style || LandingPage.css,
      });

      editor.getConfig().showDevices = 0;

      editor.Panels.addPanel({
        id: "devices-c"
      }).get("buttons").add([{
          id: "set-device-desktop",
          command: function(e) {
            return e.setDevice("Desktop")
          },
          className: "fa fa-desktop",
          active: true
        }, {
          id: "set-device-tablet",
          command: function(e) {
            return e.setDevice("Tablet")
          },
          className: "fa fa-tablet"
        }, {
          id: "set-device-mobile",
          command: function(e) {
            return e.setDevice("Mobile portrait")
          },
          className: "fa fa-mobile"
        },
      ]);

      // Panel should re render again otherwise
      // New button will not be shown on device panel
      editor.Panels.render();
    });
  }
},
</code>
it work fine an it show as enter image description here
Now i want to change it . style of the editor
Fully customize .
Hide sidebar
Show only when select canvus object
Change Icon
Change Color
Change text Editor
How to do these task . I Have no Idea . Let me know if there is some best source to clear all things
Answer: It can be done by grapes js configuration by using element id. Here is an example for the same.
<code>  grapesjs.init({
  container: '#editor',
  storageManager: false,
  blockManager: {
    appendTo: '#blocks',
  },
  styleManager: {
    appendTo: '#styles-container',
  },
  layerManager: {
    appendTo: '#layers-container',
  },
  traitManager: {
    appendTo: '#trait-container',
  },
  selectorManager: {
    appendTo: '#styles-container',
  },
  deviceManager: {},
  plugins: [],
  pluginsOpts: {},
});
</code>
And now create UI as you want. You can also check video on Youtube for the same.

How to Fully customize GrapesJs UI


How to test ReactNative Listview item with enzyme

Question: I am using enzyme to test my component rendering.
What is the usual approach to testing ListView items? For instance, in the following example to test that when an item is clicked, it triggers the onSelect prop passing the id?
I am currently using react-native-mock which means that the ListView does not render anything, and I can't separate the item into a separate component as it needs the onSelect prop from the parent.
export default class extends React.Component {
   constructor(props) {
       super(props);
       this.dataSource = new ListView.DataSource({
           rowHasChanged: (r1, r2) => r1 !== r2
       })
    }
    renderItem = ({id, title}) => {
        const {onSelect} = this.props;
        return <Button onPress={() => onSelect(id)}>{title}</Button>;
    }
    render() {
        const dataSource = this.dataSource.cloneWithRows(this.props.items);
        return (
            <ListView dataSource={dataSource}
                      renderRow={this.renderItem } />)
    }
}

Answer: I got this working using
const wrapper = shallow(<Settings onSelect={onSelectSpy}  />);
const item = shallow(wrapper.instance().renderItem(itemProps));

I found my initial attempt while seeming to work wasn't actually doing what I had expected. I have now split the list itself and the item into separate components.
So for the minimal example in my question.
export default class extends React.Component {
   constructor(props) {
       super(props);
       this.dataSource = new ListView.DataSource({
           rowHasChanged: (r1, r2) => r1 !== r2
       })
    }
    renderItem = (rowProps) => {
        const {onSelect} = this.props;
        return <ListViewItem {...rowProps} onSelect={onSelect} />
    }
    render() {
        const dataSource = this.dataSource.cloneWithRows(this.props.items);
        return (
            <ListView dataSource={dataSource}
                      renderRow={this.renderItem } />)
    }
}

And the listview item
//ListViewItem
export default ({id, title, onSelect}) =>
   (<Button onPress={() => onSelect(id)}>{title}</Button);

Comment: You forgot closing tag on button element. Thanks for this Tom. Its a great pattern.
Comment: Scratch that this doesn't work because renderSeparator cant spread properties because it doesn't pass params as an object.
Comment: the rowProps are passed as an object? https://facebook.github.io/react-native/docs/listview.html
Comment: I actually dont know what I was doing but it works now... super weird. thanks!


Do Inner control fields give you more AP?

Question: I was playing this morning and one of the control fields I created within another control field gave me more than 2k AP.
Does this give you more AP? Or might have I created 2 control fields with one link?
Answer: Inner fields don't give you more AP but it counts MU twice (which is good for your faction).
What happened to you is probably a link that create 2 fields at the same time (if you made the link between Homestead and Cutler bay in your picture, 2 fields were created). I like to create and destroy those kind of links :), more AP.


How to get string before a particular symbol within a string

Question: Is there any way in vb.net to get the username from an email address?
For example, I've a string variable and it consists of value firstname.lastname@example.com, here I need to get the username i.e tracywilly is my expected output
Dim email_addr as string
Dim usr as string
email_addr = "email@example.com"

Comment: Searching the ampersand and then using substring ?
Comment: This probbaly won't be enough to produce a username.  A username should be unique within your application and if two different users with email addresses of `email@example.com` and `email@example.com` both register, they shouldn't both have a username of `tracywilly`.  After removing the end of the email address, you need to check to see if `tracywilly` username exists and (assuming the email address isn't already associated with a different user account/username), add a numeric suffix such as `tracywilly1` and repeat the check. etc. until a username that hasn't been used is found.
Comment: @MattWilko yes, that was an obvious mistake ;-)
Answer: You can achieve this using split() or  regex in vb.net
see the following methods
1.) split() function:
 Function username(ByVal str As String) As String
        Dim arStr As String()
        arStr = str.Split("@")
        username = arStr(0)
        Return username
    End Function

2.) regex:
Function username_1(ByVal str As String) As String
    username_1 = System.Text.RegularExpressions.Regex.Match(str, "^.*?(?=@)").ToString
    Return username_1
End Function

How does it work?
Dim email_addr as string
Dim usr as string
email_addr = "firstname.lastname@example.com"
usr = username(email_addr)
usr = username_1(email_addr)

Live Demo
Comment: Thanks for the details and this is exactly what I was looking for, God bless!!


gl_ClipDistance vs gl_CullDistance

Question: Why are there very similar yet distinct arrays: gl_ClipDistance[] vs gl_CullDistance[]?
What would be some use cases where the need for two distinct entities become apparent?
Answer: The two are different because they do different things. Clipping and culling aren't the same thing at all. If an edge crosses a clip plane, the primitive has to be clipped to be within that plane. This means generating new primitives from the old one.
If all vertices of a primitive are outside of a cull plane, then the entire primitive is culled.
You use the cull planes when you want the VS to be able to cull out primitives based on some calculation. You use clip primitives when you want primitive rendering to be bounded to some non-clip-space region (though line and point width can violate those borders).
Comment: I ran this simple experiment on the triangle example from Sascha Willems' Vulkan repo. In the vertex shader `if(0 == gl_VertexIndex)   gl_CullDistance[0]=-1.0f`; and expected the whole triangle to disappear but it didn't. I had to set the gl_CullDistance[0] to -1.0f for all three vertices to make the triangle disappear. On the other hand, gl_ClipDistance[] worked as expected.

gl_ClipDistance vs gl_CullDistance


Bad window token, you cannot show a dialog before an Activity is created or after it's hidden

Question: I am using an AppIntro library in my app.
It has 3 slides. I want to ask the user something when the third slide is shown. To achieve that I am using material dialogs by afollestad.
My code in the AppIntro Activity looks like that:
@Override
    public void onNextPressed() {
        if(this.pager.getCurrentItem() == 2) {
            MaterialDialog dialog = new MaterialDialog.Builder(getApplicationContext())
                    .title("QR Code scannen")
                    .content("Möchtest du den QR Code scannen oder selbst eingeben?")
                    .positiveText("eingeben")
                    .negativeText("scannen")
                    .onPositive(new MaterialDialog.SingleButtonCallback() {
                        @Override
                        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                            Intent intent = new Intent(getApplicationContext(), RegistrationActivity.class);
                            startActivity(intent);
                        }
                    })
                    .onNegative(new MaterialDialog.SingleButtonCallback() {
                        @Override
                        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                            // TODO
                        }
                    })
                    .show();
        }
    }

Running the App I get the following issue when I slide to the third slide:
com.afollestad.materialdialogs.MaterialDialog$DialogException:
Bad window token, you cannot show a dialog before an Activity is created or after it's hidden.
at com.afollestad.materialdialogs.MaterialDialog.show(MaterialDialog.java:1328)
at com.afollestad.materialdialogs.MaterialDialog$Builder.show(MaterialDialog.java:1317)
at com.ads.adstimer.fragment.Registration.RegistrationActivity.onNextPressed(RegistrationActivity.java:64)
at com.github.paolorotolo.appintro.AppIntro$2.onClick(AppIntro.java:118)
at android.view.View.performClick(View.java:5204)
at android.view.View$PerformClick.run(View.java:21153)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

I do not really understand the problem.
Because the AppIntro Activity is already loaded and I expect it to show a dialog when a specific fragment is shown.
How can I achieve to show a dialog when a specific slide is shown?
Comment: check http://stackoverflow.com/a/2899630/2015538
Answer: MaterialDialog dialog = new MaterialDialog.Builder(getApplicationContext())

I suppose you need to pass the Activity instance here, not the application context.
Comment: For future readers, simply use this `YourActivityClassName.this`instead of `getApplicationContext()`
Comment: The one who keeps the context of the UI is Activity (through YourActivityClassName.this). The getApplicationContext() only keep the context of the application. The dialog needs the UI context, thus we pass the Activity context.
Comment: What is the difference?
Comment: what about if you using adapter then in your bindholder you call materialDialog. i got same error.
Comment: Then it's meaningless that this library wants to receive `Context` as param in its builder. It should have been `Activity`.
Answer: This can be resolved by confirming that current Activity hasWindowFocus because when you get the context in the fragment, instead of exactly which Activity it is, it might not have windowFocus :
if (((Activity) mContext).hasWindowFocus()) {
        mDialog.show();
}

Comment: thanks man , only solution worked for me is this one , but when do we get window focus , i mean i need to show that dialog some time soon right?
Comment: @ZulqurnainJutt, Checking current activity window focus is necessary during showing/hiding views that pausing/resuming current activity. And yes, you need to show the dialog at some point. Glad that I helped.
Answer: use
 MaterialDialog dialog = new MaterialDialog.Builder(YourActivityName.class)

do not use getApplicationContext().
Comment: It should be `YourActivityClassName.this`, or simply `this`, not `.class`
Answer: Use  "this"  instead of "getApplicationContext()"     if this error happening even inside the activity.
    mProgress = new MaterialDialog.Builder(this)

Answer: public class MainActivity extend Activity{

    MaterialDialog dialog;

    protected void onCreate(Bundle savedInstanceState) {

        dialog =  new MaterialDialog.Builder(OrderInfoActivity.this)
                .title("Reject?")
                .content("Are you reject this order?")
                .onPositive(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(MaterialDialog dialog, DialogAction which) {
                        Toast.makeText(OrderInfoActivity.this, "Option1", Toast.LENGTH_SHORT).show();
                        }
                })
                .onNeutral(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(MaterialDialog dialog, DialogAction which) {
                        Toast.makeText(OrderInfoActivity.this, "Option 2", Toast.LENGTH_SHORT).show();
                    }
                })
                .onNegative(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(MaterialDialog dialog, DialogAction which) {
                        Toast.makeText(OrderInfoActivity.this, "Option 3", Toast.LENGTH_SHORT).show();
                    }
                }).build();

        accept.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                  dialog.show();
            }
        });
    }
}

Here is what i'm using right now, and it's working
Hope it helps :)
Answer: MaterialDialog dialog = new MaterialDialog.Builder(getApplicationContext())
I suppose you need to pass the Activity instance here, not the application context.


Context with data from url

Question: I'm trying to make a spotify stats app and I'm trying to make a context to save the token that the app gives you in the url when the user logs in.
TokenContext.js:
import React, { useEffect, useState } from "react";

// token is the state
// logOut and logIn is a function for changing the state.
export const TokenContext = React.createContext({
    token: "",
    logOut: () => { },
    logIn: () => { }
});

function getInitialState() {
    const token = localStorage.getItem('token')
    return token ? token : ""
}

const TokenContextProvider = (props) => {

    const [token, setToken] = useState(getInitialState);

    // Use Effect for getting the token form the url and saving it in the local storage
    useEffect(() => {
        const hash = window.location.hash
        let _token = window.localStorage.getItem("token")

        if (!_token && hash) {
            _token = hash.substring(1).split("&").find(elem => elem.startsWith("access_token")).split("=")[1]

            window.location.hash = ""
            window.localStorage.setItem("token", _token)
        }
        setToken(_token)

    }, [])

    const logIn = (token) => {
        setToken(token);
    };

    const logOut = () => {
        setToken("")
        window.localStorage.removeItem("token")
    }

    return (
        <TokenContext.Provider
            value={{ token: token, logOut: logOut, logIn: logIn }}
        >
            {props.children}
        </TokenContext.Provider>
    );
};

export default TokenContextProvider;

The problem is that the useEffect hook isn't working because it is not saving the token in the local storage and the url keeps the same when the user already logged in.
Example of how the url stays:
http://localhost:3000/#access_token=BQA4OEmPw6VRknPFNW9Z2dS-uGZHbEJ3WbAWJy-jmsLFEy_PWMgMMfMYKqAQKdNgd6j1FDPIKYTNlztx2L1IgwC_gLvee-xx0hj8rKOVgDVtN1NktbhV4sHRtuzK_1EaRNGjrzxvkvXqdQ3jd0NiD4mHzd1uWC2udWTXejHDXHf9x8K3MxZGIQ&token_type=Bearer&expires_in=3600
Answer: useEffect runs only once (when the context provider is mounted) - are you sure that the URL already contains the access token at that time?
Maybe you just need to add a dependency to your effect that will cause the effect to re-run when the URL changes as described here.
Comment: It is still not working, now I'm doubting if it is the useEffect hook or something else .

Context with data from url


relation between coplanarity and collinear

Question: According to my textbook ,if a and b are two vectors which are non zero and non collinear  then any vector coplanar with them can be expressed as r=xa+yb.
Does this mean that if three vectors are coplanar then they are non-collinear and also why can't collinear vectors be coplanar?
Comment: So if vectors are collinear so we can always get a plane where the vectors or their displacement can lie ?
Comment: Coplanar vectors _can_ be collinear. And collinear vectors are _always_ coplanar.
Comment: It looks like you're misinterpreting the logic of an if-then type statement.
Comment: i just went by the definition by the book ...that's why i am asking for a detailed answer as i know i am confused.it will be kind if you post an answer for my question.
Comment: Yes, just take any new vector which is not collinear, and form a plane.
Comment: thanx,that clears my doubt
Answer: any 2 non-collinear vectors create a plane, means that any 2 vectors that non-collinear are linearly independent. so any vector in the plane can be created by linear combination of those 2. this is what your book say
let's say what collinear is: 2 vectors are collinear if they are on the same line
now what coplanar is: 2 vectors are coplanar if they are on the same plane
so collinear vectors ARE coplanar but coplanar vectors CAN BE collinear.
Comment: Can we say the same for collinear vectors for eg if there are two collinear vectors then there will be infinite number of planes passing through them so they are coplanar?
Comment: kay i understood what you were saying but how exactly does two vectors create plane?I am new to this topic so i don't know much details about these things.
Comment: @user42172 think about the x-axis and y-axis in 2D graph. Now think about 2 vectors, one will be a vector with the length of one and in the direction of the x-axis and one is the same length with the direction of the y-axis. So any point on the plane(the whole graph) is equal to the x value of the point times the first vector and the y value of the point times the second vector. This is an example for 2 perpendicular vectors but it works simularly with any 2 non-collinear(it can be more generalize after you'll learn more about linearly independent vectors)
Comment: this  really helped me a lot but i couldn't unnderstand the part  the length of the planes.Is tihe vector whose direction is in x axis extend upto its length and same with y axis.
Comment: @user42172 the 2 vectors have length of 1. Maybe an example will help. The vectors will be called $x_0,y_0$: let's say I have the point $(3,7)$(3 is the x-axis and 7 the y-axis) I can say that that point is $3x_0+7y_0$ like wise I can do for every point on the graph. So those 2 vectors creat a plane
Comment: https://www.google.co.in/search?q=vector+space+span&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjGhvS4yZjXAhWHpY8KHYu7CQ4Q_AUICigB&biw=1067&bih=529#imgrc=uq5xGPc5lBWpmM: In this example ,the two vectors spanning the plane are not of unit length infact they have different length so the will  plane still be forme even if they have different length?
Comment: Also do these vectors decide how the plane will direct i e  span in direction?
Comment: @user42172 the length is doesn't matter, the thing is that one vector times a number(scalar) plus the other vector times a number(scalar) can get you to every point on the plane.if the vector is two times longer then the number will be 2 times less(times 0.5)
Comment: @user42172 well, in higher dimensions yes, the way vectors decide the "direction" of the plane(it is not exactly direction but it is close enough for now) but in 2 dimensions the plane is the WHOLE graph so no, in 2D it doesn't matter
Comment: @user42172 exactly, this is why collinear vectors ARE coplanar, but you can't say the opposite
Comment: This pretty much solves my doubt...Thank you for your clear answers.


Make windows visual code mouse copy/paste behave like linux

Question: How to select text with double click in Visual Studio TEMINAL and copy to command line with 3 clicks instead of 4 clicks.
double click on text -> right click -> selected text in TERMINAL command line

instead of
double click on text -> right click -> right click -> selected text in TERMINAL command line

I have selected terminal.integrated.copyOnSelection, but this is not what I want.
Comment: I do not get a context menu in the Terminal, why do you need to `right-click` twice, when `right-click` in text editor I do not get this `in Terminal command line`
Comment: I would like to select text with **left double click** (in Visual Code Terminal) and paste with **one single right click** (in Visual Code Terminal). The windows command line has the same "lets say" standard behavior **left double click** to select text and to copy hit **once right click** and to paste again **right click**.
Comment: For example, PuTTY has the normal bevaiour, three simple clicks and you have text in command line. I can't get it in Visual Code. I'm using Visual Code with Kubernetes and Docker and I expect Linux behaviour : ) Any ideas?
Comment: in my windows cmd terminal it is: right-click=>Mark, select text, right-click, right-click=>Paste, 5 clicks and a select with left, in VSC cmd Integrated Terminal: select text with drag-left, right-click, right-click (paste on second right-click) double click with left does also work. I have used the terminal a lot but did not knew this.
Comment: cmd -> Properties -> Options -> Edit Options and add tick to QuickEdit Mode. You don't need to use Mark if QuickEdit Mode was set.
Comment: So, I figured out, that left mouse double on text in VS Code selects text and Shift+Insert puts text to command line. Still, I'm looking for paste with one right mouse click.
Answer: Romasius I think what you're looking for is terminal.integrated.rightClickBehavior and change that setting to 'paste' instead of 'copypaste'.


Installation failed, reverting ./composer.json to its original content symfony 3

Question: I have a problem when i install sonata bundle or fosuserbundle in terminal with command :
php ../composer.phar require sonata-project/admin-bundle

i have this error
pros-MBP:BigManage pro$ php ../composer.phar require sonata-project/admin-bundle
Using version ^3.17 for sonata-project/admin-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - symfony/framework-bundle v2.0.18 requires symfony/dependency-injection v2.0.18 -> no matching package found.
    - symfony/framework-bundle v2.0.17 requires symfony/dependency-injection v2.0.17 -> no matching package found.
    - symfony/framework-bundle 2.0.7 requires symfony/translator 2.0.7 -> no matching package found.
    - Installation request for desarrolla2/blog-bundle dev-master -> satisfiable by desarrolla2/blog-bundle[dev-master].
    - Conclusion: remove symfony/symfony v3.2.7
    - Conclusion: don't install symfony/symfony v3.2.7
    - desarrolla2/blog-bundle dev-master requires knplabs/knp-paginator-bundle ~2.4.1 -> satisfiable by knplabs/knp-paginator-bundle[2.4.1, 2.4.2].
    - knplabs/knp-paginator-bundle 2.4.2 requires symfony/framework-bundle ~2.0 -> satisfiable by symfony/framework-bundle[2.0.7, v2.0.10, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.0.21, v2.0.22, v2.0.23, v2.0.24, v2.0.25, v2.0.9, v2.1.0, v2.1.1, v2.1.10, v2.1.11, v2.1.12, v2.1.13, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9, v2.2.0, v2.2.1, v2.2.10, v2.2.11, v2.2.2, v2.2.3, v2.2.4, v2.2.5, v2.2.6, v2.2.7, v2.2.8, v2.2.9, v2.3.0, v2.3.1, v2.3.10, v2.3.11, v2.3.12, v2.3.13, v2.3.14, v2.3.15, v2.3.16, v2.3.17, v2.3.18, v2.3.19, v2.3.2, v2.3.20, v2.3.21, v2.3.22, v2.3.23, v2.3.24, v2.3.25, v2.3.26, v2.3.27, v2.3.28, v2.3.29, v2.3.3, v2.3.30, v2.3.31, v2.3.32, v2.3.33, v2.3.34, v2.3.35, v2.3.36, v2.3.37, v2.3.38, v2.3.39, v2.3.4, v2.3.40, v2.3.41, v2.3.42, v2.3.5, v2.3.6, v2.3.7, v2.3.8, v2.3.9, v2.4.0, v2.4.1, v2.4.10, v2.4.2, v2.4.3, v2.4.4, v2.4.5, v2.4.6, v2.4.7, v2.4.8, v2.4.9, v2.5.0, v2.5.1, v2.5.10, v2.5.11, v2.5.12, v2.5.2, v2.5.3, v2.5.4, v2.5.5, v2.5.6, v2.5.7, v2.5.8, v2.5.9, v2.6.0, v2.6.1, v2.6.10, v2.6.11, v2.6.12, v2.6.13, v2.6.2, v2.6.3, v2.6.4, v2.6.5, v2.6.6, v2.6.7, v2.6.8, v2.6.9, v2.7.0, v2.7.1, v2.7.10, v2.7.11, v2.7.12, v2.7.13, v2.7.14, v2.7.15, v2.7.16, v2.7.17, v2.7.18, v2.7.19, v2.7.2, v2.7.20, v2.7.21, v2.7.22, v2.7.23, v2.7.24, v2.7.25, v2.7.26, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.10, v2.8.11, v2.8.12, v2.8.13, v2.8.14, v2.8.15, v2.8.16, v2.8.17, v2.8.18, v2.8.19, v2.8.2, v2.8.3, v2.8.4, v2.8.5, v2.8.6, v2.8.7, v2.8.8, v2.8.9].
    - knplabs/knp-paginator-bundle 2.4.1 requires symfony/framework-bundle ~2.0 -> satisfiable by symfony/framework-bundle[2.0.7, v2.0.10, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.0.21, v2.0.22, v2.0.23, v2.0.24, v2.0.25, v2.0.9, v2.1.0, v2.1.1, v2.1.10, v2.1.11, v2.1.12, v2.1.13, v2.1.2, v2.1.3, v2.1.4, v2.1.5, v2.1.6, v2.1.7, v2.1.8, v2.1.9, v2.2.0, v2.2.1, v2.2.10, v2.2.11, v2.2.2, v2.2.3, v2.2.4, v2.2.5, v2.2.6, v2.2.7, v2.2.8, v2.2.9, v2.3.0, v2.3.1, v2.3.10, v2.3.11, v2.3.12, v2.3.13, v2.3.14, v2.3.15, v2.3.16, v2.3.17, v2.3.18, v2.3.19, v2.3.2, v2.3.20, v2.3.21, v2.3.22, v2.3.23, v2.3.24, v2.3.25, v2.3.26, v2.3.27, v2.3.28, v2.3.29, v2.3.3, v2.3.30, v2.3.31, v2.3.32, v2.3.33, v2.3.34, v2.3.35, v2.3.36, v2.3.37, v2.3.38, v2.3.39, v2.3.4, v2.3.40, v2.3.41, v2.3.42, v2.3.5, v2.3.6, v2.3.7, v2.3.8, v2.3.9, v2.4.0, v2.4.1, v2.4.10, v2.4.2, v2.4.3, v2.4.4, v2.4.5, v2.4.6, v2.4.7, v2.4.8, v2.4.9, v2.5.0, v2.5.1, v2.5.10, v2.5.11, v2.5.12, v2.5.2, v2.5.3, v2.5.4, v2.5.5, v2.5.6, v2.5.7, v2.5.8, v2.5.9, v2.6.0, v2.6.1, v2.6.10, v2.6.11, v2.6.12, v2.6.13, v2.6.2, v2.6.3, v2.6.4, v2.6.5, v2.6.6, v2.6.7, v2.6.8, v2.6.9, v2.7.0, v2.7.1, v2.7.10, v2.7.11, v2.7.12, v2.7.13, v2.7.14, v2.7.15, v2.7.16, v2.7.17, v2.7.18, v2.7.19, v2.7.2, v2.7.20, v2.7.21, v2.7.22, v2.7.23, v2.7.24, v2.7.25, v2.7.26, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.10, v2.8.11, v2.8.12, v2.8.13, v2.8.14, v2.8.15, v2.8.16, v2.8.17, v2.8.18, v2.8.19, v2.8.2, v2.8.3, v2.8.4, v2.8.5, v2.8.6, v2.8.7, v2.8.8, v2.8.9].
    - don't install symfony/framework-bundle v2.7.0|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.1|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.10|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.11|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.12|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.13|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.14|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.15|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.16|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.17|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.18|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.19|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.2|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.20|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.21|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.22|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.23|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.24|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.25|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.26|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.3|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.4|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.5|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.6|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.7|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.8|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.7.9|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.0|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.1|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.10|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.11|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.12|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.13|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.14|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.15|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.16|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.17|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.18|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.19|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.2|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.3|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.4|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.5|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.6|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.7|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.8|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.8.9|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.0|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.1|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.10|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.11|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.12|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.13|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.14|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.15|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.16|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.17|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.18|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.19|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.2|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.20|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.21|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.22|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.23|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.24|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.25|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.26|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.27|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.28|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.29|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.3|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.30|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.31|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.32|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.33|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.34|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.35|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.36|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.37|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.38|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.39|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.4|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.40|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.41|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.42|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.5|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.6|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.7|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.8|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.3.9|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.4.0|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.4.1|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.4.10|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.4.2|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.4.3|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.4.4|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.4.5|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.4.6|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.4.7|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.4.8|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.4.9|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.5.0|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.5.1|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.5.10|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.5.11|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.5.12|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.5.2|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.5.3|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.5.4|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.5.5|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.5.6|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.5.7|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.5.8|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.5.9|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.6.0|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.6.1|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.6.10|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.6.11|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.6.12|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.6.13|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.6.2|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.6.3|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.6.4|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.6.5|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.6.6|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.6.7|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.6.8|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.6.9|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.1.0|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.1.1|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.1.10|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.1.11|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.1.12|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.1.13|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.1.2|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.1.3|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.1.4|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.1.5|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.1.6|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.1.7|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.1.8|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.1.9|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.2.0|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.2.1|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.2.10|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.2.11|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.2.2|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.2.3|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.2.4|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.2.5|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.2.6|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.2.7|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.2.8|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.2.9|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.0.10|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.0.12|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.0.13|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.0.14|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.0.15|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.0.16|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.0.19|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.0.20|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.0.21|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.0.22|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.0.23|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.0.24|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.0.25|don't install symfony/symfony v3.2.7
    - don't install symfony/framework-bundle v2.0.9|don't install symfony/symfony v3.2.7
    - Installation request for symfony/symfony (locked at v3.2.7, required as 3.2.*) -> satisfiable by symfony/symfony[v3.2.7].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.

can you help me ??
Answer: There is a possible-error message in the composer output
Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

the repo https://github.com/sonata-project/SonataAdminBundle  doesn't seem to have the first issue.
This could possibly the second issue. As in you have to check your composer.json to make sure if you requirements match with
"php": "^5.3 || ^7.0",
"doctrine/common": "^2.2",
"doctrine/inflector": "^1.0",
"knplabs/knp-menu-bundle": "^2.1.1",
"sonata-project/block-bundle": "^3.2",
"sonata-project/core-bundle": "^3.1",
"sonata-project/exporter": "^1.7",
"symfony/class-loader": "^2.3 || ^3.0",
"symfony/config": "^2.3.9 || ^3.0",
"symfony/console": "^2.3 || ^3.0",
"symfony/dependency-injection": "^2.3.3 || ^3.0",
"symfony/expression-language": "^2.4 || ^3.0",
"symfony/form": "^2.3.5 || ^3.0",
"symfony/http-foundation": "^2.3 || ^3.0",
"symfony/property-access": "^2.3 || ^3.0",
"symfony/routing": "^2.3 || ^3.0",
"symfony/security-acl": "^2.3 || ^3.0",
"symfony/security-bundle": "^2.3 || ^3.0",
"symfony/templating": "^2.3 || ^3.0",
"symfony/translation": "^2.3 || ^3.0",
"symfony/twig-bridge": "^2.3.5 || ^3.0",
"symfony/validator": "^2.3 || ^3.0",
"twig/extensions": "^1.0",
"twig/twig": "^1.28 || ^2.0"