qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
11,627 | So tell me know, can you figure out,
The clues I'll give are all about
A subject many really quite hate,
The moment they hear it, from the gate.
It really is useful, as science would say,
Scientific conclusions use it every day.
The chances too are great, can you see
If you use it, or hear what they may be.
Consider now these clues, not so mean.
Stay away from numbered errors, as they're seen.
So check the clues, the hidden and viewed
Something's lurking, what do you conclude? | 2015/04/06 | [
"https://puzzling.stackexchange.com/questions/11627",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/9951/"
] | My guess is that it is
>
> Statistics / Probability
>
>
>
And the hidden clue is the first letter of each line:
>
> STATISTICSSS
>
>
>
So tell me know, can you figure out,
The clues I'll give are all about
A subject many really quite hate,
>
> *I* certainly did not enjoy my statistics courses
>
>
>
The moment they hear it, from the gate.
>
> "From the gate" could refer to various kinds of animal racing and odds are given in all such races for the purposes of betting
>
>
>
It really is useful, as science would say,
Scientific conclusions use it every day.
>
> All good scientific conclusions based on data will include a statistical probability of the conclusions being accurate
>
>
>
The chances too are great, can you see
If you use it, or hear what they may be.
>
> "Chances" is another term for probability
>
>
>
Consider now these clues, not so mean.
>
> "Mean" is a term used in statistics to mean the average
>
>
>
Stay away from numbered errors, as they're seen.
>
> We want to avoid errors in data collection as that'll mess up the conclusion. Small errors are one indicator of good data.
>
>
>
So check the clues, the hidden and viewed
Something's lurking, what do you conclude? | Sounds like
>
> Math
>
>
>
A subject many really quite hate,
The moment they hear it, from the gate.
>
> Many people dislike math
>
>
>
It really is useful, as science would say,
Scientific conclusions use it every day.
>
> Math is useful in science!
>
>
>
The chances too are great, can you see
If you use it, or hear what they may be.
>
> Probability is part of math
>
>
>
Consider now these clues, not so mean.
Stay away from numbered errors, as they're seen.
>
> "numbered" -> "numbers" -> "math"
>
>
> |
11,627 | So tell me know, can you figure out,
The clues I'll give are all about
A subject many really quite hate,
The moment they hear it, from the gate.
It really is useful, as science would say,
Scientific conclusions use it every day.
The chances too are great, can you see
If you use it, or hear what they may be.
Consider now these clues, not so mean.
Stay away from numbered errors, as they're seen.
So check the clues, the hidden and viewed
Something's lurking, what do you conclude? | 2015/04/06 | [
"https://puzzling.stackexchange.com/questions/11627",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/9951/"
] | Is it
>
> Statistics?
>
>
>
So tell me know, can you figure out,
The clues I'll give are all about
A subject many really quite hate,
The moment they hear it, from the gate.
>
> Many people have a negative attitude towards statistics: there are lies, there are damned lies, and there is statistics.
>
>
>
It really is useful, as science would say,
Scientific conclusions use it every day.
>
> Statistics is used everywhere in science, from physics over chemistry and biology to economics.
>
>
>
The chances too are great, can you see
If you use it, or hear what they may be.
Consider now these clues, not so mean.
Stay away from numbered errors, as they're seen.
>
> "chances", "mean", "errors": standard terms in statistics
>
>
>
So check the clues, the hidden and viewed
Something's lurking, what do you conclude? | My guess is that it is
>
> Statistics / Probability
>
>
>
And the hidden clue is the first letter of each line:
>
> STATISTICSSS
>
>
>
So tell me know, can you figure out,
The clues I'll give are all about
A subject many really quite hate,
>
> *I* certainly did not enjoy my statistics courses
>
>
>
The moment they hear it, from the gate.
>
> "From the gate" could refer to various kinds of animal racing and odds are given in all such races for the purposes of betting
>
>
>
It really is useful, as science would say,
Scientific conclusions use it every day.
>
> All good scientific conclusions based on data will include a statistical probability of the conclusions being accurate
>
>
>
The chances too are great, can you see
If you use it, or hear what they may be.
>
> "Chances" is another term for probability
>
>
>
Consider now these clues, not so mean.
>
> "Mean" is a term used in statistics to mean the average
>
>
>
Stay away from numbered errors, as they're seen.
>
> We want to avoid errors in data collection as that'll mess up the conclusion. Small errors are one indicator of good data.
>
>
>
So check the clues, the hidden and viewed
Something's lurking, what do you conclude? |
11,627 | So tell me know, can you figure out,
The clues I'll give are all about
A subject many really quite hate,
The moment they hear it, from the gate.
It really is useful, as science would say,
Scientific conclusions use it every day.
The chances too are great, can you see
If you use it, or hear what they may be.
Consider now these clues, not so mean.
Stay away from numbered errors, as they're seen.
So check the clues, the hidden and viewed
Something's lurking, what do you conclude? | 2015/04/06 | [
"https://puzzling.stackexchange.com/questions/11627",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/9951/"
] | Is it
>
> Statistics?
>
>
>
So tell me know, can you figure out,
The clues I'll give are all about
A subject many really quite hate,
The moment they hear it, from the gate.
>
> Many people have a negative attitude towards statistics: there are lies, there are damned lies, and there is statistics.
>
>
>
It really is useful, as science would say,
Scientific conclusions use it every day.
>
> Statistics is used everywhere in science, from physics over chemistry and biology to economics.
>
>
>
The chances too are great, can you see
If you use it, or hear what they may be.
Consider now these clues, not so mean.
Stay away from numbered errors, as they're seen.
>
> "chances", "mean", "errors": standard terms in statistics
>
>
>
So check the clues, the hidden and viewed
Something's lurking, what do you conclude? | The answer is
>
> Statistics.
>
>
>
Martin was too quick with the rest of the clues, but here's the hidden clue:
>
> Acrostic
>
>
> |
11,627 | So tell me know, can you figure out,
The clues I'll give are all about
A subject many really quite hate,
The moment they hear it, from the gate.
It really is useful, as science would say,
Scientific conclusions use it every day.
The chances too are great, can you see
If you use it, or hear what they may be.
Consider now these clues, not so mean.
Stay away from numbered errors, as they're seen.
So check the clues, the hidden and viewed
Something's lurking, what do you conclude? | 2015/04/06 | [
"https://puzzling.stackexchange.com/questions/11627",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/9951/"
] | My guess is that it is
>
> Statistics / Probability
>
>
>
And the hidden clue is the first letter of each line:
>
> STATISTICSSS
>
>
>
So tell me know, can you figure out,
The clues I'll give are all about
A subject many really quite hate,
>
> *I* certainly did not enjoy my statistics courses
>
>
>
The moment they hear it, from the gate.
>
> "From the gate" could refer to various kinds of animal racing and odds are given in all such races for the purposes of betting
>
>
>
It really is useful, as science would say,
Scientific conclusions use it every day.
>
> All good scientific conclusions based on data will include a statistical probability of the conclusions being accurate
>
>
>
The chances too are great, can you see
If you use it, or hear what they may be.
>
> "Chances" is another term for probability
>
>
>
Consider now these clues, not so mean.
>
> "Mean" is a term used in statistics to mean the average
>
>
>
Stay away from numbered errors, as they're seen.
>
> We want to avoid errors in data collection as that'll mess up the conclusion. Small errors are one indicator of good data.
>
>
>
So check the clues, the hidden and viewed
Something's lurking, what do you conclude? | The answer is
>
> Statistics.
>
>
>
Martin was too quick with the rest of the clues, but here's the hidden clue:
>
> Acrostic
>
>
> |
2,156 | Today suddenly in our production environment we got an error while opening any building block of any publication.
The error is:
>
> Class does not support Automation or does not support expected interface.
>
>
>
If the error was specific to a particular publication I could have narrowed it down but currently the issue is for all the publications.
The issue was resolved by restarting all the services but I really need to know the cause for it.
Event viewer logged the following:
>
> Unable to get list of SDL Tridion Content Manager items.
> Class does not support Automation or does not support expected interface
>
>
> Error Code:
> 0x1AE (430)
>
>
> Call stack:
> Folder.GetListItems
>
>
> | 2013/07/12 | [
"https://tridion.stackexchange.com/questions/2156",
"https://tridion.stackexchange.com",
"https://tridion.stackexchange.com/users/451/"
] | A possible cause of this kind of issue is a memory leak. Sometimes, instead of out-of-memory errors, COM raises automation errors or interface errors. My suggestion is that you set up some perfmon traces on the private bytes of the relevant processes. If this is the problem, you'll see the memory going up to unsustainable levels just before you start to see the errors you report.
Another thing to check is MSDTC. Do you have any unresolved transactions? Having said that, memory issues are a more likely cause. | Confirm the Windows Service 'Tridion Content Manager Service Host' service is running.
I have seen this error in the past for myself. It's a new Tridion service introduced in Tridion 2011 and is responsible for calling the Core Service from the Tridion GUI. |
542,661 | In my astro class we are learning about red/blue-shifting and I was wondering how to related to stars. So if a star is moving in some direction, the light leaving the direction of motion would be blueshifted, while the light coming out the back of the star would be red-shifted. The problem is then, doesn't the light leaving in the direction of motion carry more momentum due to its lower wavelength. So we have an unbalanced situation. So shouldn't the star slow or even stop over time?
My intuitive guess is that it has something to do with the two different relative frames, one from the star and one from an external observer. That or something do with with the changing mass of the star? Like it really is slowing down but it is losing mass at the same time so it balances out.
Not really expecting an answer but just wondering where my thinking is wrong. | 2020/04/09 | [
"https://physics.stackexchange.com/questions/542661",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/55884/"
] | First off, we know the star can't actually slow down, because we can go to the initial reference frame of the star. In this frame, the star is stationary and emits radiation equally in all directions, so it can't start accelerating. So it doesn't accelerate in the original frame either.
In the original frame, it is true that the radiation emitted carries net momentum, so the momentum of the star goes down. But momentum depends on both mass and velocity, and it's in fact the *mass* of the star that goes down, not the velocity. Specifically, the mass goes down because $E = mc^2$ and the star is losing energy to the radiation. In fact, an argument much like this was one of Einstein's arguments for $E = mc^2$. | The acceleration (or **proper** acceleration) due to the **proper** forces on the star must be calculated **in the rest frame of the star**, in which there is no Doppler shift. Otherwise you are only looking at a mangled form of the Newtonian equations, which is confusing at best and likely to be actually incorrect.
Incidentally, the idea that mass increases is a part of the mangling of Newtonian equations. It was superseded when Einstein produced general relativity in 1915 showing how to formulate the laws of physics using tensor quantities (including vectors and scalars), which are the same for all observers. Modern treatments use only invariant mass, or rest mass. It is a great pity that relativistic mass has not been banished from low grade accounts. |
60,470 | It seems to me that the degree three equations have a special place among algebraic equations. Let me clarify what I have in mind.
1. Degree 3 curves: The only curves that hold a group structure.
2. Degree 3 surfaces in $\mathbb P^3$: The only surfaces whose curves are not covered by the Noether-Lefchetz Theorem and therefore they are not complete intersection.
3. Threefold. Here, one can find examples (the only ones?) of unirrational varieties which are not rational. (can be done by looking at the intermediate jacobian).
Here is my question. Is there a phenomena like this in some other degrees?
In other words, now I'm inclined to think that there is something very special about degree three equations, could this be true? or I'm just happen to be missing other equally important examples in other degrees?
Any answers/comments/examples will be appreciated.
Edit: sure, I deliberately didn't say anything about smoothness and very general surfaces. In order to keep the question simple, please put the sentence in context. | 2011/04/03 | [
"https://mathoverflow.net/questions/60470",
"https://mathoverflow.net",
"https://mathoverflow.net/users/1547/"
] | There are certainly some very nice properties of degree $3$ objects, but I agree with Chuck and Scott, that what you are observing is that this is the first non-trivial case of *anything*. On one hand that means that you will observe interesting behavior, on the other that there might be a larger literature dealing with this case.
Also, I can't help but comment on some of what you say in the question:
You say:
>
> "Degree $3$ surfaces in $\mathbb P^3$: The only surfaces whose curves are not covered by the Noether-Lefchetz Theorem and therefore they are not complete intersection."
>
>
>
First of all the correct statement is the opposite: curves on cubic surfaces are not complete intersections and *therefore* the Noether-Lefschetz Theorem cannot be true. But this is an insignificant detail. Here $3$ is not that important. The main reason this happens is that all smooth cubics famously contain lines (27) and a curve of degree $c$ on a surface of degree $d>c$ cannot be a complete intersection. Also, the Noether-Lefschetz Theorem also fails for quadrics, that is degree $2$ surfaces: Their Picard group is rank $2$, so $\mathrm{Pic}(\mathbb P^3)\simeq \mathbb Z$ cannot surject onto it. So this isn't a real #$3$ mystery unless you count that $3$ is the largest degree where it fails, but then one could say that $4$ is the *smallest* where it holds, so $4$ is special.
Then again, you could add to your list: by the Lefschetz hyperplane theorem, the restriction of the Picard group to a hyperplane section is an isomorphism if the dimension is larger than $3$! So you could say dimension $3$ is the largest dimension where this fails. But this is really the same thing as the the Noether-Lefschetz thing.
And then you say:
>
> "Threefold. Here, one can find examples (the only ones?) of unirrational varieties which are not rational. (can be done by looking at the intermediate jacobian)."
>
>
>
There are at least two things wrong with this:
1. Those threefolds could be cubic (great!) but also quartic (that darn $4$ again).
2. This does not only happen in dimension three.
However, there is an interesting detail about cubic equations: It is expected that a very general cubic fourfold is unirational but not rational, but I believe this has not been proven yet.
In arbitrary dimension and degree we have some general results.
János Kollár proved in [this paper](http://www.ams.org/journals/jams/1995-08-01/S0894-0347-1995-1273416-8) that
>
> **Theorem** (Kollár): Let $X\_d\subset \mathbb P^{n+1}$ be a very general hypersurface over $\mathbb C$ of degree $d\geq \frac 23(n + 3)$.
> Assume in addition that $n$ and $d$ are both even. Then $X\_d$ is not (birationally) ruled.
>
>
>
*Remark* Obviously then $X\_d$ is not rational.
On the other hand, Morin proved in
Morin, Ugo
*Sull'unirazionalità dell'ipersuperficie algebrica di qualunque ordine e dimensione sufficientemente alta.* (Italian) Atti Secondo Congresso Un. Mat. Ital., Bologna, 1940, pp. 298–302 Edizioni Cremonense, Rome, 1942.
that a general hypersurface is unirational if its dimension is sufficiently large with respect to the degree. (There is an explicit formula for this). Since then there has been generalizations of this by Harris-Mazur-Pandharipande and Xi Chen.
It is also interesting to compare these to rational connectivity. Every Fano manifold is rationally connected, so Kollár's theorem implies that there are plenty of examples of rationally connected but not rational varieties.
The most interesting open problem in the area is that everyone expects that there are many rationally connected but not unirational varieties, but nobody knows an example.
Finally, let me finish with the
**Group Law**
This is indeed remarkably unique. As Scott pointed out we need to restrict to smooth cubic plane curves, but that is what you meant.
I'd like to remark that this is indeed about the number $3$ being special.
Consider curves of degree $d$ in $\mathbb P^2$. These are parametrized by a projective space $\mathbb P^N$ where $N= {d+2\choose 2}-1= \frac 12 d(d+3)$. Containing a fixed point of $\mathbb P^2$ imposes a linear condition on this space, so specifying $N$ points in general position determines a unique degree $d$ curve.
Generally two curves of degree $d$ will intersect in $d^2$ points.
It turns out that $N=d^2$ for $d=3$ and this is why the group law defined by drawing lines is associative. Of course, there are more places where $3$ is needed, but those are sort of obvious reasons that one needs to even define the group law and this is a little bit more hidden.
Anyway, I should quit, but I want to say that my goal was not to take apart your question just to show that most of the nice properties you listed actually appear in more places. | The philosophical reasons why degree three equations share unique properties could be so wide-ranging as to make the question essentially self-fulfilling: if you look for an answer you will find it. For instance, it might be because we perceive space three-dimensionally or because 3 is the first odd prime - in my mind both these explanations are irrelevant but they go to show that if you're looking for heuristics on very wide-ranging phenomena, then pretty much anything you say makes sense.
If I were you, I would instead ask the following: To what extent are the pathological properties of degree-three algebraic equations more numerous and pervasive than those of algebraic equations in other degrees *because* of reasons other than the fact that degree 3 is the first 'interesting' case of several curves and surfaces on which generalizations will be based? That is to say: is the difficulty of proving 3-dimensional Poincare an indication that there is something pathological about the 3-sphere or that 3 dimensional beings are the only ones who would find the Poincare conjecture interesting and pursue a proof?
My (underdeveloped) philosophical intuitions veer towards the latter... |
5,284,706 | I have created a ShapeDrawable and placed it within an imageview that is dynamically created within my layout. Here's the code I use to assign the drawable to my ImageView. Notice that I call on a method to set a random color, I also set the height and width using user filled text fields, but that's irrelevant here.
```
ShapeDrawable shape;
public void makeShape(){
shape = new ShapeDrawable(new RectShape());
shape.setIntrinsicHeight(Integer.parseInt(ET_Height.getText().toString()));
shape.setIntrinsicWidth(Integer.parseInt(ET_Width.getText().toString()));
shape.getPaint().setColor(chooseColor());
iView.setImageDrawable(shape);
}
```
This part of the code works wonderfully, it's when I later try and access the Drawable to change it's color on a user click, utilizing the same color method from before.
```
public void onClick(View v){
iView.getDrawable().getPaint().setColor(chooseColor());
}
```
Obviously this code doesn't work, but it's the closest I have come to being able to complete it. I can't access the drawable via "shape" either, and I don't understand why.
So what's the best way to gain access to the drawable to change it's color, alpha, rotation, etc in the onClick method?
Thanks! | 2011/03/12 | [
"https://Stackoverflow.com/questions/5284706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/599429/"
] | Try iView.setImageDrawable(shape) again after changing the **shape** parameters. | I have used Abhinav's solution to this same problem and it worked for me
Basicly useing the same parameters I Used to create the shape then just created the same shape again and set color and bounds to the existing shape |
11,954,923 | I'm having trouble converting a list object back to its original type without an explicit cast. My intention is to generalize methods so I could pass in different db Types such as Person or Company. I have no problem getting the values via reflection but I need to convert the actual list back to its original type `List<typeT>` instead of `List<object>` in the method I am passing it to. I am aware of the following methods:
```
SomeList.ConvertAll(x => (typeT)x);
SomeList.Cast<typeT>().ToList();
```
However for these methods I will have to explicitly cast typeT. I have tried the following:
```
formatted1.ConvertAll(x => Convert.ChangeType(x, typeT));
```
and
```
List<dynamic> newList = new List<dynamic>();
foreach (var p in SomeList)
{
newList.Add(Convert.ChangeType(p, typeT);
}
```
No success thus far. Maybe I should have another game-plan for generalizing these methods altogether. right now I'm passing the lists in as follows:
```
public string returnJson(List<object> entity, string someString)
{
}
``` | 2012/08/14 | [
"https://Stackoverflow.com/questions/11954923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1221641/"
] | It seems like making `returnJson` generic would resolve most of these problems:
```
public string returnJson<T>(List<T> entity, string someString)
{
}
```
Now `returnJson` can be used generically, like:
```
returnJson<Company>(listOfCompanies, "someString");
```
and
```
returnJson<Person>(listOfPersons, "someOtherString");
```
You can still reflect over the objects, but the list is always a list of the type that you need at compile time. No casting required. | Why not use generics, that way the calling function can do what it needs:
```
public string returnJson<T>(List<T> entity, string someString)
{
//not sure what someString is for or why you need the type for this naming scheme
JavaScriptSerializer jss = new JavaScriptSerializer();
return jss.Serialize(entity);
}
``` |
11,954,923 | I'm having trouble converting a list object back to its original type without an explicit cast. My intention is to generalize methods so I could pass in different db Types such as Person or Company. I have no problem getting the values via reflection but I need to convert the actual list back to its original type `List<typeT>` instead of `List<object>` in the method I am passing it to. I am aware of the following methods:
```
SomeList.ConvertAll(x => (typeT)x);
SomeList.Cast<typeT>().ToList();
```
However for these methods I will have to explicitly cast typeT. I have tried the following:
```
formatted1.ConvertAll(x => Convert.ChangeType(x, typeT));
```
and
```
List<dynamic> newList = new List<dynamic>();
foreach (var p in SomeList)
{
newList.Add(Convert.ChangeType(p, typeT);
}
```
No success thus far. Maybe I should have another game-plan for generalizing these methods altogether. right now I'm passing the lists in as follows:
```
public string returnJson(List<object> entity, string someString)
{
}
``` | 2012/08/14 | [
"https://Stackoverflow.com/questions/11954923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1221641/"
] | It seems like making `returnJson` generic would resolve most of these problems:
```
public string returnJson<T>(List<T> entity, string someString)
{
}
```
Now `returnJson` can be used generically, like:
```
returnJson<Company>(listOfCompanies, "someString");
```
and
```
returnJson<Person>(listOfPersons, "someOtherString");
```
You can still reflect over the objects, but the list is always a list of the type that you need at compile time. No casting required. | You can use the dynamic keyword and reflection to create the list.
```
dynamic newList = Activator.CreateInstance(typeof(List<>).MakeGenericType(typeT));
foreach (var p in SomeList)
{
newList.Add(p);
}
CallOtherMethodOverloadedForListOfPersonCompanyEtc(newList)
``` |
11,954,923 | I'm having trouble converting a list object back to its original type without an explicit cast. My intention is to generalize methods so I could pass in different db Types such as Person or Company. I have no problem getting the values via reflection but I need to convert the actual list back to its original type `List<typeT>` instead of `List<object>` in the method I am passing it to. I am aware of the following methods:
```
SomeList.ConvertAll(x => (typeT)x);
SomeList.Cast<typeT>().ToList();
```
However for these methods I will have to explicitly cast typeT. I have tried the following:
```
formatted1.ConvertAll(x => Convert.ChangeType(x, typeT));
```
and
```
List<dynamic> newList = new List<dynamic>();
foreach (var p in SomeList)
{
newList.Add(Convert.ChangeType(p, typeT);
}
```
No success thus far. Maybe I should have another game-plan for generalizing these methods altogether. right now I'm passing the lists in as follows:
```
public string returnJson(List<object> entity, string someString)
{
}
``` | 2012/08/14 | [
"https://Stackoverflow.com/questions/11954923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1221641/"
] | Why not use generics, that way the calling function can do what it needs:
```
public string returnJson<T>(List<T> entity, string someString)
{
//not sure what someString is for or why you need the type for this naming scheme
JavaScriptSerializer jss = new JavaScriptSerializer();
return jss.Serialize(entity);
}
``` | You can use the dynamic keyword and reflection to create the list.
```
dynamic newList = Activator.CreateInstance(typeof(List<>).MakeGenericType(typeT));
foreach (var p in SomeList)
{
newList.Add(p);
}
CallOtherMethodOverloadedForListOfPersonCompanyEtc(newList)
``` |
30,296,622 | I read quite some stuff about RESTful API Design.
But when it comes to the implementation, it wasn't that easy anymore.
I got stuck at the following problem:
Assume the following 2 endpoint:
1. /api/v1/users/:id
2. /api/v1/users/1/friends/:id
As we all can see, **friends is a collection** of the resource **user**.
A user can have n-friends in his friendslist (by standard this would be many to many, but for now, let's assume this to be one to many).
Okay, now i want to **REMOVE** a user (*id=3*) from the friendslist of user 1 by doing the following HTTP-Request:
**DELETE api/v1/users/1/friends/3**
And this is where i got stuck - either the request **deletes** the whole user resource which has id = 3 or **removes** the resource from the collection. Because both would be valid Restful implementations i think.
So the question is:
**How to remove an item from the collection without deleting the original resource**
I hope that this question is no duplicate - but i did google a lot to find the answer. Maybe i don't know the related technical term to find some pleasing results...
Thanks in forward. | 2015/05/18 | [
"https://Stackoverflow.com/questions/30296622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1835201/"
] | The approach to REST looks fine but that really only speaks to path format and HTTP verb. The problem must be in your application code or app routes. | I think it is better that DELETE api/v1/users/1/friends/3 would be used to delete user 3, just like DELETE api/v1/users/1 would be used to delete user 1.
To remove just user 3 from being a friend of user 1 I would use DELETE api/v1/users/1/friends and specify a filter to only remove friends with the id of 3.
DELETE api/v1/users/1/friends without a filter would remove all friends of user 1.
Likewise to add friends of user 1 I would use PUT api/v1/users/1/friends and specify the ids of the friends to add. |
131,144 | In software documentation, I recently read:
>
> If you move a job to a different folder, you may also need to update configuration that was referring to that job.
>
>
>
But *if* you have a "configuration that was referring to that job" you *need to* update it (or really *should*). Not doing that will result in broken configuration and ultimately, broken behavior.
Is this use of "may need to" really correct? Is there a valid reason the documentation is phrased like this, instead of "…, you also need to update"?
Doesn't the current documentation through the use of "may" imply that there are situations where you're not required to update configuration because it handles the job move correctly? | 2013/10/11 | [
"https://english.stackexchange.com/questions/131144",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/2434/"
] | Software documentation is usually written by someone following a normal or good path through the setup. Saying, "you may need to do this" is essentially a callout to known issues or problems that are extremely likely. But since the author is not going to exhaust all possibilities they just stick "may" into the sentence to cover their bases.
To attempt speaking directly to your example, the person writing the documentation doesn't actually know that such a configuration exists or that *you* in particular need to update or that it wasn't already updated and that's why you happen to be moving the job to another folder. And they don't need to worry about those things — instead they say "may" and write out the most common scenario.
More anecdotally, I personally do this all the time when writing documentation for various install procedures. I know my audience will be someone with a similar expertise to myself and all I am really trying to accomplish is sticking a relevant problem solving thought in their head in the event something goes wrong.
Also, you'd be surprised at how many things suddenly change in technology. We kind of get used to never saying "always" or "you must do X." | Use of *may* does not **entail** that there are situations where you're not required to update configuration. It does, however, **implicate** so. See Wikipedia entry on [Implicatures](http://en.wikipedia.org/wiki/Implicature). Grice's paper cited in the Wikipedia entry is [posted online](http://www.ucl.ac.uk/ls/studypacks/Grice-Logic.pdf).
If you say "it is possible that X". It entails that there is a non-zero probability that X is true. It implicates that there is a non-zero probability that X is false.
Common use of "imply" usually means "entail", but is often used to mean "implicate". |
131,144 | In software documentation, I recently read:
>
> If you move a job to a different folder, you may also need to update configuration that was referring to that job.
>
>
>
But *if* you have a "configuration that was referring to that job" you *need to* update it (or really *should*). Not doing that will result in broken configuration and ultimately, broken behavior.
Is this use of "may need to" really correct? Is there a valid reason the documentation is phrased like this, instead of "…, you also need to update"?
Doesn't the current documentation through the use of "may" imply that there are situations where you're not required to update configuration because it handles the job move correctly? | 2013/10/11 | [
"https://english.stackexchange.com/questions/131144",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/2434/"
] | Use of *may* does not **entail** that there are situations where you're not required to update configuration. It does, however, **implicate** so. See Wikipedia entry on [Implicatures](http://en.wikipedia.org/wiki/Implicature). Grice's paper cited in the Wikipedia entry is [posted online](http://www.ucl.ac.uk/ls/studypacks/Grice-Logic.pdf).
If you say "it is possible that X". It entails that there is a non-zero probability that X is true. It implicates that there is a non-zero probability that X is false.
Common use of "imply" usually means "entail", but is often used to mean "implicate". | A better phrasing might be
>
> If you move a job to a different folder, you *will* also need to update *any* configuration that *refers* to that job.
>
>
>
(italics indicate edits) The use of *will* indicates certainty, and the use of *any* makes it clear that such a configuration might not exist. *Refers* instead of *was referring to* is because the the configuration refers to the *job*, which still exists, it's only moved. |
131,144 | In software documentation, I recently read:
>
> If you move a job to a different folder, you may also need to update configuration that was referring to that job.
>
>
>
But *if* you have a "configuration that was referring to that job" you *need to* update it (or really *should*). Not doing that will result in broken configuration and ultimately, broken behavior.
Is this use of "may need to" really correct? Is there a valid reason the documentation is phrased like this, instead of "…, you also need to update"?
Doesn't the current documentation through the use of "may" imply that there are situations where you're not required to update configuration because it handles the job move correctly? | 2013/10/11 | [
"https://english.stackexchange.com/questions/131144",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/2434/"
] | Software documentation is usually written by someone following a normal or good path through the setup. Saying, "you may need to do this" is essentially a callout to known issues or problems that are extremely likely. But since the author is not going to exhaust all possibilities they just stick "may" into the sentence to cover their bases.
To attempt speaking directly to your example, the person writing the documentation doesn't actually know that such a configuration exists or that *you* in particular need to update or that it wasn't already updated and that's why you happen to be moving the job to another folder. And they don't need to worry about those things — instead they say "may" and write out the most common scenario.
More anecdotally, I personally do this all the time when writing documentation for various install procedures. I know my audience will be someone with a similar expertise to myself and all I am really trying to accomplish is sticking a relevant problem solving thought in their head in the event something goes wrong.
Also, you'd be surprised at how many things suddenly change in technology. We kind of get used to never saying "always" or "you must do X." | A better phrasing might be
>
> If you move a job to a different folder, you *will* also need to update *any* configuration that *refers* to that job.
>
>
>
(italics indicate edits) The use of *will* indicates certainty, and the use of *any* makes it clear that such a configuration might not exist. *Refers* instead of *was referring to* is because the the configuration refers to the *job*, which still exists, it's only moved. |
13,864 | Bear with me as I am brand new to expression engine and PHP in general but the headers on these pages are not showing up in IE10...running it in compatibility mode fixes it but this needs to not happen. Id like to attempt to find the problem myself so here is a sample page starting at line 1:
```
{assign_variable:sectionID="products"}
{assign_variable:pageID="index"}
{assign_variable:entryID="32"}
{assign_variable:subnav="n"}
{assign_variable:sectionTitle="Products"}
{assign_variable:pageTitle="-"}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
{embed="includes/browser-title-tag" pageTitle="{pageTitle}" sectionTitle=" {sectionTitle}"}
{exp:weblog:entries weblog="static_content" entry_id="32"}
<meta name="keywords" content="{sc_meta_tags}" />
<meta name="description" content="{sc_meta_description}" />
{/exp:weblog:entries}
{embed="includes/global-head"}
</head>
<body class="{sectionID}">
{!-- hook to put anything necessary right after the opening body tag --}
{embed="includes/global-page-top"}
{embed="includes/global-header"}
{embed="products/subnav" catID="0"}
<div id="centering-content-wrapper">
<div id="content-wrapper">
<div id="main-content">
{!-- shows plain content --}
{embed='includes/plain-content' entryID="{entryID}" sectionTitle="{sectionTitle}" sectionID="{sectionID}" pageID="{pageID}" subnav="{subnav}" pageTitle="{pageTitle}" }
<dl>
{!-- Commercial Lines --}
{exp:weblog:entries weblog="products" entry_id="50"}
<dt><a href="{title_permalink=/products/product/}"> {title}</a></dt>
<dd>{prod_short_desc}</dd>
{/exp:weblog:entries}
{!-- Personal Lines --}
{exp:weblog:entries weblog="products" entry_id="51"}
<dt><a href="{title_permalink=/products/product/}">{title}</a></dt>
<dd>{prod_short_desc}</dd>
{/exp:weblog:entries}
{!-- Workers Comp --}
{exp:weblog:entries weblog="products" entry_id="52"}
<dt><a href="{title_permalink=/products/product/}">{title}</a></dt>
<dd>{prod_short_desc}</dd>
{/exp:weblog:entries}
{!-- Specialty Programs --}
{exp:weblog:entries weblog="products" entry_id="53"}
<dt><a href="{title_permalink=/products/product/}">{title}</a></dt>
<dd>{prod_short_desc}</dd>
{/exp:weblog:entries}
{!-- All Products --}
{exp:weblog:entries weblog="products" entry_id="66"}
<dt><a href=" {title_permalink=/products/product/}">See all our Products</a></dt>
<dd>{prod_short_desc}</dd>
{/exp:weblog:entries}
</dl>
</div> <!-- /main-content -->
<div id="secondary-content">
{embed='includes/sidebars-static' entryID="{entryID}"}
</div> <!-- /secondary-content -->
</div> <!-- /content-wrapper -->
{!-- copyright, footer links, etc. --}
{embed="includes/global-footer"}
</div> <!-- /centering-content-wrapper -->
{!-- hook to put anything necessary right before the body tag, e.g. Google Analytics code --}
{embed="includes/global-page-bottom"}
```
So on this page the header not showing up is "Products" and instead is showing up as three x'S vertically in its place. When viewing the page source after the page loads the titles that are not showing are typically in an tag like in this page's case.
I believe this is EE 1.
Let me know if you need any other code! | 2013/09/18 | [
"https://expressionengine.stackexchange.com/questions/13864",
"https://expressionengine.stackexchange.com",
"https://expressionengine.stackexchange.com/users/2076/"
] | It's possible to ignore the built-in `{stars}` and `{starts_overall_avg}` tags and just output the numbers using the `{rating}` and `{overall_avg}` tags instead.
This allows you to do some clever things such as add variable class names to elements depending on the rating. Your CSS can then use these class names to alter the display of the data. For example:
```
<p class="star-{rating} rating">{rating}</p>
```
You can now use the CSS class to affect how the number is displayed by showing images other than stars and hiding the rating number using CSS text replacement techniques if desired. | You would probably have to hack mod.rating.php to make that happen.
search for stars\_avg\_rating
I don't think this would be a small undertaking. |
52,135,048 | I have two entity classes `Country` and `Language` having bi-directional one to many relationship.
Below are the entity classes:
```
@Entity
@Table(name = "COUNTRY")
public class Country {
@Id
@GeneratedValue
@Column(name = "COUNTRY_ID")
private Long id;
@Column(name = "COUNTRY_NAME")
private String name;
@Column(name = "COUNTRY_CODE")
private String code;
@JacksonXmlElementWrapper(localName = "languages")
@JacksonXmlProperty(localName = "languages")
@OneToMany(mappedBy = "country", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
List<Language> languages;
// getters and setters
}
```
And...
```
@Entity
@Table(name = "LANGUAGE")
public class Language {
@Id
@GeneratedValue
@Column(name = "LANGUAGE_ID")
private Long id;
@Column(name = "LANGUAGE_NAME")
private String name;
@ManyToOne
@JoinColumn(name = "COUNTRY_ID")
@JsonIgnore
private Country country;
//getters and setters
}
```
Below is my Rest controller:
```
@RestController
@RequestMapping("/countries")
public class CountryRestController {
private final ICountryRepository iCountryRepository;
@Autowired
public CountryRestController(ICountryRepository iCountryRepository) {
this.iCountryRepository = iCountryRepository;
}
@PostMapping("/country")
public ResponseEntity<?> postCountryDetails(@RequestBody Country country) {
Country savedCountry = this.iCountryRepository.save(country);
URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}")
.buildAndExpand(savedCountry.getId()).toUri();
return ResponseEntity.created(location).build();
}
//other methods
}
```
I'm trying to save below JSON:
```
{
"name": "Ireland",
"code": "IRE",
"languages": [
{
"name": "Irish"
}
]
}
```
The problem is that the language (child) foreign key is always null but other properties are getting inserted. I have used `@JsonIgnore` on property `Country country` of `Language` class because it was causing issues with request size as I have another API fetching data of Country along with its Languages.
Please guide. | 2018/09/02 | [
"https://Stackoverflow.com/questions/52135048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9815759/"
] | You can do it in this way :
```
Country newCountry = new Country(country.getName());
ArrayList < Language > langList = new ArrayList<>();
for (Language lang : country.getLanguages()) {
langList.add( new Language(language.getName(), newCountry ) ) ;
}
newCountry.setLanguages( langList );
iCountryRepository.save(newCountry);
```
PS : Don't forget to add appropriate constructors.
Also it is mandatory to add a default constructor if you are doing constructor overloading like this :
```
public Country() {}
public Country(String name) {this.name = name }
``` | You can do it in this way also.
Here it doesn't create new objects. In the same object which is parsing it creates the relationship in language objects.
```
@PostMapping("/country")
public Country postCountryDetails(@RequestBody Country country) {
if( country.getLanguages().size() > 0 )
{
country.getLanguages().stream().forEach( countryItem -> {
countryItem.setCountry( country );
} );
}
return country;
}
``` |
52,135,048 | I have two entity classes `Country` and `Language` having bi-directional one to many relationship.
Below are the entity classes:
```
@Entity
@Table(name = "COUNTRY")
public class Country {
@Id
@GeneratedValue
@Column(name = "COUNTRY_ID")
private Long id;
@Column(name = "COUNTRY_NAME")
private String name;
@Column(name = "COUNTRY_CODE")
private String code;
@JacksonXmlElementWrapper(localName = "languages")
@JacksonXmlProperty(localName = "languages")
@OneToMany(mappedBy = "country", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
List<Language> languages;
// getters and setters
}
```
And...
```
@Entity
@Table(name = "LANGUAGE")
public class Language {
@Id
@GeneratedValue
@Column(name = "LANGUAGE_ID")
private Long id;
@Column(name = "LANGUAGE_NAME")
private String name;
@ManyToOne
@JoinColumn(name = "COUNTRY_ID")
@JsonIgnore
private Country country;
//getters and setters
}
```
Below is my Rest controller:
```
@RestController
@RequestMapping("/countries")
public class CountryRestController {
private final ICountryRepository iCountryRepository;
@Autowired
public CountryRestController(ICountryRepository iCountryRepository) {
this.iCountryRepository = iCountryRepository;
}
@PostMapping("/country")
public ResponseEntity<?> postCountryDetails(@RequestBody Country country) {
Country savedCountry = this.iCountryRepository.save(country);
URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}")
.buildAndExpand(savedCountry.getId()).toUri();
return ResponseEntity.created(location).build();
}
//other methods
}
```
I'm trying to save below JSON:
```
{
"name": "Ireland",
"code": "IRE",
"languages": [
{
"name": "Irish"
}
]
}
```
The problem is that the language (child) foreign key is always null but other properties are getting inserted. I have used `@JsonIgnore` on property `Country country` of `Language` class because it was causing issues with request size as I have another API fetching data of Country along with its Languages.
Please guide. | 2018/09/02 | [
"https://Stackoverflow.com/questions/52135048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9815759/"
] | You can do it in this way :
```
Country newCountry = new Country(country.getName());
ArrayList < Language > langList = new ArrayList<>();
for (Language lang : country.getLanguages()) {
langList.add( new Language(language.getName(), newCountry ) ) ;
}
newCountry.setLanguages( langList );
iCountryRepository.save(newCountry);
```
PS : Don't forget to add appropriate constructors.
Also it is mandatory to add a default constructor if you are doing constructor overloading like this :
```
public Country() {}
public Country(String name) {this.name = name }
``` | Update the setter for `languages` in `Country` class to the below :
```
public void setLanguages(List<Language> languages) {
this.languages = languages;
languages.forEach(entity -> entity.setCountry(this));
}
``` |
52,135,048 | I have two entity classes `Country` and `Language` having bi-directional one to many relationship.
Below are the entity classes:
```
@Entity
@Table(name = "COUNTRY")
public class Country {
@Id
@GeneratedValue
@Column(name = "COUNTRY_ID")
private Long id;
@Column(name = "COUNTRY_NAME")
private String name;
@Column(name = "COUNTRY_CODE")
private String code;
@JacksonXmlElementWrapper(localName = "languages")
@JacksonXmlProperty(localName = "languages")
@OneToMany(mappedBy = "country", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
List<Language> languages;
// getters and setters
}
```
And...
```
@Entity
@Table(name = "LANGUAGE")
public class Language {
@Id
@GeneratedValue
@Column(name = "LANGUAGE_ID")
private Long id;
@Column(name = "LANGUAGE_NAME")
private String name;
@ManyToOne
@JoinColumn(name = "COUNTRY_ID")
@JsonIgnore
private Country country;
//getters and setters
}
```
Below is my Rest controller:
```
@RestController
@RequestMapping("/countries")
public class CountryRestController {
private final ICountryRepository iCountryRepository;
@Autowired
public CountryRestController(ICountryRepository iCountryRepository) {
this.iCountryRepository = iCountryRepository;
}
@PostMapping("/country")
public ResponseEntity<?> postCountryDetails(@RequestBody Country country) {
Country savedCountry = this.iCountryRepository.save(country);
URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}")
.buildAndExpand(savedCountry.getId()).toUri();
return ResponseEntity.created(location).build();
}
//other methods
}
```
I'm trying to save below JSON:
```
{
"name": "Ireland",
"code": "IRE",
"languages": [
{
"name": "Irish"
}
]
}
```
The problem is that the language (child) foreign key is always null but other properties are getting inserted. I have used `@JsonIgnore` on property `Country country` of `Language` class because it was causing issues with request size as I have another API fetching data of Country along with its Languages.
Please guide. | 2018/09/02 | [
"https://Stackoverflow.com/questions/52135048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9815759/"
] | You can do it in this way also.
Here it doesn't create new objects. In the same object which is parsing it creates the relationship in language objects.
```
@PostMapping("/country")
public Country postCountryDetails(@RequestBody Country country) {
if( country.getLanguages().size() > 0 )
{
country.getLanguages().stream().forEach( countryItem -> {
countryItem.setCountry( country );
} );
}
return country;
}
``` | Update the setter for `languages` in `Country` class to the below :
```
public void setLanguages(List<Language> languages) {
this.languages = languages;
languages.forEach(entity -> entity.setCountry(this));
}
``` |
28,881,663 | I have a data frame in R called `x` that has hundreds of rows. Each row is a person. I have two variables, `Height`, which is continuous, and `Country`, which is a factor. I want to plot a smoothed histogram of all of the heights of the individuals. I want to stratify it by `Country`. I know that I can do that with the following code:
```
library(ggplot2)
ggplot(x, aes(x=Height, colour = (Country == "USA"))) + geom_density()
```
This plots everyone from the USA as one color (true) and everyone from any other country as the other color (false). However, what I would really like to do is plot everyone from the USA in one color and everyone from Oman, Nigeria, and Switzerland as the other color. How would I adapt my code to do this? | 2015/03/05 | [
"https://Stackoverflow.com/questions/28881663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1073244/"
] | I made up some data for illustration:
```
head(iris)
table(iris$Species)
df <- iris
df$Species2 <- ifelse(df$Species == "setosa", "blue",
ifelse(df$Species == "virginica", "red", ""))
library(ggplot2)
p <- ggplot(df, aes(x = Sepal.Length, colour = (Species == "setosa")))
p + geom_density() # Your example
```

```
# Now let's choose the other created column
p <- ggplot(df, aes(x = Sepal.Length, colour = Species2))
p + geom_density() + facet_wrap(~Species2)
```

**Edit** to get rid of the "countries" that you don't want in the plot, just subset them out of the data frame you use in the plot (note that the labels with the colours don't exactly match but that can be changed within the data frame itself):
```
p <- ggplot(df[df$Species2 %in% c("blue", "red"),], aes(x = Sepal.Length, colour = Species2))
p + geom_density() + facet_wrap(~Species2)
```

And to overlay the lines just take out the `facet_wrap`:
```
p + geom_density()
```
 | I enjoyed working through the excellent answer above. Here are my mods.
```
df <- iris
df$Species2 <- ifelse(df$Species == "setosa", "blue",
ifelse(df$Species == "virginica", "red", ""))
homes2006 <- df
names(homes2006)[names(homes2006)=="Species"] <- "ownership"
homes2006a <- as.data.frame(sapply(homes2006, gsub,
pattern ="setosa", replacement = "renters"))
homes2006b <- as.data.frame(sapply(homes2006a, gsub, pattern = "virginica",
replacement = "home-owners"))
homes2006c <- as.data.frame(sapply(homes2006b, gsub, pattern = "versicolor",
replacement = "home-owners"))
##somehow sepal-length became a factor column
homes2006c[,1] <- as.numeric(homes2006c[,1])
library(ggplot2)
p <- ggplot(homes2006c, aes(x = Sepal.Length,
colour = (ownership == "home-owners")))
p + ylab("number of households") +
xlab("monthly income (NIS)") +
ggtitle("income distribution by home ownership") +
geom_density()
```
[](https://i.stack.imgur.com/r24qj.png) |
308,952 | I have a client who is leasing an industrial building with a local network. They are rapidly expanding and need additional space. The nearest available property is available across the street about 150 feet away door-to-door. Now obviously running an ethernet cable would be quite a feat. So I am wondering if there is any other way to connected without VPN or direct ethernet. Possibly a wireless solution? What devices do you recommend? Their current environment is Windows 2008 server with file sharing for about 15 clients and a DSL connection. When they plan to move, they will be upgrading to a T1, Exchange server, and also VoIP phones. | 2011/07/11 | [
"https://superuser.com/questions/308952",
"https://superuser.com",
"https://superuser.com/users/89751/"
] | 150 feet is not that far. For the money, versus speed, I would bury conduit with fiber in it.
It might cost a few thousand to have this **professionally** done, but this is a business, and the cost of doing business would dictate spending the money you need to do the job the best way.
Consider that a VPN with their DSL upload speeds, or T-1, are both going to be roughly 1.5 Mbps (T-1) to maybe 2 Mbps (for a typical DSL). You will still probably have to spend money on the firewalls to connect them (at least on the second one), and a second Internet connection. In the long run, you will also be paying more by having to pay for that second connection every month over the long haul. This option stinks.
Then your other option: Wireless. it is still much slower, for good equipment it costs a lot more than $200 as in the other answer (VERY bad answer, IMO), still much slower than a fiber connection, and it is not as stable as the underground method. Heavy rain, or other factors will interfere with it. You will find this to be a major pain in the butt, and they will not be happy in the long run.
Seriously, any other answer than fiber here, is probably going to get you fired (I see you are a consultant by your website) when someone, who knows what they are doing, eventually questions it.
I did not need the links below to tell you this, but do not just take my opinion on this. In each case below, they are talking much greater distances even.
<https://serverfault.com/questions/90442/what-is-the-fastest-way-to-connect-two-separate-networks-within-two-separate-buil>
<https://serverfault.com/questions/222107/how-to-build-network-across-buildings>
<https://serverfault.com/questions/126340/creating-a-network-link-between-2-buildings>
<https://serverfault.com/questions/96034/lan-between-buildings> | Any bridge you can attach a directional antenna to should work, provided you have reasonable line of sight. A wireless router that supports OpenWRT and/or DD-WRT and has detachable antennas is a cheap way to do it (under $200). Products like <http://www.ubnt.com/nanobridge> seem promising too, as there's already a directional antenna and suitable housing for outdoor use. |
72,322,732 | When I run this loop it takes in an array which contains eight numbers, it loops through and simply pushes them to a global array which is named results. For some reason when I console.log this array outside of the loop it returns 0 []. I wish it to return the eight numbers from the other array.
```js
const results = []
const validate = arr => {
for(let i = 0; i < arr.length; i++){
results.push(arr[i])
}
}
console.log(results)
``` | 2022/05/20 | [
"https://Stackoverflow.com/questions/72322732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16694938/"
] | That is because you have to run the **function** validate, now you are just printing `results[]` which has no items.
```
validate(arr);
```
```js
const results = []
const arr = [1, 2, 3, 4, 5, 6, 7, 8];
const validate = arr => {
for (let i = 0; i < arr.length; i++) {
results.push(arr[i])
}
}
validate(arr);
console.log(results);
```
But if you want to make a copy, you can just use:
```js
const arr = [1, 2, 3, 4, 5, 6, 7, 8];
const results = [...arr];
console.log(results);
``` | Your code would work if you included the original array of numbers and you call the function that iterates over it:
```js
let arr = [1,2,3,4,5,6,7,8];
let results = [];
function validate() {
for(let i = 0; i < arr.length; i++){
results.push(arr[i])
}
}
validate();
console.log(results)
```
But, the [`Array.prototype.map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) method was designed to do just this type of thing:
```js
let arr = [2,4,6,8];
let results = arr.map(function(element){
return element; // Returns item to resulting array
});
console.log(results)
``` |
72,322,732 | When I run this loop it takes in an array which contains eight numbers, it loops through and simply pushes them to a global array which is named results. For some reason when I console.log this array outside of the loop it returns 0 []. I wish it to return the eight numbers from the other array.
```js
const results = []
const validate = arr => {
for(let i = 0; i < arr.length; i++){
results.push(arr[i])
}
}
console.log(results)
``` | 2022/05/20 | [
"https://Stackoverflow.com/questions/72322732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16694938/"
] | What you have done here is simply define a function that copies the contents of the array that has been passed into it. You need to call the function
`validate` with the appropriate value.
```js
const results = []
const validate = arr => {
for(let i = 0; i < arr.length; i++){
results.push(arr[i])
}
}
validate([1,2,3,4,5,6,7,8]);
console.log(results);
``` | Your code would work if you included the original array of numbers and you call the function that iterates over it:
```js
let arr = [1,2,3,4,5,6,7,8];
let results = [];
function validate() {
for(let i = 0; i < arr.length; i++){
results.push(arr[i])
}
}
validate();
console.log(results)
```
But, the [`Array.prototype.map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) method was designed to do just this type of thing:
```js
let arr = [2,4,6,8];
let results = arr.map(function(element){
return element; // Returns item to resulting array
});
console.log(results)
``` |
72,322,732 | When I run this loop it takes in an array which contains eight numbers, it loops through and simply pushes them to a global array which is named results. For some reason when I console.log this array outside of the loop it returns 0 []. I wish it to return the eight numbers from the other array.
```js
const results = []
const validate = arr => {
for(let i = 0; i < arr.length; i++){
results.push(arr[i])
}
}
console.log(results)
``` | 2022/05/20 | [
"https://Stackoverflow.com/questions/72322732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16694938/"
] | You missed calling the function.
```js
const arr = [1, 2, 3, 4, 5, 6, 7, 8];
const result = [];
arr.map((num) => result.push(num));
console.log(result);
``` | Your code would work if you included the original array of numbers and you call the function that iterates over it:
```js
let arr = [1,2,3,4,5,6,7,8];
let results = [];
function validate() {
for(let i = 0; i < arr.length; i++){
results.push(arr[i])
}
}
validate();
console.log(results)
```
But, the [`Array.prototype.map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) method was designed to do just this type of thing:
```js
let arr = [2,4,6,8];
let results = arr.map(function(element){
return element; // Returns item to resulting array
});
console.log(results)
``` |
72,322,732 | When I run this loop it takes in an array which contains eight numbers, it loops through and simply pushes them to a global array which is named results. For some reason when I console.log this array outside of the loop it returns 0 []. I wish it to return the eight numbers from the other array.
```js
const results = []
const validate = arr => {
for(let i = 0; i < arr.length; i++){
results.push(arr[i])
}
}
console.log(results)
``` | 2022/05/20 | [
"https://Stackoverflow.com/questions/72322732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16694938/"
] | ```js
const results = []
const validate = (arr) => {
console.log(arr)
arr.forEach((value)=>{
results.push(value)
});
}
validate([1,2,3,4,5,6,7,8]);
console.log(results);
``` | Your code would work if you included the original array of numbers and you call the function that iterates over it:
```js
let arr = [1,2,3,4,5,6,7,8];
let results = [];
function validate() {
for(let i = 0; i < arr.length; i++){
results.push(arr[i])
}
}
validate();
console.log(results)
```
But, the [`Array.prototype.map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) method was designed to do just this type of thing:
```js
let arr = [2,4,6,8];
let results = arr.map(function(element){
return element; // Returns item to resulting array
});
console.log(results)
``` |
23,852,252 | This is for Rails 4.04 and Ruby 2.1. I'd like to allow my users to have addresses. So I generated an address table and gave it columns (NUMBER, STREET, CITY, STATE). Now when I go to the following url, I'd like to be able edit this information:
```
webapp.com/users/edit/
```
However I noticed it only showed the same old information (name, password, email). So I went to the view and added simple\_fields for my new relationship so the view now looks like this:
```
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<div class="form-inputs">
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :name, required: false %>
<%= f.simple_fields_for :addresses do |a| %>
<%= a.input :number %>
<%= a.input :street %>
<%= a.input :city %>
<%= a.input :state %>
<%= a.input :country %>
<% end %>
<%end%>
```
However it still doesn't generate the fields needed for address. I think this is because none of my users currently have any addresses attached to their account profile (because this migration was just created). However, in this case there should be blank fields generated so I can ADD address information.
I feel like I need to do something in the Users#Edit action like this
```
@users.each do |user|
user.address.build
end
```
Is that right? How can I override the users controller because this was created by Devise and I don't actually have a users controller (I looked for it it and couldn't find it).
UPDATE
Ok, I'm getting closer. I had to create my own controller to override Devise's default registrations controller as explained in the second answer of this stack overflow article:
[Override devise registrations controller](https://stackoverflow.com/questions/3546289/override-devise-registrations-controller)
So now I am getting into that controller which currently looks like this:
```
class Users::RegistrationsController < Devise::RegistrationsController
def edit
super
end
end
```
However, when I get to my view, it's still SKIPPING the block that starts like this:
```
<%= f.simple_fields_for :addresses do |a| %>
```
However, if I go manually into my DB and add a record in the addresses table and link it to my currently\_signed in user via the foreign key, then the block does not get skipped. So whats the best way to generate this connection if the address record does not yet exist? Is it the build method? e.g.
```
user.address.build
```
in the controller
SOLUTION
Yes, I needed to added this method to my new registrations\_controller.rb file
```
def edit
if resource.addresses.size == 0
resource.addresses.build
end
super
end
```
It is now working the way I intended it. | 2014/05/25 | [
"https://Stackoverflow.com/questions/23852252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1316464/"
] | `densityplot()` from bioconductor `flowViz` package is one option for stacked densities.
from: <http://www.bioconductor.org/packages/release/bioc/manuals/flowViz/man/flowViz.pdf> :
>
> For flowSets the idea is to horizontally stack plots of density estimates for all frames in the
> flowSet for one or several flow parameters. In the latter case, each parameter will be plotted
> in a separate panel, i.e., we implicitely condition on parameters.
>
>
>
you can see example visuals here:
<http://www.bioconductor.org/packages/release/bioc/vignettes/flowViz/inst/doc/filters.html>
```
source("http://bioconductor.org/biocLite.R")
biocLite("flowViz")
``` | I think it's going to be difficult to get `ggplot` to offset the histograms like that. At least with faceting it makes new panels, and really, this transformation makes the y-axis meaningless. (The value is in the comparison from row to row). Here's one attempt at using base graphics to try to accomplish a similar thing.
```
#plotting function
plotoffsethists <- function(vals, groups, freq=F, overlap=.25, alpha=.75, colors=apply(floor(rbind(col2rgb(scales:::hue_pal(h = c(0, 360) + 15, c = 100, l = 65)(nlevels(groups))),alpha=alpha*255)),2,function(x) {paste0("#",paste(sprintf("%02X",x),collapse=""))}), ...) {
print(colors)
if (!is.factor(groups)) {
groups<-factor(groups)
}
offsethist <- function (x, col = NULL, offset=0, freq=F, ...) {
y <- if (freq) y <- x$counts
else
x$density
nB <- length(x$breaks)
rect(x$breaks[-nB], 0+offset, x$breaks[-1L], y+offset, col = col, ...)
}
hh<-tapply(vals, groups, hist, plot=F)
ymax<-if(freq)
sapply(hh, function(x) max(x$counts))
else
sapply(hh, function(x) max(x$density))
offset<-(mean(ymax)*overlap) * (length(ymax)-1):0
ylim<-range(c(0,ymax+offset))
xlim<-range(sapply(hh, function(x) range(x$breaks)))
plot.new()
plot.window(xlim, ylim, "")
box()
axis(1)
Map(offsethist, hh, colors, offset, freq=freq, ...)
invisible(hh)
}
#sample call
par(mar=c(3,1,1,1)+.1)
plotoffsethists(my.data$V1, factor(my.data$V2), overlap=.25)
```
 |
23,852,252 | This is for Rails 4.04 and Ruby 2.1. I'd like to allow my users to have addresses. So I generated an address table and gave it columns (NUMBER, STREET, CITY, STATE). Now when I go to the following url, I'd like to be able edit this information:
```
webapp.com/users/edit/
```
However I noticed it only showed the same old information (name, password, email). So I went to the view and added simple\_fields for my new relationship so the view now looks like this:
```
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<div class="form-inputs">
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :name, required: false %>
<%= f.simple_fields_for :addresses do |a| %>
<%= a.input :number %>
<%= a.input :street %>
<%= a.input :city %>
<%= a.input :state %>
<%= a.input :country %>
<% end %>
<%end%>
```
However it still doesn't generate the fields needed for address. I think this is because none of my users currently have any addresses attached to their account profile (because this migration was just created). However, in this case there should be blank fields generated so I can ADD address information.
I feel like I need to do something in the Users#Edit action like this
```
@users.each do |user|
user.address.build
end
```
Is that right? How can I override the users controller because this was created by Devise and I don't actually have a users controller (I looked for it it and couldn't find it).
UPDATE
Ok, I'm getting closer. I had to create my own controller to override Devise's default registrations controller as explained in the second answer of this stack overflow article:
[Override devise registrations controller](https://stackoverflow.com/questions/3546289/override-devise-registrations-controller)
So now I am getting into that controller which currently looks like this:
```
class Users::RegistrationsController < Devise::RegistrationsController
def edit
super
end
end
```
However, when I get to my view, it's still SKIPPING the block that starts like this:
```
<%= f.simple_fields_for :addresses do |a| %>
```
However, if I go manually into my DB and add a record in the addresses table and link it to my currently\_signed in user via the foreign key, then the block does not get skipped. So whats the best way to generate this connection if the address record does not yet exist? Is it the build method? e.g.
```
user.address.build
```
in the controller
SOLUTION
Yes, I needed to added this method to my new registrations\_controller.rb file
```
def edit
if resource.addresses.size == 0
resource.addresses.build
end
super
end
```
It is now working the way I intended it. | 2014/05/25 | [
"https://Stackoverflow.com/questions/23852252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1316464/"
] | ```
require(ggplot2)
require(plyr)
my.data <- as.data.frame(rbind( cbind( rnorm(1e3), 1) , cbind( rnorm(1e3)+2, 2), cbind( rnorm(1e3)+3, 3), cbind( rnorm(1e3)+4, 4)))
my.data$V2=as.factor(my.data$V2)
```
calculate the density depending on V2
```
res <- dlply(my.data, .(V2), function(x) density(x$V1))
dd <- ldply(res, function(z){
data.frame(Values = z[["x"]],
V1_density = z[["y"]],
V1_count = z[["y"]]*z[["n"]])
})
```
add an offset depending on V2
```
dd$offest=-as.numeric(dd$V2)*0.2 # adapt the 0.2 value as you need
dd$V1_density_offest=dd$V1_density+dd$offest
```
and plot
```
ggplot(dd, aes(Values, V1_density_offest, color=V2)) +
geom_line()+
geom_ribbon(aes(Values, ymin=offest,ymax=V1_density_offest, fill=V2),alpha=0.3)+
scale_y_continuous(breaks=NULL)
```
 | `densityplot()` from bioconductor `flowViz` package is one option for stacked densities.
from: <http://www.bioconductor.org/packages/release/bioc/manuals/flowViz/man/flowViz.pdf> :
>
> For flowSets the idea is to horizontally stack plots of density estimates for all frames in the
> flowSet for one or several flow parameters. In the latter case, each parameter will be plotted
> in a separate panel, i.e., we implicitely condition on parameters.
>
>
>
you can see example visuals here:
<http://www.bioconductor.org/packages/release/bioc/vignettes/flowViz/inst/doc/filters.html>
```
source("http://bioconductor.org/biocLite.R")
biocLite("flowViz")
``` |
23,852,252 | This is for Rails 4.04 and Ruby 2.1. I'd like to allow my users to have addresses. So I generated an address table and gave it columns (NUMBER, STREET, CITY, STATE). Now when I go to the following url, I'd like to be able edit this information:
```
webapp.com/users/edit/
```
However I noticed it only showed the same old information (name, password, email). So I went to the view and added simple\_fields for my new relationship so the view now looks like this:
```
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<div class="form-inputs">
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :name, required: false %>
<%= f.simple_fields_for :addresses do |a| %>
<%= a.input :number %>
<%= a.input :street %>
<%= a.input :city %>
<%= a.input :state %>
<%= a.input :country %>
<% end %>
<%end%>
```
However it still doesn't generate the fields needed for address. I think this is because none of my users currently have any addresses attached to their account profile (because this migration was just created). However, in this case there should be blank fields generated so I can ADD address information.
I feel like I need to do something in the Users#Edit action like this
```
@users.each do |user|
user.address.build
end
```
Is that right? How can I override the users controller because this was created by Devise and I don't actually have a users controller (I looked for it it and couldn't find it).
UPDATE
Ok, I'm getting closer. I had to create my own controller to override Devise's default registrations controller as explained in the second answer of this stack overflow article:
[Override devise registrations controller](https://stackoverflow.com/questions/3546289/override-devise-registrations-controller)
So now I am getting into that controller which currently looks like this:
```
class Users::RegistrationsController < Devise::RegistrationsController
def edit
super
end
end
```
However, when I get to my view, it's still SKIPPING the block that starts like this:
```
<%= f.simple_fields_for :addresses do |a| %>
```
However, if I go manually into my DB and add a record in the addresses table and link it to my currently\_signed in user via the foreign key, then the block does not get skipped. So whats the best way to generate this connection if the address record does not yet exist? Is it the build method? e.g.
```
user.address.build
```
in the controller
SOLUTION
Yes, I needed to added this method to my new registrations\_controller.rb file
```
def edit
if resource.addresses.size == 0
resource.addresses.build
end
super
end
```
It is now working the way I intended it. | 2014/05/25 | [
"https://Stackoverflow.com/questions/23852252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1316464/"
] | `densityplot()` from bioconductor `flowViz` package is one option for stacked densities.
from: <http://www.bioconductor.org/packages/release/bioc/manuals/flowViz/man/flowViz.pdf> :
>
> For flowSets the idea is to horizontally stack plots of density estimates for all frames in the
> flowSet for one or several flow parameters. In the latter case, each parameter will be plotted
> in a separate panel, i.e., we implicitely condition on parameters.
>
>
>
you can see example visuals here:
<http://www.bioconductor.org/packages/release/bioc/vignettes/flowViz/inst/doc/filters.html>
```
source("http://bioconductor.org/biocLite.R")
biocLite("flowViz")
``` | Complementing Axeman's answer, you can add the option `stat="binline"` to the `geom_density_ridges` geom. This results in a histogram like plot, instead of a density line.
```
library(ggplot2)
library(ggridges)
my.data <- as.data.frame(rbind( cbind( rnorm(1e3), 1) ,
cbind( rnorm(1e3)+2, 2),
cbind( rnorm(1e3)+3, 3),
cbind( rnorm(1e3)+4, 4)))
my.data$V2 <- as.factor(my.data$V2)
ggplot(my.data, aes(x=V1, y=factor(V2), fill=factor(V2))) +
geom_density_ridges(alpha=0.6, stat="binline", bins=30)
```
Resulting image:
 |
23,852,252 | This is for Rails 4.04 and Ruby 2.1. I'd like to allow my users to have addresses. So I generated an address table and gave it columns (NUMBER, STREET, CITY, STATE). Now when I go to the following url, I'd like to be able edit this information:
```
webapp.com/users/edit/
```
However I noticed it only showed the same old information (name, password, email). So I went to the view and added simple\_fields for my new relationship so the view now looks like this:
```
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<div class="form-inputs">
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :name, required: false %>
<%= f.simple_fields_for :addresses do |a| %>
<%= a.input :number %>
<%= a.input :street %>
<%= a.input :city %>
<%= a.input :state %>
<%= a.input :country %>
<% end %>
<%end%>
```
However it still doesn't generate the fields needed for address. I think this is because none of my users currently have any addresses attached to their account profile (because this migration was just created). However, in this case there should be blank fields generated so I can ADD address information.
I feel like I need to do something in the Users#Edit action like this
```
@users.each do |user|
user.address.build
end
```
Is that right? How can I override the users controller because this was created by Devise and I don't actually have a users controller (I looked for it it and couldn't find it).
UPDATE
Ok, I'm getting closer. I had to create my own controller to override Devise's default registrations controller as explained in the second answer of this stack overflow article:
[Override devise registrations controller](https://stackoverflow.com/questions/3546289/override-devise-registrations-controller)
So now I am getting into that controller which currently looks like this:
```
class Users::RegistrationsController < Devise::RegistrationsController
def edit
super
end
end
```
However, when I get to my view, it's still SKIPPING the block that starts like this:
```
<%= f.simple_fields_for :addresses do |a| %>
```
However, if I go manually into my DB and add a record in the addresses table and link it to my currently\_signed in user via the foreign key, then the block does not get skipped. So whats the best way to generate this connection if the address record does not yet exist? Is it the build method? e.g.
```
user.address.build
```
in the controller
SOLUTION
Yes, I needed to added this method to my new registrations\_controller.rb file
```
def edit
if resource.addresses.size == 0
resource.addresses.build
end
super
end
```
It is now working the way I intended it. | 2014/05/25 | [
"https://Stackoverflow.com/questions/23852252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1316464/"
] | ```
require(ggplot2)
require(plyr)
my.data <- as.data.frame(rbind( cbind( rnorm(1e3), 1) , cbind( rnorm(1e3)+2, 2), cbind( rnorm(1e3)+3, 3), cbind( rnorm(1e3)+4, 4)))
my.data$V2=as.factor(my.data$V2)
```
calculate the density depending on V2
```
res <- dlply(my.data, .(V2), function(x) density(x$V1))
dd <- ldply(res, function(z){
data.frame(Values = z[["x"]],
V1_density = z[["y"]],
V1_count = z[["y"]]*z[["n"]])
})
```
add an offset depending on V2
```
dd$offest=-as.numeric(dd$V2)*0.2 # adapt the 0.2 value as you need
dd$V1_density_offest=dd$V1_density+dd$offest
```
and plot
```
ggplot(dd, aes(Values, V1_density_offest, color=V2)) +
geom_line()+
geom_ribbon(aes(Values, ymin=offest,ymax=V1_density_offest, fill=V2),alpha=0.3)+
scale_y_continuous(breaks=NULL)
```
 | I think it's going to be difficult to get `ggplot` to offset the histograms like that. At least with faceting it makes new panels, and really, this transformation makes the y-axis meaningless. (The value is in the comparison from row to row). Here's one attempt at using base graphics to try to accomplish a similar thing.
```
#plotting function
plotoffsethists <- function(vals, groups, freq=F, overlap=.25, alpha=.75, colors=apply(floor(rbind(col2rgb(scales:::hue_pal(h = c(0, 360) + 15, c = 100, l = 65)(nlevels(groups))),alpha=alpha*255)),2,function(x) {paste0("#",paste(sprintf("%02X",x),collapse=""))}), ...) {
print(colors)
if (!is.factor(groups)) {
groups<-factor(groups)
}
offsethist <- function (x, col = NULL, offset=0, freq=F, ...) {
y <- if (freq) y <- x$counts
else
x$density
nB <- length(x$breaks)
rect(x$breaks[-nB], 0+offset, x$breaks[-1L], y+offset, col = col, ...)
}
hh<-tapply(vals, groups, hist, plot=F)
ymax<-if(freq)
sapply(hh, function(x) max(x$counts))
else
sapply(hh, function(x) max(x$density))
offset<-(mean(ymax)*overlap) * (length(ymax)-1):0
ylim<-range(c(0,ymax+offset))
xlim<-range(sapply(hh, function(x) range(x$breaks)))
plot.new()
plot.window(xlim, ylim, "")
box()
axis(1)
Map(offsethist, hh, colors, offset, freq=freq, ...)
invisible(hh)
}
#sample call
par(mar=c(3,1,1,1)+.1)
plotoffsethists(my.data$V1, factor(my.data$V2), overlap=.25)
```
 |
23,852,252 | This is for Rails 4.04 and Ruby 2.1. I'd like to allow my users to have addresses. So I generated an address table and gave it columns (NUMBER, STREET, CITY, STATE). Now when I go to the following url, I'd like to be able edit this information:
```
webapp.com/users/edit/
```
However I noticed it only showed the same old information (name, password, email). So I went to the view and added simple\_fields for my new relationship so the view now looks like this:
```
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<div class="form-inputs">
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :name, required: false %>
<%= f.simple_fields_for :addresses do |a| %>
<%= a.input :number %>
<%= a.input :street %>
<%= a.input :city %>
<%= a.input :state %>
<%= a.input :country %>
<% end %>
<%end%>
```
However it still doesn't generate the fields needed for address. I think this is because none of my users currently have any addresses attached to their account profile (because this migration was just created). However, in this case there should be blank fields generated so I can ADD address information.
I feel like I need to do something in the Users#Edit action like this
```
@users.each do |user|
user.address.build
end
```
Is that right? How can I override the users controller because this was created by Devise and I don't actually have a users controller (I looked for it it and couldn't find it).
UPDATE
Ok, I'm getting closer. I had to create my own controller to override Devise's default registrations controller as explained in the second answer of this stack overflow article:
[Override devise registrations controller](https://stackoverflow.com/questions/3546289/override-devise-registrations-controller)
So now I am getting into that controller which currently looks like this:
```
class Users::RegistrationsController < Devise::RegistrationsController
def edit
super
end
end
```
However, when I get to my view, it's still SKIPPING the block that starts like this:
```
<%= f.simple_fields_for :addresses do |a| %>
```
However, if I go manually into my DB and add a record in the addresses table and link it to my currently\_signed in user via the foreign key, then the block does not get skipped. So whats the best way to generate this connection if the address record does not yet exist? Is it the build method? e.g.
```
user.address.build
```
in the controller
SOLUTION
Yes, I needed to added this method to my new registrations\_controller.rb file
```
def edit
if resource.addresses.size == 0
resource.addresses.build
end
super
end
```
It is now working the way I intended it. | 2014/05/25 | [
"https://Stackoverflow.com/questions/23852252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1316464/"
] | Using the `ggridges` package:
```
ggplot(my.data, aes(x = V1, y = factor(V2), fill = factor(V2), color = factor(V2))) +
geom_density_ridges(alpha = 0.5)
```
[](https://i.stack.imgur.com/v1GRE.png) | I think it's going to be difficult to get `ggplot` to offset the histograms like that. At least with faceting it makes new panels, and really, this transformation makes the y-axis meaningless. (The value is in the comparison from row to row). Here's one attempt at using base graphics to try to accomplish a similar thing.
```
#plotting function
plotoffsethists <- function(vals, groups, freq=F, overlap=.25, alpha=.75, colors=apply(floor(rbind(col2rgb(scales:::hue_pal(h = c(0, 360) + 15, c = 100, l = 65)(nlevels(groups))),alpha=alpha*255)),2,function(x) {paste0("#",paste(sprintf("%02X",x),collapse=""))}), ...) {
print(colors)
if (!is.factor(groups)) {
groups<-factor(groups)
}
offsethist <- function (x, col = NULL, offset=0, freq=F, ...) {
y <- if (freq) y <- x$counts
else
x$density
nB <- length(x$breaks)
rect(x$breaks[-nB], 0+offset, x$breaks[-1L], y+offset, col = col, ...)
}
hh<-tapply(vals, groups, hist, plot=F)
ymax<-if(freq)
sapply(hh, function(x) max(x$counts))
else
sapply(hh, function(x) max(x$density))
offset<-(mean(ymax)*overlap) * (length(ymax)-1):0
ylim<-range(c(0,ymax+offset))
xlim<-range(sapply(hh, function(x) range(x$breaks)))
plot.new()
plot.window(xlim, ylim, "")
box()
axis(1)
Map(offsethist, hh, colors, offset, freq=freq, ...)
invisible(hh)
}
#sample call
par(mar=c(3,1,1,1)+.1)
plotoffsethists(my.data$V1, factor(my.data$V2), overlap=.25)
```
 |
23,852,252 | This is for Rails 4.04 and Ruby 2.1. I'd like to allow my users to have addresses. So I generated an address table and gave it columns (NUMBER, STREET, CITY, STATE). Now when I go to the following url, I'd like to be able edit this information:
```
webapp.com/users/edit/
```
However I noticed it only showed the same old information (name, password, email). So I went to the view and added simple\_fields for my new relationship so the view now looks like this:
```
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<div class="form-inputs">
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :name, required: false %>
<%= f.simple_fields_for :addresses do |a| %>
<%= a.input :number %>
<%= a.input :street %>
<%= a.input :city %>
<%= a.input :state %>
<%= a.input :country %>
<% end %>
<%end%>
```
However it still doesn't generate the fields needed for address. I think this is because none of my users currently have any addresses attached to their account profile (because this migration was just created). However, in this case there should be blank fields generated so I can ADD address information.
I feel like I need to do something in the Users#Edit action like this
```
@users.each do |user|
user.address.build
end
```
Is that right? How can I override the users controller because this was created by Devise and I don't actually have a users controller (I looked for it it and couldn't find it).
UPDATE
Ok, I'm getting closer. I had to create my own controller to override Devise's default registrations controller as explained in the second answer of this stack overflow article:
[Override devise registrations controller](https://stackoverflow.com/questions/3546289/override-devise-registrations-controller)
So now I am getting into that controller which currently looks like this:
```
class Users::RegistrationsController < Devise::RegistrationsController
def edit
super
end
end
```
However, when I get to my view, it's still SKIPPING the block that starts like this:
```
<%= f.simple_fields_for :addresses do |a| %>
```
However, if I go manually into my DB and add a record in the addresses table and link it to my currently\_signed in user via the foreign key, then the block does not get skipped. So whats the best way to generate this connection if the address record does not yet exist? Is it the build method? e.g.
```
user.address.build
```
in the controller
SOLUTION
Yes, I needed to added this method to my new registrations\_controller.rb file
```
def edit
if resource.addresses.size == 0
resource.addresses.build
end
super
end
```
It is now working the way I intended it. | 2014/05/25 | [
"https://Stackoverflow.com/questions/23852252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1316464/"
] | ```
require(ggplot2)
require(plyr)
my.data <- as.data.frame(rbind( cbind( rnorm(1e3), 1) , cbind( rnorm(1e3)+2, 2), cbind( rnorm(1e3)+3, 3), cbind( rnorm(1e3)+4, 4)))
my.data$V2=as.factor(my.data$V2)
```
calculate the density depending on V2
```
res <- dlply(my.data, .(V2), function(x) density(x$V1))
dd <- ldply(res, function(z){
data.frame(Values = z[["x"]],
V1_density = z[["y"]],
V1_count = z[["y"]]*z[["n"]])
})
```
add an offset depending on V2
```
dd$offest=-as.numeric(dd$V2)*0.2 # adapt the 0.2 value as you need
dd$V1_density_offest=dd$V1_density+dd$offest
```
and plot
```
ggplot(dd, aes(Values, V1_density_offest, color=V2)) +
geom_line()+
geom_ribbon(aes(Values, ymin=offest,ymax=V1_density_offest, fill=V2),alpha=0.3)+
scale_y_continuous(breaks=NULL)
```
 | Using the `ggridges` package:
```
ggplot(my.data, aes(x = V1, y = factor(V2), fill = factor(V2), color = factor(V2))) +
geom_density_ridges(alpha = 0.5)
```
[](https://i.stack.imgur.com/v1GRE.png) |
23,852,252 | This is for Rails 4.04 and Ruby 2.1. I'd like to allow my users to have addresses. So I generated an address table and gave it columns (NUMBER, STREET, CITY, STATE). Now when I go to the following url, I'd like to be able edit this information:
```
webapp.com/users/edit/
```
However I noticed it only showed the same old information (name, password, email). So I went to the view and added simple\_fields for my new relationship so the view now looks like this:
```
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<div class="form-inputs">
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :name, required: false %>
<%= f.simple_fields_for :addresses do |a| %>
<%= a.input :number %>
<%= a.input :street %>
<%= a.input :city %>
<%= a.input :state %>
<%= a.input :country %>
<% end %>
<%end%>
```
However it still doesn't generate the fields needed for address. I think this is because none of my users currently have any addresses attached to their account profile (because this migration was just created). However, in this case there should be blank fields generated so I can ADD address information.
I feel like I need to do something in the Users#Edit action like this
```
@users.each do |user|
user.address.build
end
```
Is that right? How can I override the users controller because this was created by Devise and I don't actually have a users controller (I looked for it it and couldn't find it).
UPDATE
Ok, I'm getting closer. I had to create my own controller to override Devise's default registrations controller as explained in the second answer of this stack overflow article:
[Override devise registrations controller](https://stackoverflow.com/questions/3546289/override-devise-registrations-controller)
So now I am getting into that controller which currently looks like this:
```
class Users::RegistrationsController < Devise::RegistrationsController
def edit
super
end
end
```
However, when I get to my view, it's still SKIPPING the block that starts like this:
```
<%= f.simple_fields_for :addresses do |a| %>
```
However, if I go manually into my DB and add a record in the addresses table and link it to my currently\_signed in user via the foreign key, then the block does not get skipped. So whats the best way to generate this connection if the address record does not yet exist? Is it the build method? e.g.
```
user.address.build
```
in the controller
SOLUTION
Yes, I needed to added this method to my new registrations\_controller.rb file
```
def edit
if resource.addresses.size == 0
resource.addresses.build
end
super
end
```
It is now working the way I intended it. | 2014/05/25 | [
"https://Stackoverflow.com/questions/23852252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1316464/"
] | ```
require(ggplot2)
require(plyr)
my.data <- as.data.frame(rbind( cbind( rnorm(1e3), 1) , cbind( rnorm(1e3)+2, 2), cbind( rnorm(1e3)+3, 3), cbind( rnorm(1e3)+4, 4)))
my.data$V2=as.factor(my.data$V2)
```
calculate the density depending on V2
```
res <- dlply(my.data, .(V2), function(x) density(x$V1))
dd <- ldply(res, function(z){
data.frame(Values = z[["x"]],
V1_density = z[["y"]],
V1_count = z[["y"]]*z[["n"]])
})
```
add an offset depending on V2
```
dd$offest=-as.numeric(dd$V2)*0.2 # adapt the 0.2 value as you need
dd$V1_density_offest=dd$V1_density+dd$offest
```
and plot
```
ggplot(dd, aes(Values, V1_density_offest, color=V2)) +
geom_line()+
geom_ribbon(aes(Values, ymin=offest,ymax=V1_density_offest, fill=V2),alpha=0.3)+
scale_y_continuous(breaks=NULL)
```
 | Complementing Axeman's answer, you can add the option `stat="binline"` to the `geom_density_ridges` geom. This results in a histogram like plot, instead of a density line.
```
library(ggplot2)
library(ggridges)
my.data <- as.data.frame(rbind( cbind( rnorm(1e3), 1) ,
cbind( rnorm(1e3)+2, 2),
cbind( rnorm(1e3)+3, 3),
cbind( rnorm(1e3)+4, 4)))
my.data$V2 <- as.factor(my.data$V2)
ggplot(my.data, aes(x=V1, y=factor(V2), fill=factor(V2))) +
geom_density_ridges(alpha=0.6, stat="binline", bins=30)
```
Resulting image:
 |
23,852,252 | This is for Rails 4.04 and Ruby 2.1. I'd like to allow my users to have addresses. So I generated an address table and gave it columns (NUMBER, STREET, CITY, STATE). Now when I go to the following url, I'd like to be able edit this information:
```
webapp.com/users/edit/
```
However I noticed it only showed the same old information (name, password, email). So I went to the view and added simple\_fields for my new relationship so the view now looks like this:
```
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<div class="form-inputs">
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :name, required: false %>
<%= f.simple_fields_for :addresses do |a| %>
<%= a.input :number %>
<%= a.input :street %>
<%= a.input :city %>
<%= a.input :state %>
<%= a.input :country %>
<% end %>
<%end%>
```
However it still doesn't generate the fields needed for address. I think this is because none of my users currently have any addresses attached to their account profile (because this migration was just created). However, in this case there should be blank fields generated so I can ADD address information.
I feel like I need to do something in the Users#Edit action like this
```
@users.each do |user|
user.address.build
end
```
Is that right? How can I override the users controller because this was created by Devise and I don't actually have a users controller (I looked for it it and couldn't find it).
UPDATE
Ok, I'm getting closer. I had to create my own controller to override Devise's default registrations controller as explained in the second answer of this stack overflow article:
[Override devise registrations controller](https://stackoverflow.com/questions/3546289/override-devise-registrations-controller)
So now I am getting into that controller which currently looks like this:
```
class Users::RegistrationsController < Devise::RegistrationsController
def edit
super
end
end
```
However, when I get to my view, it's still SKIPPING the block that starts like this:
```
<%= f.simple_fields_for :addresses do |a| %>
```
However, if I go manually into my DB and add a record in the addresses table and link it to my currently\_signed in user via the foreign key, then the block does not get skipped. So whats the best way to generate this connection if the address record does not yet exist? Is it the build method? e.g.
```
user.address.build
```
in the controller
SOLUTION
Yes, I needed to added this method to my new registrations\_controller.rb file
```
def edit
if resource.addresses.size == 0
resource.addresses.build
end
super
end
```
It is now working the way I intended it. | 2014/05/25 | [
"https://Stackoverflow.com/questions/23852252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1316464/"
] | Using the `ggridges` package:
```
ggplot(my.data, aes(x = V1, y = factor(V2), fill = factor(V2), color = factor(V2))) +
geom_density_ridges(alpha = 0.5)
```
[](https://i.stack.imgur.com/v1GRE.png) | Complementing Axeman's answer, you can add the option `stat="binline"` to the `geom_density_ridges` geom. This results in a histogram like plot, instead of a density line.
```
library(ggplot2)
library(ggridges)
my.data <- as.data.frame(rbind( cbind( rnorm(1e3), 1) ,
cbind( rnorm(1e3)+2, 2),
cbind( rnorm(1e3)+3, 3),
cbind( rnorm(1e3)+4, 4)))
my.data$V2 <- as.factor(my.data$V2)
ggplot(my.data, aes(x=V1, y=factor(V2), fill=factor(V2))) +
geom_density_ridges(alpha=0.6, stat="binline", bins=30)
```
Resulting image:
 |
15,309,666 | I want to upgrade my existing apps to **iOS 5.0 and above.**
I want **suggestions and detailed guide line** for main points.
what changes I should make in my existing code to make it fully
compatible as new iOS coding standards.
For e.g.
* Should I change all external frameworks and my custom classes
for making it compatible for ARC?
* I should make changes into sqlite database creation.
* Should I replace old framework of Twitter & Facebook?
* What kind of changes I should do with Graphics?
**In-short, Please provide guideline and suggestion that are important for making older app fully compatible with New iOS standards.**
>
> Guys thanks for providing your comments & reply for this question.
>
>
> By Looking at your response, I think you guys are only focusing on the
> above given points. I want general suggestions from your experience.
> i.e. what things we should change in info.plist, what changes should
> be done in graphics. how we can improve app by adding automatic ARC
> support etc ...
>
>
> Main thing is how we can make it compatible for different resolutions
> of iPhone / iPad (i.e. for iPhone 5 and other devices).
>
>
>
If possible then please provide graphics changes guidelines with
resolution for new iPhone 5 Device and iPad Mini Device.
Your help / suggestions / Guidelines will be greatly appreciated! | 2013/03/09 | [
"https://Stackoverflow.com/questions/15309666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/281944/"
] | >
> Should I change all external frameworks and my custom classes for making it compatible for ARC?
>
>
>
It depends entirely upon you. ARC is a compile-time feature that is meant to obviate the task of manual memory management. It doesn't eliminate it by any stretch of the imagination, but it is miles safer than anything we as programmers could ever hope to write most of the time. It is possible to mix ARC and non-ARC frameworks and libraries in an application.
>
> I should make changes into sqlite database creation.
>
>
>
iOS has always shipped with libSQLite3, so there is absolutely no work required for you to "upgrade" this aspect of your application. You might consider a move to core data, if only because again, it obviates large portions of interfacing with SQLite.
>
> Should I replace old framework of Twitter & Facebook?
>
>
>
Again, it depends. If you plan on supporting older OSes which do not come with the new iOS social features and frameworks, then I'd leave it as is. The new API is far more limiting than accessing the actual API for each of the given social services, but it is also far easier to implement, especially for things like simple wall posts.
>
> What kind of changes I should do with Graphics?
>
>
>
Graphics files must (optimally) come in 2 flavors with an optional third format for the new iPhone: standard, retina, and stretched retina. While opting into retina-graphics is completely optional, it is recommended that you provide high-resolution assets to provide the best user experience. In regards to the actual graphics library (CoreGraphics), the framework handles the scaling of elements drawn to the screen. | **- Should I change all external frameworks and my custom classes for making it compatible for ARC?**
>
> If your frameworks are out dated then, YES you need to update it so
> its compatible for iOS 5 and above. For ARC, its not necessary. If you
> don't wanted to handle memory management then you can.
>
>
>
**- Should I replace old framework of Twitter & Facebook?**
>
> YES please.
>
>
>
**- What kind of changes I should do with Graphics?**
>
> You need to change graphics for ratina display. Google about it.
>
>
> |
56,030,013 | given the code below, how do I print the name of child process that was passed in as the `self.looper(_function=)` argument? I have no idea how to do this! I am trying to do logic based on which function was passed into `_function`. Hope I conveyed the question correctly. thanks!!
```
class okheregoes(object):
def __init__(self):
pass
def looper(self, _function):
print('the function name that was passed to _function is {}'.format(_function.__name__))
if _function.__name__ == 'child1':
print('it was child 1 this time')
if _function.__name__ == 'child2':
print('it was child 2 this time')
def child1(self, _number):
return 'my favorite number is {}'.format(_number)
def child2(self, _number):
return 'my favorite number is {}'.format(_number)
def main(self):
for i in range(1,10):
self.looper(_function=self.child1(_number=i+1))
self.looper(_function=self.child2(_number=i-1))
pleashelp = okheregoes()
if __name__ == '__main__':
pleashelp.main()
``` | 2019/05/07 | [
"https://Stackoverflow.com/questions/56030013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2891052/"
] | you can simply do a `foreach` since you haven't explained what type of array you are returning, so i'll simply assume it to be a `{key: value}` type array, so in you success function
```
success: function(response){
let select = document.querySelector('#variant_colour')
select.innerHTML = '' //if you want to remove previous options
response.forEach((op)=>{
select.innerHTML += `<option value=${op.id}>${op.value}</option>`
})
}
```
Also, you'll need to provide some value in your option value attribute in your blade
```
<option value="{{ $variant->id }}">{{$variant->attributes_colour}}</option> //set some value example id
``` | I think you should use js to loop the data. I do not know how is the structure that returns the ajax call, but you can try something like this with jquery:
```
<script>
$('#variant_model').change(function(){
var value = $('select#variant_model').val();
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
type:"POST",
url: "showVariantModel",
data: {value:value},
success: function(data){
$.each(data, function (key, value) {
$('#variant_colour').append("<option value='" + key + "'>" + value + "</option>");
});
}
})
});
</script>
``` |
21,900,923 | i have an `ArrayList` which contains `String` elements and i want to add an `int` into the `list` but with out Converting that into the String is that possible.
i have tried this and this is working too.
```
int a1 = 10;
java.util.List list = new ArrayList<String>();
list.add(a1);
System.out.println("List element"+list.get(0));
```
and but i am wondering this to be happen.
```
int a1 = 10;
java.util.List<String> list = new ArrayList<String>();
list.add(a1);
System.out.println("List element"+list.get(0));
```
is that possible to do? | 2014/02/20 | [
"https://Stackoverflow.com/questions/21900923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2762311/"
] | try this
```
list.add(String.valueOf(a1));
``` | An advantage of a typed list is, that you can assume, that you only have objects of the given type in the list - why would one want to throw this advantage away, if it is completely easy to convert the given type into the type of the list? |
21,900,923 | i have an `ArrayList` which contains `String` elements and i want to add an `int` into the `list` but with out Converting that into the String is that possible.
i have tried this and this is working too.
```
int a1 = 10;
java.util.List list = new ArrayList<String>();
list.add(a1);
System.out.println("List element"+list.get(0));
```
and but i am wondering this to be happen.
```
int a1 = 10;
java.util.List<String> list = new ArrayList<String>();
list.add(a1);
System.out.println("List element"+list.get(0));
```
is that possible to do? | 2014/02/20 | [
"https://Stackoverflow.com/questions/21900923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2762311/"
] | try this
```
list.add(String.valueOf(a1));
``` | In first case your `List` is just a raw `List`. So you can add what ever type to that since `List` is raw and again that is bad way of use of `List` in `Java`..But second case it is `String` `List` you have to add Stings there.
Now you have to use following way to add `int` to `List`.
```
int a1 = 10;
java.util.List<String> list = new ArrayList<String>();
list.add(String.valueOf(a1)); // now String value of int will add to list
System.out.println("List element"+list.get(0));
``` |
21,900,923 | i have an `ArrayList` which contains `String` elements and i want to add an `int` into the `list` but with out Converting that into the String is that possible.
i have tried this and this is working too.
```
int a1 = 10;
java.util.List list = new ArrayList<String>();
list.add(a1);
System.out.println("List element"+list.get(0));
```
and but i am wondering this to be happen.
```
int a1 = 10;
java.util.List<String> list = new ArrayList<String>();
list.add(a1);
System.out.println("List element"+list.get(0));
```
is that possible to do? | 2014/02/20 | [
"https://Stackoverflow.com/questions/21900923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2762311/"
] | try this
```
list.add(String.valueOf(a1));
``` | You can not do it without converting it to String, but one alternate way to do it by String concatination(without direct conversion from int to String):
```
list.add("" + a1);
```
but internally it will append a1 value to "" String and final result is String. |
138,729 | I currently have a metal step rail that is straight and spans three steps leading up to my front porch; it is the typical cheap metal railing you commonly see. It is at the end of its life, so my fiance wants something a bit more unique.
So, her ideal would be a cedar, flush mounted single rail (still straight, not mounted to house or wrapping around the small porch we have). My biggest concern is making sure the posts are secure since it would be flush mounted, lack right angles, and not secured to the side of the house.
I found this [advice](http://forums.finehomebuilding.com/breaktime/construction-techniques/anchoring-wood-railing-posts-concrete):
>
> Drill 4 holes 6" deep by 5/8" diameter in the bottom of each 4x4 post.
> Center the holes about 1" from the corners, and drill slightly toward
> the center of the post, i.e. the holes are slightly angled in. Use
> Simpson epoxy to glue 4 pieces of 1/2" all-thread or 3/8" rebar into
> those holes.
>
>
> When the epoxy cures, the protruding rods can be bent so
> they exit the post parallel to one another and to the post's long
> axis. Now drill 4 holes in the concrete for each post, same size and
> depth, all straight down. Brush and blow out all the dust. Mask off
> the concrete around where the base of the post will rest.
>
>
> Mask off the
> sides of the post at the bottom. When that is done, put a fresh nozzle
> on your Simpson gun and put epoxy into the slab holes, and set the
> posts. Quickly brace them plumb. While the epoxy is soft, smear the
> excess away from the bases with a gloved finger, and carefully remove
> the masking while things are still squishy.
>
>
> Take lunch, or work on
> something else. The posts will cure solid in an hour or several,
> depending on temperature, etc. When they are cured, they will feel
> like they grew there.
>
>
>
It sounds pretty good, but before I go to all the trouble of doing it this way. I wanted to know:
1. Is this a good way to do this?
2. Is there a better way? | 2018/05/10 | [
"https://diy.stackexchange.com/questions/138729",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/6276/"
] | As much as I'd like to think I know what I'm doing when buying new properties, I ALWAYS hire a home inspector. If you are concerned about Asbestos, you aren't going to be able to negotiate on price or to get it fixed unless you have a home inspector come in. The added bonus of hiring an inspector is that if they miss something that should of been caught during the inspection, like termites, they are insured to cover it for you.
Further, if you suspect Asbestos, you should work testing for that into your P&S contract. The tile floors and ceiling plaster are just as likely to be asbestos.
Moreover, an untouched house from that era is likely to have a leaky roof, and a leaky roof means you have mold (another reason to have an inspector). The air ducts may / may not be full of dust. The intake plumbing may be made out of led. The cast iron waste lines may be rotting and depending on water quality you may even need to verify the that the copper piping doesn't look like it has any pitting. At this point, the the foundation likely has a few cracks and you'll wanna test for Radon if you are in an area prone to in.
I just noticed Jasper posted while I was writing this. While I agree with him, you'll likely want to update your windows. The electrical capacity probably isn't as much of an issue as it would have been a decade or two ago now that people are moving to LED bulbs and laptops. Similarly, if your appliances either work or they don't - This isn't a 60s specific thing. Moreover, I'd argue appliances were better built and easier to repair back then, so if they are in good shape may even outlast a modern one.
**TLDR; Don't do it your self. get an inspection!** | Does your area have good, ethical home inspectors?
Charles Buell is a Seattle-area home inspector whose [blog](http://www.buellinspections.com/) provides examples of a variety of worst-case (and/or funniest case) inspection findings. A large number of Seattle-area homes were built in the early 20th century, but he also has examples from inspections of mid-20th century homes.
Mid-20th century construction often had asbestos in a variety of places, including roof shingles, siding shingles, floor tiles, insulation, and popcorn ceilings.
50-year old homes often have several obsolete systems:
* Electrical.
* The plumbing might be excellent copper pipes (except for the lead solder), or it might be clogged galvanized pipes.
* Single-pane windows. (Consider adding [custom-fit interior storm windows](https://indowwindows.com) instead of replacing the windows with new double- or triple-pane windows.)
* Kitchen appliances, especially stoves, refrigerators, and a possible lack of microwaves and dishwashers. There might not be space for larger appliances.
* HVAC systems.
* Water heaters.
* Lead paint. (It can be painted over.)
* (Lack of) earthquake-resistance and high-wind resistance.
Leaks and vermin infestations can cause serious problems in homes of any age. |
138,729 | I currently have a metal step rail that is straight and spans three steps leading up to my front porch; it is the typical cheap metal railing you commonly see. It is at the end of its life, so my fiance wants something a bit more unique.
So, her ideal would be a cedar, flush mounted single rail (still straight, not mounted to house or wrapping around the small porch we have). My biggest concern is making sure the posts are secure since it would be flush mounted, lack right angles, and not secured to the side of the house.
I found this [advice](http://forums.finehomebuilding.com/breaktime/construction-techniques/anchoring-wood-railing-posts-concrete):
>
> Drill 4 holes 6" deep by 5/8" diameter in the bottom of each 4x4 post.
> Center the holes about 1" from the corners, and drill slightly toward
> the center of the post, i.e. the holes are slightly angled in. Use
> Simpson epoxy to glue 4 pieces of 1/2" all-thread or 3/8" rebar into
> those holes.
>
>
> When the epoxy cures, the protruding rods can be bent so
> they exit the post parallel to one another and to the post's long
> axis. Now drill 4 holes in the concrete for each post, same size and
> depth, all straight down. Brush and blow out all the dust. Mask off
> the concrete around where the base of the post will rest.
>
>
> Mask off the
> sides of the post at the bottom. When that is done, put a fresh nozzle
> on your Simpson gun and put epoxy into the slab holes, and set the
> posts. Quickly brace them plumb. While the epoxy is soft, smear the
> excess away from the bases with a gloved finger, and carefully remove
> the masking while things are still squishy.
>
>
> Take lunch, or work on
> something else. The posts will cure solid in an hour or several,
> depending on temperature, etc. When they are cured, they will feel
> like they grew there.
>
>
>
It sounds pretty good, but before I go to all the trouble of doing it this way. I wanted to know:
1. Is this a good way to do this?
2. Is there a better way? | 2018/05/10 | [
"https://diy.stackexchange.com/questions/138729",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/6276/"
] | Does your area have good, ethical home inspectors?
Charles Buell is a Seattle-area home inspector whose [blog](http://www.buellinspections.com/) provides examples of a variety of worst-case (and/or funniest case) inspection findings. A large number of Seattle-area homes were built in the early 20th century, but he also has examples from inspections of mid-20th century homes.
Mid-20th century construction often had asbestos in a variety of places, including roof shingles, siding shingles, floor tiles, insulation, and popcorn ceilings.
50-year old homes often have several obsolete systems:
* Electrical.
* The plumbing might be excellent copper pipes (except for the lead solder), or it might be clogged galvanized pipes.
* Single-pane windows. (Consider adding [custom-fit interior storm windows](https://indowwindows.com) instead of replacing the windows with new double- or triple-pane windows.)
* Kitchen appliances, especially stoves, refrigerators, and a possible lack of microwaves and dishwashers. There might not be space for larger appliances.
* HVAC systems.
* Water heaters.
* Lead paint. (It can be painted over.)
* (Lack of) earthquake-resistance and high-wind resistance.
Leaks and vermin infestations can cause serious problems in homes of any age. | One important item you need to know about houses that were built before the 1965 NEC was approved and went into effect in you area.
Grounding and GFCI protection were nonexistent. Now if no new work was ever done, then the resident falls under the grandfather clause, meaning it can stay as it is unless it stops working. So when you walk around the house and look at the receptacles they should be the type with only 2 slots and no ground connection. This is important because someone may have gone around and changed out these receptacles, and they have no ground protection which make it illegal. If the receptacles are labeled as ungrounded they may be protected by installing a GFCI protection device at the beginning of the circuit. So be sure and ask if they are protected in such a manner and ask to point out the location of the protection. I doubt any seller would want to rewire and entire residence because of the cost.
As everyone has already recommended hire an independent inspector yourself and follow his recommendations. Do not be misled by having someone else bring one in and paying for it. It's a matter of legal liability. If I were to hire an Inspector, Engineer, Lawyer or any professional, then they work for me and in my best interest. If you hire them yourself then they work for you and in your best interest.
Good luck. |
138,729 | I currently have a metal step rail that is straight and spans three steps leading up to my front porch; it is the typical cheap metal railing you commonly see. It is at the end of its life, so my fiance wants something a bit more unique.
So, her ideal would be a cedar, flush mounted single rail (still straight, not mounted to house or wrapping around the small porch we have). My biggest concern is making sure the posts are secure since it would be flush mounted, lack right angles, and not secured to the side of the house.
I found this [advice](http://forums.finehomebuilding.com/breaktime/construction-techniques/anchoring-wood-railing-posts-concrete):
>
> Drill 4 holes 6" deep by 5/8" diameter in the bottom of each 4x4 post.
> Center the holes about 1" from the corners, and drill slightly toward
> the center of the post, i.e. the holes are slightly angled in. Use
> Simpson epoxy to glue 4 pieces of 1/2" all-thread or 3/8" rebar into
> those holes.
>
>
> When the epoxy cures, the protruding rods can be bent so
> they exit the post parallel to one another and to the post's long
> axis. Now drill 4 holes in the concrete for each post, same size and
> depth, all straight down. Brush and blow out all the dust. Mask off
> the concrete around where the base of the post will rest.
>
>
> Mask off the
> sides of the post at the bottom. When that is done, put a fresh nozzle
> on your Simpson gun and put epoxy into the slab holes, and set the
> posts. Quickly brace them plumb. While the epoxy is soft, smear the
> excess away from the bases with a gloved finger, and carefully remove
> the masking while things are still squishy.
>
>
> Take lunch, or work on
> something else. The posts will cure solid in an hour or several,
> depending on temperature, etc. When they are cured, they will feel
> like they grew there.
>
>
>
It sounds pretty good, but before I go to all the trouble of doing it this way. I wanted to know:
1. Is this a good way to do this?
2. Is there a better way? | 2018/05/10 | [
"https://diy.stackexchange.com/questions/138729",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/6276/"
] | Answer based on it being a UK house:
**Wiring**
* An old style fusebox is unlikely to have RCD protection (UK wording of GFCI mentioned in another answer). Replacing with a consumer unit is recommended.
* Old wiring may have degraded. They used to wrap the wires in rubber to make the cables, which deteriorates over time. If so, a complete rewire is recommended.
* There are unlikely to be sufficient sockets (UK wording of "receptacle" mentioned in another answer) for modern usage. This can be fixed with a rewire.
* There is unlikely to be an electric shower. If you want one, you need a new circuit for it. I don't believe you're allowed to add new circuits to old style fuseboxes, so score another one for replacing with a consumer unit.
**Asbestos**
* As you said, the hot air ducts may be surrounded with asbestos. If you want rid (in order to install central heating instead) then removal is costly
* The ceiling is probably artexed which may contain asbestos. Only way to find out is to get it tested.
**Structural**
* A brick built house in the UK with a tiled roof is unlikely to be in much structural distress; most 60s houses are still standing fine.
* In theory the roof is beyond its design life, but that doesn't mean there's necessarily anything wrong with it. A surveyor and/or structural engineer can help you determine if there is. Probably there isn't any felt underneath the tiles - it's not up to modern standards but it's not necessarily a problem; it's just a failsafe / back-up layer that you don't have.
**Guttering**
* I'd have a good look at the guttering. I'd be surprised if the original's lasted 50 years in good condition. Guttering failure leads to damp problems.
**Comments**
People have talked about getting in a home inspector, so a surveyor in UK wording. Not a bad idea, but the internet is littered with people complaining that surveyors refuse to comment on most of the important aspects (saying you should get in specialists) and make minor required repairs sound catastrophic. Getting in a structural engineer instead is probably more expensive, but probably more beneficial (at least for the structural aspects; they won't comment on electrical or asbestos at all).
Overall I like [Dan's comment](https://diy.stackexchange.com/questions/138712/what-issues-should-i-be-aware-of-when-buying-a-60s-house-that-hasnt-had-anythi#comment223963_138712):
>
> I'd be working under the assumption that a house like that needs a full renovation - at a minimum, you'll be wanting to replace electrical systems, plumbing, water heating and any central heating. At that point, you're going to be tearing the house apart anyway.
>
>
>
In which case the only thing that matters is the structure, as the rest of it is coming out. (Although I don't agree with Dan's whole list - the plumbing might be ok.) | Does your area have good, ethical home inspectors?
Charles Buell is a Seattle-area home inspector whose [blog](http://www.buellinspections.com/) provides examples of a variety of worst-case (and/or funniest case) inspection findings. A large number of Seattle-area homes were built in the early 20th century, but he also has examples from inspections of mid-20th century homes.
Mid-20th century construction often had asbestos in a variety of places, including roof shingles, siding shingles, floor tiles, insulation, and popcorn ceilings.
50-year old homes often have several obsolete systems:
* Electrical.
* The plumbing might be excellent copper pipes (except for the lead solder), or it might be clogged galvanized pipes.
* Single-pane windows. (Consider adding [custom-fit interior storm windows](https://indowwindows.com) instead of replacing the windows with new double- or triple-pane windows.)
* Kitchen appliances, especially stoves, refrigerators, and a possible lack of microwaves and dishwashers. There might not be space for larger appliances.
* HVAC systems.
* Water heaters.
* Lead paint. (It can be painted over.)
* (Lack of) earthquake-resistance and high-wind resistance.
Leaks and vermin infestations can cause serious problems in homes of any age. |
138,729 | I currently have a metal step rail that is straight and spans three steps leading up to my front porch; it is the typical cheap metal railing you commonly see. It is at the end of its life, so my fiance wants something a bit more unique.
So, her ideal would be a cedar, flush mounted single rail (still straight, not mounted to house or wrapping around the small porch we have). My biggest concern is making sure the posts are secure since it would be flush mounted, lack right angles, and not secured to the side of the house.
I found this [advice](http://forums.finehomebuilding.com/breaktime/construction-techniques/anchoring-wood-railing-posts-concrete):
>
> Drill 4 holes 6" deep by 5/8" diameter in the bottom of each 4x4 post.
> Center the holes about 1" from the corners, and drill slightly toward
> the center of the post, i.e. the holes are slightly angled in. Use
> Simpson epoxy to glue 4 pieces of 1/2" all-thread or 3/8" rebar into
> those holes.
>
>
> When the epoxy cures, the protruding rods can be bent so
> they exit the post parallel to one another and to the post's long
> axis. Now drill 4 holes in the concrete for each post, same size and
> depth, all straight down. Brush and blow out all the dust. Mask off
> the concrete around where the base of the post will rest.
>
>
> Mask off the
> sides of the post at the bottom. When that is done, put a fresh nozzle
> on your Simpson gun and put epoxy into the slab holes, and set the
> posts. Quickly brace them plumb. While the epoxy is soft, smear the
> excess away from the bases with a gloved finger, and carefully remove
> the masking while things are still squishy.
>
>
> Take lunch, or work on
> something else. The posts will cure solid in an hour or several,
> depending on temperature, etc. When they are cured, they will feel
> like they grew there.
>
>
>
It sounds pretty good, but before I go to all the trouble of doing it this way. I wanted to know:
1. Is this a good way to do this?
2. Is there a better way? | 2018/05/10 | [
"https://diy.stackexchange.com/questions/138729",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/6276/"
] | As much as I'd like to think I know what I'm doing when buying new properties, I ALWAYS hire a home inspector. If you are concerned about Asbestos, you aren't going to be able to negotiate on price or to get it fixed unless you have a home inspector come in. The added bonus of hiring an inspector is that if they miss something that should of been caught during the inspection, like termites, they are insured to cover it for you.
Further, if you suspect Asbestos, you should work testing for that into your P&S contract. The tile floors and ceiling plaster are just as likely to be asbestos.
Moreover, an untouched house from that era is likely to have a leaky roof, and a leaky roof means you have mold (another reason to have an inspector). The air ducts may / may not be full of dust. The intake plumbing may be made out of led. The cast iron waste lines may be rotting and depending on water quality you may even need to verify the that the copper piping doesn't look like it has any pitting. At this point, the the foundation likely has a few cracks and you'll wanna test for Radon if you are in an area prone to in.
I just noticed Jasper posted while I was writing this. While I agree with him, you'll likely want to update your windows. The electrical capacity probably isn't as much of an issue as it would have been a decade or two ago now that people are moving to LED bulbs and laptops. Similarly, if your appliances either work or they don't - This isn't a 60s specific thing. Moreover, I'd argue appliances were better built and easier to repair back then, so if they are in good shape may even outlast a modern one.
**TLDR; Don't do it your self. get an inspection!** | One important item you need to know about houses that were built before the 1965 NEC was approved and went into effect in you area.
Grounding and GFCI protection were nonexistent. Now if no new work was ever done, then the resident falls under the grandfather clause, meaning it can stay as it is unless it stops working. So when you walk around the house and look at the receptacles they should be the type with only 2 slots and no ground connection. This is important because someone may have gone around and changed out these receptacles, and they have no ground protection which make it illegal. If the receptacles are labeled as ungrounded they may be protected by installing a GFCI protection device at the beginning of the circuit. So be sure and ask if they are protected in such a manner and ask to point out the location of the protection. I doubt any seller would want to rewire and entire residence because of the cost.
As everyone has already recommended hire an independent inspector yourself and follow his recommendations. Do not be misled by having someone else bring one in and paying for it. It's a matter of legal liability. If I were to hire an Inspector, Engineer, Lawyer or any professional, then they work for me and in my best interest. If you hire them yourself then they work for you and in your best interest.
Good luck. |
138,729 | I currently have a metal step rail that is straight and spans three steps leading up to my front porch; it is the typical cheap metal railing you commonly see. It is at the end of its life, so my fiance wants something a bit more unique.
So, her ideal would be a cedar, flush mounted single rail (still straight, not mounted to house or wrapping around the small porch we have). My biggest concern is making sure the posts are secure since it would be flush mounted, lack right angles, and not secured to the side of the house.
I found this [advice](http://forums.finehomebuilding.com/breaktime/construction-techniques/anchoring-wood-railing-posts-concrete):
>
> Drill 4 holes 6" deep by 5/8" diameter in the bottom of each 4x4 post.
> Center the holes about 1" from the corners, and drill slightly toward
> the center of the post, i.e. the holes are slightly angled in. Use
> Simpson epoxy to glue 4 pieces of 1/2" all-thread or 3/8" rebar into
> those holes.
>
>
> When the epoxy cures, the protruding rods can be bent so
> they exit the post parallel to one another and to the post's long
> axis. Now drill 4 holes in the concrete for each post, same size and
> depth, all straight down. Brush and blow out all the dust. Mask off
> the concrete around where the base of the post will rest.
>
>
> Mask off the
> sides of the post at the bottom. When that is done, put a fresh nozzle
> on your Simpson gun and put epoxy into the slab holes, and set the
> posts. Quickly brace them plumb. While the epoxy is soft, smear the
> excess away from the bases with a gloved finger, and carefully remove
> the masking while things are still squishy.
>
>
> Take lunch, or work on
> something else. The posts will cure solid in an hour or several,
> depending on temperature, etc. When they are cured, they will feel
> like they grew there.
>
>
>
It sounds pretty good, but before I go to all the trouble of doing it this way. I wanted to know:
1. Is this a good way to do this?
2. Is there a better way? | 2018/05/10 | [
"https://diy.stackexchange.com/questions/138729",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/6276/"
] | Answer based on it being a UK house:
**Wiring**
* An old style fusebox is unlikely to have RCD protection (UK wording of GFCI mentioned in another answer). Replacing with a consumer unit is recommended.
* Old wiring may have degraded. They used to wrap the wires in rubber to make the cables, which deteriorates over time. If so, a complete rewire is recommended.
* There are unlikely to be sufficient sockets (UK wording of "receptacle" mentioned in another answer) for modern usage. This can be fixed with a rewire.
* There is unlikely to be an electric shower. If you want one, you need a new circuit for it. I don't believe you're allowed to add new circuits to old style fuseboxes, so score another one for replacing with a consumer unit.
**Asbestos**
* As you said, the hot air ducts may be surrounded with asbestos. If you want rid (in order to install central heating instead) then removal is costly
* The ceiling is probably artexed which may contain asbestos. Only way to find out is to get it tested.
**Structural**
* A brick built house in the UK with a tiled roof is unlikely to be in much structural distress; most 60s houses are still standing fine.
* In theory the roof is beyond its design life, but that doesn't mean there's necessarily anything wrong with it. A surveyor and/or structural engineer can help you determine if there is. Probably there isn't any felt underneath the tiles - it's not up to modern standards but it's not necessarily a problem; it's just a failsafe / back-up layer that you don't have.
**Guttering**
* I'd have a good look at the guttering. I'd be surprised if the original's lasted 50 years in good condition. Guttering failure leads to damp problems.
**Comments**
People have talked about getting in a home inspector, so a surveyor in UK wording. Not a bad idea, but the internet is littered with people complaining that surveyors refuse to comment on most of the important aspects (saying you should get in specialists) and make minor required repairs sound catastrophic. Getting in a structural engineer instead is probably more expensive, but probably more beneficial (at least for the structural aspects; they won't comment on electrical or asbestos at all).
Overall I like [Dan's comment](https://diy.stackexchange.com/questions/138712/what-issues-should-i-be-aware-of-when-buying-a-60s-house-that-hasnt-had-anythi#comment223963_138712):
>
> I'd be working under the assumption that a house like that needs a full renovation - at a minimum, you'll be wanting to replace electrical systems, plumbing, water heating and any central heating. At that point, you're going to be tearing the house apart anyway.
>
>
>
In which case the only thing that matters is the structure, as the rest of it is coming out. (Although I don't agree with Dan's whole list - the plumbing might be ok.) | One important item you need to know about houses that were built before the 1965 NEC was approved and went into effect in you area.
Grounding and GFCI protection were nonexistent. Now if no new work was ever done, then the resident falls under the grandfather clause, meaning it can stay as it is unless it stops working. So when you walk around the house and look at the receptacles they should be the type with only 2 slots and no ground connection. This is important because someone may have gone around and changed out these receptacles, and they have no ground protection which make it illegal. If the receptacles are labeled as ungrounded they may be protected by installing a GFCI protection device at the beginning of the circuit. So be sure and ask if they are protected in such a manner and ask to point out the location of the protection. I doubt any seller would want to rewire and entire residence because of the cost.
As everyone has already recommended hire an independent inspector yourself and follow his recommendations. Do not be misled by having someone else bring one in and paying for it. It's a matter of legal liability. If I were to hire an Inspector, Engineer, Lawyer or any professional, then they work for me and in my best interest. If you hire them yourself then they work for you and in your best interest.
Good luck. |
131,319 | Going to Europe imminently to study a short tertiary course, half of which will be in France. Haven’t booked my return flight from Germany yet. Will this be a problem for entering Paris?
I have tried to book the flight from the airport in Doha, however despite telling my Australian banks exactly where I was going, my credit cards aren’t working. I don’t have a travel SIM yet and as such cannot receive confirmation messages from either bank, nor call them or indeed anyone else. The wifi here is somewhat functional, but that’s of little consolation. | 2019/02/01 | [
"https://travel.stackexchange.com/questions/131319",
"https://travel.stackexchange.com",
"https://travel.stackexchange.com/users/91371/"
] | First of all: Coming from Australia, no European immigration officer will consider you a particular threat and unless you look or behave suspiciously, chances are close to zero that you will get any question at all at the border.
If you for some reason should be more thoroughly checked, the actual requirement is to have sufficient means to provide for yourself during the intended stay and to leave the Schengen area again. That does not mean that you have to show already booked accomodation or onward transport, but you must strictly speaking be able to show that you have enough money to buy so. If you don't have either a booked accomodation, nor an onward ticket and also currently have problems accessing cash, it might, at least in theory, actually be a problem. | To pass French immigration with a Schengen visa or waiver, you need:
* A valid passport issued less than 10 years before and valid for at least 3 months after the envisaged departure date;
* Proof of accommodation covering the whole duration of the stay (hotel reservation and/or certificate of staying with a relative validated in the town hall);
**However, if you do not present any proof of accommodation, the consequence is that your minimum amount per day will increase.**
* Sufficient financial means. The means of subsistence shall be assessed according to the duration and purpose of the stay and by reference to the average prices for accommodation and food in the Member States;
For France, this amount (per day) is:
+ 32.50 euros per day if you are hosted by an individual, supposing you presented the certificate of staying validated by the town hall;
+ 65 euros per day of stay in the case of presentation of a hotel booking;
+ 120 euros per day in the case of non-presentation of a hotel booking;
+ In the case of a partial hotel booking: 65 euros per day for the period covered by the booking and 120 euros per day for the remainder of the stay.
* **Your return ticket or the financial means to acquire one at the envisaged return date;**
Note that the financial means are defined by R211-31 (see link below) as:
+ a declaration of a financial institution translated to French, if not already, that guarantees the return of the alien if ever he cannot afford his return.
* For stays not exceeding 90 days (unless exempt), trips for tourism or business require valid travel insurance covering any possible costs for medical repatriation, and emergency and/or hospital treatment. This is mandatory. This insurance must be valid throughout the Member States’ territory in the Schengen area, which fully apply the provisions of the Schengen accord and for the duration of your stay. It must allow you to access services in the Schengen area. This insurance must also provide coverage of €30,000 minimum including medical repatriation, and emergency and/or hospital treatment.
* Any document providing details on the profession or the capacity of the traveller as well as on the establishments or organisations located in France which are expecting you, if you are on a professional trip.
Sources:
* <https://france-visas.gouv.fr/en_US/web/france-visas/your-arrival-in-france>
* <https://www.service-public.fr/particuliers/vosdroits/F1765> (in French)
* <https://france-visas.gouv.fr/en_US/web/france-visas/faq>
* <https://www.legifrance.gouv.fr/affichCode.do?idSectionTA=LEGISCTA000006180217&cidTexte=LEGITEXT000006070158> (in French) |
60,378,345 | my Test Schema:
```
var TestSchema = new Schema({
testName: String,
topic: {
topicTitle: String,
topicQuestion: [
{
questionTitle: String,
choice: [
{
name: String
age: Number
}
]
}
]
}
}, { collection: 'test' });
var Test = mongoose.model('test', TestSchema);
```
I want to update one **age** ($inc)value which I have the choice id.
I can have **test id**, **topicQuestion id** and **choice id**.
How to write this query in mongoose in NodeJS?
Normally I use the below query to update a value:
```
Test.findOneAndUpdate({ _id: testId }, { $inc: { ... } }, function (err, response) {
...
});
```
but it is so difficult to get in array and one more array. Thanks | 2020/02/24 | [
"https://Stackoverflow.com/questions/60378345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5996188/"
] | You can use the [$[] positional operator](https://docs.mongodb.com/manual/reference/operator/update/positional-all/#update-nested-arrays-in-conjunction-with-identifier) to update nested arrays.
```js
router.put("/tests/:testId/:topicQuestionId/:choiceId", async (req, res) => {
const { testId, topicQuestionId, choiceId } = req.params;
const result = await Test.findByIdAndUpdate(
testId,
{
$inc: {
"topic.topicQuestion.$[i].choice.$[j].age": 1
}
},
{
arrayFilters: [{ "i._id": topicQuestionId }, { "j._id": choiceId }],
new: true
}
);
res.send(result);
});
```
Let's say we have this existing document:
```
{
"_id" : ObjectId("5e53e7d9bf65ac4f5cbf2116"),
"testName" : "Test 1",
"topic" : {
"topicTitle" : "Title",
"topicQuestion" : [
{
"_id" : ObjectId("5e53e7d9bf65ac4f5cbf211a"),
"questionTitle" : "Question 1 Title",
"choice" : [
{
"_id" : ObjectId("5e53e7d9bf65ac4f5cbf211c"),
"name" : "A",
"age" : 1
},
{
"_id" : ObjectId("5e53e7d9bf65ac4f5cbf211b"),
"name" : "B",
"age" : 2
}
]
},
{
"_id" : ObjectId("5e53e7d9bf65ac4f5cbf2117"),
"questionTitle" : "Question 2 Title",
"choice" : [
{
"_id" : ObjectId("5e53e7d9bf65ac4f5cbf2119"),
"name" : "C",
"age" : 3
},
{
"_id" : ObjectId("5e53e7d9bf65ac4f5cbf2118"),
"name" : "D",
"age" : 4
}
]
}
]
},
"__v" : 0
}
```
If we want to increment `age` value of a given choice, we send a `PUT` request using endpoint like this `http://.../tests/5e53e7d9bf65ac4f5cbf2116/5e53e7d9bf65ac4f5cbf211a/5e53e7d9bf65ac4f5cbf211b` where
`"testId": "5e53e7d9bf65ac4f5cbf2116"`
`"topicQuestionId": "5e53e7d9bf65ac4f5cbf211a"`
`"choiceId": "5e53e7d9bf65ac4f5cbf211b"` | You need to inform what choice you want and, on the update section, you need change the way you do increment.
Example:
```
Test.findOneAndUpdate({ _id: testId, topicQuestion.choice._id: choiceId}, { 'topicQuestion.$.choice': {$inc: { age: <numberToIncrement> }}}, {new: true}, function (err, response) {
...
});
``` |
28,062,894 | Not sure why I am getting a ClassCastException in the code below. Changing ListActivity to Activity corrects the error but I want ListActivity as this is a part of the bigger code I am trying to build. Any help will be appreciated. Thanks
**MainActivity.java**
```
package com.example.debug;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
```
**activity\_main.xml:**
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- Name Label -->
<TextView
android:id="@+id/vehicleType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#43bd00"
android:textSize="16sp"
android:textStyle="bold"
android:paddingTop="6dip"
android:text="Mobile1"
android:paddingBottom="2dip" />
<!-- Description Label -->
<TextView
android:id="@+id/vehicleColor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile2"
android:paddingBottom="2dip" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<!-- Cost Label -->
<TextView
android:id="@+id/fuel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:gravity="left"
android:textStyle="bold"
android:text="Mobile3" />
<!-- Price Label -->
<TextView
android:id="@+id/treadType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile4"
android:paddingBottom="2dip" />
</LinearLayout>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
```
**Stacktrace**
```
FATAL EXCEPTION: main
Process: com.example.debug, PID: 1370
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.debug/com.example.debug.MainActivity}: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ListActivity.onContentChanged(ListActivity.java:241)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:293)
at android.app.Activity.setContentView(Activity.java:1929)
at com.example.debug.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
... 11 more
``` | 2015/01/21 | [
"https://Stackoverflow.com/questions/28062894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4477297/"
] | your problem is with the root of your layout
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
```
you give it the `android:id="@android:id/list"` the id the android reserves for the `ListView` widget. Change it in something else. E.g
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/my_linear_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
``` | The solution of this error is LinearLayout expects ID attribute.
```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_container2"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/toolbar_noaction"
layout="@layout/toolbar"/>
</LinearLayout>
``` |
28,062,894 | Not sure why I am getting a ClassCastException in the code below. Changing ListActivity to Activity corrects the error but I want ListActivity as this is a part of the bigger code I am trying to build. Any help will be appreciated. Thanks
**MainActivity.java**
```
package com.example.debug;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
```
**activity\_main.xml:**
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- Name Label -->
<TextView
android:id="@+id/vehicleType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#43bd00"
android:textSize="16sp"
android:textStyle="bold"
android:paddingTop="6dip"
android:text="Mobile1"
android:paddingBottom="2dip" />
<!-- Description Label -->
<TextView
android:id="@+id/vehicleColor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile2"
android:paddingBottom="2dip" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<!-- Cost Label -->
<TextView
android:id="@+id/fuel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:gravity="left"
android:textStyle="bold"
android:text="Mobile3" />
<!-- Price Label -->
<TextView
android:id="@+id/treadType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile4"
android:paddingBottom="2dip" />
</LinearLayout>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
```
**Stacktrace**
```
FATAL EXCEPTION: main
Process: com.example.debug, PID: 1370
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.debug/com.example.debug.MainActivity}: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ListActivity.onContentChanged(ListActivity.java:241)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:293)
at android.app.Activity.setContentView(Activity.java:1929)
at com.example.debug.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
... 11 more
``` | 2015/01/21 | [
"https://Stackoverflow.com/questions/28062894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4477297/"
] | your problem is with the root of your layout
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
```
you give it the `android:id="@android:id/list"` the id the android reserves for the `ListView` widget. Change it in something else. E.g
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/my_linear_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
``` | Find all usages of problematic id.
In IDEA IDE You can press Ctrl and click on your id for getting all usages.
Note: It must be only one item with this id. |
28,062,894 | Not sure why I am getting a ClassCastException in the code below. Changing ListActivity to Activity corrects the error but I want ListActivity as this is a part of the bigger code I am trying to build. Any help will be appreciated. Thanks
**MainActivity.java**
```
package com.example.debug;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
```
**activity\_main.xml:**
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- Name Label -->
<TextView
android:id="@+id/vehicleType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#43bd00"
android:textSize="16sp"
android:textStyle="bold"
android:paddingTop="6dip"
android:text="Mobile1"
android:paddingBottom="2dip" />
<!-- Description Label -->
<TextView
android:id="@+id/vehicleColor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile2"
android:paddingBottom="2dip" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<!-- Cost Label -->
<TextView
android:id="@+id/fuel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:gravity="left"
android:textStyle="bold"
android:text="Mobile3" />
<!-- Price Label -->
<TextView
android:id="@+id/treadType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile4"
android:paddingBottom="2dip" />
</LinearLayout>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
```
**Stacktrace**
```
FATAL EXCEPTION: main
Process: com.example.debug, PID: 1370
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.debug/com.example.debug.MainActivity}: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ListActivity.onContentChanged(ListActivity.java:241)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:293)
at android.app.Activity.setContentView(Activity.java:1929)
at com.example.debug.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
... 11 more
``` | 2015/01/21 | [
"https://Stackoverflow.com/questions/28062894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4477297/"
] | your problem is with the root of your layout
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
```
you give it the `android:id="@android:id/list"` the id the android reserves for the `ListView` widget. Change it in something else. E.g
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/my_linear_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
``` | This problem can occur when we have a container in so many case a LinearLayout without id declared, you must put an android:id="@+id/layout\_container" in your LinearLayout at the second level |
28,062,894 | Not sure why I am getting a ClassCastException in the code below. Changing ListActivity to Activity corrects the error but I want ListActivity as this is a part of the bigger code I am trying to build. Any help will be appreciated. Thanks
**MainActivity.java**
```
package com.example.debug;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
```
**activity\_main.xml:**
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- Name Label -->
<TextView
android:id="@+id/vehicleType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#43bd00"
android:textSize="16sp"
android:textStyle="bold"
android:paddingTop="6dip"
android:text="Mobile1"
android:paddingBottom="2dip" />
<!-- Description Label -->
<TextView
android:id="@+id/vehicleColor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile2"
android:paddingBottom="2dip" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<!-- Cost Label -->
<TextView
android:id="@+id/fuel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:gravity="left"
android:textStyle="bold"
android:text="Mobile3" />
<!-- Price Label -->
<TextView
android:id="@+id/treadType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile4"
android:paddingBottom="2dip" />
</LinearLayout>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
```
**Stacktrace**
```
FATAL EXCEPTION: main
Process: com.example.debug, PID: 1370
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.debug/com.example.debug.MainActivity}: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ListActivity.onContentChanged(ListActivity.java:241)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:293)
at android.app.Activity.setContentView(Activity.java:1929)
at com.example.debug.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
... 11 more
``` | 2015/01/21 | [
"https://Stackoverflow.com/questions/28062894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4477297/"
] | Your linear layout id should be as follows
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/my_linear_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
``` | The solution of this error is LinearLayout expects ID attribute.
```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_container2"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/toolbar_noaction"
layout="@layout/toolbar"/>
</LinearLayout>
``` |
28,062,894 | Not sure why I am getting a ClassCastException in the code below. Changing ListActivity to Activity corrects the error but I want ListActivity as this is a part of the bigger code I am trying to build. Any help will be appreciated. Thanks
**MainActivity.java**
```
package com.example.debug;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
```
**activity\_main.xml:**
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- Name Label -->
<TextView
android:id="@+id/vehicleType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#43bd00"
android:textSize="16sp"
android:textStyle="bold"
android:paddingTop="6dip"
android:text="Mobile1"
android:paddingBottom="2dip" />
<!-- Description Label -->
<TextView
android:id="@+id/vehicleColor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile2"
android:paddingBottom="2dip" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<!-- Cost Label -->
<TextView
android:id="@+id/fuel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:gravity="left"
android:textStyle="bold"
android:text="Mobile3" />
<!-- Price Label -->
<TextView
android:id="@+id/treadType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile4"
android:paddingBottom="2dip" />
</LinearLayout>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
```
**Stacktrace**
```
FATAL EXCEPTION: main
Process: com.example.debug, PID: 1370
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.debug/com.example.debug.MainActivity}: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ListActivity.onContentChanged(ListActivity.java:241)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:293)
at android.app.Activity.setContentView(Activity.java:1929)
at com.example.debug.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
... 11 more
``` | 2015/01/21 | [
"https://Stackoverflow.com/questions/28062894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4477297/"
] | The solution of this error is LinearLayout expects ID attribute.
```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_container2"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/toolbar_noaction"
layout="@layout/toolbar"/>
</LinearLayout>
``` | This problem can occur when we have a container in so many case a LinearLayout without id declared, you must put an android:id="@+id/layout\_container" in your LinearLayout at the second level |
28,062,894 | Not sure why I am getting a ClassCastException in the code below. Changing ListActivity to Activity corrects the error but I want ListActivity as this is a part of the bigger code I am trying to build. Any help will be appreciated. Thanks
**MainActivity.java**
```
package com.example.debug;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
```
**activity\_main.xml:**
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- Name Label -->
<TextView
android:id="@+id/vehicleType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#43bd00"
android:textSize="16sp"
android:textStyle="bold"
android:paddingTop="6dip"
android:text="Mobile1"
android:paddingBottom="2dip" />
<!-- Description Label -->
<TextView
android:id="@+id/vehicleColor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile2"
android:paddingBottom="2dip" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<!-- Cost Label -->
<TextView
android:id="@+id/fuel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:gravity="left"
android:textStyle="bold"
android:text="Mobile3" />
<!-- Price Label -->
<TextView
android:id="@+id/treadType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile4"
android:paddingBottom="2dip" />
</LinearLayout>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
```
**Stacktrace**
```
FATAL EXCEPTION: main
Process: com.example.debug, PID: 1370
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.debug/com.example.debug.MainActivity}: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ListActivity.onContentChanged(ListActivity.java:241)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:293)
at android.app.Activity.setContentView(Activity.java:1929)
at com.example.debug.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
... 11 more
``` | 2015/01/21 | [
"https://Stackoverflow.com/questions/28062894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4477297/"
] | Your linear layout id should be as follows
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/my_linear_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
``` | Find all usages of problematic id.
In IDEA IDE You can press Ctrl and click on your id for getting all usages.
Note: It must be only one item with this id. |
28,062,894 | Not sure why I am getting a ClassCastException in the code below. Changing ListActivity to Activity corrects the error but I want ListActivity as this is a part of the bigger code I am trying to build. Any help will be appreciated. Thanks
**MainActivity.java**
```
package com.example.debug;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
```
**activity\_main.xml:**
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- Name Label -->
<TextView
android:id="@+id/vehicleType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#43bd00"
android:textSize="16sp"
android:textStyle="bold"
android:paddingTop="6dip"
android:text="Mobile1"
android:paddingBottom="2dip" />
<!-- Description Label -->
<TextView
android:id="@+id/vehicleColor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile2"
android:paddingBottom="2dip" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<!-- Cost Label -->
<TextView
android:id="@+id/fuel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:gravity="left"
android:textStyle="bold"
android:text="Mobile3" />
<!-- Price Label -->
<TextView
android:id="@+id/treadType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile4"
android:paddingBottom="2dip" />
</LinearLayout>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
```
**Stacktrace**
```
FATAL EXCEPTION: main
Process: com.example.debug, PID: 1370
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.debug/com.example.debug.MainActivity}: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ListActivity.onContentChanged(ListActivity.java:241)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:293)
at android.app.Activity.setContentView(Activity.java:1929)
at com.example.debug.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
... 11 more
``` | 2015/01/21 | [
"https://Stackoverflow.com/questions/28062894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4477297/"
] | In a ListActivity android looks for the widget with `android:id="@android:id/list"` and expects a ListView but in your case it finds the root LinearLayout and tries to cast it to a ListView hence the exception :
```
Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
```
To solve it, you just need to provide a different id as mentioned by Blackbelt. | The solution of this error is LinearLayout expects ID attribute.
```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_container2"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/toolbar_noaction"
layout="@layout/toolbar"/>
</LinearLayout>
``` |
28,062,894 | Not sure why I am getting a ClassCastException in the code below. Changing ListActivity to Activity corrects the error but I want ListActivity as this is a part of the bigger code I am trying to build. Any help will be appreciated. Thanks
**MainActivity.java**
```
package com.example.debug;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
```
**activity\_main.xml:**
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- Name Label -->
<TextView
android:id="@+id/vehicleType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#43bd00"
android:textSize="16sp"
android:textStyle="bold"
android:paddingTop="6dip"
android:text="Mobile1"
android:paddingBottom="2dip" />
<!-- Description Label -->
<TextView
android:id="@+id/vehicleColor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile2"
android:paddingBottom="2dip" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<!-- Cost Label -->
<TextView
android:id="@+id/fuel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:gravity="left"
android:textStyle="bold"
android:text="Mobile3" />
<!-- Price Label -->
<TextView
android:id="@+id/treadType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile4"
android:paddingBottom="2dip" />
</LinearLayout>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
```
**Stacktrace**
```
FATAL EXCEPTION: main
Process: com.example.debug, PID: 1370
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.debug/com.example.debug.MainActivity}: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ListActivity.onContentChanged(ListActivity.java:241)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:293)
at android.app.Activity.setContentView(Activity.java:1929)
at com.example.debug.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
... 11 more
``` | 2015/01/21 | [
"https://Stackoverflow.com/questions/28062894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4477297/"
] | Your linear layout id should be as follows
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/my_linear_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
``` | This problem can occur when we have a container in so many case a LinearLayout without id declared, you must put an android:id="@+id/layout\_container" in your LinearLayout at the second level |
28,062,894 | Not sure why I am getting a ClassCastException in the code below. Changing ListActivity to Activity corrects the error but I want ListActivity as this is a part of the bigger code I am trying to build. Any help will be appreciated. Thanks
**MainActivity.java**
```
package com.example.debug;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
```
**activity\_main.xml:**
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- Name Label -->
<TextView
android:id="@+id/vehicleType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#43bd00"
android:textSize="16sp"
android:textStyle="bold"
android:paddingTop="6dip"
android:text="Mobile1"
android:paddingBottom="2dip" />
<!-- Description Label -->
<TextView
android:id="@+id/vehicleColor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile2"
android:paddingBottom="2dip" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<!-- Cost Label -->
<TextView
android:id="@+id/fuel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:gravity="left"
android:textStyle="bold"
android:text="Mobile3" />
<!-- Price Label -->
<TextView
android:id="@+id/treadType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile4"
android:paddingBottom="2dip" />
</LinearLayout>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
```
**Stacktrace**
```
FATAL EXCEPTION: main
Process: com.example.debug, PID: 1370
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.debug/com.example.debug.MainActivity}: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ListActivity.onContentChanged(ListActivity.java:241)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:293)
at android.app.Activity.setContentView(Activity.java:1929)
at com.example.debug.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
... 11 more
``` | 2015/01/21 | [
"https://Stackoverflow.com/questions/28062894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4477297/"
] | your problem is with the root of your layout
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
```
you give it the `android:id="@android:id/list"` the id the android reserves for the `ListView` widget. Change it in something else. E.g
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/my_linear_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
``` | Your linear layout id should be as follows
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/my_linear_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
``` |
28,062,894 | Not sure why I am getting a ClassCastException in the code below. Changing ListActivity to Activity corrects the error but I want ListActivity as this is a part of the bigger code I am trying to build. Any help will be appreciated. Thanks
**MainActivity.java**
```
package com.example.debug;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
```
**activity\_main.xml:**
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- Name Label -->
<TextView
android:id="@+id/vehicleType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#43bd00"
android:textSize="16sp"
android:textStyle="bold"
android:paddingTop="6dip"
android:text="Mobile1"
android:paddingBottom="2dip" />
<!-- Description Label -->
<TextView
android:id="@+id/vehicleColor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile2"
android:paddingBottom="2dip" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<!-- Cost Label -->
<TextView
android:id="@+id/fuel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:gravity="left"
android:textStyle="bold"
android:text="Mobile3" />
<!-- Price Label -->
<TextView
android:id="@+id/treadType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:text="Mobile4"
android:paddingBottom="2dip" />
</LinearLayout>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
```
**Stacktrace**
```
FATAL EXCEPTION: main
Process: com.example.debug, PID: 1370
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.debug/com.example.debug.MainActivity}: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
at android.app.ListActivity.onContentChanged(ListActivity.java:241)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:293)
at android.app.Activity.setContentView(Activity.java:1929)
at com.example.debug.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
... 11 more
``` | 2015/01/21 | [
"https://Stackoverflow.com/questions/28062894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4477297/"
] | In a ListActivity android looks for the widget with `android:id="@android:id/list"` and expects a ListView but in your case it finds the root LinearLayout and tries to cast it to a ListView hence the exception :
```
Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.ListView
```
To solve it, you just need to provide a different id as mentioned by Blackbelt. | Find all usages of problematic id.
In IDEA IDE You can press Ctrl and click on your id for getting all usages.
Note: It must be only one item with this id. |
43,269,905 | Consider I have a table structure like this,
```
id Email
-----------
1 abc@gmail.com
2 abc1@gmail.com
3 abc@gmail.com
4 abc@gmail.com
5 abc@gmail.com
```
And another table
```
id userId name
---------------------
1 1 A
2 2 B
3 3 C
4 4 D
5 5 E
```
Now if I want to remove duplicates from table 1, i.e. `2, 3, 4, 5` should be deleted from `table1` and its corresponding data in `table2`.
How would I do this?
Is this possible? | 2017/04/07 | [
"https://Stackoverflow.com/questions/43269905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7573053/"
] | first try to delete duplicate row from user table by keeping the one using below code :
```
DELETE FROM `user` WHERE `id` NOT IN (select * from ( SELECT MIN(`id`) FROM `user` GROUP BY `email` ) as t)
```
secondly try to delete other dependent rows from another table by following :
```
DELETE FROM `user_data` WHERE `u_id` NOT IN (select * from ( SELECT MIN(`id`) FROM `user` GROUP BY `email` ) as t)
```
hope this will work for you. | In a DML way, try the following query with your table (Edit it according to your tables). NOTE: Delete can be rolled back.
```
DELETE t1
FROM t1, holdkey
WHERE t1.col1 = holdkey.col1
AND t1.col2 = holdkey.col2
``` |
59,533,127 | I've a form with a `ChoiceType` field and I need to do something with selected datas AND something else with not selected datas.
I think I need to retrieve unselected datas with using the selected datas but is there a way to send them to the controller directly ? Maybe with `empty_data` but I'm not sure to understand how to use it.
To clarify if I have it in the vue :
```
<select name="carlist" form="carform" multiple>
<option value="volvo" selected>Volvo</option>
<option value="saab" selected>Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
```
How can I retrieve "audi" and "opel" values using `$form->getData()` ? ( if it's possible of course ) | 2019/12/30 | [
"https://Stackoverflow.com/questions/59533127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12366580/"
] | To [update a resource in an Azure Resource Manager template](https://learn.microsoft.com/en-us/azure/architecture/building-blocks/extending-templates/update-resource), you need to specify the updated resource in a second template that's either linked or included as a subtemplate using the `Microsoft.Resources/deployments` resource type.
>
> First, you must reference the resource once in the template to create
> it and then reference the resource by the same name to update it
> later. However, if two resources have the same name in a template,
> Resource Manager throws an exception. To avoid this error, specify the
> updated resource in a second template that's either linked or included
> as a subtemplate using the Microsoft.Resources/deployments resource
> type.
>
>
> Second, you must either specify the name of the existing property to
> change or a new name for a property to add in the nested template. You
> must also specify the original properties and their original values.
> If you fail to provide the original properties and values, Resource
> Manager assumes you want to create a new resource and deletes the
> original resource.
>
>
>
For example, if you have created resources from this 201-2-vms-loadbalancer-lbrules [template](https://github.com/Azure/azure-quickstart-templates/tree/master/201-2-vms-loadbalancer-lbrules), you just need to download the existing template from Load balancer----Settings---Export template. Then add the new loadBalancingRules and probes, edit the template to meet your requirements, then redeploy the edited full template with this command
```
New-AzResourceGroupDeployment -ResourceGroupName yourRG -mode Incremental -TemplateFile ".\template.json" -TemplateParameterFile ".\parameters.json"
```
For example,
```
"loadBalancingRules": [
{
"name": "LBRule",
"properties": {
"frontendIPConfiguration": {
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_myLB_name')), '/frontendIPConfigurations/LoadBalancerFrontEnd')]"
},
"frontendPort": 80,
"backendPort": 80,
"enableFloatingIP": false,
"idleTimeoutInMinutes": 5,
"protocol": "Tcp",
"enableTcpReset": false,
"loadDistribution": "Default",
"backendAddressPool": {
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_myLB_name')), '/backendAddressPools/BackendPool1')]"
},
"probe": {
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_myLB_name')), '/probes/tcpProbe')]"
}
}
},
{
"name": "LBRule-new",
"properties": {
"frontendIPConfiguration": {
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_myLB_name')), '/frontendIPConfigurations/LoadBalancerFrontEnd')]"
},
"frontendPort": 8080,
"backendPort": 8080,
"enableFloatingIP": false,
"idleTimeoutInMinutes": 5,
"protocol": "Tcp",
"enableTcpReset": false,
"loadDistribution": "Default",
"backendAddressPool": {
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_myLB_name')), '/backendAddressPools/BackendPool1')]"
},
"probe": {
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_myLB_name')), '/probes/tcpProbe')]"
}
}
}
],
"probes": [
{
"name": "tcpProbe",
"properties": {
"protocol": "Tcp",
"port": 80,
"intervalInSeconds": 5,
"numberOfProbes": 2
}
},
{
"name": "tcpProbe-new",
"properties": {
"protocol": "Tcp",
"port": 8080,
"intervalInSeconds": 5,
"numberOfProbes": 2
}
}
],
....
``` | You will need to run PowerShell or CLI from your ARM templates |
58,890,574 | When I build the project the issue has occurred
Error
>
> ERROR in node\_modules/@coreui/angular/lib/sidebar/app-sidebar-nav.d.ts(1,10): error TS2305: Module '"C:/Users/amare/Desktop/New folder/tb/node\_modules/@angular/router/router"' has no exported member 'QueryParamsHandling'.
>
>
>
package.json
```
"name": "@coreui/coreui-free-angular-admin-template",
"version": "2.4.5",
"description": "CoreUI Free Angular 2+ Admin Template",
"author": {
"name": "Łukasz Holeczek",
"url": "http://holeczek.pl",
"github": "https://github.com/mrholek",
"twitter": "https://twitter.com/lukaszholeczek"
},
"contributors": [
{
"name": "Andrzej Kopański",
"url": "https://github.com/xidedix"
}
],
"homepage": "https://coreui.io/angular",
"copyright": "Copyright 2018 creativeLabs Łukasz Holeczek",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod --aot --buildOptimizer --commonChunk --vendorChunk --optimization --progress",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.2.10",
"@angular/common": "^7.2.10",
"@angular/compiler": "^7.2.10",
"@angular/core": "^7.2.10",
"@angular/forms": "^7.2.10",
"@angular/http": "^7.2.10",
"@angular/platform-browser": "^7.2.10",
"@angular/platform-browser-dynamic": "^7.2.10",
"@angular/router": "^7.2.10",
"@coreui/angular": "^2.4.5",
"@coreui/coreui": "^2.1.8",
"@coreui/coreui-plugin-chartjs-custom-tooltips": "^1.3.1",
"@coreui/icons": "0.3.0",
"ag-grid-angular": "^20.2.0",
"ag-grid-community": "^20.2.0",
"angular-gauge-chart": "^0.6.0",
"angular-jwt": "^0.1.11",
"angular2-jwt": "^0.2.3",
"bootstrap": "^4.3.1",
"chart.js": "^2.8.0",
"core-js": "^2.6.5",
"file-saver": "^2.0.1",
"flag-icon-css": "^3.3.0",
"font-awesome": "^4.7.0",
"jspdf": "^1.5.3",
"jspdf-autotable": "^3.1.1",
"moment": "^2.24.0",
"mutationobserver-shim": "^0.3.3",
"ng2-charts": "^1.6.0",
"ngx-bootstrap": "^3.2.0",
"ngx-perfect-scrollbar": "^7.2.1",
"ngx-toastr": "^10.0.4",
"rxjs": "^6.4.0",
"simple-line-icons": "^2.4.1",
"ts-helpers": "^1.1.2",
"tsickle": "^0.34.3",
"tslib": "^1.9.0",
"xlsx": "^0.14.2",
"zone.js": "^0.8.29"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.13.6",
"@angular/cli": "^7.3.6",
"@angular/compiler-cli": "^7.2.10",
"@angular/language-service": "^7.2.10",
"@types/jasmine": "^3.3.12",
"@types/jasminewd2": "^2.0.6",
"@types/node": "^11.11.4",
"codelyzer": "^4.5.0",
"jasmine-core": "^3.3.0",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^4.0.1",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.5",
"karma-jasmine": "^2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "^5.4.2",
"ts-node": "^8.0.3",
"tslint": "^5.14.0",
"typescript": "~3.2.4"
},
"engines": {
"node": ">= 8.9.4",
"npm": ">= 5.6.0"
}
}
```
When I build the project the issue has occurred
Error
>
> ERROR in node\_modules/@coreui/angular/lib/sidebar/app-sidebar-nav.d.ts(1,10): error TS2305: Module '"C:/Users/amare/Desktop/New folder/tb/node\_modules/@angular/router/router"' has no exported member 'QueryParamsHandling'.
>
>
> | 2019/11/16 | [
"https://Stackoverflow.com/questions/58890574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10934942/"
] | I also faced same issue and this worked for me.
Use this version of coreui - "@coreui/angular": "2.5.3"
Look like the QueryParamsHandling is not referred in this version as per code of this version.
Also if you have already run npm install then you need to remove it manually then add it again with version 2.5.3 and make sure you have mentioned exact version in your package.json (without cart or tilde symbol). | I managed to solve it like this. Go to @ angular / router / router "and insert the word 'export' before the QueryParamsHandling declaration:
export declare type QueryParamsHandling = 'merge' | 'preserve' | ''; |
58,890,574 | When I build the project the issue has occurred
Error
>
> ERROR in node\_modules/@coreui/angular/lib/sidebar/app-sidebar-nav.d.ts(1,10): error TS2305: Module '"C:/Users/amare/Desktop/New folder/tb/node\_modules/@angular/router/router"' has no exported member 'QueryParamsHandling'.
>
>
>
package.json
```
"name": "@coreui/coreui-free-angular-admin-template",
"version": "2.4.5",
"description": "CoreUI Free Angular 2+ Admin Template",
"author": {
"name": "Łukasz Holeczek",
"url": "http://holeczek.pl",
"github": "https://github.com/mrholek",
"twitter": "https://twitter.com/lukaszholeczek"
},
"contributors": [
{
"name": "Andrzej Kopański",
"url": "https://github.com/xidedix"
}
],
"homepage": "https://coreui.io/angular",
"copyright": "Copyright 2018 creativeLabs Łukasz Holeczek",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod --aot --buildOptimizer --commonChunk --vendorChunk --optimization --progress",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.2.10",
"@angular/common": "^7.2.10",
"@angular/compiler": "^7.2.10",
"@angular/core": "^7.2.10",
"@angular/forms": "^7.2.10",
"@angular/http": "^7.2.10",
"@angular/platform-browser": "^7.2.10",
"@angular/platform-browser-dynamic": "^7.2.10",
"@angular/router": "^7.2.10",
"@coreui/angular": "^2.4.5",
"@coreui/coreui": "^2.1.8",
"@coreui/coreui-plugin-chartjs-custom-tooltips": "^1.3.1",
"@coreui/icons": "0.3.0",
"ag-grid-angular": "^20.2.0",
"ag-grid-community": "^20.2.0",
"angular-gauge-chart": "^0.6.0",
"angular-jwt": "^0.1.11",
"angular2-jwt": "^0.2.3",
"bootstrap": "^4.3.1",
"chart.js": "^2.8.0",
"core-js": "^2.6.5",
"file-saver": "^2.0.1",
"flag-icon-css": "^3.3.0",
"font-awesome": "^4.7.0",
"jspdf": "^1.5.3",
"jspdf-autotable": "^3.1.1",
"moment": "^2.24.0",
"mutationobserver-shim": "^0.3.3",
"ng2-charts": "^1.6.0",
"ngx-bootstrap": "^3.2.0",
"ngx-perfect-scrollbar": "^7.2.1",
"ngx-toastr": "^10.0.4",
"rxjs": "^6.4.0",
"simple-line-icons": "^2.4.1",
"ts-helpers": "^1.1.2",
"tsickle": "^0.34.3",
"tslib": "^1.9.0",
"xlsx": "^0.14.2",
"zone.js": "^0.8.29"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.13.6",
"@angular/cli": "^7.3.6",
"@angular/compiler-cli": "^7.2.10",
"@angular/language-service": "^7.2.10",
"@types/jasmine": "^3.3.12",
"@types/jasminewd2": "^2.0.6",
"@types/node": "^11.11.4",
"codelyzer": "^4.5.0",
"jasmine-core": "^3.3.0",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^4.0.1",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.5",
"karma-jasmine": "^2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "^5.4.2",
"ts-node": "^8.0.3",
"tslint": "^5.14.0",
"typescript": "~3.2.4"
},
"engines": {
"node": ">= 8.9.4",
"npm": ">= 5.6.0"
}
}
```
When I build the project the issue has occurred
Error
>
> ERROR in node\_modules/@coreui/angular/lib/sidebar/app-sidebar-nav.d.ts(1,10): error TS2305: Module '"C:/Users/amare/Desktop/New folder/tb/node\_modules/@angular/router/router"' has no exported member 'QueryParamsHandling'.
>
>
> | 2019/11/16 | [
"https://Stackoverflow.com/questions/58890574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10934942/"
] | Changing @coreui/angular version didn't work for me,
but changing import statement in the `node_modules\@coreui\angular\lib\sidebar\app-sidebar-nav.d.ts` file to :
```
import { QueryParamsHandling } from '@angular/router/src/config';
```
will immediately work. | I managed to solve it like this. Go to @ angular / router / router "and insert the word 'export' before the QueryParamsHandling declaration:
export declare type QueryParamsHandling = 'merge' | 'preserve' | ''; |
6,714,659 | I've set a cookie just fine, and the cookie is in the request header, but when I access that cookie in the PHP superglobal `$_COOKIE` it isn't set. Dumping `$_COOKIE` shows the other cookies but one, and all were in the request header.
If I dump `$_SERVER` I can see that cookie in `$_SERVER['HTTP_COOKIE']`. PHP sets all of the cookies into `$_COOKIE` but one.
What could cause this and whats a fix?
Server is running PHP 5.3.3.
Update:
At the top of my index.php I `var_dump($_SERVER);` and then `var_dump($_COOKIE);` on the next line, and an expected cookie isn't printed from the second dump.
Update2:
Here's the Cookie part of my request
```
Cookie:SESSe00cd0d8b79da0906c77d52ed6e26907=2f9fhsomr2skcfmivagb1i8gj7; __utma=172891446.852439441.1310775539.1310775539.1310775539.1; __utmc=172891446; __utmv=172891446.%3A; __utmb=172891446.4.10.1310780296; OATMEAL=%9Ey%EE%C9J%956%C0%06%B3%EBZ%83%D1%80%C0%AC%D2%D0T%86%9A%2A%2A%A2E%B7f%86%D7i%C1%28%19L%1Fl%920%3CE%10%B6%C9c%1D%E3%A7H%D9%E1%29%1C%7E5%C8q%CC3%21C%0C%DC%CC%A5%F3i%10%F7%DCJjF%EE%B9%80%3C%C6Jy%A2%0E%3F%E3%BD%7B%BF%CD%84%85%91%BB3%B9%EA%CB%92%89%AC%FBc%BA%A32s%B5L%3E%DF%9B%CDk%08%DEZ%13%5Da1Q%B0%1CJ%90%AE%AF%3F%15%98%1B%E1%C1g%A9%BBzR%F5Q%82%8F%81%1A%D1%0E%87%DC%F3%3B%FF%B7%8E%09%0F%BF%DFK%A3t%D1%F3%DA_%ECKt%01%00x%D2%CCE%24%BB0%C2w%B4%82%F0Q%00O%F1v%19%11%0A%3A%BB%9Fy%B1%BC9hgy%C4%DC%DEN%C4%A4%3B%7D%E8%84h%07%E3+%0B%85y%8B%B5y%1B%FC%CE%86B%F55%ED%E0%01%EB%18%13%B0%09%CA%F9%3D%26%05%FC%A7%F8%E4%CD%3C%9E%D7%24%B1%BF%27t%B4%3C%89%D76%F0%CF%C0%D4%E7Z%A6%02%19j%D7%60%28%82%DF%DF%9C%05%25%CB%CA%04%B9%21N%D2r%A76%DD%D1%CB%97%B0%A9%13%29%3C%D6kdm%D1%14%EA%D4%1Fz%F9%CF%21i%BD%19RN%C3%8Dh%27R%15%99%13%FAv%13%8F%BBd%7B%F5%AD%D5%22%13q%13Z%F219%B9%B0_%AB%16%7B%D2%18%E3%F0%F6%9D%A4X
```
The cookie that's dropped is named "OATMEAL".
Update3: This PHP bug sound similar <https://bugs.php.net/bug.php?id=52018> | 2011/07/16 | [
"https://Stackoverflow.com/questions/6714659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249413/"
] | You shouldn't use the value in `$_SERVER["HTTP_COOKIE"]`. [It's not documented](http://www.php.net/manual/en/reserved.variables.server.php), so it's probably not reliable.
[This message](http://www.php.net/manual/en/function.setcookie.php#91140) in comments for the setcookie function might answer your question.
>
> Note that the $\_COOKIE variable not will hold multiple cookies with the same name. ...
>
>
> | Could it be that you have not set the right path for the cookie? I have had problems with this before where it would not let me access the cookie because it was being set to a strange path automatically. I had to specify the correct path when I set the cookie.
You probably already know this but sometimes things can hide right under our noses.
<http://us3.php.net/manual/en/function.setcookie.php>
cheers,
Michael |
6,714,659 | I've set a cookie just fine, and the cookie is in the request header, but when I access that cookie in the PHP superglobal `$_COOKIE` it isn't set. Dumping `$_COOKIE` shows the other cookies but one, and all were in the request header.
If I dump `$_SERVER` I can see that cookie in `$_SERVER['HTTP_COOKIE']`. PHP sets all of the cookies into `$_COOKIE` but one.
What could cause this and whats a fix?
Server is running PHP 5.3.3.
Update:
At the top of my index.php I `var_dump($_SERVER);` and then `var_dump($_COOKIE);` on the next line, and an expected cookie isn't printed from the second dump.
Update2:
Here's the Cookie part of my request
```
Cookie:SESSe00cd0d8b79da0906c77d52ed6e26907=2f9fhsomr2skcfmivagb1i8gj7; __utma=172891446.852439441.1310775539.1310775539.1310775539.1; __utmc=172891446; __utmv=172891446.%3A; __utmb=172891446.4.10.1310780296; OATMEAL=%9Ey%EE%C9J%956%C0%06%B3%EBZ%83%D1%80%C0%AC%D2%D0T%86%9A%2A%2A%A2E%B7f%86%D7i%C1%28%19L%1Fl%920%3CE%10%B6%C9c%1D%E3%A7H%D9%E1%29%1C%7E5%C8q%CC3%21C%0C%DC%CC%A5%F3i%10%F7%DCJjF%EE%B9%80%3C%C6Jy%A2%0E%3F%E3%BD%7B%BF%CD%84%85%91%BB3%B9%EA%CB%92%89%AC%FBc%BA%A32s%B5L%3E%DF%9B%CDk%08%DEZ%13%5Da1Q%B0%1CJ%90%AE%AF%3F%15%98%1B%E1%C1g%A9%BBzR%F5Q%82%8F%81%1A%D1%0E%87%DC%F3%3B%FF%B7%8E%09%0F%BF%DFK%A3t%D1%F3%DA_%ECKt%01%00x%D2%CCE%24%BB0%C2w%B4%82%F0Q%00O%F1v%19%11%0A%3A%BB%9Fy%B1%BC9hgy%C4%DC%DEN%C4%A4%3B%7D%E8%84h%07%E3+%0B%85y%8B%B5y%1B%FC%CE%86B%F55%ED%E0%01%EB%18%13%B0%09%CA%F9%3D%26%05%FC%A7%F8%E4%CD%3C%9E%D7%24%B1%BF%27t%B4%3C%89%D76%F0%CF%C0%D4%E7Z%A6%02%19j%D7%60%28%82%DF%DF%9C%05%25%CB%CA%04%B9%21N%D2r%A76%DD%D1%CB%97%B0%A9%13%29%3C%D6kdm%D1%14%EA%D4%1Fz%F9%CF%21i%BD%19RN%C3%8Dh%27R%15%99%13%FAv%13%8F%BBd%7B%F5%AD%D5%22%13q%13Z%F219%B9%B0_%AB%16%7B%D2%18%E3%F0%F6%9D%A4X
```
The cookie that's dropped is named "OATMEAL".
Update3: This PHP bug sound similar <https://bugs.php.net/bug.php?id=52018> | 2011/07/16 | [
"https://Stackoverflow.com/questions/6714659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249413/"
] | **Your string is 1099 characters long.**
Max length for a Cookie is 4Kb.
Assuming UTF-8 characters with 4 bytes per char you should be able to store between 1024.
Try to make OATMEAL smaller. Much smaller and let us know if that was the culprit. | You shouldn't use the value in `$_SERVER["HTTP_COOKIE"]`. [It's not documented](http://www.php.net/manual/en/reserved.variables.server.php), so it's probably not reliable.
[This message](http://www.php.net/manual/en/function.setcookie.php#91140) in comments for the setcookie function might answer your question.
>
> Note that the $\_COOKIE variable not will hold multiple cookies with the same name. ...
>
>
> |
6,714,659 | I've set a cookie just fine, and the cookie is in the request header, but when I access that cookie in the PHP superglobal `$_COOKIE` it isn't set. Dumping `$_COOKIE` shows the other cookies but one, and all were in the request header.
If I dump `$_SERVER` I can see that cookie in `$_SERVER['HTTP_COOKIE']`. PHP sets all of the cookies into `$_COOKIE` but one.
What could cause this and whats a fix?
Server is running PHP 5.3.3.
Update:
At the top of my index.php I `var_dump($_SERVER);` and then `var_dump($_COOKIE);` on the next line, and an expected cookie isn't printed from the second dump.
Update2:
Here's the Cookie part of my request
```
Cookie:SESSe00cd0d8b79da0906c77d52ed6e26907=2f9fhsomr2skcfmivagb1i8gj7; __utma=172891446.852439441.1310775539.1310775539.1310775539.1; __utmc=172891446; __utmv=172891446.%3A; __utmb=172891446.4.10.1310780296; OATMEAL=%9Ey%EE%C9J%956%C0%06%B3%EBZ%83%D1%80%C0%AC%D2%D0T%86%9A%2A%2A%A2E%B7f%86%D7i%C1%28%19L%1Fl%920%3CE%10%B6%C9c%1D%E3%A7H%D9%E1%29%1C%7E5%C8q%CC3%21C%0C%DC%CC%A5%F3i%10%F7%DCJjF%EE%B9%80%3C%C6Jy%A2%0E%3F%E3%BD%7B%BF%CD%84%85%91%BB3%B9%EA%CB%92%89%AC%FBc%BA%A32s%B5L%3E%DF%9B%CDk%08%DEZ%13%5Da1Q%B0%1CJ%90%AE%AF%3F%15%98%1B%E1%C1g%A9%BBzR%F5Q%82%8F%81%1A%D1%0E%87%DC%F3%3B%FF%B7%8E%09%0F%BF%DFK%A3t%D1%F3%DA_%ECKt%01%00x%D2%CCE%24%BB0%C2w%B4%82%F0Q%00O%F1v%19%11%0A%3A%BB%9Fy%B1%BC9hgy%C4%DC%DEN%C4%A4%3B%7D%E8%84h%07%E3+%0B%85y%8B%B5y%1B%FC%CE%86B%F55%ED%E0%01%EB%18%13%B0%09%CA%F9%3D%26%05%FC%A7%F8%E4%CD%3C%9E%D7%24%B1%BF%27t%B4%3C%89%D76%F0%CF%C0%D4%E7Z%A6%02%19j%D7%60%28%82%DF%DF%9C%05%25%CB%CA%04%B9%21N%D2r%A76%DD%D1%CB%97%B0%A9%13%29%3C%D6kdm%D1%14%EA%D4%1Fz%F9%CF%21i%BD%19RN%C3%8Dh%27R%15%99%13%FAv%13%8F%BBd%7B%F5%AD%D5%22%13q%13Z%F219%B9%B0_%AB%16%7B%D2%18%E3%F0%F6%9D%A4X
```
The cookie that's dropped is named "OATMEAL".
Update3: This PHP bug sound similar <https://bugs.php.net/bug.php?id=52018> | 2011/07/16 | [
"https://Stackoverflow.com/questions/6714659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249413/"
] | You shouldn't use the value in `$_SERVER["HTTP_COOKIE"]`. [It's not documented](http://www.php.net/manual/en/reserved.variables.server.php), so it's probably not reliable.
[This message](http://www.php.net/manual/en/function.setcookie.php#91140) in comments for the setcookie function might answer your question.
>
> Note that the $\_COOKIE variable not will hold multiple cookies with the same name. ...
>
>
> | As others have already said, it's almost certainly to do with the length of your cookie string. You should make it shorter.
It's also worth pointing out that even if it works, there's a very good reason for not having such a long cookie string -- the entire cookie string gets sent in both directions for every single HTTP request you make.
Let's say you have a typical page, that loads twenty images, two CSS files and two Javascript files, plus the main HTML page itself. For a 1K cookies string like yours, that would be an extra 50K on your server's bandwidth (and your user's bandwidth) for every single page load. That's going to add up quickly if you've got a reasonable amount of traffic, and if you've got any kind of limits or metering on your bandwidth, it's going to cost you extra money.
Secondly, I don't know what that OATMEAL cookie contains; I don't have the time to decode it, but it looks a lot like you're obfuscating data (including adding some deliberate spoiler characters). Be aware that if this data is sensitive enough to want to obfuscate, then the cookie is a *really* bad place to be storing it.
If you really do need to pass that amount of data to the server, you should be sending it in a POST request. If the PHP program needs to access it with subsequent page loads, then set it in your `$_SESSION` array. If your Javascript code needs to be able to use it or set it, then use an Ajax request. |
6,714,659 | I've set a cookie just fine, and the cookie is in the request header, but when I access that cookie in the PHP superglobal `$_COOKIE` it isn't set. Dumping `$_COOKIE` shows the other cookies but one, and all were in the request header.
If I dump `$_SERVER` I can see that cookie in `$_SERVER['HTTP_COOKIE']`. PHP sets all of the cookies into `$_COOKIE` but one.
What could cause this and whats a fix?
Server is running PHP 5.3.3.
Update:
At the top of my index.php I `var_dump($_SERVER);` and then `var_dump($_COOKIE);` on the next line, and an expected cookie isn't printed from the second dump.
Update2:
Here's the Cookie part of my request
```
Cookie:SESSe00cd0d8b79da0906c77d52ed6e26907=2f9fhsomr2skcfmivagb1i8gj7; __utma=172891446.852439441.1310775539.1310775539.1310775539.1; __utmc=172891446; __utmv=172891446.%3A; __utmb=172891446.4.10.1310780296; OATMEAL=%9Ey%EE%C9J%956%C0%06%B3%EBZ%83%D1%80%C0%AC%D2%D0T%86%9A%2A%2A%A2E%B7f%86%D7i%C1%28%19L%1Fl%920%3CE%10%B6%C9c%1D%E3%A7H%D9%E1%29%1C%7E5%C8q%CC3%21C%0C%DC%CC%A5%F3i%10%F7%DCJjF%EE%B9%80%3C%C6Jy%A2%0E%3F%E3%BD%7B%BF%CD%84%85%91%BB3%B9%EA%CB%92%89%AC%FBc%BA%A32s%B5L%3E%DF%9B%CDk%08%DEZ%13%5Da1Q%B0%1CJ%90%AE%AF%3F%15%98%1B%E1%C1g%A9%BBzR%F5Q%82%8F%81%1A%D1%0E%87%DC%F3%3B%FF%B7%8E%09%0F%BF%DFK%A3t%D1%F3%DA_%ECKt%01%00x%D2%CCE%24%BB0%C2w%B4%82%F0Q%00O%F1v%19%11%0A%3A%BB%9Fy%B1%BC9hgy%C4%DC%DEN%C4%A4%3B%7D%E8%84h%07%E3+%0B%85y%8B%B5y%1B%FC%CE%86B%F55%ED%E0%01%EB%18%13%B0%09%CA%F9%3D%26%05%FC%A7%F8%E4%CD%3C%9E%D7%24%B1%BF%27t%B4%3C%89%D76%F0%CF%C0%D4%E7Z%A6%02%19j%D7%60%28%82%DF%DF%9C%05%25%CB%CA%04%B9%21N%D2r%A76%DD%D1%CB%97%B0%A9%13%29%3C%D6kdm%D1%14%EA%D4%1Fz%F9%CF%21i%BD%19RN%C3%8Dh%27R%15%99%13%FAv%13%8F%BBd%7B%F5%AD%D5%22%13q%13Z%F219%B9%B0_%AB%16%7B%D2%18%E3%F0%F6%9D%A4X
```
The cookie that's dropped is named "OATMEAL".
Update3: This PHP bug sound similar <https://bugs.php.net/bug.php?id=52018> | 2011/07/16 | [
"https://Stackoverflow.com/questions/6714659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249413/"
] | **Your string is 1099 characters long.**
Max length for a Cookie is 4Kb.
Assuming UTF-8 characters with 4 bytes per char you should be able to store between 1024.
Try to make OATMEAL smaller. Much smaller and let us know if that was the culprit. | Could it be that you have not set the right path for the cookie? I have had problems with this before where it would not let me access the cookie because it was being set to a strange path automatically. I had to specify the correct path when I set the cookie.
You probably already know this but sometimes things can hide right under our noses.
<http://us3.php.net/manual/en/function.setcookie.php>
cheers,
Michael |
6,714,659 | I've set a cookie just fine, and the cookie is in the request header, but when I access that cookie in the PHP superglobal `$_COOKIE` it isn't set. Dumping `$_COOKIE` shows the other cookies but one, and all were in the request header.
If I dump `$_SERVER` I can see that cookie in `$_SERVER['HTTP_COOKIE']`. PHP sets all of the cookies into `$_COOKIE` but one.
What could cause this and whats a fix?
Server is running PHP 5.3.3.
Update:
At the top of my index.php I `var_dump($_SERVER);` and then `var_dump($_COOKIE);` on the next line, and an expected cookie isn't printed from the second dump.
Update2:
Here's the Cookie part of my request
```
Cookie:SESSe00cd0d8b79da0906c77d52ed6e26907=2f9fhsomr2skcfmivagb1i8gj7; __utma=172891446.852439441.1310775539.1310775539.1310775539.1; __utmc=172891446; __utmv=172891446.%3A; __utmb=172891446.4.10.1310780296; OATMEAL=%9Ey%EE%C9J%956%C0%06%B3%EBZ%83%D1%80%C0%AC%D2%D0T%86%9A%2A%2A%A2E%B7f%86%D7i%C1%28%19L%1Fl%920%3CE%10%B6%C9c%1D%E3%A7H%D9%E1%29%1C%7E5%C8q%CC3%21C%0C%DC%CC%A5%F3i%10%F7%DCJjF%EE%B9%80%3C%C6Jy%A2%0E%3F%E3%BD%7B%BF%CD%84%85%91%BB3%B9%EA%CB%92%89%AC%FBc%BA%A32s%B5L%3E%DF%9B%CDk%08%DEZ%13%5Da1Q%B0%1CJ%90%AE%AF%3F%15%98%1B%E1%C1g%A9%BBzR%F5Q%82%8F%81%1A%D1%0E%87%DC%F3%3B%FF%B7%8E%09%0F%BF%DFK%A3t%D1%F3%DA_%ECKt%01%00x%D2%CCE%24%BB0%C2w%B4%82%F0Q%00O%F1v%19%11%0A%3A%BB%9Fy%B1%BC9hgy%C4%DC%DEN%C4%A4%3B%7D%E8%84h%07%E3+%0B%85y%8B%B5y%1B%FC%CE%86B%F55%ED%E0%01%EB%18%13%B0%09%CA%F9%3D%26%05%FC%A7%F8%E4%CD%3C%9E%D7%24%B1%BF%27t%B4%3C%89%D76%F0%CF%C0%D4%E7Z%A6%02%19j%D7%60%28%82%DF%DF%9C%05%25%CB%CA%04%B9%21N%D2r%A76%DD%D1%CB%97%B0%A9%13%29%3C%D6kdm%D1%14%EA%D4%1Fz%F9%CF%21i%BD%19RN%C3%8Dh%27R%15%99%13%FAv%13%8F%BBd%7B%F5%AD%D5%22%13q%13Z%F219%B9%B0_%AB%16%7B%D2%18%E3%F0%F6%9D%A4X
```
The cookie that's dropped is named "OATMEAL".
Update3: This PHP bug sound similar <https://bugs.php.net/bug.php?id=52018> | 2011/07/16 | [
"https://Stackoverflow.com/questions/6714659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249413/"
] | Thanks everyone, but offline from this thread another dev suggested base64 encoding the cookie data when sent. That worked and kept the data alive and I was able to base64 decode server-side and continue on. | Could it be that you have not set the right path for the cookie? I have had problems with this before where it would not let me access the cookie because it was being set to a strange path automatically. I had to specify the correct path when I set the cookie.
You probably already know this but sometimes things can hide right under our noses.
<http://us3.php.net/manual/en/function.setcookie.php>
cheers,
Michael |
6,714,659 | I've set a cookie just fine, and the cookie is in the request header, but when I access that cookie in the PHP superglobal `$_COOKIE` it isn't set. Dumping `$_COOKIE` shows the other cookies but one, and all were in the request header.
If I dump `$_SERVER` I can see that cookie in `$_SERVER['HTTP_COOKIE']`. PHP sets all of the cookies into `$_COOKIE` but one.
What could cause this and whats a fix?
Server is running PHP 5.3.3.
Update:
At the top of my index.php I `var_dump($_SERVER);` and then `var_dump($_COOKIE);` on the next line, and an expected cookie isn't printed from the second dump.
Update2:
Here's the Cookie part of my request
```
Cookie:SESSe00cd0d8b79da0906c77d52ed6e26907=2f9fhsomr2skcfmivagb1i8gj7; __utma=172891446.852439441.1310775539.1310775539.1310775539.1; __utmc=172891446; __utmv=172891446.%3A; __utmb=172891446.4.10.1310780296; OATMEAL=%9Ey%EE%C9J%956%C0%06%B3%EBZ%83%D1%80%C0%AC%D2%D0T%86%9A%2A%2A%A2E%B7f%86%D7i%C1%28%19L%1Fl%920%3CE%10%B6%C9c%1D%E3%A7H%D9%E1%29%1C%7E5%C8q%CC3%21C%0C%DC%CC%A5%F3i%10%F7%DCJjF%EE%B9%80%3C%C6Jy%A2%0E%3F%E3%BD%7B%BF%CD%84%85%91%BB3%B9%EA%CB%92%89%AC%FBc%BA%A32s%B5L%3E%DF%9B%CDk%08%DEZ%13%5Da1Q%B0%1CJ%90%AE%AF%3F%15%98%1B%E1%C1g%A9%BBzR%F5Q%82%8F%81%1A%D1%0E%87%DC%F3%3B%FF%B7%8E%09%0F%BF%DFK%A3t%D1%F3%DA_%ECKt%01%00x%D2%CCE%24%BB0%C2w%B4%82%F0Q%00O%F1v%19%11%0A%3A%BB%9Fy%B1%BC9hgy%C4%DC%DEN%C4%A4%3B%7D%E8%84h%07%E3+%0B%85y%8B%B5y%1B%FC%CE%86B%F55%ED%E0%01%EB%18%13%B0%09%CA%F9%3D%26%05%FC%A7%F8%E4%CD%3C%9E%D7%24%B1%BF%27t%B4%3C%89%D76%F0%CF%C0%D4%E7Z%A6%02%19j%D7%60%28%82%DF%DF%9C%05%25%CB%CA%04%B9%21N%D2r%A76%DD%D1%CB%97%B0%A9%13%29%3C%D6kdm%D1%14%EA%D4%1Fz%F9%CF%21i%BD%19RN%C3%8Dh%27R%15%99%13%FAv%13%8F%BBd%7B%F5%AD%D5%22%13q%13Z%F219%B9%B0_%AB%16%7B%D2%18%E3%F0%F6%9D%A4X
```
The cookie that's dropped is named "OATMEAL".
Update3: This PHP bug sound similar <https://bugs.php.net/bug.php?id=52018> | 2011/07/16 | [
"https://Stackoverflow.com/questions/6714659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249413/"
] | **Your string is 1099 characters long.**
Max length for a Cookie is 4Kb.
Assuming UTF-8 characters with 4 bytes per char you should be able to store between 1024.
Try to make OATMEAL smaller. Much smaller and let us know if that was the culprit. | As others have already said, it's almost certainly to do with the length of your cookie string. You should make it shorter.
It's also worth pointing out that even if it works, there's a very good reason for not having such a long cookie string -- the entire cookie string gets sent in both directions for every single HTTP request you make.
Let's say you have a typical page, that loads twenty images, two CSS files and two Javascript files, plus the main HTML page itself. For a 1K cookies string like yours, that would be an extra 50K on your server's bandwidth (and your user's bandwidth) for every single page load. That's going to add up quickly if you've got a reasonable amount of traffic, and if you've got any kind of limits or metering on your bandwidth, it's going to cost you extra money.
Secondly, I don't know what that OATMEAL cookie contains; I don't have the time to decode it, but it looks a lot like you're obfuscating data (including adding some deliberate spoiler characters). Be aware that if this data is sensitive enough to want to obfuscate, then the cookie is a *really* bad place to be storing it.
If you really do need to pass that amount of data to the server, you should be sending it in a POST request. If the PHP program needs to access it with subsequent page loads, then set it in your `$_SESSION` array. If your Javascript code needs to be able to use it or set it, then use an Ajax request. |
6,714,659 | I've set a cookie just fine, and the cookie is in the request header, but when I access that cookie in the PHP superglobal `$_COOKIE` it isn't set. Dumping `$_COOKIE` shows the other cookies but one, and all were in the request header.
If I dump `$_SERVER` I can see that cookie in `$_SERVER['HTTP_COOKIE']`. PHP sets all of the cookies into `$_COOKIE` but one.
What could cause this and whats a fix?
Server is running PHP 5.3.3.
Update:
At the top of my index.php I `var_dump($_SERVER);` and then `var_dump($_COOKIE);` on the next line, and an expected cookie isn't printed from the second dump.
Update2:
Here's the Cookie part of my request
```
Cookie:SESSe00cd0d8b79da0906c77d52ed6e26907=2f9fhsomr2skcfmivagb1i8gj7; __utma=172891446.852439441.1310775539.1310775539.1310775539.1; __utmc=172891446; __utmv=172891446.%3A; __utmb=172891446.4.10.1310780296; OATMEAL=%9Ey%EE%C9J%956%C0%06%B3%EBZ%83%D1%80%C0%AC%D2%D0T%86%9A%2A%2A%A2E%B7f%86%D7i%C1%28%19L%1Fl%920%3CE%10%B6%C9c%1D%E3%A7H%D9%E1%29%1C%7E5%C8q%CC3%21C%0C%DC%CC%A5%F3i%10%F7%DCJjF%EE%B9%80%3C%C6Jy%A2%0E%3F%E3%BD%7B%BF%CD%84%85%91%BB3%B9%EA%CB%92%89%AC%FBc%BA%A32s%B5L%3E%DF%9B%CDk%08%DEZ%13%5Da1Q%B0%1CJ%90%AE%AF%3F%15%98%1B%E1%C1g%A9%BBzR%F5Q%82%8F%81%1A%D1%0E%87%DC%F3%3B%FF%B7%8E%09%0F%BF%DFK%A3t%D1%F3%DA_%ECKt%01%00x%D2%CCE%24%BB0%C2w%B4%82%F0Q%00O%F1v%19%11%0A%3A%BB%9Fy%B1%BC9hgy%C4%DC%DEN%C4%A4%3B%7D%E8%84h%07%E3+%0B%85y%8B%B5y%1B%FC%CE%86B%F55%ED%E0%01%EB%18%13%B0%09%CA%F9%3D%26%05%FC%A7%F8%E4%CD%3C%9E%D7%24%B1%BF%27t%B4%3C%89%D76%F0%CF%C0%D4%E7Z%A6%02%19j%D7%60%28%82%DF%DF%9C%05%25%CB%CA%04%B9%21N%D2r%A76%DD%D1%CB%97%B0%A9%13%29%3C%D6kdm%D1%14%EA%D4%1Fz%F9%CF%21i%BD%19RN%C3%8Dh%27R%15%99%13%FAv%13%8F%BBd%7B%F5%AD%D5%22%13q%13Z%F219%B9%B0_%AB%16%7B%D2%18%E3%F0%F6%9D%A4X
```
The cookie that's dropped is named "OATMEAL".
Update3: This PHP bug sound similar <https://bugs.php.net/bug.php?id=52018> | 2011/07/16 | [
"https://Stackoverflow.com/questions/6714659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249413/"
] | **Your string is 1099 characters long.**
Max length for a Cookie is 4Kb.
Assuming UTF-8 characters with 4 bytes per char you should be able to store between 1024.
Try to make OATMEAL smaller. Much smaller and let us know if that was the culprit. | Thanks everyone, but offline from this thread another dev suggested base64 encoding the cookie data when sent. That worked and kept the data alive and I was able to base64 decode server-side and continue on. |
6,714,659 | I've set a cookie just fine, and the cookie is in the request header, but when I access that cookie in the PHP superglobal `$_COOKIE` it isn't set. Dumping `$_COOKIE` shows the other cookies but one, and all were in the request header.
If I dump `$_SERVER` I can see that cookie in `$_SERVER['HTTP_COOKIE']`. PHP sets all of the cookies into `$_COOKIE` but one.
What could cause this and whats a fix?
Server is running PHP 5.3.3.
Update:
At the top of my index.php I `var_dump($_SERVER);` and then `var_dump($_COOKIE);` on the next line, and an expected cookie isn't printed from the second dump.
Update2:
Here's the Cookie part of my request
```
Cookie:SESSe00cd0d8b79da0906c77d52ed6e26907=2f9fhsomr2skcfmivagb1i8gj7; __utma=172891446.852439441.1310775539.1310775539.1310775539.1; __utmc=172891446; __utmv=172891446.%3A; __utmb=172891446.4.10.1310780296; OATMEAL=%9Ey%EE%C9J%956%C0%06%B3%EBZ%83%D1%80%C0%AC%D2%D0T%86%9A%2A%2A%A2E%B7f%86%D7i%C1%28%19L%1Fl%920%3CE%10%B6%C9c%1D%E3%A7H%D9%E1%29%1C%7E5%C8q%CC3%21C%0C%DC%CC%A5%F3i%10%F7%DCJjF%EE%B9%80%3C%C6Jy%A2%0E%3F%E3%BD%7B%BF%CD%84%85%91%BB3%B9%EA%CB%92%89%AC%FBc%BA%A32s%B5L%3E%DF%9B%CDk%08%DEZ%13%5Da1Q%B0%1CJ%90%AE%AF%3F%15%98%1B%E1%C1g%A9%BBzR%F5Q%82%8F%81%1A%D1%0E%87%DC%F3%3B%FF%B7%8E%09%0F%BF%DFK%A3t%D1%F3%DA_%ECKt%01%00x%D2%CCE%24%BB0%C2w%B4%82%F0Q%00O%F1v%19%11%0A%3A%BB%9Fy%B1%BC9hgy%C4%DC%DEN%C4%A4%3B%7D%E8%84h%07%E3+%0B%85y%8B%B5y%1B%FC%CE%86B%F55%ED%E0%01%EB%18%13%B0%09%CA%F9%3D%26%05%FC%A7%F8%E4%CD%3C%9E%D7%24%B1%BF%27t%B4%3C%89%D76%F0%CF%C0%D4%E7Z%A6%02%19j%D7%60%28%82%DF%DF%9C%05%25%CB%CA%04%B9%21N%D2r%A76%DD%D1%CB%97%B0%A9%13%29%3C%D6kdm%D1%14%EA%D4%1Fz%F9%CF%21i%BD%19RN%C3%8Dh%27R%15%99%13%FAv%13%8F%BBd%7B%F5%AD%D5%22%13q%13Z%F219%B9%B0_%AB%16%7B%D2%18%E3%F0%F6%9D%A4X
```
The cookie that's dropped is named "OATMEAL".
Update3: This PHP bug sound similar <https://bugs.php.net/bug.php?id=52018> | 2011/07/16 | [
"https://Stackoverflow.com/questions/6714659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249413/"
] | Thanks everyone, but offline from this thread another dev suggested base64 encoding the cookie data when sent. That worked and kept the data alive and I was able to base64 decode server-side and continue on. | As others have already said, it's almost certainly to do with the length of your cookie string. You should make it shorter.
It's also worth pointing out that even if it works, there's a very good reason for not having such a long cookie string -- the entire cookie string gets sent in both directions for every single HTTP request you make.
Let's say you have a typical page, that loads twenty images, two CSS files and two Javascript files, plus the main HTML page itself. For a 1K cookies string like yours, that would be an extra 50K on your server's bandwidth (and your user's bandwidth) for every single page load. That's going to add up quickly if you've got a reasonable amount of traffic, and if you've got any kind of limits or metering on your bandwidth, it's going to cost you extra money.
Secondly, I don't know what that OATMEAL cookie contains; I don't have the time to decode it, but it looks a lot like you're obfuscating data (including adding some deliberate spoiler characters). Be aware that if this data is sensitive enough to want to obfuscate, then the cookie is a *really* bad place to be storing it.
If you really do need to pass that amount of data to the server, you should be sending it in a POST request. If the PHP program needs to access it with subsequent page loads, then set it in your `$_SESSION` array. If your Javascript code needs to be able to use it or set it, then use an Ajax request. |
45,296,626 | Everyone, I have a little problem here. The idea is simple. I need to extract value to child table **each time I insert** new rows into the master table.
Master table :
```
+--------+------------+-------+
+ id + dates + time +
+--------+------------+-------+
+ 101 + 2017/07/24 + 07:12 +
+ 101 + 2017/07/24 + 16:02 +
+ 102 + 2017/07/24 + 07:10 +
+ 102 + 2017/07/24 + 15:58 +
+ 103 + 2017/07/24 + 07:02 +
+ 103 + 2017/07/24 + 16:05 +
+ 101 + 2017/07/25 + 07:10 +
+ 101 + 2017/07/25 + 15:34 +
+ 102 + 2017/07/25 + 07:00 +
+ 102 + 2017/07/25 + 16:38 +
+ 103 + 2017/07/25 + 07:02 +
+ 103 + 2017/07/25 + 16:18 +
```
Then we go for the child table which triggered each time the new rows is inserted to the master table. The table should be like :
```
+--------+------------+---------+----------+
+ id + dates + time_in + time_out +
+--------+------------+---------+----------+
+ 101 + 2017/07/24 + 07:12 + 16:02 +
+ 102 + 2017/07/24 + 07:10 + 15:58 +
+ 103 + 2017/07/24 + 07:02 + 16:05 +
+ 101 + 2017/07/25 + 07:10 + 15:34 +
+ 102 + 2017/07/25 + 07:00 + 16:38 +
+ 103 + 2017/07/25 + 07:02 + 16:18 +
```
Usualy, I make this **SQL** code to generate the child table :
```
INSERT INTO child_table (id, dates, time_in, time_out)
SELECT id, dates, MIN(time) as time_in, MAX(time) as time_out FROM
master_table GROUP BY dates, id
```
Before I realize that my codes take much longer to load the page. I think It'd be much efficient to work with trigger. Please help :) | 2017/07/25 | [
"https://Stackoverflow.com/questions/45296626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8361758/"
] | it seems you complicate your code you just try simple code below
```
@Override
public void onBackPressed() {
if (webView.canGoBack()) {
webView.goBack();
} else {
super.onBackPressed();
}
}
```
this is simple code work fine for you,i dont know if you are using flag for other reasons. | You can do like this.
```
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && webView.canGoBack()) {
webView.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
```
And you Web page not available,you can use `onReceivedError` method.
```
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@TargetApi(Build.VERSION_CODES.M)
@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
super.onReceivedError(view, request, error);
if (request.isForMainFrame()) {
// you can do something when you Web page not available
// webView.goBack();
}
}
});
``` |
30,342 | I'm a NYC based director.
What is the best way to avoid feedback from wireless mics in a Theater in the Round layout or in an environmental immersive staging? | 2014/09/30 | [
"https://sound.stackexchange.com/questions/30342",
"https://sound.stackexchange.com",
"https://sound.stackexchange.com/users/10014/"
] | The biggest thing is going to be careful EQing and using microphones as close to the actor's mouthes and as directional as possible. Feedback occurs when the amount of amplification applied to the microphone signal becomes enough that the background noise that the microphone picks up from the speaker is louder than the signal it is amplifying, thus forming a loop that makes it keep growing louder.
You prevent the loop by either increasing the source signal, thus reducing the amount of amplification needed or by reducing the amount of the signal picked up in the background from the speaker. The first is accomplished by micing closer to the source. Sound falls off rapidly with distance, so the closer you can get to the speaker's mouth, generally the stronger it will be (though angle also matters as people project sound outward).
For the second part, directional mics and careful EQing help. Directional mics will pick up more focused in one direction than another. If you can aim them carefully, it can prevent picking up background noise coming from other directions and thus give a cleaner signal more resistant to feedback.
EQing works similarly, though you are limited by the actual sound of your source. Certain frequencies will travel through the room better than others due to various acoustic effects, this is why feedback is generally a single frequency (whichever frequency hits the threshold first). You can alter the EQ to reduce those particular frequencies if it doesn't harm the sound of the speaker's voice too much, thus preventing the loop while still boosting the intended signal.
There are actually feedback suppression devices that you can use that will automatically look for rapidly growing feedback loops and make notch adjustments to EQ to prevent them, however such units will often have a slight negative impact on sound quality if they have to act as they generally don't consider what is needed by the source when eliminating feedback, so they are more of a safety mechanism than an ideal solution.
It may also be helpful to have your system leveled if it has not been. As previously mentioned, rooms have natural frequencies that they amplify more than others. Leveling a system in a room involves playing pink noise through the system at the intended volume level and then measuring how the room alters the sound. Those adjustments are then placed in to a 31 band equalizer that adjusts for the sound of the room in the future. This won't directly prevent feedback, but it will help counteract issues with natural reverberating frequencies in the room. | AJ is correct on all accounts.
There are a couple more things I'd like to add: speaker placement, aim, and signal route.
Since you have an arena theater setup, think about where to put your speakers, where to aim them, and what signals you want to route to them.
As best as you can, route voices only to speakers facing away from the arena stage. Route track and environmental sounds to all speakers, keeping in mind their proximity to the performers mics. Rule of thumb is to keep the sound going to your audience as much as possible, and keep as little sound as possible going to your stage. The omni-directional wireless mics on your performers will thank you, and not complain with feedback.
If your performers need monitoring, IEM's are a good solution. I use IEM's for our touring theater group. They're lighter equipment to pack and I have no floor wedges to feedback on me. IEM's are a bit more expensive and complicated to setup, but are worth it. |
25,109,554 | I want my div to fit the body's height and always touch the bottom of my body when I scroll, so I made it 100% height.
But I've quickly understood that isn't the right solution. When another div goes away from the window, when I scroll, I see my div scrolling with a margin right down to it between the bottom and it.
So I've just made a small snippet in jQuery:
```
$(window).resize(function(){
var pageHeight = $(document).height();
$('#menu').css('height', 'px');
$('#menu').css('height', pageHeight + 'px');
});
```
But it doesn't work well.
So I don't know what to do. | 2014/08/03 | [
"https://Stackoverflow.com/questions/25109554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3369641/"
] | That might well be faster, but since you're using C++, an alternative might be to use an iterator instead:
```
// declare it to be some appropriate type of iterator
for (it = my_vector.begin(); it != my_vector.end(); ++it)
doSomething(*it);
```
You will want to be careful here, though, that you're not inadvertently constructing temporary copies of each item in `my_vector`.
If you're using C++11, another option is to use range-for:
```
for (const auto &thing : my_vector)
doSomething(thing);
```
Note that the use of `const` and `&` mean that we avoid copying each item in `my_vector`. | If you don't want to modify the elements, you can try this:
```
for (const auto &elem : my_vector)
{
//
}
``` |
171,809 | >
> I hope he doesn’t think I’m **off** prostituting myself.
>
>
>
[source - *One Week Girlfriend*](http://khnovel.com/one-week-girlfriend/page-3-10042110.html)
I looked up "be off", seemed no right meaning. | 2018/07/10 | [
"https://ell.stackexchange.com/questions/171809",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/72993/"
] | To be off doing something= Usually, you might be at a place such as home or work, if you are not there, you can be said to be off [doing something] by another person. **It means not present at work, at home or at some other place where you are supposed to be or where you usually are**.
It is constructed using: off + verb + ing + object [sometimes]. The idiom includes the gerund after off.
Where's John?
* He's **off playing tennis**. [He has gone off to play tennis]
* He's **off seeing his family**. [He has gone off to see his family].
It is a shortened form of: to go off and do something.
So, in your sentence, **off prostituting myself** means: away from the place the person is expected to be and engaged in prostitution. The verb form here is to prostitute oneself. | In your cited context, the *(**optional**)* preposition could be any of ***off, away, out*** (and doubtless several others). Most if not all of those optional prepositions have little or no effect on the meaning, apart from the general implication of the hypothetical prostitution happening *"**somewhere else**"* (not where "he" or the speaker is, or more metaphorically ***doing something which is far away from one's normal behaviour***.
(transcribed from comment) |
273,836 | I have a project that builds fine If I build it manually but it fails with CC.NET.
The error that shows up on CC.NET is basically related to an import that's failing because file was not found; one of the projects (C++ dll) tries to import a dll built by another project. Dll should be in the right place since there's a dependency between the projects - indeeed when I build manually everything works fine (Note that when I say manually I am getting everything fresh from source code repository then invoking a Rebuild from VS2005 to simulate CC.NET automation).
looks like dependencies are ignored when the build is automated through CC.NET.
I am building in Release MinDependency mode.
Any help would be highly appreciated! | 2008/11/07 | [
"https://Stackoverflow.com/questions/273836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311500/"
] | Try building it from the command line and see what happens. | As Alex said, I think that your problem is that the CC.NET service runs as a local user account. Unfortunatly some of the C++ environment variables are per user and will not be carried over to the default build environment. In my case it was the lib and include files defined in **Tools -> Options -> Projects and Solutions -> VC++ Directories**. This same issue evidently causes other issues and is called out in [this article](http://confluence.public.thoughtworks.org/display/CCNET/The+Server+Service+Application) as a yellow block.
My solution was to create a new user (*BuildUser*) on the build machine specifically for building. The key was to then log in as *BuildUser* and set up the environment. Finally, I changed the CC.NET service to login as *BuildUser* and restarted it. |
273,836 | I have a project that builds fine If I build it manually but it fails with CC.NET.
The error that shows up on CC.NET is basically related to an import that's failing because file was not found; one of the projects (C++ dll) tries to import a dll built by another project. Dll should be in the right place since there's a dependency between the projects - indeeed when I build manually everything works fine (Note that when I say manually I am getting everything fresh from source code repository then invoking a Rebuild from VS2005 to simulate CC.NET automation).
looks like dependencies are ignored when the build is automated through CC.NET.
I am building in Release MinDependency mode.
Any help would be highly appreciated! | 2008/11/07 | [
"https://Stackoverflow.com/questions/273836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311500/"
] | After a long investigation - my understanding on this at current stage is that the problem is related to the fact that I am using devenv to build through CruiseControl.NET but when I build manually VisualStudio is using msbuild.
Basically this causes dependencies to be ignored (because of some msbuild command arg that I am not reproducing using devenv).
I think the fact that dependencies are set between C++ projects is relevant too to some extent, since I've been able in other occasions to build properly with CC.NET setting dependencies between .NET projects and C++ projects.
In order to figure out exactly what is generating this different
behavior I'd have to follow [this lead](https://stackoverflow.com/questions/280559/how-to-get-cmd-line-build-command-for-vs-solution).
I'd like to hear other people's opinions on this. | My guess would be that the user that the service is configured has different permissions and/or environment variables as you do when actually running it. If you are on the same physical box and it compiles fine with visual studio and you are also using visual studio in CruiseControl (not MSBuild) then it is almost assuredly the user. If however you are using MSBuild in CruiseControl there is a huge set of diffrence when MSBuild (2.0) compiles a C++ sln and when Visual Studio compiles it. If you must use MSBuild on C++ solutions try v3.5 it has much more support for C++ solutions. |
273,836 | I have a project that builds fine If I build it manually but it fails with CC.NET.
The error that shows up on CC.NET is basically related to an import that's failing because file was not found; one of the projects (C++ dll) tries to import a dll built by another project. Dll should be in the right place since there's a dependency between the projects - indeeed when I build manually everything works fine (Note that when I say manually I am getting everything fresh from source code repository then invoking a Rebuild from VS2005 to simulate CC.NET automation).
looks like dependencies are ignored when the build is automated through CC.NET.
I am building in Release MinDependency mode.
Any help would be highly appreciated! | 2008/11/07 | [
"https://Stackoverflow.com/questions/273836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311500/"
] | Can you change CC to use msbuild instead of devenv? That seems like the optimal solution to me, as it means the build is the same in both situations. | Try building it from the command line and see what happens. |
273,836 | I have a project that builds fine If I build it manually but it fails with CC.NET.
The error that shows up on CC.NET is basically related to an import that's failing because file was not found; one of the projects (C++ dll) tries to import a dll built by another project. Dll should be in the right place since there's a dependency between the projects - indeeed when I build manually everything works fine (Note that when I say manually I am getting everything fresh from source code repository then invoking a Rebuild from VS2005 to simulate CC.NET automation).
looks like dependencies are ignored when the build is automated through CC.NET.
I am building in Release MinDependency mode.
Any help would be highly appreciated! | 2008/11/07 | [
"https://Stackoverflow.com/questions/273836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311500/"
] | After a long investigation - my understanding on this at current stage is that the problem is related to the fact that I am using devenv to build through CruiseControl.NET but when I build manually VisualStudio is using msbuild.
Basically this causes dependencies to be ignored (because of some msbuild command arg that I am not reproducing using devenv).
I think the fact that dependencies are set between C++ projects is relevant too to some extent, since I've been able in other occasions to build properly with CC.NET setting dependencies between .NET projects and C++ projects.
In order to figure out exactly what is generating this different
behavior I'd have to follow [this lead](https://stackoverflow.com/questions/280559/how-to-get-cmd-line-build-command-for-vs-solution).
I'd like to hear other people's opinions on this. | Try building it from the command line and see what happens. |
273,836 | I have a project that builds fine If I build it manually but it fails with CC.NET.
The error that shows up on CC.NET is basically related to an import that's failing because file was not found; one of the projects (C++ dll) tries to import a dll built by another project. Dll should be in the right place since there's a dependency between the projects - indeeed when I build manually everything works fine (Note that when I say manually I am getting everything fresh from source code repository then invoking a Rebuild from VS2005 to simulate CC.NET automation).
looks like dependencies are ignored when the build is automated through CC.NET.
I am building in Release MinDependency mode.
Any help would be highly appreciated! | 2008/11/07 | [
"https://Stackoverflow.com/questions/273836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311500/"
] | Can you change CC to use msbuild instead of devenv? That seems like the optimal solution to me, as it means the build is the same in both situations. | My guess would be that the user that the service is configured has different permissions and/or environment variables as you do when actually running it. If you are on the same physical box and it compiles fine with visual studio and you are also using visual studio in CruiseControl (not MSBuild) then it is almost assuredly the user. If however you are using MSBuild in CruiseControl there is a huge set of diffrence when MSBuild (2.0) compiles a C++ sln and when Visual Studio compiles it. If you must use MSBuild on C++ solutions try v3.5 it has much more support for C++ solutions. |
273,836 | I have a project that builds fine If I build it manually but it fails with CC.NET.
The error that shows up on CC.NET is basically related to an import that's failing because file was not found; one of the projects (C++ dll) tries to import a dll built by another project. Dll should be in the right place since there's a dependency between the projects - indeeed when I build manually everything works fine (Note that when I say manually I am getting everything fresh from source code repository then invoking a Rebuild from VS2005 to simulate CC.NET automation).
looks like dependencies are ignored when the build is automated through CC.NET.
I am building in Release MinDependency mode.
Any help would be highly appreciated! | 2008/11/07 | [
"https://Stackoverflow.com/questions/273836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311500/"
] | After a long investigation - my understanding on this at current stage is that the problem is related to the fact that I am using devenv to build through CruiseControl.NET but when I build manually VisualStudio is using msbuild.
Basically this causes dependencies to be ignored (because of some msbuild command arg that I am not reproducing using devenv).
I think the fact that dependencies are set between C++ projects is relevant too to some extent, since I've been able in other occasions to build properly with CC.NET setting dependencies between .NET projects and C++ projects.
In order to figure out exactly what is generating this different
behavior I'd have to follow [this lead](https://stackoverflow.com/questions/280559/how-to-get-cmd-line-build-command-for-vs-solution).
I'd like to hear other people's opinions on this. | As Alex said, I think that your problem is that the CC.NET service runs as a local user account. Unfortunatly some of the C++ environment variables are per user and will not be carried over to the default build environment. In my case it was the lib and include files defined in **Tools -> Options -> Projects and Solutions -> VC++ Directories**. This same issue evidently causes other issues and is called out in [this article](http://confluence.public.thoughtworks.org/display/CCNET/The+Server+Service+Application) as a yellow block.
My solution was to create a new user (*BuildUser*) on the build machine specifically for building. The key was to then log in as *BuildUser* and set up the environment. Finally, I changed the CC.NET service to login as *BuildUser* and restarted it. |
273,836 | I have a project that builds fine If I build it manually but it fails with CC.NET.
The error that shows up on CC.NET is basically related to an import that's failing because file was not found; one of the projects (C++ dll) tries to import a dll built by another project. Dll should be in the right place since there's a dependency between the projects - indeeed when I build manually everything works fine (Note that when I say manually I am getting everything fresh from source code repository then invoking a Rebuild from VS2005 to simulate CC.NET automation).
looks like dependencies are ignored when the build is automated through CC.NET.
I am building in Release MinDependency mode.
Any help would be highly appreciated! | 2008/11/07 | [
"https://Stackoverflow.com/questions/273836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311500/"
] | My guess would be that the user that the service is configured has different permissions and/or environment variables as you do when actually running it. If you are on the same physical box and it compiles fine with visual studio and you are also using visual studio in CruiseControl (not MSBuild) then it is almost assuredly the user. If however you are using MSBuild in CruiseControl there is a huge set of diffrence when MSBuild (2.0) compiles a C++ sln and when Visual Studio compiles it. If you must use MSBuild on C++ solutions try v3.5 it has much more support for C++ solutions. | I've run into instances where my solution builds if I open it in the IDE and compile, but fails if I run from a command line (either msbuild or devenv.) In each case, the problem was due to a bad reference - likely from paths not matching between your local box and the build server. You see it compile in the IDE correctly because VisualStudio, when opening a solution, will attempt to auto-resolve broken paths. When it does this, it won't tell you about it and usually won't change your solution and project files (which is what you'd hope for.)
Try opening your solution file and/or project files in a text editor and make sure all relative paths are valid. |
273,836 | I have a project that builds fine If I build it manually but it fails with CC.NET.
The error that shows up on CC.NET is basically related to an import that's failing because file was not found; one of the projects (C++ dll) tries to import a dll built by another project. Dll should be in the right place since there's a dependency between the projects - indeeed when I build manually everything works fine (Note that when I say manually I am getting everything fresh from source code repository then invoking a Rebuild from VS2005 to simulate CC.NET automation).
looks like dependencies are ignored when the build is automated through CC.NET.
I am building in Release MinDependency mode.
Any help would be highly appreciated! | 2008/11/07 | [
"https://Stackoverflow.com/questions/273836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311500/"
] | Can you change CC to use msbuild instead of devenv? That seems like the optimal solution to me, as it means the build is the same in both situations. | (reposting as my initial post seems to have failed)
VC2003 seems to have an inconsistency between dependencies and input libraries.
An example:
* ProjectA --> A.lib
* ProjectB --> B.exe
+ In Properties-->Linker-->Additional Input Libraries, A.lib is specified.
+ In Project Dependencies, ProjectA is unchecked (why it is not automatic is still a mystery to me)
When cleaning ProjectB, A.lib is not deleted, nor is it rebuilt when ProjectB is compiled. So the build appears to succeed in your local machine.
CC.NET starts from scratch, and the build fails as A.lib is not found in the first place. |
273,836 | I have a project that builds fine If I build it manually but it fails with CC.NET.
The error that shows up on CC.NET is basically related to an import that's failing because file was not found; one of the projects (C++ dll) tries to import a dll built by another project. Dll should be in the right place since there's a dependency between the projects - indeeed when I build manually everything works fine (Note that when I say manually I am getting everything fresh from source code repository then invoking a Rebuild from VS2005 to simulate CC.NET automation).
looks like dependencies are ignored when the build is automated through CC.NET.
I am building in Release MinDependency mode.
Any help would be highly appreciated! | 2008/11/07 | [
"https://Stackoverflow.com/questions/273836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311500/"
] | Can you change CC to use msbuild instead of devenv? That seems like the optimal solution to me, as it means the build is the same in both situations. | I wonder if CC.Net is building with different environment variables, such that the necessary library directories aren't properly added to the path.
Is there any specific error message in the CC.Net build log as to why that particular DLL import failed? Could not find file? Permissions? Look in the detailed CC.Net build log for the failure and see where it differs from a normal command-line build. |
273,836 | I have a project that builds fine If I build it manually but it fails with CC.NET.
The error that shows up on CC.NET is basically related to an import that's failing because file was not found; one of the projects (C++ dll) tries to import a dll built by another project. Dll should be in the right place since there's a dependency between the projects - indeeed when I build manually everything works fine (Note that when I say manually I am getting everything fresh from source code repository then invoking a Rebuild from VS2005 to simulate CC.NET automation).
looks like dependencies are ignored when the build is automated through CC.NET.
I am building in Release MinDependency mode.
Any help would be highly appreciated! | 2008/11/07 | [
"https://Stackoverflow.com/questions/273836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311500/"
] | Try building it from the command line and see what happens. | I've run into instances where my solution builds if I open it in the IDE and compile, but fails if I run from a command line (either msbuild or devenv.) In each case, the problem was due to a bad reference - likely from paths not matching between your local box and the build server. You see it compile in the IDE correctly because VisualStudio, when opening a solution, will attempt to auto-resolve broken paths. When it does this, it won't tell you about it and usually won't change your solution and project files (which is what you'd hope for.)
Try opening your solution file and/or project files in a text editor and make sure all relative paths are valid. |
44,759,324 | ```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Menu_Attempts
{
class Program
{
static void Main(string[] args)
{
bool forever = true;
do
{
Console.WriteLine("1. Stone to Pounds");
Console.WriteLine("2. Quit");
int reply = Convert.ToInt32(Console.ReadLine());
switch (reply)
{
case 1:
Console.WriteLine("Enter an amount in Stone");
double UserInput = double.Parse(Console.ReadLine());
StoneToPounds(UserInput);
break;
case 2:
Console.WriteLine("You've decided to quit.");
forever = false;
break;
}
} while (forever);
}
public static double StoneToPounds(double number)
{
double answer = number * 14;
return answer;
}
}
}
```
So I'm trying to make a console based menu, and calling methods when needed to clean it up. I select option 1. to convert stone to pounds and it gives me the option to input a number. But when I do it simply loops back to the begging of the menu? | 2017/06/26 | [
"https://Stackoverflow.com/questions/44759324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8215410/"
] | Yes, your method is being called (and you can prove that by adding a breakpoint), but you're not actually doing anything with the `StoneToPounds` method result. Maybe you can do something like this:
```
case 1:
Console.WriteLine("Enter an amount in Stone");
double UserInput = double.Parse(Console.ReadLine());
Console.WriteLine("The result is {0}", StoneToPounds(UserInput));
break;
```
You'll see, soon enough, that you code will break whenever the user enters a text or anything different than a number; I would suggest to take a look into [TryParse](https://msdn.microsoft.com/en-us/library/994c0zb1(v=vs.110).aspx) method | The methods are fine. You are just not printing the answer. Change your code like this to print the answer:
```
case 1:
Console.WriteLine("Enter an amount in Stone");
double UserInput = double.Parse(Console.ReadLine());
double result = StoneToPounds(UserInput);
Console.WriteLine(result.ToString());
break;
``` |
44,759,324 | ```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Menu_Attempts
{
class Program
{
static void Main(string[] args)
{
bool forever = true;
do
{
Console.WriteLine("1. Stone to Pounds");
Console.WriteLine("2. Quit");
int reply = Convert.ToInt32(Console.ReadLine());
switch (reply)
{
case 1:
Console.WriteLine("Enter an amount in Stone");
double UserInput = double.Parse(Console.ReadLine());
StoneToPounds(UserInput);
break;
case 2:
Console.WriteLine("You've decided to quit.");
forever = false;
break;
}
} while (forever);
}
public static double StoneToPounds(double number)
{
double answer = number * 14;
return answer;
}
}
}
```
So I'm trying to make a console based menu, and calling methods when needed to clean it up. I select option 1. to convert stone to pounds and it gives me the option to input a number. But when I do it simply loops back to the begging of the menu? | 2017/06/26 | [
"https://Stackoverflow.com/questions/44759324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8215410/"
] | Yes, your method is being called (and you can prove that by adding a breakpoint), but you're not actually doing anything with the `StoneToPounds` method result. Maybe you can do something like this:
```
case 1:
Console.WriteLine("Enter an amount in Stone");
double UserInput = double.Parse(Console.ReadLine());
Console.WriteLine("The result is {0}", StoneToPounds(UserInput));
break;
```
You'll see, soon enough, that you code will break whenever the user enters a text or anything different than a number; I would suggest to take a look into [TryParse](https://msdn.microsoft.com/en-us/library/994c0zb1(v=vs.110).aspx) method | You could simply add this line of code just before you call `break`:
```
Console.WriteLine("The result is {0}", StoneToPounds(UserInput));
Console.WriteLine("Press any key to continue");
Console.ReadKey();
``` |
44,759,324 | ```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Menu_Attempts
{
class Program
{
static void Main(string[] args)
{
bool forever = true;
do
{
Console.WriteLine("1. Stone to Pounds");
Console.WriteLine("2. Quit");
int reply = Convert.ToInt32(Console.ReadLine());
switch (reply)
{
case 1:
Console.WriteLine("Enter an amount in Stone");
double UserInput = double.Parse(Console.ReadLine());
StoneToPounds(UserInput);
break;
case 2:
Console.WriteLine("You've decided to quit.");
forever = false;
break;
}
} while (forever);
}
public static double StoneToPounds(double number)
{
double answer = number * 14;
return answer;
}
}
}
```
So I'm trying to make a console based menu, and calling methods when needed to clean it up. I select option 1. to convert stone to pounds and it gives me the option to input a number. But when I do it simply loops back to the begging of the menu? | 2017/06/26 | [
"https://Stackoverflow.com/questions/44759324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8215410/"
] | Yes, your method is being called (and you can prove that by adding a breakpoint), but you're not actually doing anything with the `StoneToPounds` method result. Maybe you can do something like this:
```
case 1:
Console.WriteLine("Enter an amount in Stone");
double UserInput = double.Parse(Console.ReadLine());
Console.WriteLine("The result is {0}", StoneToPounds(UserInput));
break;
```
You'll see, soon enough, that you code will break whenever the user enters a text or anything different than a number; I would suggest to take a look into [TryParse](https://msdn.microsoft.com/en-us/library/994c0zb1(v=vs.110).aspx) method | as others said ... you method is called and returning the double value ...but you are not saving it any kind of variables , if u wan't ur method to operate on the variable itself you can pass it as a ref parameter this way any change happens to the variable inside ur method will affect the variable globally
```
public static void StoneToPounds(ref double number)
{
number *= 14
}
```
btw the operator \*= could eliminate ur need for a separate function , if u r a beginner then you should now that less code is always better as long as u can keep it clean and organized :D |
44,759,324 | ```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Menu_Attempts
{
class Program
{
static void Main(string[] args)
{
bool forever = true;
do
{
Console.WriteLine("1. Stone to Pounds");
Console.WriteLine("2. Quit");
int reply = Convert.ToInt32(Console.ReadLine());
switch (reply)
{
case 1:
Console.WriteLine("Enter an amount in Stone");
double UserInput = double.Parse(Console.ReadLine());
StoneToPounds(UserInput);
break;
case 2:
Console.WriteLine("You've decided to quit.");
forever = false;
break;
}
} while (forever);
}
public static double StoneToPounds(double number)
{
double answer = number * 14;
return answer;
}
}
}
```
So I'm trying to make a console based menu, and calling methods when needed to clean it up. I select option 1. to convert stone to pounds and it gives me the option to input a number. But when I do it simply loops back to the begging of the menu? | 2017/06/26 | [
"https://Stackoverflow.com/questions/44759324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8215410/"
] | The methods are fine. You are just not printing the answer. Change your code like this to print the answer:
```
case 1:
Console.WriteLine("Enter an amount in Stone");
double UserInput = double.Parse(Console.ReadLine());
double result = StoneToPounds(UserInput);
Console.WriteLine(result.ToString());
break;
``` | as others said ... you method is called and returning the double value ...but you are not saving it any kind of variables , if u wan't ur method to operate on the variable itself you can pass it as a ref parameter this way any change happens to the variable inside ur method will affect the variable globally
```
public static void StoneToPounds(ref double number)
{
number *= 14
}
```
btw the operator \*= could eliminate ur need for a separate function , if u r a beginner then you should now that less code is always better as long as u can keep it clean and organized :D |
44,759,324 | ```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Menu_Attempts
{
class Program
{
static void Main(string[] args)
{
bool forever = true;
do
{
Console.WriteLine("1. Stone to Pounds");
Console.WriteLine("2. Quit");
int reply = Convert.ToInt32(Console.ReadLine());
switch (reply)
{
case 1:
Console.WriteLine("Enter an amount in Stone");
double UserInput = double.Parse(Console.ReadLine());
StoneToPounds(UserInput);
break;
case 2:
Console.WriteLine("You've decided to quit.");
forever = false;
break;
}
} while (forever);
}
public static double StoneToPounds(double number)
{
double answer = number * 14;
return answer;
}
}
}
```
So I'm trying to make a console based menu, and calling methods when needed to clean it up. I select option 1. to convert stone to pounds and it gives me the option to input a number. But when I do it simply loops back to the begging of the menu? | 2017/06/26 | [
"https://Stackoverflow.com/questions/44759324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8215410/"
] | You could simply add this line of code just before you call `break`:
```
Console.WriteLine("The result is {0}", StoneToPounds(UserInput));
Console.WriteLine("Press any key to continue");
Console.ReadKey();
``` | as others said ... you method is called and returning the double value ...but you are not saving it any kind of variables , if u wan't ur method to operate on the variable itself you can pass it as a ref parameter this way any change happens to the variable inside ur method will affect the variable globally
```
public static void StoneToPounds(ref double number)
{
number *= 14
}
```
btw the operator \*= could eliminate ur need for a separate function , if u r a beginner then you should now that less code is always better as long as u can keep it clean and organized :D |
1,109,391 | Calculate $S =\displaystyle\sum\_{k=1}^n\frac {1}{k(k+1)(k+2)}$. This sequence is neither arithmetic nor geometric. How can you solve this. Thanks! | 2015/01/18 | [
"https://math.stackexchange.com/questions/1109391",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/139617/"
] | Since $$\frac{1}{k(k+2)} = \frac{1}{2} \frac{2}{k(k+2)} = \frac{1}{2}\left(\frac{1}{k} - \frac{1}{k+2}\right)$$
for all $k$, we have
$$\sum\_{k = 1}^n \frac{1}{k(k+1)(k+2)} = \frac{1}{2}\sum\_{k = 1}^n \left(\frac{1}{k(k+1)} - \frac{1}{(k+1)(k+2)}\right),$$
which telescopes to $$\frac{1}{2}\left(\frac{1}{2} - \frac{1}{(n+1)(n+2)}\right) = \frac{1}{4} - \frac{1}{2(n+1)(n+2)}.$$ | hint: use that $\frac{1}{k(k+1)(k+2)}=- \left( k+1 \right) ^{-1}+1/2\,{k}^{-1}+1/2\, \left( k+2 \right) ^{-1
}
$ |
1,109,391 | Calculate $S =\displaystyle\sum\_{k=1}^n\frac {1}{k(k+1)(k+2)}$. This sequence is neither arithmetic nor geometric. How can you solve this. Thanks! | 2015/01/18 | [
"https://math.stackexchange.com/questions/1109391",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/139617/"
] | $$u\_k = \dfrac{1}{k(k+1)(k+2)} = \dfrac{1}{2k(k+1)} - \dfrac{1}{2(k+1)(k+2)} =
f\_k - f\_{k+1}$$
so $$u\_1 + u\_2 + \cdots u\_n = (f\_1 - f\_2) + (f\_2 - f\_3) + \cdots + (f\_n - f\_{n+1}) = f\_1 - f\_{n+1} =
\dfrac{1}{4} - \dfrac{1}{2(n+1)(n+2)}
$$ | hint: use that $\frac{1}{k(k+1)(k+2)}=- \left( k+1 \right) ^{-1}+1/2\,{k}^{-1}+1/2\, \left( k+2 \right) ^{-1
}
$ |
1,109,391 | Calculate $S =\displaystyle\sum\_{k=1}^n\frac {1}{k(k+1)(k+2)}$. This sequence is neither arithmetic nor geometric. How can you solve this. Thanks! | 2015/01/18 | [
"https://math.stackexchange.com/questions/1109391",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/139617/"
] | The method of partial fractions works for these. You have
$${1 \over x(x+1)(x +2)} = {1 \over 2} \bigg({1 \over x}\bigg) - {1 \over x + 1} + {1 \over 2} \bigg({1 \over x + 2}\bigg)$$
So your sum is the same as
$$\sum\_{k = 1}^{n} \bigg[{1 \over 2} \bigg({1 \over k}\bigg) - {1 \over k + 1} + {1 \over 2} \bigg({1 \over k + 2}\bigg)\bigg]$$
This can be rewritten as
$$\sum\_{k = 1}^{n} \bigg[{1 \over 2}\bigg({1 \over k} - {1 \over k + 1}\bigg) + {1 \over 2}\bigg({1 \over k + 2} - {1 \over k + 1}\bigg)\bigg]$$
Now you have two telescoping sums which you can add. The result will be
$$\bigg({1 \over 2} - {1 \over 2(n + 1)}\bigg) + \bigg({1 \over 2(n + 2)} - {1 \over 4}\bigg)$$
$$= {1 \over 4} -{1 \over 2(n+1)(n+2)}$$ | hint: use that $\frac{1}{k(k+1)(k+2)}=- \left( k+1 \right) ^{-1}+1/2\,{k}^{-1}+1/2\, \left( k+2 \right) ^{-1
}
$ |
1,109,391 | Calculate $S =\displaystyle\sum\_{k=1}^n\frac {1}{k(k+1)(k+2)}$. This sequence is neither arithmetic nor geometric. How can you solve this. Thanks! | 2015/01/18 | [
"https://math.stackexchange.com/questions/1109391",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/139617/"
] | Since $$\frac{1}{k(k+2)} = \frac{1}{2} \frac{2}{k(k+2)} = \frac{1}{2}\left(\frac{1}{k} - \frac{1}{k+2}\right)$$
for all $k$, we have
$$\sum\_{k = 1}^n \frac{1}{k(k+1)(k+2)} = \frac{1}{2}\sum\_{k = 1}^n \left(\frac{1}{k(k+1)} - \frac{1}{(k+1)(k+2)}\right),$$
which telescopes to $$\frac{1}{2}\left(\frac{1}{2} - \frac{1}{(n+1)(n+2)}\right) = \frac{1}{4} - \frac{1}{2(n+1)(n+2)}.$$ | $$u\_k = \dfrac{1}{k(k+1)(k+2)} = \dfrac{1}{2k(k+1)} - \dfrac{1}{2(k+1)(k+2)} =
f\_k - f\_{k+1}$$
so $$u\_1 + u\_2 + \cdots u\_n = (f\_1 - f\_2) + (f\_2 - f\_3) + \cdots + (f\_n - f\_{n+1}) = f\_1 - f\_{n+1} =
\dfrac{1}{4} - \dfrac{1}{2(n+1)(n+2)}
$$ |
1,109,391 | Calculate $S =\displaystyle\sum\_{k=1}^n\frac {1}{k(k+1)(k+2)}$. This sequence is neither arithmetic nor geometric. How can you solve this. Thanks! | 2015/01/18 | [
"https://math.stackexchange.com/questions/1109391",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/139617/"
] | Since $$\frac{1}{k(k+2)} = \frac{1}{2} \frac{2}{k(k+2)} = \frac{1}{2}\left(\frac{1}{k} - \frac{1}{k+2}\right)$$
for all $k$, we have
$$\sum\_{k = 1}^n \frac{1}{k(k+1)(k+2)} = \frac{1}{2}\sum\_{k = 1}^n \left(\frac{1}{k(k+1)} - \frac{1}{(k+1)(k+2)}\right),$$
which telescopes to $$\frac{1}{2}\left(\frac{1}{2} - \frac{1}{(n+1)(n+2)}\right) = \frac{1}{4} - \frac{1}{2(n+1)(n+2)}.$$ | The method of partial fractions works for these. You have
$${1 \over x(x+1)(x +2)} = {1 \over 2} \bigg({1 \over x}\bigg) - {1 \over x + 1} + {1 \over 2} \bigg({1 \over x + 2}\bigg)$$
So your sum is the same as
$$\sum\_{k = 1}^{n} \bigg[{1 \over 2} \bigg({1 \over k}\bigg) - {1 \over k + 1} + {1 \over 2} \bigg({1 \over k + 2}\bigg)\bigg]$$
This can be rewritten as
$$\sum\_{k = 1}^{n} \bigg[{1 \over 2}\bigg({1 \over k} - {1 \over k + 1}\bigg) + {1 \over 2}\bigg({1 \over k + 2} - {1 \over k + 1}\bigg)\bigg]$$
Now you have two telescoping sums which you can add. The result will be
$$\bigg({1 \over 2} - {1 \over 2(n + 1)}\bigg) + \bigg({1 \over 2(n + 2)} - {1 \over 4}\bigg)$$
$$= {1 \over 4} -{1 \over 2(n+1)(n+2)}$$ |
354,770 | I want to insert text in a **defined** (= set with a number, not just "bottom", "center" or "top") vertical position at the side of a figure. I managed to insert text at the side, but I can't figure out how to set the vertical position. Ideally, I would like to add different lines of text on the same side, each one with its position.
Here's what I did:
```
\documentclass{article}
\begin{document}
\begin{figure}[h]
text on the left side
\includegraphics[width=0.5\textwidth]{image}
\end{figure}
\end{document}
```
Alternatively, I can insert text and figure in a tabular, but again I don't know how to set the vertical position of the text:
```
\documentclass{article}
\usepackage[demo]{graphicx}
\begin{document}
\begin{center}
\begin{tabular}{cc}
text on the left & \includegraphics[width=0.5\textwidth]{image}
\end{tabular}
\end{center}
\end{document}
``` | 2017/02/20 | [
"https://tex.stackexchange.com/questions/354770",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/60126/"
] | You can use a normal `tabular` for the text on the left of the image and by specifying some distance after each newline `\\ [<some v. distance>]`, you can control the vertical position of the text. Since pictures are normally placed above the baseline, you need to specify the `[t]` option from `adjustbox` package for the top text line to be adjusted with the top line of the image.
```
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[export]{adjustbox}
\begin{document}
\begin{center}
\begin{tabular}[t]{r}
text on the left1 \\[.5cm]
text on the left2 \\[.5cm]
text on the left3 \\
text on the left4 \\[.5cm]
text on the left5
\end{tabular}
\includegraphics[width=0.5\textwidth,valign=t]{image}
\end{center}
\end{document}
```
>
> [](https://i.stack.imgur.com/foQdB.png)
>
>
>
Another option would be using Ti*K*Z like this:
```
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{center}
\begin{tikzpicture}
\node (p) {\includegraphics[width=0.5\textwidth]{image}};
\node [left] at ($(p.north west)!.1!(p.south west)$) {text on the left1};
\node [left] at ($(p.north west)!.3!(p.south west)$) {text on the left2};
\node [left] at ($(p.north west)!.5!(p.south west)$) {text on the left3};
\node [left] at ($(p.north west)!.7!(p.south west)$) {text on the left4};
\node [left] at ($(p.north west)!.9!(p.south west)$) {text on the left5};
\end{tikzpicture}
\end{center}
\end{document}
```
with a similar (or better) output:
>
> [](https://i.stack.imgur.com/DyRrk.png)
>
>
> | Without using TikZ or the `tabular` environment, one can use the `minipage` environment to split the page in two subpages. Then, the position of the text can be set using the classical spacing and positioning commands `vspace`, `hspace`, `centering`, `flushleft`, `flushright`, etc. For your example, one can code
```
\documentclass{article}
\usepackage[demo]{graphicx}
\begin{document}
\begin{minipage}[b]{0.5\textwidth}
\flushright
text on the left 1
text on the left 2
\vspace{1em}
text on the left 3
\end{minipage}
\begin{minipage}{0.5\textwidth}
\flushleft
\includegraphics[]{image}
\end{minipage}
\end{document}
```
and obtain the following output:
[](https://i.stack.imgur.com/ffzEh.png) |
38,966,527 | I have an articles container:
```
<div ng-controller="articlesCtrl" >
<ul id="articles-container" >
<li class="article">
<div>Article 1</div>
<div>Article Text</div>
</li>
<li>
<div>Article 1</div>
<div>Article Text</div>
</li>
</ul>
</div>
<button ng-click="getArticles();" class="uk-button" >Get Articles</button>
```
Once the button clicked I receive JSON data response and I need to add the received into the articles container.
I'd like to use this Angular template for the purpose:
```
<script type="text/ng-template" id="articles-container.tpl">
<div ng-bind-html="articlesContainer">
<div ng-repeat="article in articles"></div>
<div>{{article.title}}</div>
<div>{{article.text}}</div>
</div>
</script>
```
Please give me directions how I can implement the functionality or where I can see an example.
Thanks for advance. | 2016/08/16 | [
"https://Stackoverflow.com/questions/38966527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I can speak with some authority on this question as I'm the one who wrote this code.
Here is the comparison which is asserting in your example:
<https://github.com/llvm-mirror/libcxx/blob/master/include/algorithm#L3994-L3995>
As the link is likely to go stale (point to the wrong line) as time goes on, I'll also quote the code here:
```
// __m still guards upward moving __i
while (__comp(*__i, *__m))
++__i;
```
This is known as an "unguarded" loop because there is no check for the iterator `__i` running off the end of the sequence as it is incremented. The reason this works is because an invariant of this algorithm is that at this point it is known that `__i <= __m` (which is also in a comment 3 lines above this quote).
If you look at the code above this quote, you will see these comments:
```
// The search going up is known to be guarded but the search coming down isn't.
// Prime the downward search with a guard.
```
So before we get to this point, a guarded search down the sequence is done. That is, this test:
```
if (__i == --__j)
```
After this test finds the lower guard, the algorithm then jumps to the unguarded loops which have only one test per iteration, whereas otherwise there would be two tests per iteration (a test on the iterator and a test on the dereferenced value of the iterator).
The use of "unguarded loops" is the cause of an element being compared with itself. During development I measured that the cost of the one extra comparison in the loop was a better deal than including two comparisons per iteration in the loop.
Of course this is an engineering tradeoff. If the comparison function turned out to be horribly expensive compared to the cost of comparing the iterators themselves, one could come to a different conclusion.
This answer is completely consistent with [rici's answer](https://stackoverflow.com/a/38966593/576911) which is also correct (and I've upvoted it). I added my voice as I could drop the "presumably" and point to specific lines of code in the algorithm. | Presumably, in the opinion of the standard-library authors, it is faster to do a test which is guaranteed to return false than to constantly check for equal indices as well as comparing elements. This might come about because the pivot element is used as a loop sentinel.
It is certainly permitted for the comparison function to be called in this way, and the `assert` in your code is not permitted. |
33,082,011 | i have a problem about looping throught json output on ajax success. this is my code :
```
<?php
$product = mysqli_query($con,select * from product LIMIT 3);
while ($dataproduct = mysqli_fetch_assoc($product) {
echo json_encode(array(
"product" => $dataproduct['product']
));
}
?>
$.ajax({
type : "GET",
url : test.php,
dataType : "json",
success : function(data) {
$.each(data, function() {
$.each(this, function(k, v) {
$("ul").html(data.product);
});
});
}
});
<ul>
<li></li>
</ul>
```
how to make that "ajax success looping
. so i can make an output to "ul" element?
what's wrong with my code? | 2015/10/12 | [
"https://Stackoverflow.com/questions/33082011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5069063/"
] | Why keeping too much processing on end user low power PC. You can generate the output HTML at server side and get the resulted html and put it in your required place in html DOM.
You can change your PHP code to below:
```
<?php
$html = "";
$product = mysqli_query($con,select * from product LIMIT 3);
while ($dataproduct = mysqli_fetch_assoc($product) {
$html .= '<li>'.$dataproduct['product'].'</li>';
}
echo $html;
?>
```
Now you can change your JS to below:
```
$.ajax({
type : "GET",
url : test.php,
dataType : "html",
success : function(data) {
$('ul.product-list').html(data);
}
});
```
Now your html can be like:
```
<ul class="product-list">
<!-- Insert Products here -->
</ul>
```
This code is not tested and is just to give you the idea. Check it at your end and modify it according to your requirements. | Try following, it should work for you:-
```
<?php
$product = mysqli_query($con,select * from product LIMIT 3);
$temp = array();
while ($dataproduct = mysqli_fetch_assoc($product) {
$temp[] = $dataproduct['product'];
}
echo json_encode($temp);
?>
$.ajax({
type : "GET",
url : test.php,
dataType : "json",
success : function(data) {
$.each(data, function(k,v) {
$("ul").html(v);
});
});
}
});
<ul>
<li></li>
</ul>
``` |
33,082,011 | i have a problem about looping throught json output on ajax success. this is my code :
```
<?php
$product = mysqli_query($con,select * from product LIMIT 3);
while ($dataproduct = mysqli_fetch_assoc($product) {
echo json_encode(array(
"product" => $dataproduct['product']
));
}
?>
$.ajax({
type : "GET",
url : test.php,
dataType : "json",
success : function(data) {
$.each(data, function() {
$.each(this, function(k, v) {
$("ul").html(data.product);
});
});
}
});
<ul>
<li></li>
</ul>
```
how to make that "ajax success looping
. so i can make an output to "ul" element?
what's wrong with my code? | 2015/10/12 | [
"https://Stackoverflow.com/questions/33082011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5069063/"
] | Why keeping too much processing on end user low power PC. You can generate the output HTML at server side and get the resulted html and put it in your required place in html DOM.
You can change your PHP code to below:
```
<?php
$html = "";
$product = mysqli_query($con,select * from product LIMIT 3);
while ($dataproduct = mysqli_fetch_assoc($product) {
$html .= '<li>'.$dataproduct['product'].'</li>';
}
echo $html;
?>
```
Now you can change your JS to below:
```
$.ajax({
type : "GET",
url : test.php,
dataType : "html",
success : function(data) {
$('ul.product-list').html(data);
}
});
```
Now your html can be like:
```
<ul class="product-list">
<!-- Insert Products here -->
</ul>
```
This code is not tested and is just to give you the idea. Check it at your end and modify it according to your requirements. | If i'm not totally incorrect, you at first will have to parse the JSON, don't you? Like $.parseJSON(data) and then you may iterate over it.
Also in the outest $.each you do not use key and value, but at least the value will be the one that has further elements as childs. |
60,554,653 | So I have an application that downloads a zip folder with a bunch of audio files in it. I want to encrypt that zip file on download, and then be able to decrypt the zip file at some other point in the application so that it can be extracted. I have basic logic for encryption and decryption using Node's Crypto package and AES-256 with CTR mode, but I can't seem to get a usable zip file at the end of the process.
Here's my http.get request that I use to download the zip file
```
http.get(fileURI).on('response', function(res) {
res.on('data', function(chunk) {
let encryptedChunk = encrypt(chunk);
writeStream.write(encryptedChunk);
}).on('end', function() {
writeStream.end();
})
})
```
So that get request encrypts every chunk of data as its downloaded and sends it to the writeStream which is open to a specific file, and then the writestream is ended when the zip is done downloading. This seems to encrypt correctly, in the sense that I can't open the zip file (a Windows cannot open the folder error pops up).
My encrypt function is very basic that is called in the http request looks like this:
```
function encrypt(data) {
try {
let cipher = crypto.createCipher('aes-256-ctr', key); // key is a random string
let encrypted = Buffer.concat([cipher.update(new Buffer(data, "utf8")), cipher.final()]);
return encrypted;
} catch (exception) {
console.error(exception);
}
}
```
I then have a function that creates a readStream that attempts to decrypt this file, it looks like this:
```
function decryptzip() {
// assume there are a bunch of necessary filepaths up here
let readStream = fs.createReadStream(downloadedZipFilePath);
let writeStream = fs.createWriteStream(newDecryptedZipFilePath);
readStream.on('data', (chunk) => {
let decryptedChunk = decrypt(chunk);
writeStream.write(decryptedChunk); // the goal of this write stream is to have a usable zip file once it closes
}).on('finish', () => {
writeStream.end();
})
}
```
And then my actual decrypt function looks like this:
```
function decrypt(data) {
try {
let decipher = crypto.createDecipher('aes-256-ctr', key); // same key used in encrypt
let decrypted = Buffer.concat([decipher.update(data), decipher.final()]);
return decrypted;
} catch (exception) {
console.error(exception);
}
}
```
Both these encrypt and decrypt functions work find with plain text, but the "decrypted" zip file is still unusable and gives me the "Windows cannot open the folder error" when I try to see whats inside. I really have no clue what I'm doing in terms of this stuff so any help would be appreciated, I'm pretty lost lol. | 2020/03/05 | [
"https://Stackoverflow.com/questions/60554653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7607817/"
] | The issue here is that you are taking chunks of the file, encrypting them separately and then writing those to disk. What you end up with is a bunch of different encrypted parts of a file rather than one encrypted file. You'll want to utilize Node's stream functionalities here probably:
```js
const http = require('http');
const { createWriteStream, createReadStream } = require('fs');
const { createCipheriv, createDecipheriv, randomBytes } = require('crypto');
const { pipeline } = require('stream');
const { promisify } = require('util');
const pipelineAsync = promisify(pipeline);
const downloadAndEncryptFile = async (uri, path) => {
const response = await new Promise((resolve, reject) => {
http.get(uri).on('response', resolve).on('error', reject);
});
const secret = randomBytes(32);
const iv = randomBytes(16);
await pipelineAsync(
response,
createCipheriv('aes-256-ctr', secret, iv),
createWriteStream(path),
);
return { secret: secret.toString('base64'), iv: iv.toString('base64'), path };
};
const decryptFile = async ({ path, secret, iv }) => {
const secretBuf = Buffer.from(secret, 'base64');
const ivBuf = Buffer.from(iv, 'base64');
await pipelineAsync(
createReadStream(path),
createDecipheriv('aes-256-ctr', secretBuf, ivBuf),
createWriteStream(`${path}-decrypted`),
);
};
downloadAndEncryptFile('http://www.google.com/', 'encrypted-path')
.then(decryptFile);
```
In order to encrypt, we:
1. make the request and receive a response object, which is a readable stream,
2. pipe the *entire* response through one cipher,
3. pipe the output of the cipher to a file
By utilizing streams, we keep a lower memory footprint and can pretty efficiently encrypt and decrypt even large files.
The above snippet is ready to run (tested on Node v12.18.3). | The Node crypto API is still sufficiently low-level enough that a lot can go wrong. For example you might want to add an HMAC to the encrypted data to ensure its integrity.
My proposal would be to use a Javascript binding of libsodium or similar so you get an even more high-level API. The native bindings I could find weren't making the most mature impression or using outdated versions of libsodium.
As such, my recommendation would be to go with <https://github.com/dchest/tweetnacl-js> as it has undergone a professional audit. The API is very straightforward, too. |
11,209,132 | ```
array(2) {
[0]=>
array(4) {
["id"]=>
string(1) "1"
["name"]=>
string(3) "Lim"
["subproject_id"]=>
string(1) "5"
["subproject_name"]=>
string(4) "Mads"
}
[1]=>
array(1) {
[0]=>
array(4) {
["id"]=>
string(1) "1"
["name"]=>
string(3) "Lim"
["subproject_id"]=>
string(1) "4"
["subproject_name"]=>
string(5) "KANYE"
}
}
}
```
How can I output each `name` and `subproject_name`?
A simple `foreach()` will only get the first one. | 2012/06/26 | [
"https://Stackoverflow.com/questions/11209132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/267304/"
] | Don't know how much that array could vary, but here is one simple solution.
```
foreach($array as $key => $value){
if(!isset($value['id']))
$value = $value[0];
echo $value['name'];
echo $value['subproject_name'];
}
```
if its getting deeper, you can use 'while' instead of 'if'. | Consult the php documentation, look for "array\_walk" and "array\_walk\_recursive". |
11,209,132 | ```
array(2) {
[0]=>
array(4) {
["id"]=>
string(1) "1"
["name"]=>
string(3) "Lim"
["subproject_id"]=>
string(1) "5"
["subproject_name"]=>
string(4) "Mads"
}
[1]=>
array(1) {
[0]=>
array(4) {
["id"]=>
string(1) "1"
["name"]=>
string(3) "Lim"
["subproject_id"]=>
string(1) "4"
["subproject_name"]=>
string(5) "KANYE"
}
}
}
```
How can I output each `name` and `subproject_name`?
A simple `foreach()` will only get the first one. | 2012/06/26 | [
"https://Stackoverflow.com/questions/11209132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/267304/"
] | Try this:
```
array_walk_recursive($array, function($item, $key) {
if (in_array($key, array('name', 'subproject_name'))) {
echo $item;
}
});
```
See <http://php.net/manual/en/function.array-walk-recursive.php>
Note: for PHP 5.3.0 you can use [callback](http://www.php.net/manual/en/functions.anonymous.php), in earlier versions you need non-anonymous function. | Consult the php documentation, look for "array\_walk" and "array\_walk\_recursive". |
11,209,132 | ```
array(2) {
[0]=>
array(4) {
["id"]=>
string(1) "1"
["name"]=>
string(3) "Lim"
["subproject_id"]=>
string(1) "5"
["subproject_name"]=>
string(4) "Mads"
}
[1]=>
array(1) {
[0]=>
array(4) {
["id"]=>
string(1) "1"
["name"]=>
string(3) "Lim"
["subproject_id"]=>
string(1) "4"
["subproject_name"]=>
string(5) "KANYE"
}
}
}
```
How can I output each `name` and `subproject_name`?
A simple `foreach()` will only get the first one. | 2012/06/26 | [
"https://Stackoverflow.com/questions/11209132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/267304/"
] | Try this:
```
array_walk_recursive($array, function($item, $key) {
if (in_array($key, array('name', 'subproject_name'))) {
echo $item;
}
});
```
See <http://php.net/manual/en/function.array-walk-recursive.php>
Note: for PHP 5.3.0 you can use [callback](http://www.php.net/manual/en/functions.anonymous.php), in earlier versions you need non-anonymous function. | Don't know how much that array could vary, but here is one simple solution.
```
foreach($array as $key => $value){
if(!isset($value['id']))
$value = $value[0];
echo $value['name'];
echo $value['subproject_name'];
}
```
if its getting deeper, you can use 'while' instead of 'if'. |
25,403,082 | Got a table in SQL Server which contains a `varchar` column with date data. Unfortunately the dates are in a whole slew of different formats.
```
2012-05-01
27/05/2012
07MAY2014
19/07/13
```
There may be others, but that's all I've encountered so far.
I need to squeeze these into a `datetime` column into another table, so I've been trying to select them as standard date-time values. At first, I thought that'd be easy:
```
UPDATE myTable
SET myDateColumn = CONVERT(DATETIME, myDateColumn, 103)
WHERE ISDATE(myDateColumn) = 0
```
But the trouble is that SQL Server treats `dd/mm/yy` and `dd/mm/yyyy` as separate formats. The former is code 3, and the latter is code 103. So whichever way I run that update, it chokes on the opposite format.
Is there any way I can select/update based on the date format, and get all these dates converted to a single valid `DateTime` format? | 2014/08/20 | [
"https://Stackoverflow.com/questions/25403082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/271907/"
] | My guess is that you just have to try to differentiate between the different classes and handle each case in the appropriate way. Something like this:
```
declare @tab table (d varchar(20))
insert @tab values ('2012-05-01'),('27/05/2012'),('07MAY2014'),('19/07/13')
select
case
when isnumeric(left(d,4)) = 1 then cast(d as date)
when len(d) = 10 then convert(date, d, 103)
when len(d) = 8 then convert(date, d, 3)
when charindex('/',d) = 0 and isnumeric(d) = 0 then convert(date, d, 106)
end as [date]
from @tab
```
Output:
```
date
----------
2012-05-01
2012-05-27
2014-05-07
2013-07-19
```
It might not be that efficient, but I presume this is a one-off operation. I didn't write it as an update statement, but the query should be easy to adapt, and you should consider adding the converted date as a new proper datetime column if possible in my opinion.
Edit: here's the corresponding update statement:
```
update @tab
set d =
case
when isnumeric(left(d,4)) = 1 then cast(d as date)
when len(d) = 10 then convert(date, d, 103)
when len(d) = 8 then convert(date, d, 3)
when charindex('/',d) = 0 and isnumeric(d) = 0 then convert(date, d, 106)
end
from @tab
``` | For this first you can convert all the data into another format such as `110` the `USA date fromat`, and then further again update the whole table with the desired format. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.