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 |
|---|---|---|---|---|---|
7,488,122 | I have a very basic question about SVN. I know SVN has pretty strict rules about things & was wonedring if I would mess up my project if I tried this.
I use two computers regularly - onsite & from home. I have Eclipse(Galelio) + subclipse(1.6.x) installed on both. If I were to checkout the same project from SVN repository on different machines using the SAME user ID, would there be any sort of problems during commits or updates?
I will be committing from different machines regularly, but of course it will be the same user ID. | 2011/09/20 | [
"https://Stackoverflow.com/questions/7488122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/289918/"
] | You are probably missing the `END` at the end of the stored proc definition that you neglected to show us. I get the same error If I append
```
create proc foo
as
begin
```
to the beginning of your posted code. | Do you have exactly this?
```
CREATE PROCEDURE GetCurrentLoadDate
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
declare @date datetime
declare @vardate varchar(10)
set @date=getDate()
set @vardate=CONVERT(varchar(10), @date ,101)
select tableloaded,insertdatetime,sourcesystemdatetime,FriendlyDescription
from dbo.tbl_loadSourcedates_dttm
where CONVERT(varchar(10), insertdatetime ,101)=@vardate
END
GO
```
Because it looks to me that you are missing something when you declare your proc since you are getting a syntax exception on the very first line. |
23,098 | Is it possible to use a custom route for your plugin's CP section, instead of `cpTrigger/plugin-handle`, or to direct `cpTrigger/plugin-handle` to a different template other than `plugin-handle/index.twig`? | 2017/12/07 | [
"https://craftcms.stackexchange.com/questions/23098",
"https://craftcms.stackexchange.com",
"https://craftcms.stackexchange.com/users/3613/"
] | Whoops, sorry, just found out that Github Pages only works with static content (No PHP, No database).
Closing. | Cloudways support Git Deployment. Using this you could have your site on Git and make continuous pushes from anywhere and pull it through Cloudways Control panel. For more information about this you could visit [here](https://support.cloudways.com/using-git-for-deployment/) |
20,728,377 | I have a WPF app which is going to be deployed to multiple users on a LAN. The users of this app will be factory workers in a manufacturing company, who will be using the app to update their progress on each order.
The customer also has an ASP.NET webforms app which is used for entering orders among other things. What I want to build in this ASP.NET app is a screen that will give live updates of the progress of the factory workers. I've been looking at SignalR for this, but I'm unsure about whether it'll let me send updates from a separate application (I.e WPF to the WebForms app). Is this possible? If so are there any examples of cross application SignalR use online?
Thanks! | 2013/12/22 | [
"https://Stackoverflow.com/questions/20728377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/460407/"
] | Try it
You need to `ClientID`
```
document.getElementById('<%=hdn_empname.ClientID%>').value = 1;
```
I found out your main problems
>
> The hidden field values will assign after the if condition call.
>
>
>
**Edit :**
So, You need to call your logic's in javascript side using ajax
```
if (confirm("Employee Introduced already.Continue?") == true) {
//some code to execute
}
``` | `hdn_empname` is server controls Id which is different from client sided id, to get client sided id you need to use ClientID
try this:
```
document.getElementById('<%=hdn_empname.ClientID%>').value = "1";
```
You dont need to compare
```
if (confirm("Employee Introduced already.Continue?") == true)
```
this will work:
```
if (confirm("Employee Introduced already.Continue?"))
``` |
20,728,377 | I have a WPF app which is going to be deployed to multiple users on a LAN. The users of this app will be factory workers in a manufacturing company, who will be using the app to update their progress on each order.
The customer also has an ASP.NET webforms app which is used for entering orders among other things. What I want to build in this ASP.NET app is a screen that will give live updates of the progress of the factory workers. I've been looking at SignalR for this, but I'm unsure about whether it'll let me send updates from a separate application (I.e WPF to the WebForms app). Is this possible? If so are there any examples of cross application SignalR use online?
Thanks! | 2013/12/22 | [
"https://Stackoverflow.com/questions/20728377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/460407/"
] | Where is your break point? If reader2.HasRows returns true your javascript will be registered. But it set the value on client and you get the result after postback. | `hdn_empname` is server controls Id which is different from client sided id, to get client sided id you need to use ClientID
try this:
```
document.getElementById('<%=hdn_empname.ClientID%>').value = "1";
```
You dont need to compare
```
if (confirm("Employee Introduced already.Continue?") == true)
```
this will work:
```
if (confirm("Employee Introduced already.Continue?"))
``` |
3,633,481 | getting below error in IBM AIX server "JVMJ9VM015W Initialization error for library j9gc23(2): Failed to instantiate heap. 3584M requested" how to resolve the proble ? i want to increase the heap menmory up to 10gb | 2010/09/03 | [
"https://Stackoverflow.com/questions/3633481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/438672/"
] | `operator int()` is a *conversion function* that declares a user-defined conversion from `A` to `int` so that you can write code like
```
A a;
int x = a; // invokes operator int()
```
This is different from `int operator()()`, which declares a function-call operator that takes no arguments and returns an `int`. The function-call operator allows you to write code like
```
A a;
int x = a(); // invokes operator()()
```
Which one you want to use depends entirely on the behavior that you want to get. Note that conversion operators (e.g., `operator int()`) can get invoked at unexpected times and can cause pernicious errors. | you can use this one
```
#include <iostream>
using namespace std;
class A{
public:
A(int n) { _num=n;}
operator int();
private:
int _num;
};
A::operator int(){
return _num;
}
int main(){
A a(10);
cout<<a.operator int()<<endl;
return 0;
}
``` |
48,100,432 | I have multiple small files in parquet format in a given HDFS location (the count is incremental for a given month as we receive two or more files per day for a given month). When I try to read the files from the HDFS location in SPARK 2.1 the time taken to read these files is more and is incremental when more small files are added to the given location.
Since the files are small I do not want to partition any further in HDFS.
Partitions are created by creating directories on HDFS and then the files are placed in those directories.
File format is Parquet.
Is there any other format or process to read all the small files at once so that I can reduce the small files reading time.
Note:
1) Trying to create a program which can merge all the small files to one single file will add additional processing over head to my over all SLA to complete my process so I would keep this as my last option. | 2018/01/04 | [
"https://Stackoverflow.com/questions/48100432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7460319/"
] | If you don't want to merge your files, you should consider redesigning upstream process to limit the number of created files in the first place. If producer is Spark you can for example `coalesce` or `repartition` ([Spark dataframe write method writing many small files](https://stackoverflow.com/q/44459355)) the data before writing.
Other than this (or merging as a separate step) there is not much you can do. Reading small files is just expensive. Adjusting [`spark.sql.files.openCostInBytes`](https://spark.apache.org/docs/latest/sql-programming-guide.html#other-configuration-options):
>
> The estimated cost to open a file, measured by the number of bytes could be scanned in the same time. This is used when putting multiple files into a partition. It is better to over estimated, then the partitions with small files will be faster than partitions with bigger files (which is scheduled first).
>
>
>
might help to some extent, but I wouldn't expect miracles. | Please try wholeTextFiles!
That works for many small files. |
47,128,753 | I have an application on Google Cloud Platform that uses FireStore as the Database.
I am getting this error when trying to insert records on FireStore.
```
google.api_core.exceptions.NotFound: 404 The project "book-shop-c73ec" does not
exist or it does not contain an active Cloud Datastore database. Please visit ht
tp://console.cloud.google.com to create a project or https://console.cloud.googl
e.com/datastore/setup?project="book-shop-c73ec" to add a Cloud Datastore databas
e. Note that Cloud Datastore always has an associated App Engine app and this ap
p must not be disabled.
```
This is the sample code I am using.
```
from google.cloud import firestore
# Add a new document
db = firestore.Client()
doc_ref = db.collection(u'users').document(u'alovelace')
doc_ref.set({
u'first': u'Ada',
u'last': u'Lovelace',
u'born': 1815
})
# Then query for documents
users_ref = db.collection(u'users')
docs = users_ref.get()
for doc in docs:
print(u'{} => {}'.format(doc.id, doc.to_dict()))
```
My application is enabled on app engine :
[](https://i.stack.imgur.com/vzivw.png)
And when I go to the DataStore Tab, I am pointed to FireStore.
[](https://i.stack.imgur.com/OFQs1.png)
Did I miss any step here?
Found this [link](https://stackoverflow.com/questions/36560659/google-cloud-datastore-api-cannot-find-project-when-app-engine-application-is-di), but its just suggesting to enable the app on app engine, which I already did. | 2017/11/06 | [
"https://Stackoverflow.com/questions/47128753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4364985/"
] | It was just an error on my environment variable on windows.
I had set it to
```
set GCLOUD_PROJECT="project-name"
```
instead
```
set GCLOUD_PROJECT=project-name
``` | I was having this exact error, but my problem was that app engine was disabled in the project, enabling it solved the problem and I was able to upgrade to Firestore. |
47,128,753 | I have an application on Google Cloud Platform that uses FireStore as the Database.
I am getting this error when trying to insert records on FireStore.
```
google.api_core.exceptions.NotFound: 404 The project "book-shop-c73ec" does not
exist or it does not contain an active Cloud Datastore database. Please visit ht
tp://console.cloud.google.com to create a project or https://console.cloud.googl
e.com/datastore/setup?project="book-shop-c73ec" to add a Cloud Datastore databas
e. Note that Cloud Datastore always has an associated App Engine app and this ap
p must not be disabled.
```
This is the sample code I am using.
```
from google.cloud import firestore
# Add a new document
db = firestore.Client()
doc_ref = db.collection(u'users').document(u'alovelace')
doc_ref.set({
u'first': u'Ada',
u'last': u'Lovelace',
u'born': 1815
})
# Then query for documents
users_ref = db.collection(u'users')
docs = users_ref.get()
for doc in docs:
print(u'{} => {}'.format(doc.id, doc.to_dict()))
```
My application is enabled on app engine :
[](https://i.stack.imgur.com/vzivw.png)
And when I go to the DataStore Tab, I am pointed to FireStore.
[](https://i.stack.imgur.com/OFQs1.png)
Did I miss any step here?
Found this [link](https://stackoverflow.com/questions/36560659/google-cloud-datastore-api-cannot-find-project-when-app-engine-application-is-di), but its just suggesting to enable the app on app engine, which I already did. | 2017/11/06 | [
"https://Stackoverflow.com/questions/47128753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4364985/"
] | It was just an error on my environment variable on windows.
I had set it to
```
set GCLOUD_PROJECT="project-name"
```
instead
```
set GCLOUD_PROJECT=project-name
``` | **GCLOUD\_PROJECT** is already deprecated in favor of **GOOGLE\_CLOUD\_PROJECT**, where btw you are expected to set **the project id and not the name**! |
47,128,753 | I have an application on Google Cloud Platform that uses FireStore as the Database.
I am getting this error when trying to insert records on FireStore.
```
google.api_core.exceptions.NotFound: 404 The project "book-shop-c73ec" does not
exist or it does not contain an active Cloud Datastore database. Please visit ht
tp://console.cloud.google.com to create a project or https://console.cloud.googl
e.com/datastore/setup?project="book-shop-c73ec" to add a Cloud Datastore databas
e. Note that Cloud Datastore always has an associated App Engine app and this ap
p must not be disabled.
```
This is the sample code I am using.
```
from google.cloud import firestore
# Add a new document
db = firestore.Client()
doc_ref = db.collection(u'users').document(u'alovelace')
doc_ref.set({
u'first': u'Ada',
u'last': u'Lovelace',
u'born': 1815
})
# Then query for documents
users_ref = db.collection(u'users')
docs = users_ref.get()
for doc in docs:
print(u'{} => {}'.format(doc.id, doc.to_dict()))
```
My application is enabled on app engine :
[](https://i.stack.imgur.com/vzivw.png)
And when I go to the DataStore Tab, I am pointed to FireStore.
[](https://i.stack.imgur.com/OFQs1.png)
Did I miss any step here?
Found this [link](https://stackoverflow.com/questions/36560659/google-cloud-datastore-api-cannot-find-project-when-app-engine-application-is-di), but its just suggesting to enable the app on app engine, which I already did. | 2017/11/06 | [
"https://Stackoverflow.com/questions/47128753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4364985/"
] | I was having this exact error, but my problem was that app engine was disabled in the project, enabling it solved the problem and I was able to upgrade to Firestore. | **GCLOUD\_PROJECT** is already deprecated in favor of **GOOGLE\_CLOUD\_PROJECT**, where btw you are expected to set **the project id and not the name**! |
58,501,850 | I'm a beginner with google mock and I'm not sure how to use it and the concept.
If I'm trying to Test a method from a class that is calling some other methods from different classes.
Do I need to mock all these methods from this different classes that my Test method is calling.
Here is a example:
```
class A {
public:
A () {}
int setnum(int num) {//do some stuff return 1 or 0//
}
private:
int _num;
};
class B {
public:
B (){}
int init(A *a, int number){
if(a->setnum(number))
return 1;
return 0;
}
void setNum(int num){_num=num;}
private:
A *_a;
int _num;
};
class C {
public:
int doSoemthing(A *a, int number){
if (domore(a,number))
return 1;
return 0;
}
int domore(A *a, int number){
if(_b.init(a,number))
return 1;
return 0;
;}
private:
B _b;
};
```
Do I need to mock all the methods from class A and B that I need to Test my Test method?
Or can I just mock one Class , and test if this class is working. | 2019/10/22 | [
"https://Stackoverflow.com/questions/58501850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7902477/"
] | In order to test C class with mocks, you need to introduce an interface for the dependency than is to be used in C class (here, added BIface). Then you need to use dependency injection of BIface to C class (via added ctor). Having that you will be able to test interactions of B and C classes. IMO A class doesn't need to be mocked in CTest (but most probably need to be tested in BTest)
```
class A {
public:
A() {} // not needed
int setnum(int num) { // do some stuff return 1 or 0//
}
private:
int _num;
};
class BIface {
public:
virtual ~BIface() = default;
virtual int init(A *a, int number) = 0;
virtual void setNum(int num) = 0;
};
class B : public BIface {
public:
B() {} // not needed
int init(A *a, int number) override {
if (a->setnum(number))
return 1;
return 0;
}
void setNum(int num) override {
_num = num;
}
private:
A *_a;
int _num;
};
class C {
public:
C(BIface &b) : _b{b} {}
int doSoemthing(A *a, int number) {
if (domore(a, number))
return 1;
return 0;
}
int domore(A *a, int number) {
if (_b.init(a, number))
return 1;
return 0;
;
}
private:
BIface &_b;
};
class BIfaceMock : public BIface {
public:
MOCK_METHOD2(init, int(A *, int));
MOCK_METHOD1(setNum, void(int));
};
TEST(CTest, givenDoingMoreWhenInitOfBReturnOneThenReturnOne) {
// can be done in CTest ctor if more tests are needed to avoid code duplciation
BIfaceMock bMock{};
A a{}; // `a` doesn't need to be mocked in CTest. It shall be mocked in BTest as it is dependency of B class, not C class
C testedObject{bMock}; // dependency injection of BFace to C
const auto SOME_INT_PARAM = 42;
// Eq mather is used to match both &a and SOME_INT_PARAM. This confirms proper parameters were passed to init
EXPECT_CALL(bMock, init(&a, SOME_INT_PARAM)).WillOnce(Return(1));
ASSERT_EQ(1, testedObject.domore(&a, SOME_INT_PARAM));
}
``` | I'm not 100% sure but in your example you don't have to use mocks at all. You can create your objects really easy here.
I would use mocks when I would expect that some method will be called and should return specific value - I'm not testing this method but for example if-statment:
```
A a;
if(a.method())
{
// some logic
}
```
* To manipulate what if will get I would use mocks like this: `EXPECT_CALL(aMock.method()).WillOnce(Return(true));`
But you can use it in many more situations (e.g: you can avoid creating really big class and replace it with mock object). |
59,795,353 | I’ve been spinning around a bit on how to accomplish this in SQL DW. I need to extract the text between two periods in a returned value. So my value returned for Result is:
[](https://i.stack.imgur.com/G7VOC.png)
I’m trying to extract the values between period 1 and 2, so the red portion above:
[](https://i.stack.imgur.com/CtvEI.png)
The values will be a wide variety of lengths.
I’ve got this code:
`substring(Result,charindex('.',Result)+1,3) as ResultMid`
that results in this:
[](https://i.stack.imgur.com/tOGiN.png)
My problem is I’m not sure how to get to a variable length to return so that I can pull the full value between the two periods. Would someone happen to know how I can accomplish this?
Thx,
Joe | 2020/01/17 | [
"https://Stackoverflow.com/questions/59795353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4495150/"
] | We can build on your current attempt:
```
substring(
result,
charindex('.', result) + 1,
charindex('.', result, charindex('.', result) + 1) - charindex('.', result) - 1
)
```
Rationale: you alreay have the first two arguments to `substring()` right. The third argument defines the number of characters to capture. For this, we compute the position of the *next* dot (`.`) with expression: `charindex('.', result, charindex('.', result) + 1)`. Then we substract the position of the first dot from that value, which gives us the number of characters that we should capture.
**[Demo on DB Fiddle](https://dbfiddle.uk/?rdbms=sqlserver_2017&fiddle=253a8a4e817ab78adcc4bfe1deee6c46)**:
```
result | result_mid
:----------------------- | :---------
sam.pdc.sys.paas.l.com | pdc
sm.ridl.sys.paas.m.com | ridl
s.sandbox.sys.paas.g.com | sandbox
``` | If you are dealing with up to 128 characters per delimited part of the string, try `parsename` as below. Otherwise, GMB has a pretty solid solution up there.
```
select *, parsename(left(result,charindex('.',result,charindex('.',result)+1)-1),1) as mid
from your_table;
```
Another method that you can easily modify to extract 3rd, 4th...(hopefully not too remote) part of the string using `cross apply`.
```
select result, mid
from your_table t1
cross apply (select charindex('.',result) as i1) t2
cross apply (select charindex('.',result,(i1 + 1)) as i2) t3
cross apply (select substring(result,(i1+1),(i2-i1-1)) as mid) t4;
```
**[DEMO](https://dbfiddle.uk/?rdbms=sqlserver_2017&fiddle=2f46c51fa28e128877cbea3f3cac5172)** |
73,176 | Wright Pianoforte Tutor -
Around a year and half back, after I started my tentative steps towards learning piano at the ripe age of 50, My then tutor in Mumbai suggested this book to me. While it was available in a city music store I was surprised to see very little reference of this book on the internet. Most recordings of from the book on the YouTube, although not many, came from India only. The book however is printed in England.
I had on my own purchase Alfred's adult all in one level 1.
Side by side, I preferred the latter much more but kept on persevering on the first book as well. However when there was the longish break in my lessons on account of move across the country, I totally weaned off the first book.
I took another break, (not from playing) from my present tutor in this month, and on a whim, reopened the book - and faced these two pieces. And I am totally at a loss!!
My questions are:
1. Doesn't the first piece sound very un-melodic? In fact, I don't know what that 8th bar is doing?
2. What are these pieces teaching? Especially the LH movements in the second piece?
3. And, (I know that this is subjective), aren't these pieces a tad too difficult (technically) as early pieces in a beginner book?! | 2018/07/29 | [
"https://music.stackexchange.com/questions/73176",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/35326/"
] | Good question; it's important to know what skills are being emphasized with etudes like these.
1. The first piece is a little un-melodic, but that's probably because this piece is *designed to test right hand parallel thirds*. In doing so, they wanted the notes themselves to be very easy, so they stuck with a clear five-finger setup. Notice how your right hand really never moves away from the C–G range; your thumb sticks on C, your pinky is on G, and the other fingers just fall right in place. (The only exception to this is when the thumb hops down to B a couple of times.) By sticking with this range limitation, it's understandably tough for them to create the most memorable melody. (Note: As Todd Wilcox correctly says in the comments, this piece may also serve to introduce the player to the waltz style.)
2. The second piece seems to be getting the player comfortable with the [Alberti bass](https://en.wikipedia.org/wiki/Alberti_bass), a very common left hand arpeggiated figure in the Classical style. If you ever have intentions of playing any Classical piano sonatas, you must become comfortable with the Alberti bass.
3. Yes, they're probably a bit difficult for early pieces in a beginner's piano book. But that really all depends on how "early" it is and just how "beginner" of a book it is. | I would give my beginning students pieces like these a little bit after they finish book 1 (kid version) of the Alfred series.
I don't find those pieces to be too difficult for a beginner who has built up a little experience, though the second one is significantly more difficult than the first. They are probably grouped together for fitting on the page.
Any note on the piano can be played by any finger, so I try to get my students away from "positions" as soon as possible. What matters is what finger plays each note, because it is fingering that really sets up the pianist's ability to move from place to place on the piano.
Both these pieces are missing articulation, dynamic, and phrasing markings, which contribute to the impression of a lack of musicality. I believe if they were added in, the character of the pieces would improve.
I would recommend this book if you are looking for beginner classical pieces. The book contains pieces of a wide variety of difficulty, though all are at the beginner level.
[https://www.amazon.com/Joy-First-Classics/dp/0825680662/ref=sr\_1\_1?ie=UTF8&qid=1532859942&sr=8-1&keywords=joy+of+classics+piano](https://rads.stackoverflow.com/amzn/click/0825680662) |
73,176 | Wright Pianoforte Tutor -
Around a year and half back, after I started my tentative steps towards learning piano at the ripe age of 50, My then tutor in Mumbai suggested this book to me. While it was available in a city music store I was surprised to see very little reference of this book on the internet. Most recordings of from the book on the YouTube, although not many, came from India only. The book however is printed in England.
I had on my own purchase Alfred's adult all in one level 1.
Side by side, I preferred the latter much more but kept on persevering on the first book as well. However when there was the longish break in my lessons on account of move across the country, I totally weaned off the first book.
I took another break, (not from playing) from my present tutor in this month, and on a whim, reopened the book - and faced these two pieces. And I am totally at a loss!!
My questions are:
1. Doesn't the first piece sound very un-melodic? In fact, I don't know what that 8th bar is doing?
2. What are these pieces teaching? Especially the LH movements in the second piece?
3. And, (I know that this is subjective), aren't these pieces a tad too difficult (technically) as early pieces in a beginner book?! | 2018/07/29 | [
"https://music.stackexchange.com/questions/73176",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/35326/"
] | Good question; it's important to know what skills are being emphasized with etudes like these.
1. The first piece is a little un-melodic, but that's probably because this piece is *designed to test right hand parallel thirds*. In doing so, they wanted the notes themselves to be very easy, so they stuck with a clear five-finger setup. Notice how your right hand really never moves away from the C–G range; your thumb sticks on C, your pinky is on G, and the other fingers just fall right in place. (The only exception to this is when the thumb hops down to B a couple of times.) By sticking with this range limitation, it's understandably tough for them to create the most memorable melody. (Note: As Todd Wilcox correctly says in the comments, this piece may also serve to introduce the player to the waltz style.)
2. The second piece seems to be getting the player comfortable with the [Alberti bass](https://en.wikipedia.org/wiki/Alberti_bass), a very common left hand arpeggiated figure in the Classical style. If you ever have intentions of playing any Classical piano sonatas, you must become comfortable with the Alberti bass.
3. Yes, they're probably a bit difficult for early pieces in a beginner's piano book. But that really all depends on how "early" it is and just how "beginner" of a book it is. | "The Wright Pianoforte Tutor" is a bit old-fashioned, but none the worse for that! I've seen it in many British piano stools. We still play melodies in 3rds and 'Alberti' patterns in the LH. (Not sure why @jjmusicnotes says it isn't Alberti?)
If these are too hard for you, come back to them later. |
73,176 | Wright Pianoforte Tutor -
Around a year and half back, after I started my tentative steps towards learning piano at the ripe age of 50, My then tutor in Mumbai suggested this book to me. While it was available in a city music store I was surprised to see very little reference of this book on the internet. Most recordings of from the book on the YouTube, although not many, came from India only. The book however is printed in England.
I had on my own purchase Alfred's adult all in one level 1.
Side by side, I preferred the latter much more but kept on persevering on the first book as well. However when there was the longish break in my lessons on account of move across the country, I totally weaned off the first book.
I took another break, (not from playing) from my present tutor in this month, and on a whim, reopened the book - and faced these two pieces. And I am totally at a loss!!
My questions are:
1. Doesn't the first piece sound very un-melodic? In fact, I don't know what that 8th bar is doing?
2. What are these pieces teaching? Especially the LH movements in the second piece?
3. And, (I know that this is subjective), aren't these pieces a tad too difficult (technically) as early pieces in a beginner book?! | 2018/07/29 | [
"https://music.stackexchange.com/questions/73176",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/35326/"
] | "The Wright Pianoforte Tutor" is a bit old-fashioned, but none the worse for that! I've seen it in many British piano stools. We still play melodies in 3rds and 'Alberti' patterns in the LH. (Not sure why @jjmusicnotes says it isn't Alberti?)
If these are too hard for you, come back to them later. | I would give my beginning students pieces like these a little bit after they finish book 1 (kid version) of the Alfred series.
I don't find those pieces to be too difficult for a beginner who has built up a little experience, though the second one is significantly more difficult than the first. They are probably grouped together for fitting on the page.
Any note on the piano can be played by any finger, so I try to get my students away from "positions" as soon as possible. What matters is what finger plays each note, because it is fingering that really sets up the pianist's ability to move from place to place on the piano.
Both these pieces are missing articulation, dynamic, and phrasing markings, which contribute to the impression of a lack of musicality. I believe if they were added in, the character of the pieces would improve.
I would recommend this book if you are looking for beginner classical pieces. The book contains pieces of a wide variety of difficulty, though all are at the beginner level.
[https://www.amazon.com/Joy-First-Classics/dp/0825680662/ref=sr\_1\_1?ie=UTF8&qid=1532859942&sr=8-1&keywords=joy+of+classics+piano](https://rads.stackoverflow.com/amzn/click/0825680662) |
113,255 | 
What I'd like to know is the best and least expensive way to dress up an old concrete storage floor ? I thought about paint or stain or a mixture of both. Do u have any suggestions? | 2017/04/20 | [
"https://diy.stackexchange.com/questions/113255",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/68734/"
] | Linoleum square tiles are cheap, ~0.88/ea and can be cut/scored with a utility knife and then snapped but the floor needs to be sound and flat. All high spots removed. Do a search for installing linoleum square tiles. | There are a lot of options. Asking for "the best" depends on your values—not anybody else—so I list options and you choose.
* Skim coat with more concrete. This makes the appearance uniform and smooths over deviations. However, this introduces a "step up" edge which may be undesirable.
* Sanding/grinding the surface. This is the most messy, noisy, and likely the most perilous. What if there is some subsurface reinforcing bar (re bar)? What if the concrete is thin in some spots?
* Flooring: tile, linoleum, wood laminate, carpet, hardwood, etc.
If you are okay with a painting solution, maybe also reduce the amount of light in the room. :-) |
3,048,967 | I had been reading [this](https://math.stackexchange.com/questions/2985740/let-%CE%B1-be-an-ordinal-and-a-be-a-set-of-ordinals-then-sup-limits-%CE%B2%E2%88%88a-%CE%B1%CE%B2).
In the proof, below lemma is used. I don't know how to go for proving it.*Notice that I want to prove this theorem for set of ordinals not real numbers*
>
> Let $B,C$ be sets, $B\subseteq C$ such that $\forall c∈C,\exists b\in B: c\le b$.
> Then $\sup B=\sup C$.
>
>
>
>
> | 2018/12/21 | [
"https://math.stackexchange.com/questions/3048967",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/108744/"
] | First of all $B\subseteq C$, so any upper bound of $C$ is an upper bound of $B$, hence $\sup C$ is an upper bound of $B$. Because $\sup B$ is the least upper bound of $B$ we conclude that $\sup B\leq\sup C$.
Now let any $c\in C$. There is an element $b\in B$ such that $c\leq b\leq \sup B$. Hence $\sup B$ is an upper bound of $C$. But $\sup C$ is the least upper bound of $C$, so we conclude $\sup C\leq\sup B$. | This holds generally in partially ordered sets.
>
> *Let $B\subseteq C$ be subsets of the partially ordered set $(X,\le)$. Suppose that, for every $c\in C$ there exists $b\in B$ such that $c\le b$. If one among $B$ and $C$ has the supremum, then both have and they are equal.*
>
>
>
Consider $B^\*$ the set of upper bounds of $B$ and define similarly $C^\*$. From $B\subseteq C$ it follows that $C^\*\subseteq B^\*$.
Let $x\in B^\*$ and suppose $c\in C$. Then there is $b\in B$ such that $c\le b$. As $b\le x$, we have $c\le x$. Hence $x\in C^\*$.
Therefore $B^\*=C^\*$ and the statement follows.
If $X$ is a set of ordinals, then every upper bounded subset of $X$ has the supremum (but a subset may not be upper bounded). |
24,404,224 | I am using Parse loginViewController to Log In the User via Facebook. I just cant figure out how to call the Graph API in Swift. I found the following on Parse
```
[PFFacebookUtils logInWithPermissions:permissionsArray block:(PFUseruser, NSError error) { if (user) {
[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Store the current user's Facebook ID on the user
[[PFUser currentUser] setObject:[result objectForKey:@"id"]
forKey:@"fbId"];
[[PFUser currentUser] saveInBackground];
}
}];
} }];
```
But I cant seem to translate it into Swift. I am trying to run this inside the following function:
```
func logInViewController(controller: PFLogInViewController, didLogInUser user: PFUser) -> Void
``` | 2014/06/25 | [
"https://Stackoverflow.com/questions/24404224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3720883/"
] | ```
func logInViewController(logInController: PFLogInViewController!, didLogInUser user: PFUser!) -> Void
{
FBRequestConnection.startForMeWithCompletionHandler({connection, result, error in
if !error
{
PFUser.currentUser().setObject(result.id as? String, forKey: "fbId")
PFUser.currentUser().saveInBackground()
}
else
{
println("Error")
}
})
}
``` | ```
func getFBData(user: PFUser!){
FBRequestConnection.startForMeWithCompletionHandler({connection, result, error in
if (error != nil) {
println(result)
}else {
println("Error")
}
})
}
``` |
10,394,010 | There are quite a few tutorials on how to access crash reports [using a computer](http://iphonedevelopertips.com/debugging/locating-crash-reports.html), but what I would like my app to do is scan for crash reports (from itself) on startup--so that users can use my app to send me their reports. Is this possible? | 2012/05/01 | [
"https://Stackoverflow.com/questions/10394010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1046898/"
] | [PLCrashReporter](https://www.plcrashreporter.org/) is an open source crash reporting framework that can be added to an iOS App. Reports are generated in protobuf encoded format, which should allow an app to upload these reports to a server. | Take a look at these few resources that may have the solution you need:
* ~~<https://testflightapp.com/>~~
* <http://www.hockeyapp.net/>
* <http://quincykit.net/> |
10,394,010 | There are quite a few tutorials on how to access crash reports [using a computer](http://iphonedevelopertips.com/debugging/locating-crash-reports.html), but what I would like my app to do is scan for crash reports (from itself) on startup--so that users can use my app to send me their reports. Is this possible? | 2012/05/01 | [
"https://Stackoverflow.com/questions/10394010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1046898/"
] | [PLCrashReporter](https://www.plcrashreporter.org/) is an open source crash reporting framework that can be added to an iOS App. Reports are generated in protobuf encoded format, which should allow an app to upload these reports to a server. | You can get them using your itunes connect account
```
When the user synchronizes their device using iTunes, crash reports are copied to a
directory on the user's computer. If the application was distributed via the App Store and
the user has chosen to submit crash logs to Apple, the crash log will be uploaded and the
developer can download it via iTunes Connect.
```
You can also use [Crittercism](http://www.crittercism.com/) which directly sends you an email once a crash happens. |
10,394,010 | There are quite a few tutorials on how to access crash reports [using a computer](http://iphonedevelopertips.com/debugging/locating-crash-reports.html), but what I would like my app to do is scan for crash reports (from itself) on startup--so that users can use my app to send me their reports. Is this possible? | 2012/05/01 | [
"https://Stackoverflow.com/questions/10394010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1046898/"
] | [PLCrashReporter](https://www.plcrashreporter.org/) is an open source crash reporting framework that can be added to an iOS App. Reports are generated in protobuf encoded format, which should allow an app to upload these reports to a server. | Another proprietary (but free) framework you can use for crash reporting is [Crashlytics](http://crashlytics.com/ "Crashlytics"). |
7,304,033 | As far as I know, we use SqlTransaction to enable rollback if a statement in a batch of commands fails. My question is, is it necessary to use SqlTransaction when retrieving data/using select statements? | 2011/09/05 | [
"https://Stackoverflow.com/questions/7304033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/724689/"
] | No, it is not necessary. Each Sql statement has an implicit transaction. But it can be useful if either the default transaction is not optimal - such as a Read Uncommitted would be better - or if you have multiple reads and you want the data to be consistent - such as separate statements for the summary and detail and you want the detail to add up to the summary. | No, there's no need to do this. Transactions are only needed if you want to recover from error on an insert/update/delete operation. If you can't read something, tough luck, but data integrity won't be affected. |
38,361,657 | **HERE IS WHAT I DO NOT EXPECT**
Strangely, the `<picture>` appears to have its own location and height below the image itself. Its CSS `height` is set to `auto`, so I'm unsure where this height of `18px` is coming from.
**HERE IS THE EXPECTED BEHAVIOR**
The `<picture>` to contain the `<img>` within the `<picture>`. The `<picture>` to have the same height as what is contained within it in the HTML/DOM, e.g. the `<img>`.
**HERE IS WHAT I'VE DONE TO TRY TO FIX THE PROBLEM**
I've tried removing the [PictureFill](https://github.com/scottjehl/picturefill) library we're using to ensure the image fills the container, but that's not what is affecting that height.
I've also tried inspecting the DOM to see where the height of `<picture>` is coming from. There is no padding or margin or height set on this element. The only content is its `<source>` and `<img>`, which are standard included elements for a `<picture>`.
Any help or insight is highly appreciated. [Example code on JSBin](http://jsbin.com/foweyepozo/edit?html,output)!
**HERE IS THE EXAMPLE CODE**
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<picture content="https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a">
<source srcset="
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=480&rect=0%2C205%2C3264%2C1632&s=d3ce62073acf8faef26303df602d98ca 480w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=600&rect=0%2C205%2C3264%2C1632&s=299ee1965b7991d853f1c74ece47a4fc 600w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=800&rect=0%2C205%2C3264%2C1632&s=7b00f35515de1a75308074e0b8531606 800w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a 1000w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=2000&rect=0%2C205%2C3264%2C1632&s=03b760c29e398261cef276c2bdb0fcb2 2000w
" sizes="100vw">
<img class="listing-hero-image js-picturefill-img" data-automation="listing-hero-image" alt="The Cat is in the (Hockey) Bag">
</picture>
</body>
</html>
```
**HERE IS A SCREENSHOT OF WHAT I AM SEEING**
[](https://i.stack.imgur.com/FbLiG.jpg) | 2016/07/13 | [
"https://Stackoverflow.com/questions/38361657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1003754/"
] | **CORRECTION**
@Alohci's assessment in the answer below is correct. However, in this case, applying `display: block` to the contained `<img>` rather than the outer `<picture>` solves the problem. Doing so forces the `<picture>` container to take on the size of the block level `<img>`.
Turns out the answer to this question is somewhat based in the vertical alignment of the `<img>`, not the structure of the `<picture>` element. This Stack Overflow answer appears to fix the issue:
[Why is there space under the image in this code?](https://stackoverflow.com/questions/15796414/why-is-there-space-under-the-image-in-this-code) | I found the following in [**WHATWG**](https://html.spec.whatwg.org/multipage/embedded-content.html#the-picture-element):
>
> The picture element is somewhat different from the similar-looking video and audio elements. While all of them contain source elements, the source element's src attribute has no meaning when the element is nested within a picture element, and the resource selection algorithm is different. **Also, the picture element itself does not display anything; it merely provides a context for its contained img element that enables it to choose from multiple URLs.**
>
>
>
1. Why does my HTML5 `<picture>` have a height outside of its `<img>`?
This implies that the `<picture>` element doesn't take on the dimensions of it's children, including `<img>`. I say *implies* because the description does not explicitly says: *`<picture>` does not have the dimensions of `<img>`*, but if it doesn't actually display the `<img>`, then it's safe to assume it won't have the dimensions of said `<img>`.
2. why does it not contain the `<img>`?
It does contain the `<img>` and it contains the `<source>`s as well, it's not a traditional container. *it merely provides a context for its contained img element...* Meaning that `<picture>` is more like a list for the `<img>` to refer to when selecting a proper `<source>`.
That being said, if you need a container to wrap that group in, use `<figure>`. It's a nice semantic block element that will contain and take on it's content's dimensions...more or less (needs a little adjusting Chrome likes to add junk to it. see BIN)
### [JSBIN](http://jsbin.com/mopafuy/edit?html,output) |
38,361,657 | **HERE IS WHAT I DO NOT EXPECT**
Strangely, the `<picture>` appears to have its own location and height below the image itself. Its CSS `height` is set to `auto`, so I'm unsure where this height of `18px` is coming from.
**HERE IS THE EXPECTED BEHAVIOR**
The `<picture>` to contain the `<img>` within the `<picture>`. The `<picture>` to have the same height as what is contained within it in the HTML/DOM, e.g. the `<img>`.
**HERE IS WHAT I'VE DONE TO TRY TO FIX THE PROBLEM**
I've tried removing the [PictureFill](https://github.com/scottjehl/picturefill) library we're using to ensure the image fills the container, but that's not what is affecting that height.
I've also tried inspecting the DOM to see where the height of `<picture>` is coming from. There is no padding or margin or height set on this element. The only content is its `<source>` and `<img>`, which are standard included elements for a `<picture>`.
Any help or insight is highly appreciated. [Example code on JSBin](http://jsbin.com/foweyepozo/edit?html,output)!
**HERE IS THE EXAMPLE CODE**
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<picture content="https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a">
<source srcset="
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=480&rect=0%2C205%2C3264%2C1632&s=d3ce62073acf8faef26303df602d98ca 480w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=600&rect=0%2C205%2C3264%2C1632&s=299ee1965b7991d853f1c74ece47a4fc 600w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=800&rect=0%2C205%2C3264%2C1632&s=7b00f35515de1a75308074e0b8531606 800w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a 1000w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=2000&rect=0%2C205%2C3264%2C1632&s=03b760c29e398261cef276c2bdb0fcb2 2000w
" sizes="100vw">
<img class="listing-hero-image js-picturefill-img" data-automation="listing-hero-image" alt="The Cat is in the (Hockey) Bag">
</picture>
</body>
</html>
```
**HERE IS A SCREENSHOT OF WHAT I AM SEEING**
[](https://i.stack.imgur.com/FbLiG.jpg) | 2016/07/13 | [
"https://Stackoverflow.com/questions/38361657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1003754/"
] | The picture element is by default a non-replaced inline element. [CSS 2.2 says of such elements:](https://www.w3.org/TR/CSS22/visudet.html#inline-non-replaced)
>
> The height of the content area should be based on the font, but this
> specification does not specify how.
>
>
>
So the picture element's height is that of one line of text, and nothing to do with the img element it contains.
To fix, just apply this css: `picture { display:block; }` | I found the following in [**WHATWG**](https://html.spec.whatwg.org/multipage/embedded-content.html#the-picture-element):
>
> The picture element is somewhat different from the similar-looking video and audio elements. While all of them contain source elements, the source element's src attribute has no meaning when the element is nested within a picture element, and the resource selection algorithm is different. **Also, the picture element itself does not display anything; it merely provides a context for its contained img element that enables it to choose from multiple URLs.**
>
>
>
1. Why does my HTML5 `<picture>` have a height outside of its `<img>`?
This implies that the `<picture>` element doesn't take on the dimensions of it's children, including `<img>`. I say *implies* because the description does not explicitly says: *`<picture>` does not have the dimensions of `<img>`*, but if it doesn't actually display the `<img>`, then it's safe to assume it won't have the dimensions of said `<img>`.
2. why does it not contain the `<img>`?
It does contain the `<img>` and it contains the `<source>`s as well, it's not a traditional container. *it merely provides a context for its contained img element...* Meaning that `<picture>` is more like a list for the `<img>` to refer to when selecting a proper `<source>`.
That being said, if you need a container to wrap that group in, use `<figure>`. It's a nice semantic block element that will contain and take on it's content's dimensions...more or less (needs a little adjusting Chrome likes to add junk to it. see BIN)
### [JSBIN](http://jsbin.com/mopafuy/edit?html,output) |
38,361,657 | **HERE IS WHAT I DO NOT EXPECT**
Strangely, the `<picture>` appears to have its own location and height below the image itself. Its CSS `height` is set to `auto`, so I'm unsure where this height of `18px` is coming from.
**HERE IS THE EXPECTED BEHAVIOR**
The `<picture>` to contain the `<img>` within the `<picture>`. The `<picture>` to have the same height as what is contained within it in the HTML/DOM, e.g. the `<img>`.
**HERE IS WHAT I'VE DONE TO TRY TO FIX THE PROBLEM**
I've tried removing the [PictureFill](https://github.com/scottjehl/picturefill) library we're using to ensure the image fills the container, but that's not what is affecting that height.
I've also tried inspecting the DOM to see where the height of `<picture>` is coming from. There is no padding or margin or height set on this element. The only content is its `<source>` and `<img>`, which are standard included elements for a `<picture>`.
Any help or insight is highly appreciated. [Example code on JSBin](http://jsbin.com/foweyepozo/edit?html,output)!
**HERE IS THE EXAMPLE CODE**
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<picture content="https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a">
<source srcset="
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=480&rect=0%2C205%2C3264%2C1632&s=d3ce62073acf8faef26303df602d98ca 480w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=600&rect=0%2C205%2C3264%2C1632&s=299ee1965b7991d853f1c74ece47a4fc 600w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=800&rect=0%2C205%2C3264%2C1632&s=7b00f35515de1a75308074e0b8531606 800w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a 1000w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=2000&rect=0%2C205%2C3264%2C1632&s=03b760c29e398261cef276c2bdb0fcb2 2000w
" sizes="100vw">
<img class="listing-hero-image js-picturefill-img" data-automation="listing-hero-image" alt="The Cat is in the (Hockey) Bag">
</picture>
</body>
</html>
```
**HERE IS A SCREENSHOT OF WHAT I AM SEEING**
[](https://i.stack.imgur.com/FbLiG.jpg) | 2016/07/13 | [
"https://Stackoverflow.com/questions/38361657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1003754/"
] | The problem seems to be the "picture" element, the problem is due to the alignment of its element (the image).
You just only have to edit you img css instruction:
```
img {display:block}
``` | I found the following in [**WHATWG**](https://html.spec.whatwg.org/multipage/embedded-content.html#the-picture-element):
>
> The picture element is somewhat different from the similar-looking video and audio elements. While all of them contain source elements, the source element's src attribute has no meaning when the element is nested within a picture element, and the resource selection algorithm is different. **Also, the picture element itself does not display anything; it merely provides a context for its contained img element that enables it to choose from multiple URLs.**
>
>
>
1. Why does my HTML5 `<picture>` have a height outside of its `<img>`?
This implies that the `<picture>` element doesn't take on the dimensions of it's children, including `<img>`. I say *implies* because the description does not explicitly says: *`<picture>` does not have the dimensions of `<img>`*, but if it doesn't actually display the `<img>`, then it's safe to assume it won't have the dimensions of said `<img>`.
2. why does it not contain the `<img>`?
It does contain the `<img>` and it contains the `<source>`s as well, it's not a traditional container. *it merely provides a context for its contained img element...* Meaning that `<picture>` is more like a list for the `<img>` to refer to when selecting a proper `<source>`.
That being said, if you need a container to wrap that group in, use `<figure>`. It's a nice semantic block element that will contain and take on it's content's dimensions...more or less (needs a little adjusting Chrome likes to add junk to it. see BIN)
### [JSBIN](http://jsbin.com/mopafuy/edit?html,output) |
38,361,657 | **HERE IS WHAT I DO NOT EXPECT**
Strangely, the `<picture>` appears to have its own location and height below the image itself. Its CSS `height` is set to `auto`, so I'm unsure where this height of `18px` is coming from.
**HERE IS THE EXPECTED BEHAVIOR**
The `<picture>` to contain the `<img>` within the `<picture>`. The `<picture>` to have the same height as what is contained within it in the HTML/DOM, e.g. the `<img>`.
**HERE IS WHAT I'VE DONE TO TRY TO FIX THE PROBLEM**
I've tried removing the [PictureFill](https://github.com/scottjehl/picturefill) library we're using to ensure the image fills the container, but that's not what is affecting that height.
I've also tried inspecting the DOM to see where the height of `<picture>` is coming from. There is no padding or margin or height set on this element. The only content is its `<source>` and `<img>`, which are standard included elements for a `<picture>`.
Any help or insight is highly appreciated. [Example code on JSBin](http://jsbin.com/foweyepozo/edit?html,output)!
**HERE IS THE EXAMPLE CODE**
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<picture content="https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a">
<source srcset="
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=480&rect=0%2C205%2C3264%2C1632&s=d3ce62073acf8faef26303df602d98ca 480w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=600&rect=0%2C205%2C3264%2C1632&s=299ee1965b7991d853f1c74ece47a4fc 600w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=800&rect=0%2C205%2C3264%2C1632&s=7b00f35515de1a75308074e0b8531606 800w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a 1000w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=2000&rect=0%2C205%2C3264%2C1632&s=03b760c29e398261cef276c2bdb0fcb2 2000w
" sizes="100vw">
<img class="listing-hero-image js-picturefill-img" data-automation="listing-hero-image" alt="The Cat is in the (Hockey) Bag">
</picture>
</body>
</html>
```
**HERE IS A SCREENSHOT OF WHAT I AM SEEING**
[](https://i.stack.imgur.com/FbLiG.jpg) | 2016/07/13 | [
"https://Stackoverflow.com/questions/38361657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1003754/"
] | I found the following in [**WHATWG**](https://html.spec.whatwg.org/multipage/embedded-content.html#the-picture-element):
>
> The picture element is somewhat different from the similar-looking video and audio elements. While all of them contain source elements, the source element's src attribute has no meaning when the element is nested within a picture element, and the resource selection algorithm is different. **Also, the picture element itself does not display anything; it merely provides a context for its contained img element that enables it to choose from multiple URLs.**
>
>
>
1. Why does my HTML5 `<picture>` have a height outside of its `<img>`?
This implies that the `<picture>` element doesn't take on the dimensions of it's children, including `<img>`. I say *implies* because the description does not explicitly says: *`<picture>` does not have the dimensions of `<img>`*, but if it doesn't actually display the `<img>`, then it's safe to assume it won't have the dimensions of said `<img>`.
2. why does it not contain the `<img>`?
It does contain the `<img>` and it contains the `<source>`s as well, it's not a traditional container. *it merely provides a context for its contained img element...* Meaning that `<picture>` is more like a list for the `<img>` to refer to when selecting a proper `<source>`.
That being said, if you need a container to wrap that group in, use `<figure>`. It's a nice semantic block element that will contain and take on it's content's dimensions...more or less (needs a little adjusting Chrome likes to add junk to it. see BIN)
### [JSBIN](http://jsbin.com/mopafuy/edit?html,output) | This forces `img` tags inside of a `picture` to respect the boundaries of the parent container (the `picture`) instead of just arbitrarily being bigger or smaller than it:
```
picture {
display: flex;
}
```
Once the `picture` has sane layout rules (its contents stay inside of it), other layout adjustments can be made (such as horizontal centering, vertical centering, margins, padding, borders, etc.) using normal flexbox CSS. |
38,361,657 | **HERE IS WHAT I DO NOT EXPECT**
Strangely, the `<picture>` appears to have its own location and height below the image itself. Its CSS `height` is set to `auto`, so I'm unsure where this height of `18px` is coming from.
**HERE IS THE EXPECTED BEHAVIOR**
The `<picture>` to contain the `<img>` within the `<picture>`. The `<picture>` to have the same height as what is contained within it in the HTML/DOM, e.g. the `<img>`.
**HERE IS WHAT I'VE DONE TO TRY TO FIX THE PROBLEM**
I've tried removing the [PictureFill](https://github.com/scottjehl/picturefill) library we're using to ensure the image fills the container, but that's not what is affecting that height.
I've also tried inspecting the DOM to see where the height of `<picture>` is coming from. There is no padding or margin or height set on this element. The only content is its `<source>` and `<img>`, which are standard included elements for a `<picture>`.
Any help or insight is highly appreciated. [Example code on JSBin](http://jsbin.com/foweyepozo/edit?html,output)!
**HERE IS THE EXAMPLE CODE**
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<picture content="https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a">
<source srcset="
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=480&rect=0%2C205%2C3264%2C1632&s=d3ce62073acf8faef26303df602d98ca 480w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=600&rect=0%2C205%2C3264%2C1632&s=299ee1965b7991d853f1c74ece47a4fc 600w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=800&rect=0%2C205%2C3264%2C1632&s=7b00f35515de1a75308074e0b8531606 800w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a 1000w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=2000&rect=0%2C205%2C3264%2C1632&s=03b760c29e398261cef276c2bdb0fcb2 2000w
" sizes="100vw">
<img class="listing-hero-image js-picturefill-img" data-automation="listing-hero-image" alt="The Cat is in the (Hockey) Bag">
</picture>
</body>
</html>
```
**HERE IS A SCREENSHOT OF WHAT I AM SEEING**
[](https://i.stack.imgur.com/FbLiG.jpg) | 2016/07/13 | [
"https://Stackoverflow.com/questions/38361657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1003754/"
] | The picture element is by default a non-replaced inline element. [CSS 2.2 says of such elements:](https://www.w3.org/TR/CSS22/visudet.html#inline-non-replaced)
>
> The height of the content area should be based on the font, but this
> specification does not specify how.
>
>
>
So the picture element's height is that of one line of text, and nothing to do with the img element it contains.
To fix, just apply this css: `picture { display:block; }` | **CORRECTION**
@Alohci's assessment in the answer below is correct. However, in this case, applying `display: block` to the contained `<img>` rather than the outer `<picture>` solves the problem. Doing so forces the `<picture>` container to take on the size of the block level `<img>`.
Turns out the answer to this question is somewhat based in the vertical alignment of the `<img>`, not the structure of the `<picture>` element. This Stack Overflow answer appears to fix the issue:
[Why is there space under the image in this code?](https://stackoverflow.com/questions/15796414/why-is-there-space-under-the-image-in-this-code) |
38,361,657 | **HERE IS WHAT I DO NOT EXPECT**
Strangely, the `<picture>` appears to have its own location and height below the image itself. Its CSS `height` is set to `auto`, so I'm unsure where this height of `18px` is coming from.
**HERE IS THE EXPECTED BEHAVIOR**
The `<picture>` to contain the `<img>` within the `<picture>`. The `<picture>` to have the same height as what is contained within it in the HTML/DOM, e.g. the `<img>`.
**HERE IS WHAT I'VE DONE TO TRY TO FIX THE PROBLEM**
I've tried removing the [PictureFill](https://github.com/scottjehl/picturefill) library we're using to ensure the image fills the container, but that's not what is affecting that height.
I've also tried inspecting the DOM to see where the height of `<picture>` is coming from. There is no padding or margin or height set on this element. The only content is its `<source>` and `<img>`, which are standard included elements for a `<picture>`.
Any help or insight is highly appreciated. [Example code on JSBin](http://jsbin.com/foweyepozo/edit?html,output)!
**HERE IS THE EXAMPLE CODE**
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<picture content="https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a">
<source srcset="
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=480&rect=0%2C205%2C3264%2C1632&s=d3ce62073acf8faef26303df602d98ca 480w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=600&rect=0%2C205%2C3264%2C1632&s=299ee1965b7991d853f1c74ece47a4fc 600w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=800&rect=0%2C205%2C3264%2C1632&s=7b00f35515de1a75308074e0b8531606 800w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a 1000w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=2000&rect=0%2C205%2C3264%2C1632&s=03b760c29e398261cef276c2bdb0fcb2 2000w
" sizes="100vw">
<img class="listing-hero-image js-picturefill-img" data-automation="listing-hero-image" alt="The Cat is in the (Hockey) Bag">
</picture>
</body>
</html>
```
**HERE IS A SCREENSHOT OF WHAT I AM SEEING**
[](https://i.stack.imgur.com/FbLiG.jpg) | 2016/07/13 | [
"https://Stackoverflow.com/questions/38361657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1003754/"
] | The problem seems to be the "picture" element, the problem is due to the alignment of its element (the image).
You just only have to edit you img css instruction:
```
img {display:block}
``` | **CORRECTION**
@Alohci's assessment in the answer below is correct. However, in this case, applying `display: block` to the contained `<img>` rather than the outer `<picture>` solves the problem. Doing so forces the `<picture>` container to take on the size of the block level `<img>`.
Turns out the answer to this question is somewhat based in the vertical alignment of the `<img>`, not the structure of the `<picture>` element. This Stack Overflow answer appears to fix the issue:
[Why is there space under the image in this code?](https://stackoverflow.com/questions/15796414/why-is-there-space-under-the-image-in-this-code) |
38,361,657 | **HERE IS WHAT I DO NOT EXPECT**
Strangely, the `<picture>` appears to have its own location and height below the image itself. Its CSS `height` is set to `auto`, so I'm unsure where this height of `18px` is coming from.
**HERE IS THE EXPECTED BEHAVIOR**
The `<picture>` to contain the `<img>` within the `<picture>`. The `<picture>` to have the same height as what is contained within it in the HTML/DOM, e.g. the `<img>`.
**HERE IS WHAT I'VE DONE TO TRY TO FIX THE PROBLEM**
I've tried removing the [PictureFill](https://github.com/scottjehl/picturefill) library we're using to ensure the image fills the container, but that's not what is affecting that height.
I've also tried inspecting the DOM to see where the height of `<picture>` is coming from. There is no padding or margin or height set on this element. The only content is its `<source>` and `<img>`, which are standard included elements for a `<picture>`.
Any help or insight is highly appreciated. [Example code on JSBin](http://jsbin.com/foweyepozo/edit?html,output)!
**HERE IS THE EXAMPLE CODE**
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<picture content="https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a">
<source srcset="
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=480&rect=0%2C205%2C3264%2C1632&s=d3ce62073acf8faef26303df602d98ca 480w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=600&rect=0%2C205%2C3264%2C1632&s=299ee1965b7991d853f1c74ece47a4fc 600w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=800&rect=0%2C205%2C3264%2C1632&s=7b00f35515de1a75308074e0b8531606 800w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a 1000w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=2000&rect=0%2C205%2C3264%2C1632&s=03b760c29e398261cef276c2bdb0fcb2 2000w
" sizes="100vw">
<img class="listing-hero-image js-picturefill-img" data-automation="listing-hero-image" alt="The Cat is in the (Hockey) Bag">
</picture>
</body>
</html>
```
**HERE IS A SCREENSHOT OF WHAT I AM SEEING**
[](https://i.stack.imgur.com/FbLiG.jpg) | 2016/07/13 | [
"https://Stackoverflow.com/questions/38361657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1003754/"
] | **CORRECTION**
@Alohci's assessment in the answer below is correct. However, in this case, applying `display: block` to the contained `<img>` rather than the outer `<picture>` solves the problem. Doing so forces the `<picture>` container to take on the size of the block level `<img>`.
Turns out the answer to this question is somewhat based in the vertical alignment of the `<img>`, not the structure of the `<picture>` element. This Stack Overflow answer appears to fix the issue:
[Why is there space under the image in this code?](https://stackoverflow.com/questions/15796414/why-is-there-space-under-the-image-in-this-code) | This forces `img` tags inside of a `picture` to respect the boundaries of the parent container (the `picture`) instead of just arbitrarily being bigger or smaller than it:
```
picture {
display: flex;
}
```
Once the `picture` has sane layout rules (its contents stay inside of it), other layout adjustments can be made (such as horizontal centering, vertical centering, margins, padding, borders, etc.) using normal flexbox CSS. |
38,361,657 | **HERE IS WHAT I DO NOT EXPECT**
Strangely, the `<picture>` appears to have its own location and height below the image itself. Its CSS `height` is set to `auto`, so I'm unsure where this height of `18px` is coming from.
**HERE IS THE EXPECTED BEHAVIOR**
The `<picture>` to contain the `<img>` within the `<picture>`. The `<picture>` to have the same height as what is contained within it in the HTML/DOM, e.g. the `<img>`.
**HERE IS WHAT I'VE DONE TO TRY TO FIX THE PROBLEM**
I've tried removing the [PictureFill](https://github.com/scottjehl/picturefill) library we're using to ensure the image fills the container, but that's not what is affecting that height.
I've also tried inspecting the DOM to see where the height of `<picture>` is coming from. There is no padding or margin or height set on this element. The only content is its `<source>` and `<img>`, which are standard included elements for a `<picture>`.
Any help or insight is highly appreciated. [Example code on JSBin](http://jsbin.com/foweyepozo/edit?html,output)!
**HERE IS THE EXAMPLE CODE**
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<picture content="https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a">
<source srcset="
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=480&rect=0%2C205%2C3264%2C1632&s=d3ce62073acf8faef26303df602d98ca 480w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=600&rect=0%2C205%2C3264%2C1632&s=299ee1965b7991d853f1c74ece47a4fc 600w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=800&rect=0%2C205%2C3264%2C1632&s=7b00f35515de1a75308074e0b8531606 800w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a 1000w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=2000&rect=0%2C205%2C3264%2C1632&s=03b760c29e398261cef276c2bdb0fcb2 2000w
" sizes="100vw">
<img class="listing-hero-image js-picturefill-img" data-automation="listing-hero-image" alt="The Cat is in the (Hockey) Bag">
</picture>
</body>
</html>
```
**HERE IS A SCREENSHOT OF WHAT I AM SEEING**
[](https://i.stack.imgur.com/FbLiG.jpg) | 2016/07/13 | [
"https://Stackoverflow.com/questions/38361657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1003754/"
] | The picture element is by default a non-replaced inline element. [CSS 2.2 says of such elements:](https://www.w3.org/TR/CSS22/visudet.html#inline-non-replaced)
>
> The height of the content area should be based on the font, but this
> specification does not specify how.
>
>
>
So the picture element's height is that of one line of text, and nothing to do with the img element it contains.
To fix, just apply this css: `picture { display:block; }` | The problem seems to be the "picture" element, the problem is due to the alignment of its element (the image).
You just only have to edit you img css instruction:
```
img {display:block}
``` |
38,361,657 | **HERE IS WHAT I DO NOT EXPECT**
Strangely, the `<picture>` appears to have its own location and height below the image itself. Its CSS `height` is set to `auto`, so I'm unsure where this height of `18px` is coming from.
**HERE IS THE EXPECTED BEHAVIOR**
The `<picture>` to contain the `<img>` within the `<picture>`. The `<picture>` to have the same height as what is contained within it in the HTML/DOM, e.g. the `<img>`.
**HERE IS WHAT I'VE DONE TO TRY TO FIX THE PROBLEM**
I've tried removing the [PictureFill](https://github.com/scottjehl/picturefill) library we're using to ensure the image fills the container, but that's not what is affecting that height.
I've also tried inspecting the DOM to see where the height of `<picture>` is coming from. There is no padding or margin or height set on this element. The only content is its `<source>` and `<img>`, which are standard included elements for a `<picture>`.
Any help or insight is highly appreciated. [Example code on JSBin](http://jsbin.com/foweyepozo/edit?html,output)!
**HERE IS THE EXAMPLE CODE**
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<picture content="https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a">
<source srcset="
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=480&rect=0%2C205%2C3264%2C1632&s=d3ce62073acf8faef26303df602d98ca 480w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=600&rect=0%2C205%2C3264%2C1632&s=299ee1965b7991d853f1c74ece47a4fc 600w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=800&rect=0%2C205%2C3264%2C1632&s=7b00f35515de1a75308074e0b8531606 800w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a 1000w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=2000&rect=0%2C205%2C3264%2C1632&s=03b760c29e398261cef276c2bdb0fcb2 2000w
" sizes="100vw">
<img class="listing-hero-image js-picturefill-img" data-automation="listing-hero-image" alt="The Cat is in the (Hockey) Bag">
</picture>
</body>
</html>
```
**HERE IS A SCREENSHOT OF WHAT I AM SEEING**
[](https://i.stack.imgur.com/FbLiG.jpg) | 2016/07/13 | [
"https://Stackoverflow.com/questions/38361657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1003754/"
] | The picture element is by default a non-replaced inline element. [CSS 2.2 says of such elements:](https://www.w3.org/TR/CSS22/visudet.html#inline-non-replaced)
>
> The height of the content area should be based on the font, but this
> specification does not specify how.
>
>
>
So the picture element's height is that of one line of text, and nothing to do with the img element it contains.
To fix, just apply this css: `picture { display:block; }` | This forces `img` tags inside of a `picture` to respect the boundaries of the parent container (the `picture`) instead of just arbitrarily being bigger or smaller than it:
```
picture {
display: flex;
}
```
Once the `picture` has sane layout rules (its contents stay inside of it), other layout adjustments can be made (such as horizontal centering, vertical centering, margins, padding, borders, etc.) using normal flexbox CSS. |
38,361,657 | **HERE IS WHAT I DO NOT EXPECT**
Strangely, the `<picture>` appears to have its own location and height below the image itself. Its CSS `height` is set to `auto`, so I'm unsure where this height of `18px` is coming from.
**HERE IS THE EXPECTED BEHAVIOR**
The `<picture>` to contain the `<img>` within the `<picture>`. The `<picture>` to have the same height as what is contained within it in the HTML/DOM, e.g. the `<img>`.
**HERE IS WHAT I'VE DONE TO TRY TO FIX THE PROBLEM**
I've tried removing the [PictureFill](https://github.com/scottjehl/picturefill) library we're using to ensure the image fills the container, but that's not what is affecting that height.
I've also tried inspecting the DOM to see where the height of `<picture>` is coming from. There is no padding or margin or height set on this element. The only content is its `<source>` and `<img>`, which are standard included elements for a `<picture>`.
Any help or insight is highly appreciated. [Example code on JSBin](http://jsbin.com/foweyepozo/edit?html,output)!
**HERE IS THE EXAMPLE CODE**
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<picture content="https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a">
<source srcset="
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=480&rect=0%2C205%2C3264%2C1632&s=d3ce62073acf8faef26303df602d98ca 480w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=600&rect=0%2C205%2C3264%2C1632&s=299ee1965b7991d853f1c74ece47a4fc 600w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=800&rect=0%2C205%2C3264%2C1632&s=7b00f35515de1a75308074e0b8531606 800w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=1000&rect=0%2C205%2C3264%2C1632&s=6fa833f7049033ffa33ac3f11ec4433a 1000w,
https://img-dev.evbuc.com/https%3A%2F%2Fs3.amazonaws.com%2Feventbrite-dev%2Fimages%2F10068705%2F149308521389%2F1%2Foriginal.jpg?w=2000&rect=0%2C205%2C3264%2C1632&s=03b760c29e398261cef276c2bdb0fcb2 2000w
" sizes="100vw">
<img class="listing-hero-image js-picturefill-img" data-automation="listing-hero-image" alt="The Cat is in the (Hockey) Bag">
</picture>
</body>
</html>
```
**HERE IS A SCREENSHOT OF WHAT I AM SEEING**
[](https://i.stack.imgur.com/FbLiG.jpg) | 2016/07/13 | [
"https://Stackoverflow.com/questions/38361657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1003754/"
] | The problem seems to be the "picture" element, the problem is due to the alignment of its element (the image).
You just only have to edit you img css instruction:
```
img {display:block}
``` | This forces `img` tags inside of a `picture` to respect the boundaries of the parent container (the `picture`) instead of just arbitrarily being bigger or smaller than it:
```
picture {
display: flex;
}
```
Once the `picture` has sane layout rules (its contents stay inside of it), other layout adjustments can be made (such as horizontal centering, vertical centering, margins, padding, borders, etc.) using normal flexbox CSS. |
50,213,815 | I need to implement a hall booking system and there is a requirement to get the free halls based on booked `FromDateTime` to `ToDateTime`
Order Table
```
HallID FromDateTime ToDateTime
1 2018-01-01 03:00:00 2018-01-01 05:00:00
2 2018-01-01 06:30:00 2018-01-01 12:00:00
3 2018-01-01 13:00:00 2018-01-01 15:15:00
```
The user should be able to input the `FromDateTime` to `ToDateTime` to check whether there is a record in the Order table. If exists then hall is not available for booking.
Test scenarios: Inputs
```
FromDateTime ToDateTime Result
2018-01-01 03:00:00 2018-01-01 05:00:00 : Hall not available
2018-01-01 08:45:00 2018-01-01 10:30:00 : Hall not available (This time is between Hall ID 2s booking time)
2018-01-01 15:30:00 2018-01-01 18:00:00 : Hall available
```
Question
Is it possible to use between clause within `FromDateTime` and `ToDateTime` in this scenario to solve this problem?
I was unable to find a way to use between so I used the below method. But its cost is very high.
```
-- Selecting all the records related to perticular product(hall) in to a temp table.
DECLARE @TempOrderDateTime TABLE (FromDateTime DATETIME,ToDateTime DATETIME)
INSERT INTO @TempOrderDateTime
SELECT FromDateTime,ToDateTime
FROM [Order].[Order]
WHERE ProductID = 7
```
Splitting each and every record into 1-hour potions and storing inside temp table. This creates another issue.
The issue is if I use 1-hour segments algorithm will not be able to deal with records which are having minutes in FromDateTime or ToDateTime
```
DECLARE @ProdTimes TABLE (Dates DATETIME)
DECLARE @PRowCount INT = (SELECT COUNT(*) FROM @TempOrderDateTime)
WHILE(@PRowCount>0)
BEGIN
DECLARE @TopFromDateTime DATETIME = (SELECT TOP(1)FromDateTime FROM
@TempOrderDateTime)
DECLARE @TopToDateTime DATETIME = (SELECT TOP(1)ToDateTime FROM @TempOrderDateTime)
;WITH Dates_CTE
AS (SELECT @TopFromDateTime AS Dates
UNION ALL
SELECT DATEADD(HOUR, 1, Dates)
FROM Dates_CTE
WHERE Dates < @TopToDateTime)
INSERT INTO @ProdTimes
SELECT Dates
FROM Dates_CTE AS t
OPTION (MAXRECURSION 0);
DELETE TOP(1) FROM @TempOrderDateTime
SET @PRowCount = (SELECT COUNT(*) FROM @TempOrderDateTime)
END
```
Here I am givingFromDateTime and ToDateTime as inputs in order to check the availability.
```
DECLARE @FromDateTime DATETIME = '2018-06-01 12:00:00.000'
DECLARE @ToDateTime DATETIME = '2018-06-01 14:00:00.000'
DECLARE @PTimes TABLE (Dates DateTime)
;WITH Dates_CTE
AS (SELECT @FromDateTime AS Dates
UNION ALL
SELECT DATEADD(HOUR, 1, Dates)
FROM Dates_CTE
WHERE Dates < @ToDateTime)
INSERT INTO @PTimes
SELECT *
FROM Dates_CTE AS t
OPTION (MAXRECURSION 0);
DELETE FROM @PTimes WHERE Dates = @FromDateTime OR Dates = @ToDateTime
```
Finally doing the below operation to match the tables. If no records found, the hall is available for booking.
```
SELECT * FROM @PTimes p
WHERE EXISTS (SELECT 1 FROM @ProdTimes pt WHERE p.Dates = pt.Dates)
```
My approach is currently applicable. But the major drawback is
* If the order table records contain an entry with Minutes, the algorithm will not work. Because it only filters out 1-hour potions.
* Cost is very high.
Please suggest me a proper way to handle this problem.
Thanks in advance. | 2018/05/07 | [
"https://Stackoverflow.com/questions/50213815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5733738/"
] | ```
@Component({
selector: 'app-transaction',
templateUrl: './transaction.component.html',
styleUrls:
['./transaction.component.scss',]
})
```
Another component (if you have it):
```
@Component({
selector: 'my-app',
templateUrl: './my-app.component.html',
styleUrls:
['./my-app.component.scss',]
})
export class MyAppComponent {
...
}
```
And in template use that selector:
```
<my-app>
<div class="loaded" *ngIf="loaded">
<div class="text-center">
<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i>
<div> Data Waiting To Be Loaded </div>
</div>
</div>
</my-app>
```
If you don't have the MyAppComponent, then you can't use it in template. Why do you have the in the template? | I think your problem is a syntax error. You have defined two selectors for this component. I think this line in your **transaction.component.ts**
```
selector: 'app-transaction','my-app',
```
should only be
```
selector: 'app-transaction',
```
since the selector doesn't take arrays as value (like e.g. styleUrls does). |
52,305,860 | When I try:
```
>>> from skimage import io
```
I get at the end the following:
```
from ..color import rgb2gray
ImportError: cannot import name 'rgb2gray' from 'skimage.color' (C:\Users\user\A
ppData\Local\Programs\Python\Python37-32\lib\site-packages\skimage\color\__init_
_.py)
```
Although I have installed the packages: matplotlib, scipy, pillow, numpy and six
How can I fix it? Any help would be appreciated | 2018/09/13 | [
"https://Stackoverflow.com/questions/52305860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10254054/"
] | It looks like you haven't installed *`scikit-image`* package.
Try this on terminal:
```
pip install -U scikit-image
```
And then try importing like this:
```
from skimage import io
from skimage.color import rgb2gray
```
If you still got the *error or you have installed the package* previously,
[try reinstalling the package first.](http://scikit-image.org/docs/dev/install.html)
If it still don't resolve your issue, then try updating the following packages:
`matplotlib`, `scipy`, `pil`, `numpy` and `six`
However, try not to *import all of the subpackages* to *improve loading time*. You can however try something like:
```
from skimage import color
...
gray_img = color.rgb2gray(img)
```
If you still got errors, *make sure that you are using the correct python kernel and dependent modules are updated and installed*.
If that did not help either, then try [*`Anaconda`*](https://www.anaconda.com/download/), it come with many *pre-installed* packages.
Leave a comment if you still have a problem :) | three ways to convert RGB2Gray:
opencv:
```
import cv2
img=cv2.imread("file.jpg",0) [enter link description here][1]
```
or you can do this:
```
img=cv2.imread("file.jpg")
gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
```
**cv2.COLOR\_BGR2GRAY** beacause it reads BGR mode.
another methods you can look this link:
[enter link description here](https://stackoverflow.com/questions/52305280/grab-image-from-screen-to-numpy-array-and-display-it-as-black-and-white-image) |
52,305,860 | When I try:
```
>>> from skimage import io
```
I get at the end the following:
```
from ..color import rgb2gray
ImportError: cannot import name 'rgb2gray' from 'skimage.color' (C:\Users\user\A
ppData\Local\Programs\Python\Python37-32\lib\site-packages\skimage\color\__init_
_.py)
```
Although I have installed the packages: matplotlib, scipy, pillow, numpy and six
How can I fix it? Any help would be appreciated | 2018/09/13 | [
"https://Stackoverflow.com/questions/52305860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10254054/"
] | In case you run into this error from inside a Jupyter Notebook, try restarting the kernel [as suggested in this GitHub issue.](https://github.com/scikit-image/scikit-image/issues/3273)
That solved the problem for me. | three ways to convert RGB2Gray:
opencv:
```
import cv2
img=cv2.imread("file.jpg",0) [enter link description here][1]
```
or you can do this:
```
img=cv2.imread("file.jpg")
gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
```
**cv2.COLOR\_BGR2GRAY** beacause it reads BGR mode.
another methods you can look this link:
[enter link description here](https://stackoverflow.com/questions/52305280/grab-image-from-screen-to-numpy-array-and-display-it-as-black-and-white-image) |
52,305,860 | When I try:
```
>>> from skimage import io
```
I get at the end the following:
```
from ..color import rgb2gray
ImportError: cannot import name 'rgb2gray' from 'skimage.color' (C:\Users\user\A
ppData\Local\Programs\Python\Python37-32\lib\site-packages\skimage\color\__init_
_.py)
```
Although I have installed the packages: matplotlib, scipy, pillow, numpy and six
How can I fix it? Any help would be appreciated | 2018/09/13 | [
"https://Stackoverflow.com/questions/52305860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10254054/"
] | In case you run into this error from inside a Jupyter Notebook, try restarting the kernel [as suggested in this GitHub issue.](https://github.com/scikit-image/scikit-image/issues/3273)
That solved the problem for me. | It looks like you haven't installed *`scikit-image`* package.
Try this on terminal:
```
pip install -U scikit-image
```
And then try importing like this:
```
from skimage import io
from skimage.color import rgb2gray
```
If you still got the *error or you have installed the package* previously,
[try reinstalling the package first.](http://scikit-image.org/docs/dev/install.html)
If it still don't resolve your issue, then try updating the following packages:
`matplotlib`, `scipy`, `pil`, `numpy` and `six`
However, try not to *import all of the subpackages* to *improve loading time*. You can however try something like:
```
from skimage import color
...
gray_img = color.rgb2gray(img)
```
If you still got errors, *make sure that you are using the correct python kernel and dependent modules are updated and installed*.
If that did not help either, then try [*`Anaconda`*](https://www.anaconda.com/download/), it come with many *pre-installed* packages.
Leave a comment if you still have a problem :) |
52,305,860 | When I try:
```
>>> from skimage import io
```
I get at the end the following:
```
from ..color import rgb2gray
ImportError: cannot import name 'rgb2gray' from 'skimage.color' (C:\Users\user\A
ppData\Local\Programs\Python\Python37-32\lib\site-packages\skimage\color\__init_
_.py)
```
Although I have installed the packages: matplotlib, scipy, pillow, numpy and six
How can I fix it? Any help would be appreciated | 2018/09/13 | [
"https://Stackoverflow.com/questions/52305860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10254054/"
] | It looks like you haven't installed *`scikit-image`* package.
Try this on terminal:
```
pip install -U scikit-image
```
And then try importing like this:
```
from skimage import io
from skimage.color import rgb2gray
```
If you still got the *error or you have installed the package* previously,
[try reinstalling the package first.](http://scikit-image.org/docs/dev/install.html)
If it still don't resolve your issue, then try updating the following packages:
`matplotlib`, `scipy`, `pil`, `numpy` and `six`
However, try not to *import all of the subpackages* to *improve loading time*. You can however try something like:
```
from skimage import color
...
gray_img = color.rgb2gray(img)
```
If you still got errors, *make sure that you are using the correct python kernel and dependent modules are updated and installed*.
If that did not help either, then try [*`Anaconda`*](https://www.anaconda.com/download/), it come with many *pre-installed* packages.
Leave a comment if you still have a problem :) | It happened to me once when I import `skimage` using `env conda` on Jupyter. I installed by `pip` or `conda` in env, that error happened. However, after restart the Jupyter, it worked. |
52,305,860 | When I try:
```
>>> from skimage import io
```
I get at the end the following:
```
from ..color import rgb2gray
ImportError: cannot import name 'rgb2gray' from 'skimage.color' (C:\Users\user\A
ppData\Local\Programs\Python\Python37-32\lib\site-packages\skimage\color\__init_
_.py)
```
Although I have installed the packages: matplotlib, scipy, pillow, numpy and six
How can I fix it? Any help would be appreciated | 2018/09/13 | [
"https://Stackoverflow.com/questions/52305860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10254054/"
] | In case you run into this error from inside a Jupyter Notebook, try restarting the kernel [as suggested in this GitHub issue.](https://github.com/scikit-image/scikit-image/issues/3273)
That solved the problem for me. | It happened to me once when I import `skimage` using `env conda` on Jupyter. I installed by `pip` or `conda` in env, that error happened. However, after restart the Jupyter, it worked. |
517,212 | I have a small problem. I have seven partitions:
```
Device Boot Begin End Blocks Id System
/dev/sda1 * 206848 219013119 109403136 7 HPFS/NTFS/exFAT <-- wINDOWS 7
/dev/sda2 219013120 735516671 258251776 7 HPFS/NTFS/exFAT <--Musik,....
/dev/sda3 735516672 815638527 40060928 7 HPFS/NTFS/exFAT <-- Android
/dev/sda4 815640574 976771071 80565249 5 Erweiterte <-- No Idea:D
Partition 4 does not start at a physical sector boundary.
/dev/sda5 815640576 872494091 28426758 83 Linux <--Kali Linux
/dev/sda6 970151936 976771071 3309568 82 Linux Swap / Solaris
/dev/sda7 872495104 970149887 48827392 83 Linux <-- Ubuntu
```
I found a tutorial, but I tried this and it doesn't work. Here's the link:
<http://www.webupd8.org/2012/03/how-to-dual-boot-android-x86-and-ubuntu.html>
I used this Android from android-x86.org and the version android-x86-4.4-r1.iso.
This is my 40\_Costum document:
```
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Android-x86" {
set root='(hd0,3)'
linux /android-x86-4.4-r1/kernel quiet root=/dev/ram0 androidboot_hardware=eeepc acpi_sleep=s3_bios,s3_mode SRC=/android-x86-4.4-r1
initrd /android-x86-4.4-r1/initrd.img}
```
If I start my PC the [GRUB](http://en.wikipedia.org/wiki/GNU_GRUB) boot manager comes and I can choose Android, but it doesn't boot Android. The background is purple and nothing happens.
What would be a complete and working `40_Customm` script?
---
It doesn't work if I make a script in Grub Customizer and save it. It doesn't show on the boot menu if I open the Grub Customizer again the script is removed.
This is my code :
```
set root='(hd0,3)'
`search --no-floppy --fs-uuid --set=root 28D9FDF951298246
linux android-x86/kernel root=UUID=28D9FDF951298246 quiet
androidboot.hardware=generic_x86 SRC=/android-x86 acpi_sleep=s3_bios,s3_mode
initrd Android-x86/android-4.4-r1/initrd.img
```
Now I have one extra Problem:
If I Start my laptop it shows Ubuntu, Windows, Kali Linux and Android (which doesn't work ), but if I start the GRub Costumizer the Windows isn't listed?! But Why? | 2014/08/28 | [
"https://askubuntu.com/questions/517212",
"https://askubuntu.com",
"https://askubuntu.com/users/321414/"
] | Regarding Android x86 6.0
The "EEEPC" assignment is only for ASUS EEEPCs, only use it if you have one, otherwise use `android_x86`, **do not use generic\_x86**, you will get stuck at the boot animation and have to restart by using `CTRL`+`F1` to access the terminal and issue `reboot` as the GUI will not get loaded. I know this because I spent several hours following bad, though well intentioned, advice.
```
set root='(hd0,4)'
linux /android-6.0-rc1/kernel quiet root=/dev/ram0 androidboot.hardware=android_x86 acpi_sleep=s3_bios,s3_mode SRC=/android-6.0-rc1
initrd /android-6.0-rc1/initrd.img
```
This was the final configuration that worked for me on an old school SONY VAIO 64 bit on a triple boot setup.
`'(0,4)'` was the location of my hard drive and partition Android x86 was installed to, change it accordingly. You do not need your UUID, you only need exactly what I have put above with your installation location being the only change. | None of the other answers worked for me, so I decided to find the solution myself in the files provided by the ISO image with Android-x86 installation files.
In `Android-x86 LiveCD1/efi/boot/android.cfg` I found the following menu entry:
```
set root=$android
linux $kdir/kernel root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug $src $@
initrd $kdir/initrd.img
```
The question was what the values of `$kdir` and `$android` should be. After mounting the partition I installed the system on (`sda2`), I found the name of the directory - `cm-x86-14.1-r2`.
`$@` are additional parameters (`quiet` in my solution) and `$src` can be ignored. Finally, I made the following grub entry:
```
set root='(hd0,2)'
linux /cm-x86-14.1-r2/kernel quiet root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug
initrd /cm-x86-14.1-r2/initrd.img
```
And it works. |
517,212 | I have a small problem. I have seven partitions:
```
Device Boot Begin End Blocks Id System
/dev/sda1 * 206848 219013119 109403136 7 HPFS/NTFS/exFAT <-- wINDOWS 7
/dev/sda2 219013120 735516671 258251776 7 HPFS/NTFS/exFAT <--Musik,....
/dev/sda3 735516672 815638527 40060928 7 HPFS/NTFS/exFAT <-- Android
/dev/sda4 815640574 976771071 80565249 5 Erweiterte <-- No Idea:D
Partition 4 does not start at a physical sector boundary.
/dev/sda5 815640576 872494091 28426758 83 Linux <--Kali Linux
/dev/sda6 970151936 976771071 3309568 82 Linux Swap / Solaris
/dev/sda7 872495104 970149887 48827392 83 Linux <-- Ubuntu
```
I found a tutorial, but I tried this and it doesn't work. Here's the link:
<http://www.webupd8.org/2012/03/how-to-dual-boot-android-x86-and-ubuntu.html>
I used this Android from android-x86.org and the version android-x86-4.4-r1.iso.
This is my 40\_Costum document:
```
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Android-x86" {
set root='(hd0,3)'
linux /android-x86-4.4-r1/kernel quiet root=/dev/ram0 androidboot_hardware=eeepc acpi_sleep=s3_bios,s3_mode SRC=/android-x86-4.4-r1
initrd /android-x86-4.4-r1/initrd.img}
```
If I start my PC the [GRUB](http://en.wikipedia.org/wiki/GNU_GRUB) boot manager comes and I can choose Android, but it doesn't boot Android. The background is purple and nothing happens.
What would be a complete and working `40_Customm` script?
---
It doesn't work if I make a script in Grub Customizer and save it. It doesn't show on the boot menu if I open the Grub Customizer again the script is removed.
This is my code :
```
set root='(hd0,3)'
`search --no-floppy --fs-uuid --set=root 28D9FDF951298246
linux android-x86/kernel root=UUID=28D9FDF951298246 quiet
androidboot.hardware=generic_x86 SRC=/android-x86 acpi_sleep=s3_bios,s3_mode
initrd Android-x86/android-4.4-r1/initrd.img
```
Now I have one extra Problem:
If I Start my laptop it shows Ubuntu, Windows, Kali Linux and Android (which doesn't work ), but if I start the GRub Costumizer the Windows isn't listed?! But Why? | 2014/08/28 | [
"https://askubuntu.com/questions/517212",
"https://askubuntu.com",
"https://askubuntu.com/users/321414/"
] | [This is from XDA Developers](http://forum.xda-developers.com/showthread.php?t=2703270)
For GRUB 1.97 - 1.99 & 2.00 +
1. To make it easy, install GRUB Customizer
Type these into terminal emulator :
Code:
```
sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer
```
2. Open GRUB customizer and make a new GRUB entry.
3. Open 'Sources' tab, type these :
```
set root='(hd0,4)'
search --no-floppy --fs-uuid --set=root e1f9de05-8d18-48aa-8f08-f0377f663de3
linux androidx86/kernel root=UUID=e1f9de05-8d18-48aa-8f08-f0377f663de3 quiet androidboot.hardware=generic_x86 SRC=/androidx86 acpi_sleep=s3_bios,s3_mode
initrd androidx86/initrd.img
```
Here's what to change :
>
> 1. `set root='(hd0,4)'` : Change the (hd0,4) to partiton Android x86 is installed. The hd0 means sda, so if you install it to sdb, it'll be
> hd1 and so on. The hd0,4 means the partition number, in my case, hd0,4
> means sda4. So if you install it on sda6, it'll be hd0,6.
> 2. `--set=root e1f9de05-8d18-48aa-8f08-f0377f663de3` : The random number here is the UUID of partition Android x86 is installed You must change
> it to correct UUID, you can easily got UUID by creating new entry in
> GRUB Customizer then go to Options tab, then select the 'Linux' option
> in dropdown. You'll see partition dropdown, select your partition.
> Open the source tab, you'll see the UUID there.
> 3. `androidx86/` : The root of Android x86 Change it into your Android x86 root. You can see what's your Android x86 root by navigating to
> Android x86 partition, and you'll see a folder name started with
> 'android', that's the root of your Android x86
> 4. `androidboot.hardware` : Your device, of course. Note : If you're using Android 2.3 - 4.0.3, change it to androidboot\_hardware Here's the list of hardware :
>
>
>
* `generic_x86` : If your hardware isn't listed, use this
* `eeepc` : EEEPC laptops
* `asus_laptop` : ASUS laptops (supported ASUS laptops only) | * Open `40_custom`:
```
sudo -H gedit /etc/burg.d/40_custom
```
* Add Android x86 menu entry:
```
menuentry "Android-4.3-x86" --class android {
set root='(hd*,msdos*)'
linux /path/android-4.3-x86/kernel quiet root=/dev/ram0 androidboot.hardware=tx2500 acpi_sleep=s3_bios,s3_mode SRC=/path/android-4.3-x86 vga=788
initrd /path/android-4.3-x86/initrd.img
```
(set `path` and `*` as yours)
* Update grub:
```
sudo update-grub
``` |
517,212 | I have a small problem. I have seven partitions:
```
Device Boot Begin End Blocks Id System
/dev/sda1 * 206848 219013119 109403136 7 HPFS/NTFS/exFAT <-- wINDOWS 7
/dev/sda2 219013120 735516671 258251776 7 HPFS/NTFS/exFAT <--Musik,....
/dev/sda3 735516672 815638527 40060928 7 HPFS/NTFS/exFAT <-- Android
/dev/sda4 815640574 976771071 80565249 5 Erweiterte <-- No Idea:D
Partition 4 does not start at a physical sector boundary.
/dev/sda5 815640576 872494091 28426758 83 Linux <--Kali Linux
/dev/sda6 970151936 976771071 3309568 82 Linux Swap / Solaris
/dev/sda7 872495104 970149887 48827392 83 Linux <-- Ubuntu
```
I found a tutorial, but I tried this and it doesn't work. Here's the link:
<http://www.webupd8.org/2012/03/how-to-dual-boot-android-x86-and-ubuntu.html>
I used this Android from android-x86.org and the version android-x86-4.4-r1.iso.
This is my 40\_Costum document:
```
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Android-x86" {
set root='(hd0,3)'
linux /android-x86-4.4-r1/kernel quiet root=/dev/ram0 androidboot_hardware=eeepc acpi_sleep=s3_bios,s3_mode SRC=/android-x86-4.4-r1
initrd /android-x86-4.4-r1/initrd.img}
```
If I start my PC the [GRUB](http://en.wikipedia.org/wiki/GNU_GRUB) boot manager comes and I can choose Android, but it doesn't boot Android. The background is purple and nothing happens.
What would be a complete and working `40_Customm` script?
---
It doesn't work if I make a script in Grub Customizer and save it. It doesn't show on the boot menu if I open the Grub Customizer again the script is removed.
This is my code :
```
set root='(hd0,3)'
`search --no-floppy --fs-uuid --set=root 28D9FDF951298246
linux android-x86/kernel root=UUID=28D9FDF951298246 quiet
androidboot.hardware=generic_x86 SRC=/android-x86 acpi_sleep=s3_bios,s3_mode
initrd Android-x86/android-4.4-r1/initrd.img
```
Now I have one extra Problem:
If I Start my laptop it shows Ubuntu, Windows, Kali Linux and Android (which doesn't work ), but if I start the GRub Costumizer the Windows isn't listed?! But Why? | 2014/08/28 | [
"https://askubuntu.com/questions/517212",
"https://askubuntu.com",
"https://askubuntu.com/users/321414/"
] | This is a ten month old question but I figured I'd help anyway. It's actually a very simple fix. I'm throwing the fix in my answer instead of hitting "edit" on the above answer because I don't want to wait for peer reviewing or whatever.
Anyway, the answer with the most votes states that you should use the following code:
```
set root='(hd0,4)'
`search --no-floppy --fs-uuid --set=root e1f9de05-8d18-48aa-8f08-f0377f663de3
linux androidx86/kernel root=UUID=e1f9de05-8d18-48aa-8f08-f0377f663de3 quiet androidboot.hardware=generic_x86 SRC=/androidx86 acpi_sleep=s3_bios,s3_mode
initrd androidx86/initrd.img
```
The issue is in line two. There's a stray grave (`) at the beginning of line two. Literally as simple as that. Sometimes it's the most simple of things that make everything stop working.
I imagine that you either have found a way to add Android x86 to GRUB or you just don't care anymore but yeah. So here's the correct code:
```
set root='(hd0,4)'
search --no-floppy --fs-uuid --set=root e1f9de05-8d18-48aa-8f08-f0377f663de3
linux androidx86/kernel root=UUID=e1f9de05-8d18-48aa-8f08-f0377f663de3 quiet androidboot.hardware=generic_x86 SRC=/androidx86 acpi_sleep=s3_bios,s3_mode
initrd androidx86/initrd.img
```
Here is my entire `/etc/grub.d/40_custom` file (excluding the `exec tail` and the commented out lines at the beginning):
```
menuentry "Android x86 4.4 R2" --class android --class gnu-linux --class gnu --class os {
set root='(hd0,msdos2)'
search --no-floppy --fs-uuid --set=root a47b5fe5-8969-4774-be9c-72c32a3fd14b
linux /android-4.4-r2/kernel root=UUID=a47b5fe5-8969-4774-be9c-72c32a3fd14b quiet androidboot.hardware=generic_x86 SRC=/android-4.4-r2 acpi_sleep=s3_bios,s3_mode
initrd /android-4.4-r2/initrd.img
}
menuentry "Android x86 5.0.2 UNOFFICIAL" --class android --class gnu-linux --class gnu --class os {
set root='(hd0,msdos4)'
search --no-floppy --fs-uuid --set=root d2edeae9-3dc8-41b1-b775-25d0a8028092
linux /android-2014-12-25/kernel root=UUID=d2edeae9-3dc8-41b1-b775-25d0a8028092 quiet androidboot.hardware=generic_x86 SRC/android-2014-12-25 acpi_sleep=s3_bios,s3_mode
initrd /android-2014-12-25/initrd.img
}
```
Obviously `hd0,msdos2` is the partition that I have Android 4.4 R2 installed on and `a47b5fe5-8969-4774-be9c-72c32a3fd14b` is the UUID of said partition and `hd0,msdos4` is the partition that I have Android 5.0.2 (unofficial and highly unstable) installed on and `d2edeae9-3dc8-41b1-b775-25d0a8028092` being that partition's UUID.
For me, `hd0,msdos2` is `/dev/sdb2` and `hd0,msdos4` is `/dev/sdb4`. I'm not sure on the following, but I think that GRUB does `hd0`, `hd1`, `hd2`, etc. in a different order than Linux does `sda/hda`, `sdb/hdb`, `sdc/hdc`, etc. Again, not sure, but I think GRUB does it in physical order (as they would be identified in your BIOS) and Linux does them in...uhh...some other way, I guess. Again, not sure on that.
But yeah if you need to figure out which partition in GRUB partition format (`hdX,msdosY`) your Android partition is (which I see is `/dev/sda3`), restart your PC and hit C to go to a command line. Then type `(hd` and hit tab (tab autocompletes things) and it will then list all drives as autocomplete options (not 100% sure but I'm like 70% sure it doesn't display USB drives unless they're SATA drives connected with a USB to SATA adapter). Then type `(hd0`, and hit tab and it will list all partitions on `hd0` as autocomplete options. If you have multiple drives, figuring out which one `/dev/sda3` is just a matter of trial and error with using autocomplete on `(hd`. I'm not sure *exactly* what the results look like but I do know for a fact that the results for `(hd0`, will (obviously) display the GRUB-style partition identifiers for all partitions on `hd0` (for you, it'd be `msdos1` through `msdos7`; in GRUB, `hd` starts at 0 but `msdos` starts at 1), the labels of all the partitions on `hd0`, and the filesystem (usually you throw Android x86 onto ext2 but since you have it on NTFS, it'd display the filesystem as NTFS; for most people it'd display ext2 which is how I know which one it is because my Android partitions are the only ext2 partitions I have).
Hmm...I had initially intended to only correct the mistake in line two of the most popular answer and I ended up with a damn near full tutorial on how to add Android x86 to GRUB... | This was all very helpful, but in the end, it was missing a small bit for me and it wouldn't work until I added in all the parts.
```
set root='(hd0,2)'
linux /cm-x86-14.1-r2/kernel quiet root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug
initrd /cm-x86-14.1-r2/initrd.img
```
As posted by Banan3'14 was right, but it was missing:
```
search --no-floppy --fs-uuid --set=root a47b5fe5-8969-4774-be9c-72c32a3fd14b
```
Maybe that was implied and I'm too new to have gotten that, but once I got it all together, it worked.
```
set root='(hd0,2)'
search --no-floppy --fs-uuid --set=root a47b5fe5-8969-4774-be9c-72c32a3fd14b
linux /cm-x86-14.1-r2/kernel quiet root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug
initrd /cm-x86-14.1-r2/initrd.img
``` |
517,212 | I have a small problem. I have seven partitions:
```
Device Boot Begin End Blocks Id System
/dev/sda1 * 206848 219013119 109403136 7 HPFS/NTFS/exFAT <-- wINDOWS 7
/dev/sda2 219013120 735516671 258251776 7 HPFS/NTFS/exFAT <--Musik,....
/dev/sda3 735516672 815638527 40060928 7 HPFS/NTFS/exFAT <-- Android
/dev/sda4 815640574 976771071 80565249 5 Erweiterte <-- No Idea:D
Partition 4 does not start at a physical sector boundary.
/dev/sda5 815640576 872494091 28426758 83 Linux <--Kali Linux
/dev/sda6 970151936 976771071 3309568 82 Linux Swap / Solaris
/dev/sda7 872495104 970149887 48827392 83 Linux <-- Ubuntu
```
I found a tutorial, but I tried this and it doesn't work. Here's the link:
<http://www.webupd8.org/2012/03/how-to-dual-boot-android-x86-and-ubuntu.html>
I used this Android from android-x86.org and the version android-x86-4.4-r1.iso.
This is my 40\_Costum document:
```
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Android-x86" {
set root='(hd0,3)'
linux /android-x86-4.4-r1/kernel quiet root=/dev/ram0 androidboot_hardware=eeepc acpi_sleep=s3_bios,s3_mode SRC=/android-x86-4.4-r1
initrd /android-x86-4.4-r1/initrd.img}
```
If I start my PC the [GRUB](http://en.wikipedia.org/wiki/GNU_GRUB) boot manager comes and I can choose Android, but it doesn't boot Android. The background is purple and nothing happens.
What would be a complete and working `40_Customm` script?
---
It doesn't work if I make a script in Grub Customizer and save it. It doesn't show on the boot menu if I open the Grub Customizer again the script is removed.
This is my code :
```
set root='(hd0,3)'
`search --no-floppy --fs-uuid --set=root 28D9FDF951298246
linux android-x86/kernel root=UUID=28D9FDF951298246 quiet
androidboot.hardware=generic_x86 SRC=/android-x86 acpi_sleep=s3_bios,s3_mode
initrd Android-x86/android-4.4-r1/initrd.img
```
Now I have one extra Problem:
If I Start my laptop it shows Ubuntu, Windows, Kali Linux and Android (which doesn't work ), but if I start the GRub Costumizer the Windows isn't listed?! But Why? | 2014/08/28 | [
"https://askubuntu.com/questions/517212",
"https://askubuntu.com",
"https://askubuntu.com/users/321414/"
] | [This is from XDA Developers](http://forum.xda-developers.com/showthread.php?t=2703270)
For GRUB 1.97 - 1.99 & 2.00 +
1. To make it easy, install GRUB Customizer
Type these into terminal emulator :
Code:
```
sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer
```
2. Open GRUB customizer and make a new GRUB entry.
3. Open 'Sources' tab, type these :
```
set root='(hd0,4)'
search --no-floppy --fs-uuid --set=root e1f9de05-8d18-48aa-8f08-f0377f663de3
linux androidx86/kernel root=UUID=e1f9de05-8d18-48aa-8f08-f0377f663de3 quiet androidboot.hardware=generic_x86 SRC=/androidx86 acpi_sleep=s3_bios,s3_mode
initrd androidx86/initrd.img
```
Here's what to change :
>
> 1. `set root='(hd0,4)'` : Change the (hd0,4) to partiton Android x86 is installed. The hd0 means sda, so if you install it to sdb, it'll be
> hd1 and so on. The hd0,4 means the partition number, in my case, hd0,4
> means sda4. So if you install it on sda6, it'll be hd0,6.
> 2. `--set=root e1f9de05-8d18-48aa-8f08-f0377f663de3` : The random number here is the UUID of partition Android x86 is installed You must change
> it to correct UUID, you can easily got UUID by creating new entry in
> GRUB Customizer then go to Options tab, then select the 'Linux' option
> in dropdown. You'll see partition dropdown, select your partition.
> Open the source tab, you'll see the UUID there.
> 3. `androidx86/` : The root of Android x86 Change it into your Android x86 root. You can see what's your Android x86 root by navigating to
> Android x86 partition, and you'll see a folder name started with
> 'android', that's the root of your Android x86
> 4. `androidboot.hardware` : Your device, of course. Note : If you're using Android 2.3 - 4.0.3, change it to androidboot\_hardware Here's the list of hardware :
>
>
>
* `generic_x86` : If your hardware isn't listed, use this
* `eeepc` : EEEPC laptops
* `asus_laptop` : ASUS laptops (supported ASUS laptops only) | This is a ten month old question but I figured I'd help anyway. It's actually a very simple fix. I'm throwing the fix in my answer instead of hitting "edit" on the above answer because I don't want to wait for peer reviewing or whatever.
Anyway, the answer with the most votes states that you should use the following code:
```
set root='(hd0,4)'
`search --no-floppy --fs-uuid --set=root e1f9de05-8d18-48aa-8f08-f0377f663de3
linux androidx86/kernel root=UUID=e1f9de05-8d18-48aa-8f08-f0377f663de3 quiet androidboot.hardware=generic_x86 SRC=/androidx86 acpi_sleep=s3_bios,s3_mode
initrd androidx86/initrd.img
```
The issue is in line two. There's a stray grave (`) at the beginning of line two. Literally as simple as that. Sometimes it's the most simple of things that make everything stop working.
I imagine that you either have found a way to add Android x86 to GRUB or you just don't care anymore but yeah. So here's the correct code:
```
set root='(hd0,4)'
search --no-floppy --fs-uuid --set=root e1f9de05-8d18-48aa-8f08-f0377f663de3
linux androidx86/kernel root=UUID=e1f9de05-8d18-48aa-8f08-f0377f663de3 quiet androidboot.hardware=generic_x86 SRC=/androidx86 acpi_sleep=s3_bios,s3_mode
initrd androidx86/initrd.img
```
Here is my entire `/etc/grub.d/40_custom` file (excluding the `exec tail` and the commented out lines at the beginning):
```
menuentry "Android x86 4.4 R2" --class android --class gnu-linux --class gnu --class os {
set root='(hd0,msdos2)'
search --no-floppy --fs-uuid --set=root a47b5fe5-8969-4774-be9c-72c32a3fd14b
linux /android-4.4-r2/kernel root=UUID=a47b5fe5-8969-4774-be9c-72c32a3fd14b quiet androidboot.hardware=generic_x86 SRC=/android-4.4-r2 acpi_sleep=s3_bios,s3_mode
initrd /android-4.4-r2/initrd.img
}
menuentry "Android x86 5.0.2 UNOFFICIAL" --class android --class gnu-linux --class gnu --class os {
set root='(hd0,msdos4)'
search --no-floppy --fs-uuid --set=root d2edeae9-3dc8-41b1-b775-25d0a8028092
linux /android-2014-12-25/kernel root=UUID=d2edeae9-3dc8-41b1-b775-25d0a8028092 quiet androidboot.hardware=generic_x86 SRC/android-2014-12-25 acpi_sleep=s3_bios,s3_mode
initrd /android-2014-12-25/initrd.img
}
```
Obviously `hd0,msdos2` is the partition that I have Android 4.4 R2 installed on and `a47b5fe5-8969-4774-be9c-72c32a3fd14b` is the UUID of said partition and `hd0,msdos4` is the partition that I have Android 5.0.2 (unofficial and highly unstable) installed on and `d2edeae9-3dc8-41b1-b775-25d0a8028092` being that partition's UUID.
For me, `hd0,msdos2` is `/dev/sdb2` and `hd0,msdos4` is `/dev/sdb4`. I'm not sure on the following, but I think that GRUB does `hd0`, `hd1`, `hd2`, etc. in a different order than Linux does `sda/hda`, `sdb/hdb`, `sdc/hdc`, etc. Again, not sure, but I think GRUB does it in physical order (as they would be identified in your BIOS) and Linux does them in...uhh...some other way, I guess. Again, not sure on that.
But yeah if you need to figure out which partition in GRUB partition format (`hdX,msdosY`) your Android partition is (which I see is `/dev/sda3`), restart your PC and hit C to go to a command line. Then type `(hd` and hit tab (tab autocompletes things) and it will then list all drives as autocomplete options (not 100% sure but I'm like 70% sure it doesn't display USB drives unless they're SATA drives connected with a USB to SATA adapter). Then type `(hd0`, and hit tab and it will list all partitions on `hd0` as autocomplete options. If you have multiple drives, figuring out which one `/dev/sda3` is just a matter of trial and error with using autocomplete on `(hd`. I'm not sure *exactly* what the results look like but I do know for a fact that the results for `(hd0`, will (obviously) display the GRUB-style partition identifiers for all partitions on `hd0` (for you, it'd be `msdos1` through `msdos7`; in GRUB, `hd` starts at 0 but `msdos` starts at 1), the labels of all the partitions on `hd0`, and the filesystem (usually you throw Android x86 onto ext2 but since you have it on NTFS, it'd display the filesystem as NTFS; for most people it'd display ext2 which is how I know which one it is because my Android partitions are the only ext2 partitions I have).
Hmm...I had initially intended to only correct the mistake in line two of the most popular answer and I ended up with a damn near full tutorial on how to add Android x86 to GRUB... |
517,212 | I have a small problem. I have seven partitions:
```
Device Boot Begin End Blocks Id System
/dev/sda1 * 206848 219013119 109403136 7 HPFS/NTFS/exFAT <-- wINDOWS 7
/dev/sda2 219013120 735516671 258251776 7 HPFS/NTFS/exFAT <--Musik,....
/dev/sda3 735516672 815638527 40060928 7 HPFS/NTFS/exFAT <-- Android
/dev/sda4 815640574 976771071 80565249 5 Erweiterte <-- No Idea:D
Partition 4 does not start at a physical sector boundary.
/dev/sda5 815640576 872494091 28426758 83 Linux <--Kali Linux
/dev/sda6 970151936 976771071 3309568 82 Linux Swap / Solaris
/dev/sda7 872495104 970149887 48827392 83 Linux <-- Ubuntu
```
I found a tutorial, but I tried this and it doesn't work. Here's the link:
<http://www.webupd8.org/2012/03/how-to-dual-boot-android-x86-and-ubuntu.html>
I used this Android from android-x86.org and the version android-x86-4.4-r1.iso.
This is my 40\_Costum document:
```
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Android-x86" {
set root='(hd0,3)'
linux /android-x86-4.4-r1/kernel quiet root=/dev/ram0 androidboot_hardware=eeepc acpi_sleep=s3_bios,s3_mode SRC=/android-x86-4.4-r1
initrd /android-x86-4.4-r1/initrd.img}
```
If I start my PC the [GRUB](http://en.wikipedia.org/wiki/GNU_GRUB) boot manager comes and I can choose Android, but it doesn't boot Android. The background is purple and nothing happens.
What would be a complete and working `40_Customm` script?
---
It doesn't work if I make a script in Grub Customizer and save it. It doesn't show on the boot menu if I open the Grub Customizer again the script is removed.
This is my code :
```
set root='(hd0,3)'
`search --no-floppy --fs-uuid --set=root 28D9FDF951298246
linux android-x86/kernel root=UUID=28D9FDF951298246 quiet
androidboot.hardware=generic_x86 SRC=/android-x86 acpi_sleep=s3_bios,s3_mode
initrd Android-x86/android-4.4-r1/initrd.img
```
Now I have one extra Problem:
If I Start my laptop it shows Ubuntu, Windows, Kali Linux and Android (which doesn't work ), but if I start the GRub Costumizer the Windows isn't listed?! But Why? | 2014/08/28 | [
"https://askubuntu.com/questions/517212",
"https://askubuntu.com",
"https://askubuntu.com/users/321414/"
] | * Open `40_custom`:
```
sudo -H gedit /etc/burg.d/40_custom
```
* Add Android x86 menu entry:
```
menuentry "Android-4.3-x86" --class android {
set root='(hd*,msdos*)'
linux /path/android-4.3-x86/kernel quiet root=/dev/ram0 androidboot.hardware=tx2500 acpi_sleep=s3_bios,s3_mode SRC=/path/android-4.3-x86 vga=788
initrd /path/android-4.3-x86/initrd.img
```
(set `path` and `*` as yours)
* Update grub:
```
sudo update-grub
``` | None of the other answers worked for me, so I decided to find the solution myself in the files provided by the ISO image with Android-x86 installation files.
In `Android-x86 LiveCD1/efi/boot/android.cfg` I found the following menu entry:
```
set root=$android
linux $kdir/kernel root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug $src $@
initrd $kdir/initrd.img
```
The question was what the values of `$kdir` and `$android` should be. After mounting the partition I installed the system on (`sda2`), I found the name of the directory - `cm-x86-14.1-r2`.
`$@` are additional parameters (`quiet` in my solution) and `$src` can be ignored. Finally, I made the following grub entry:
```
set root='(hd0,2)'
linux /cm-x86-14.1-r2/kernel quiet root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug
initrd /cm-x86-14.1-r2/initrd.img
```
And it works. |
517,212 | I have a small problem. I have seven partitions:
```
Device Boot Begin End Blocks Id System
/dev/sda1 * 206848 219013119 109403136 7 HPFS/NTFS/exFAT <-- wINDOWS 7
/dev/sda2 219013120 735516671 258251776 7 HPFS/NTFS/exFAT <--Musik,....
/dev/sda3 735516672 815638527 40060928 7 HPFS/NTFS/exFAT <-- Android
/dev/sda4 815640574 976771071 80565249 5 Erweiterte <-- No Idea:D
Partition 4 does not start at a physical sector boundary.
/dev/sda5 815640576 872494091 28426758 83 Linux <--Kali Linux
/dev/sda6 970151936 976771071 3309568 82 Linux Swap / Solaris
/dev/sda7 872495104 970149887 48827392 83 Linux <-- Ubuntu
```
I found a tutorial, but I tried this and it doesn't work. Here's the link:
<http://www.webupd8.org/2012/03/how-to-dual-boot-android-x86-and-ubuntu.html>
I used this Android from android-x86.org and the version android-x86-4.4-r1.iso.
This is my 40\_Costum document:
```
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Android-x86" {
set root='(hd0,3)'
linux /android-x86-4.4-r1/kernel quiet root=/dev/ram0 androidboot_hardware=eeepc acpi_sleep=s3_bios,s3_mode SRC=/android-x86-4.4-r1
initrd /android-x86-4.4-r1/initrd.img}
```
If I start my PC the [GRUB](http://en.wikipedia.org/wiki/GNU_GRUB) boot manager comes and I can choose Android, but it doesn't boot Android. The background is purple and nothing happens.
What would be a complete and working `40_Customm` script?
---
It doesn't work if I make a script in Grub Customizer and save it. It doesn't show on the boot menu if I open the Grub Customizer again the script is removed.
This is my code :
```
set root='(hd0,3)'
`search --no-floppy --fs-uuid --set=root 28D9FDF951298246
linux android-x86/kernel root=UUID=28D9FDF951298246 quiet
androidboot.hardware=generic_x86 SRC=/android-x86 acpi_sleep=s3_bios,s3_mode
initrd Android-x86/android-4.4-r1/initrd.img
```
Now I have one extra Problem:
If I Start my laptop it shows Ubuntu, Windows, Kali Linux and Android (which doesn't work ), but if I start the GRub Costumizer the Windows isn't listed?! But Why? | 2014/08/28 | [
"https://askubuntu.com/questions/517212",
"https://askubuntu.com",
"https://askubuntu.com/users/321414/"
] | This is a ten month old question but I figured I'd help anyway. It's actually a very simple fix. I'm throwing the fix in my answer instead of hitting "edit" on the above answer because I don't want to wait for peer reviewing or whatever.
Anyway, the answer with the most votes states that you should use the following code:
```
set root='(hd0,4)'
`search --no-floppy --fs-uuid --set=root e1f9de05-8d18-48aa-8f08-f0377f663de3
linux androidx86/kernel root=UUID=e1f9de05-8d18-48aa-8f08-f0377f663de3 quiet androidboot.hardware=generic_x86 SRC=/androidx86 acpi_sleep=s3_bios,s3_mode
initrd androidx86/initrd.img
```
The issue is in line two. There's a stray grave (`) at the beginning of line two. Literally as simple as that. Sometimes it's the most simple of things that make everything stop working.
I imagine that you either have found a way to add Android x86 to GRUB or you just don't care anymore but yeah. So here's the correct code:
```
set root='(hd0,4)'
search --no-floppy --fs-uuid --set=root e1f9de05-8d18-48aa-8f08-f0377f663de3
linux androidx86/kernel root=UUID=e1f9de05-8d18-48aa-8f08-f0377f663de3 quiet androidboot.hardware=generic_x86 SRC=/androidx86 acpi_sleep=s3_bios,s3_mode
initrd androidx86/initrd.img
```
Here is my entire `/etc/grub.d/40_custom` file (excluding the `exec tail` and the commented out lines at the beginning):
```
menuentry "Android x86 4.4 R2" --class android --class gnu-linux --class gnu --class os {
set root='(hd0,msdos2)'
search --no-floppy --fs-uuid --set=root a47b5fe5-8969-4774-be9c-72c32a3fd14b
linux /android-4.4-r2/kernel root=UUID=a47b5fe5-8969-4774-be9c-72c32a3fd14b quiet androidboot.hardware=generic_x86 SRC=/android-4.4-r2 acpi_sleep=s3_bios,s3_mode
initrd /android-4.4-r2/initrd.img
}
menuentry "Android x86 5.0.2 UNOFFICIAL" --class android --class gnu-linux --class gnu --class os {
set root='(hd0,msdos4)'
search --no-floppy --fs-uuid --set=root d2edeae9-3dc8-41b1-b775-25d0a8028092
linux /android-2014-12-25/kernel root=UUID=d2edeae9-3dc8-41b1-b775-25d0a8028092 quiet androidboot.hardware=generic_x86 SRC/android-2014-12-25 acpi_sleep=s3_bios,s3_mode
initrd /android-2014-12-25/initrd.img
}
```
Obviously `hd0,msdos2` is the partition that I have Android 4.4 R2 installed on and `a47b5fe5-8969-4774-be9c-72c32a3fd14b` is the UUID of said partition and `hd0,msdos4` is the partition that I have Android 5.0.2 (unofficial and highly unstable) installed on and `d2edeae9-3dc8-41b1-b775-25d0a8028092` being that partition's UUID.
For me, `hd0,msdos2` is `/dev/sdb2` and `hd0,msdos4` is `/dev/sdb4`. I'm not sure on the following, but I think that GRUB does `hd0`, `hd1`, `hd2`, etc. in a different order than Linux does `sda/hda`, `sdb/hdb`, `sdc/hdc`, etc. Again, not sure, but I think GRUB does it in physical order (as they would be identified in your BIOS) and Linux does them in...uhh...some other way, I guess. Again, not sure on that.
But yeah if you need to figure out which partition in GRUB partition format (`hdX,msdosY`) your Android partition is (which I see is `/dev/sda3`), restart your PC and hit C to go to a command line. Then type `(hd` and hit tab (tab autocompletes things) and it will then list all drives as autocomplete options (not 100% sure but I'm like 70% sure it doesn't display USB drives unless they're SATA drives connected with a USB to SATA adapter). Then type `(hd0`, and hit tab and it will list all partitions on `hd0` as autocomplete options. If you have multiple drives, figuring out which one `/dev/sda3` is just a matter of trial and error with using autocomplete on `(hd`. I'm not sure *exactly* what the results look like but I do know for a fact that the results for `(hd0`, will (obviously) display the GRUB-style partition identifiers for all partitions on `hd0` (for you, it'd be `msdos1` through `msdos7`; in GRUB, `hd` starts at 0 but `msdos` starts at 1), the labels of all the partitions on `hd0`, and the filesystem (usually you throw Android x86 onto ext2 but since you have it on NTFS, it'd display the filesystem as NTFS; for most people it'd display ext2 which is how I know which one it is because my Android partitions are the only ext2 partitions I have).
Hmm...I had initially intended to only correct the mistake in line two of the most popular answer and I ended up with a damn near full tutorial on how to add Android x86 to GRUB... | Don't bother with the sda or sdc, it is always (hd0,x) in my case if you installed the android x86 to the booting device. That's to say, in my case, whether your device is listed in os like ubuntu as /dev/sda or /dev/sdb, you should add (hd0,x), x is the number of your android x86 partition, in the grub 2 item, as long as you boot up with the same device you installed your android x86(for example, you installed android x86 in a usb drive named U at partition 3, and U listed in your ubuntu as /dev/sdc, but you boot from U, then you should add root=(hd0,3) but not root=(hd2,3) in the grub). |
517,212 | I have a small problem. I have seven partitions:
```
Device Boot Begin End Blocks Id System
/dev/sda1 * 206848 219013119 109403136 7 HPFS/NTFS/exFAT <-- wINDOWS 7
/dev/sda2 219013120 735516671 258251776 7 HPFS/NTFS/exFAT <--Musik,....
/dev/sda3 735516672 815638527 40060928 7 HPFS/NTFS/exFAT <-- Android
/dev/sda4 815640574 976771071 80565249 5 Erweiterte <-- No Idea:D
Partition 4 does not start at a physical sector boundary.
/dev/sda5 815640576 872494091 28426758 83 Linux <--Kali Linux
/dev/sda6 970151936 976771071 3309568 82 Linux Swap / Solaris
/dev/sda7 872495104 970149887 48827392 83 Linux <-- Ubuntu
```
I found a tutorial, but I tried this and it doesn't work. Here's the link:
<http://www.webupd8.org/2012/03/how-to-dual-boot-android-x86-and-ubuntu.html>
I used this Android from android-x86.org and the version android-x86-4.4-r1.iso.
This is my 40\_Costum document:
```
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Android-x86" {
set root='(hd0,3)'
linux /android-x86-4.4-r1/kernel quiet root=/dev/ram0 androidboot_hardware=eeepc acpi_sleep=s3_bios,s3_mode SRC=/android-x86-4.4-r1
initrd /android-x86-4.4-r1/initrd.img}
```
If I start my PC the [GRUB](http://en.wikipedia.org/wiki/GNU_GRUB) boot manager comes and I can choose Android, but it doesn't boot Android. The background is purple and nothing happens.
What would be a complete and working `40_Customm` script?
---
It doesn't work if I make a script in Grub Customizer and save it. It doesn't show on the boot menu if I open the Grub Customizer again the script is removed.
This is my code :
```
set root='(hd0,3)'
`search --no-floppy --fs-uuid --set=root 28D9FDF951298246
linux android-x86/kernel root=UUID=28D9FDF951298246 quiet
androidboot.hardware=generic_x86 SRC=/android-x86 acpi_sleep=s3_bios,s3_mode
initrd Android-x86/android-4.4-r1/initrd.img
```
Now I have one extra Problem:
If I Start my laptop it shows Ubuntu, Windows, Kali Linux and Android (which doesn't work ), but if I start the GRub Costumizer the Windows isn't listed?! But Why? | 2014/08/28 | [
"https://askubuntu.com/questions/517212",
"https://askubuntu.com",
"https://askubuntu.com/users/321414/"
] | Regarding Android x86 6.0
The "EEEPC" assignment is only for ASUS EEEPCs, only use it if you have one, otherwise use `android_x86`, **do not use generic\_x86**, you will get stuck at the boot animation and have to restart by using `CTRL`+`F1` to access the terminal and issue `reboot` as the GUI will not get loaded. I know this because I spent several hours following bad, though well intentioned, advice.
```
set root='(hd0,4)'
linux /android-6.0-rc1/kernel quiet root=/dev/ram0 androidboot.hardware=android_x86 acpi_sleep=s3_bios,s3_mode SRC=/android-6.0-rc1
initrd /android-6.0-rc1/initrd.img
```
This was the final configuration that worked for me on an old school SONY VAIO 64 bit on a triple boot setup.
`'(0,4)'` was the location of my hard drive and partition Android x86 was installed to, change it accordingly. You do not need your UUID, you only need exactly what I have put above with your installation location being the only change. | This was all very helpful, but in the end, it was missing a small bit for me and it wouldn't work until I added in all the parts.
```
set root='(hd0,2)'
linux /cm-x86-14.1-r2/kernel quiet root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug
initrd /cm-x86-14.1-r2/initrd.img
```
As posted by Banan3'14 was right, but it was missing:
```
search --no-floppy --fs-uuid --set=root a47b5fe5-8969-4774-be9c-72c32a3fd14b
```
Maybe that was implied and I'm too new to have gotten that, but once I got it all together, it worked.
```
set root='(hd0,2)'
search --no-floppy --fs-uuid --set=root a47b5fe5-8969-4774-be9c-72c32a3fd14b
linux /cm-x86-14.1-r2/kernel quiet root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug
initrd /cm-x86-14.1-r2/initrd.img
``` |
517,212 | I have a small problem. I have seven partitions:
```
Device Boot Begin End Blocks Id System
/dev/sda1 * 206848 219013119 109403136 7 HPFS/NTFS/exFAT <-- wINDOWS 7
/dev/sda2 219013120 735516671 258251776 7 HPFS/NTFS/exFAT <--Musik,....
/dev/sda3 735516672 815638527 40060928 7 HPFS/NTFS/exFAT <-- Android
/dev/sda4 815640574 976771071 80565249 5 Erweiterte <-- No Idea:D
Partition 4 does not start at a physical sector boundary.
/dev/sda5 815640576 872494091 28426758 83 Linux <--Kali Linux
/dev/sda6 970151936 976771071 3309568 82 Linux Swap / Solaris
/dev/sda7 872495104 970149887 48827392 83 Linux <-- Ubuntu
```
I found a tutorial, but I tried this and it doesn't work. Here's the link:
<http://www.webupd8.org/2012/03/how-to-dual-boot-android-x86-and-ubuntu.html>
I used this Android from android-x86.org and the version android-x86-4.4-r1.iso.
This is my 40\_Costum document:
```
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Android-x86" {
set root='(hd0,3)'
linux /android-x86-4.4-r1/kernel quiet root=/dev/ram0 androidboot_hardware=eeepc acpi_sleep=s3_bios,s3_mode SRC=/android-x86-4.4-r1
initrd /android-x86-4.4-r1/initrd.img}
```
If I start my PC the [GRUB](http://en.wikipedia.org/wiki/GNU_GRUB) boot manager comes and I can choose Android, but it doesn't boot Android. The background is purple and nothing happens.
What would be a complete and working `40_Customm` script?
---
It doesn't work if I make a script in Grub Customizer and save it. It doesn't show on the boot menu if I open the Grub Customizer again the script is removed.
This is my code :
```
set root='(hd0,3)'
`search --no-floppy --fs-uuid --set=root 28D9FDF951298246
linux android-x86/kernel root=UUID=28D9FDF951298246 quiet
androidboot.hardware=generic_x86 SRC=/android-x86 acpi_sleep=s3_bios,s3_mode
initrd Android-x86/android-4.4-r1/initrd.img
```
Now I have one extra Problem:
If I Start my laptop it shows Ubuntu, Windows, Kali Linux and Android (which doesn't work ), but if I start the GRub Costumizer the Windows isn't listed?! But Why? | 2014/08/28 | [
"https://askubuntu.com/questions/517212",
"https://askubuntu.com",
"https://askubuntu.com/users/321414/"
] | [This is from XDA Developers](http://forum.xda-developers.com/showthread.php?t=2703270)
For GRUB 1.97 - 1.99 & 2.00 +
1. To make it easy, install GRUB Customizer
Type these into terminal emulator :
Code:
```
sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer
```
2. Open GRUB customizer and make a new GRUB entry.
3. Open 'Sources' tab, type these :
```
set root='(hd0,4)'
search --no-floppy --fs-uuid --set=root e1f9de05-8d18-48aa-8f08-f0377f663de3
linux androidx86/kernel root=UUID=e1f9de05-8d18-48aa-8f08-f0377f663de3 quiet androidboot.hardware=generic_x86 SRC=/androidx86 acpi_sleep=s3_bios,s3_mode
initrd androidx86/initrd.img
```
Here's what to change :
>
> 1. `set root='(hd0,4)'` : Change the (hd0,4) to partiton Android x86 is installed. The hd0 means sda, so if you install it to sdb, it'll be
> hd1 and so on. The hd0,4 means the partition number, in my case, hd0,4
> means sda4. So if you install it on sda6, it'll be hd0,6.
> 2. `--set=root e1f9de05-8d18-48aa-8f08-f0377f663de3` : The random number here is the UUID of partition Android x86 is installed You must change
> it to correct UUID, you can easily got UUID by creating new entry in
> GRUB Customizer then go to Options tab, then select the 'Linux' option
> in dropdown. You'll see partition dropdown, select your partition.
> Open the source tab, you'll see the UUID there.
> 3. `androidx86/` : The root of Android x86 Change it into your Android x86 root. You can see what's your Android x86 root by navigating to
> Android x86 partition, and you'll see a folder name started with
> 'android', that's the root of your Android x86
> 4. `androidboot.hardware` : Your device, of course. Note : If you're using Android 2.3 - 4.0.3, change it to androidboot\_hardware Here's the list of hardware :
>
>
>
* `generic_x86` : If your hardware isn't listed, use this
* `eeepc` : EEEPC laptops
* `asus_laptop` : ASUS laptops (supported ASUS laptops only) | None of the other answers worked for me, so I decided to find the solution myself in the files provided by the ISO image with Android-x86 installation files.
In `Android-x86 LiveCD1/efi/boot/android.cfg` I found the following menu entry:
```
set root=$android
linux $kdir/kernel root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug $src $@
initrd $kdir/initrd.img
```
The question was what the values of `$kdir` and `$android` should be. After mounting the partition I installed the system on (`sda2`), I found the name of the directory - `cm-x86-14.1-r2`.
`$@` are additional parameters (`quiet` in my solution) and `$src` can be ignored. Finally, I made the following grub entry:
```
set root='(hd0,2)'
linux /cm-x86-14.1-r2/kernel quiet root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug
initrd /cm-x86-14.1-r2/initrd.img
```
And it works. |
517,212 | I have a small problem. I have seven partitions:
```
Device Boot Begin End Blocks Id System
/dev/sda1 * 206848 219013119 109403136 7 HPFS/NTFS/exFAT <-- wINDOWS 7
/dev/sda2 219013120 735516671 258251776 7 HPFS/NTFS/exFAT <--Musik,....
/dev/sda3 735516672 815638527 40060928 7 HPFS/NTFS/exFAT <-- Android
/dev/sda4 815640574 976771071 80565249 5 Erweiterte <-- No Idea:D
Partition 4 does not start at a physical sector boundary.
/dev/sda5 815640576 872494091 28426758 83 Linux <--Kali Linux
/dev/sda6 970151936 976771071 3309568 82 Linux Swap / Solaris
/dev/sda7 872495104 970149887 48827392 83 Linux <-- Ubuntu
```
I found a tutorial, but I tried this and it doesn't work. Here's the link:
<http://www.webupd8.org/2012/03/how-to-dual-boot-android-x86-and-ubuntu.html>
I used this Android from android-x86.org and the version android-x86-4.4-r1.iso.
This is my 40\_Costum document:
```
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Android-x86" {
set root='(hd0,3)'
linux /android-x86-4.4-r1/kernel quiet root=/dev/ram0 androidboot_hardware=eeepc acpi_sleep=s3_bios,s3_mode SRC=/android-x86-4.4-r1
initrd /android-x86-4.4-r1/initrd.img}
```
If I start my PC the [GRUB](http://en.wikipedia.org/wiki/GNU_GRUB) boot manager comes and I can choose Android, but it doesn't boot Android. The background is purple and nothing happens.
What would be a complete and working `40_Customm` script?
---
It doesn't work if I make a script in Grub Customizer and save it. It doesn't show on the boot menu if I open the Grub Customizer again the script is removed.
This is my code :
```
set root='(hd0,3)'
`search --no-floppy --fs-uuid --set=root 28D9FDF951298246
linux android-x86/kernel root=UUID=28D9FDF951298246 quiet
androidboot.hardware=generic_x86 SRC=/android-x86 acpi_sleep=s3_bios,s3_mode
initrd Android-x86/android-4.4-r1/initrd.img
```
Now I have one extra Problem:
If I Start my laptop it shows Ubuntu, Windows, Kali Linux and Android (which doesn't work ), but if I start the GRub Costumizer the Windows isn't listed?! But Why? | 2014/08/28 | [
"https://askubuntu.com/questions/517212",
"https://askubuntu.com",
"https://askubuntu.com/users/321414/"
] | [This is from XDA Developers](http://forum.xda-developers.com/showthread.php?t=2703270)
For GRUB 1.97 - 1.99 & 2.00 +
1. To make it easy, install GRUB Customizer
Type these into terminal emulator :
Code:
```
sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer
```
2. Open GRUB customizer and make a new GRUB entry.
3. Open 'Sources' tab, type these :
```
set root='(hd0,4)'
search --no-floppy --fs-uuid --set=root e1f9de05-8d18-48aa-8f08-f0377f663de3
linux androidx86/kernel root=UUID=e1f9de05-8d18-48aa-8f08-f0377f663de3 quiet androidboot.hardware=generic_x86 SRC=/androidx86 acpi_sleep=s3_bios,s3_mode
initrd androidx86/initrd.img
```
Here's what to change :
>
> 1. `set root='(hd0,4)'` : Change the (hd0,4) to partiton Android x86 is installed. The hd0 means sda, so if you install it to sdb, it'll be
> hd1 and so on. The hd0,4 means the partition number, in my case, hd0,4
> means sda4. So if you install it on sda6, it'll be hd0,6.
> 2. `--set=root e1f9de05-8d18-48aa-8f08-f0377f663de3` : The random number here is the UUID of partition Android x86 is installed You must change
> it to correct UUID, you can easily got UUID by creating new entry in
> GRUB Customizer then go to Options tab, then select the 'Linux' option
> in dropdown. You'll see partition dropdown, select your partition.
> Open the source tab, you'll see the UUID there.
> 3. `androidx86/` : The root of Android x86 Change it into your Android x86 root. You can see what's your Android x86 root by navigating to
> Android x86 partition, and you'll see a folder name started with
> 'android', that's the root of your Android x86
> 4. `androidboot.hardware` : Your device, of course. Note : If you're using Android 2.3 - 4.0.3, change it to androidboot\_hardware Here's the list of hardware :
>
>
>
* `generic_x86` : If your hardware isn't listed, use this
* `eeepc` : EEEPC laptops
* `asus_laptop` : ASUS laptops (supported ASUS laptops only) | This was all very helpful, but in the end, it was missing a small bit for me and it wouldn't work until I added in all the parts.
```
set root='(hd0,2)'
linux /cm-x86-14.1-r2/kernel quiet root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug
initrd /cm-x86-14.1-r2/initrd.img
```
As posted by Banan3'14 was right, but it was missing:
```
search --no-floppy --fs-uuid --set=root a47b5fe5-8969-4774-be9c-72c32a3fd14b
```
Maybe that was implied and I'm too new to have gotten that, but once I got it all together, it worked.
```
set root='(hd0,2)'
search --no-floppy --fs-uuid --set=root a47b5fe5-8969-4774-be9c-72c32a3fd14b
linux /cm-x86-14.1-r2/kernel quiet root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug
initrd /cm-x86-14.1-r2/initrd.img
``` |
517,212 | I have a small problem. I have seven partitions:
```
Device Boot Begin End Blocks Id System
/dev/sda1 * 206848 219013119 109403136 7 HPFS/NTFS/exFAT <-- wINDOWS 7
/dev/sda2 219013120 735516671 258251776 7 HPFS/NTFS/exFAT <--Musik,....
/dev/sda3 735516672 815638527 40060928 7 HPFS/NTFS/exFAT <-- Android
/dev/sda4 815640574 976771071 80565249 5 Erweiterte <-- No Idea:D
Partition 4 does not start at a physical sector boundary.
/dev/sda5 815640576 872494091 28426758 83 Linux <--Kali Linux
/dev/sda6 970151936 976771071 3309568 82 Linux Swap / Solaris
/dev/sda7 872495104 970149887 48827392 83 Linux <-- Ubuntu
```
I found a tutorial, but I tried this and it doesn't work. Here's the link:
<http://www.webupd8.org/2012/03/how-to-dual-boot-android-x86-and-ubuntu.html>
I used this Android from android-x86.org and the version android-x86-4.4-r1.iso.
This is my 40\_Costum document:
```
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Android-x86" {
set root='(hd0,3)'
linux /android-x86-4.4-r1/kernel quiet root=/dev/ram0 androidboot_hardware=eeepc acpi_sleep=s3_bios,s3_mode SRC=/android-x86-4.4-r1
initrd /android-x86-4.4-r1/initrd.img}
```
If I start my PC the [GRUB](http://en.wikipedia.org/wiki/GNU_GRUB) boot manager comes and I can choose Android, but it doesn't boot Android. The background is purple and nothing happens.
What would be a complete and working `40_Customm` script?
---
It doesn't work if I make a script in Grub Customizer and save it. It doesn't show on the boot menu if I open the Grub Customizer again the script is removed.
This is my code :
```
set root='(hd0,3)'
`search --no-floppy --fs-uuid --set=root 28D9FDF951298246
linux android-x86/kernel root=UUID=28D9FDF951298246 quiet
androidboot.hardware=generic_x86 SRC=/android-x86 acpi_sleep=s3_bios,s3_mode
initrd Android-x86/android-4.4-r1/initrd.img
```
Now I have one extra Problem:
If I Start my laptop it shows Ubuntu, Windows, Kali Linux and Android (which doesn't work ), but if I start the GRub Costumizer the Windows isn't listed?! But Why? | 2014/08/28 | [
"https://askubuntu.com/questions/517212",
"https://askubuntu.com",
"https://askubuntu.com/users/321414/"
] | This was all very helpful, but in the end, it was missing a small bit for me and it wouldn't work until I added in all the parts.
```
set root='(hd0,2)'
linux /cm-x86-14.1-r2/kernel quiet root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug
initrd /cm-x86-14.1-r2/initrd.img
```
As posted by Banan3'14 was right, but it was missing:
```
search --no-floppy --fs-uuid --set=root a47b5fe5-8969-4774-be9c-72c32a3fd14b
```
Maybe that was implied and I'm too new to have gotten that, but once I got it all together, it worked.
```
set root='(hd0,2)'
search --no-floppy --fs-uuid --set=root a47b5fe5-8969-4774-be9c-72c32a3fd14b
linux /cm-x86-14.1-r2/kernel quiet root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug
initrd /cm-x86-14.1-r2/initrd.img
``` | Don't bother with the sda or sdc, it is always (hd0,x) in my case if you installed the android x86 to the booting device. That's to say, in my case, whether your device is listed in os like ubuntu as /dev/sda or /dev/sdb, you should add (hd0,x), x is the number of your android x86 partition, in the grub 2 item, as long as you boot up with the same device you installed your android x86(for example, you installed android x86 in a usb drive named U at partition 3, and U listed in your ubuntu as /dev/sdc, but you boot from U, then you should add root=(hd0,3) but not root=(hd2,3) in the grub). |
123,320 | In showing that MSE can be decomposed into variance plus the square of Bias, [the proof in Wikipedia](https://en.wikipedia.org/wiki/Mean_squared_error#Proof_of_variance_and_bias_relationship) has a step, highlighted in the picture. How does this work? How is the expectation pushed in to the product from the 3rd step to the 4th step? If the two terms are independent, shouldn't the expectation be applied to both the terms? and if they aren't, is this step valid? | 2014/11/09 | [
"https://stats.stackexchange.com/questions/123320",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/55780/"
] | The trick is that $\mathbb{E}(\hat{\theta}) - \theta$ is a constant. | $E(\hat{\theta}) - \theta$ is not a constant.
The comment of @user1158559 is actually the correct one:
$$
E[\hat{\theta} - E(\hat{\theta})] = E(\hat{\theta}) - E[E(\hat{\theta})]
= E(\hat{\theta}) - E(\hat{\theta}) = 0
$$ |
123,320 | In showing that MSE can be decomposed into variance plus the square of Bias, [the proof in Wikipedia](https://en.wikipedia.org/wiki/Mean_squared_error#Proof_of_variance_and_bias_relationship) has a step, highlighted in the picture. How does this work? How is the expectation pushed in to the product from the 3rd step to the 4th step? If the two terms are independent, shouldn't the expectation be applied to both the terms? and if they aren't, is this step valid? | 2014/11/09 | [
"https://stats.stackexchange.com/questions/123320",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/55780/"
] | The trick is that $\mathbb{E}(\hat{\theta}) - \theta$ is a constant. | There has been some confusion about the question which was ambiguous being about the highlight **and** the step from line three to line four.
There are two terms that look a lot like each other.
$$\mathbb{E}\left[\hat{\theta}\right] - \theta \quad \text{vs} \quad \mathbb{E}\left[\hat{\theta}\right] - \hat\theta$$
The question, about the step from 3rd to 4th line, relates to the first term:
* $\mathbb{E}[\hat{\theta}] - \theta$ this is **the bias** for the estimator $\hat\theta$
The bias is the same (constant) value every time you take a sample, and because of that you can take it out of the expectation operator (so that is how the step from the 3rd to 4th line, taking the constant out, is done).
Note that you should not interpret this as a Bayesian analysis where $\theta$ is variable. It is a frequentist analysis which *conditions* on the parameters $\theta$. So we are computing more specifically $\mathbb{E}[(\hat{\theta} - \theta)^2 \vert \theta]$, the expectation value of the squared error *conditional* on $\theta$, instead of $\mathbb{E}[(\hat{\theta} - \theta)^2]$. This conditioning is often implied implicitly in a frequentist analysis.
The question about the highlighted expression is about the second term
* $\mathbb{E}[\hat{\theta}] - \hat{\theta}$ this is **the deviation from the mean** for the estimator $\hat{\theta}$.
It's expectation value is also called the 1st [central moment](https://en.m.wikipedia.org/wiki/Central_moment) which is always zero (so that is how the highlighted step, putting the expectation equal to zero, is done). |
13,321,304 | i need the query for count the number of Columns in my SQL Server table . | 2012/11/10 | [
"https://Stackoverflow.com/questions/13321304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1814317/"
] | ```
select count(*) from your_table
```
counts **all** rows, even when some records contain `NULL` entries.
```
select count(some_column) from your_table
```
counts records where `some_column` `IS NOT NULL` | this
```
select count(*) from table
```
`*` means all columns |
21,628,601 | I am looking for over 12 hours to find a proper solution for this particular problem...
I have an ASP MVC (.NET framework 4.5) application that utilizes an Interbase XE database.
As long as I run it locally on my own machine, it works correctly. However, when I try to publish the site to my remote server, I get some assembly errors...
>
> Could not load file or assembly 'Borland.Data.DbxCommonDriver,
> Version=16.0.0.0, Culture=neutral, PublicKeyToken=a91a7c5705831a4f' or
> one of its dependencies. The located assembly's manifest definition
> does not match the assembly reference. (Exception from HRESULT:
> 0x80131040)
>
>
>
Besides on looking on every possible solution posted on the internet (which did not help for me unfortunately). I also opened up the Borland.Data.DbxCommonDriver.dll in Reflector.
What amazes me there, is that Reflector states that the version I have (both local AND remote!!) has PublicKeyToken=**91d62ebb5b0d1b1b** instead of **a91a7c5705831a4f**, all other settings are equal (including the versionnumber 16.0.0.0).
So the next thing I did, was tracing down all possible .dll files on the servermachine. I uninstalled the ADO.NET 2.0 driver, and removed all existing occurrences of the dll's.
As soon as the server was freed of any DLL's, I rebooted it and reinstalled the ADO.NET 2.0 for Interbase driver.
However, I instantly got the same assembly error. Now, I am a little bit exhausted of ideas...
1. How can the error that is shown, show a different PublicKeyToken?
2. Do I need to put things in the web.config file (to force a usuage of an assembly or such)?
3. How can I determine where the erroneous PublicKeyToken is referenced from?
**NOTES:**
The servermachine is a 64-bit machine. This means that I have set the ApplicationPool to accept 32-bit applications, in order to support the ADO.NET 2.0 drivers from Embarcadero.
I have developed my web application with MS Visual Studio 2012 Pro.
**Resources:**
<https://forums.embarcadero.com/message.jspa?messageID=528498>
<http://docs.embarcadero.com/products/interbase/IBXEUpdate5/Readme.html> | 2014/02/07 | [
"https://Stackoverflow.com/questions/21628601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1077345/"
] | Finally after a few weeks, I have managed to solve this particular issue.
It turned out to be a simple solution, as simple solutions are most often the hardest ones to find...
It turns out that Embarcadero RAD Studio has the Borland.Data.DbxCommonDriver.dll, Borland.Data.AdoDBXClient.dll and the Borland.Data.DBXInterBaseDriver.dll installed locally as well. These dll's have a different version number than the DLL's provided by the ADO.NET 2.0 drivers provided by Embarcadero. I tracked this down by performing a search in the Windows Registry. So if you are facing an equal problem, find out what drivers are registered in the registry to find their exact location...
After removing the references that pointed towards the ADO.NET 2.0 drivers (typically installed at C:\Embarcadero\Interbase\_ADO.NET) and setting the references to the DLL's located at the Embarcadero RAD Studio installation folder, things were still working locally.
After publishing the site, it still did not work. So I removed every reference from the machine.config files and updated the web.config file for the webapplication. Finally, I deployed the files 'dbxconnections.ini' and 'dbxdrivers.ini' alongside my webapplication (which was stated in [this Embarcadero knowledgebase article](http://docs.embarcadero.com/products/rad_studio/radstudio2007/RS2007_helpupdates/HUpdate4/EN/html/devnet/deployingdbnetapps_xml.html "Deploying Database applications")).
After cleaning the server, I did another publish of the webapplication and it works!
It still is a pity however that there are so many different versions available of these Borland.Data.DbxXXX drivers, things might get tricky to really find out what is wrong.
Though I still doubt that there are not many programmers facing this particular issue, I still thought it might be handy to post my solution. I do hope it may help :) | I am having the same issue ( you posted on my thread)
Maybe this cna be of help : <http://docs.embarcadero.com/products/rad_studio/radstudio2007/RS2007_helpupdates/HUpdate4/EN/html/devcommon/deployingadodbxclient_xml.html>
I am too novice to find the PublicKeytoken.. but maybe you can work it out for your project with this! |
1,339,188 | I was wondering, if I deploy a WSP using the stsadm command:
```
stsadm -o addsolution –filename myWSP.wsp
```
Will this also install the required DLL's (already included in the WSP) into the GAC?
Or is this another manual process? | 2009/08/27 | [
"https://Stackoverflow.com/questions/1339188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41543/"
] | This is determined by the **DeploymentTarget attribute** in the solution's `manifest.xml`. If you are maintaining this file yourself, using the following syntax will deploy the code to the GAC:
```
<Assemblies>
<Assembly DeploymentTarget="GlobalAssemblyCache"
Location="MyGAC.dll" />
</Assemblies>
```
If you are using a tool to create the solution, it depends on the tool. WSPBuilder defaults to deploying to the GAC however it can be configured otherwise. See the "Scoping the assembly for BIN instead of GAC (including Code Access Security generation)" section of [this article by Tobias Zimmergren](http://www.zimmergren.net/archive/2009/04/08/wspbuilder-walkthrough-of-the-visual-studio-add-in.aspx) for steps on how to deploy to `bin`. | As the command says **addsolution** it is just going to add the solution to the Solution store. You need to call the command **deploysolution** to get the stuffs to place. Here is the command that you need to call
```
stsadmin -o deploysolution -name [solutionname] -allowgacdeployment
```
Note that **allowgacdeployment** is mandatory to place the files to gac. you can more help on this command with this
```
STSADM.EXE -help deploysolution
```
There is an alternate option to get this done,through UI. Go to **Central Admin -> Operations ->Solution management** select the solution and say deploy. this will be easier way to get it done quick. |
1,339,188 | I was wondering, if I deploy a WSP using the stsadm command:
```
stsadm -o addsolution –filename myWSP.wsp
```
Will this also install the required DLL's (already included in the WSP) into the GAC?
Or is this another manual process? | 2009/08/27 | [
"https://Stackoverflow.com/questions/1339188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41543/"
] | This is determined by the **DeploymentTarget attribute** in the solution's `manifest.xml`. If you are maintaining this file yourself, using the following syntax will deploy the code to the GAC:
```
<Assemblies>
<Assembly DeploymentTarget="GlobalAssemblyCache"
Location="MyGAC.dll" />
</Assemblies>
```
If you are using a tool to create the solution, it depends on the tool. WSPBuilder defaults to deploying to the GAC however it can be configured otherwise. See the "Scoping the assembly for BIN instead of GAC (including Code Access Security generation)" section of [this article by Tobias Zimmergren](http://www.zimmergren.net/archive/2009/04/08/wspbuilder-walkthrough-of-the-visual-studio-add-in.aspx) for steps on how to deploy to `bin`. | If you're building the packages via VS, open the Package and click the Advanced tab on the bottom. You'll be able to add additional assemblies and specify the Deployment Target from here. I'd strongly recommend doing this rather than updating the XML directly...but that's just me. |
1,077,258 | I am using the following to search for a file defined as a macro DB\_CONFIG\_FILE\_PATH\_1.
```
wchar_t filename[100];
SearchPath( L".\\", DB_CONFIG_FILE_PATH_1, NULL, 100, filename, NULL);
```
If the file is in C:\ directory, it is found. But, if the file is in one of its sub-directories the function doesn't find it.
Can some explain how to search all the drives including subdirectories for a file with the above function.
I am not using FindFirstFile function because, I am unable to retrieve the path to the file even though the function returns handle to the file.
To put it, I want full path name of a file. I know the name of the file, but do not know where it is on the comp. | 2009/07/02 | [
"https://Stackoverflow.com/questions/1077258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | For searching subdirectories in native code on Win32, you need to do it yourself, using FindFirstFile and then recursing into subdirectories.
The return value of FindFirstFile isn't a file handle - the file information is contained in the WIN32\_FIND\_DATA structure returned. The handle is used in calls to FindNextFile to continue the search. To get a full path name during your search, you'll need to keep track of what directory you are currently in and append the discovered directory names to the path.
SearchPath only searches in the PATH environment variable or the first parameter if present and doesn't search subdirectories. | `GetCurrentDirectory()` should tell you the path:
<http://msdn.microsoft.com/en-us/library/aa364934(VS.85).aspx>
and the second argument of `FindFirstFile()`:
<http://msdn.microsoft.com/en-us/library/aa364418(VS.85).aspx>
which is a `WIN32_FIND_DATA` Structure should tell you the name of the file:
<http://msdn.microsoft.com/en-us/library/aa365740(VS.85).aspx> |
45,969,767 | How can I generate a narrative functionally in RMarkdown? For instance, say I want to generate 3 headers like
```
##First
##Second
#Third
```
from a vector `c('First', 'Second', 'Third')`, then knit to pdf | 2017/08/30 | [
"https://Stackoverflow.com/questions/45969767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4997164/"
] | >
> How to get this parameter displayed as dropdown?
>
>
>
As bmoore-msft mentioned we could replace the `defaultValue` with `allowedValues` and `array` with `string`. We also could set the dropdownlist default value from the template. In your case, please have a try to use the following code. More details we could refer to the [Customize the template](https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-create-first-template?toc=%2Fazure%2Ftemplates%2Ftoc.json&bc=%2Fazure%2Ftemplates%2Fbreadcrumb%2Ftoc.json#customize-the-template).
```
"parameters": {
"EnvironmentType": {
"type": "string",
"allowedValues": [
"Dev",
"Test",
"PreProd",
"Prod"
],
"defaultValue": "Dev",
"metadata": {
"description": "The type of replication to use for the EnvironmentType."
}
}
``` | Replace "defaultValue" with "allowedValues" and "array" with "string". |
35,278,669 | I have saved my JSON object in a variable and I am making calculations off of the properties within the object; however, I am finding that the calculations are very long to write and if the data becomes larger, the calculations can become pretty long.
I am hoping that there is a simpler way to make calculations than how I am currently doing it.
Here is the JSON data saved within a javascript file:
```
var obj = {
"Open": [{
"Sprint_2":null,
"Sprint_3":null,
"Sprint_4":null,
"Sprint_5":6,
"Sprint_6":38,
"Sprint_7":7
}],
"Design": [{
"Sprint_2":null,
"Sprint_3":null,
"Sprint_4":null,
"Sprint_5":null,
"Sprint_6":1,
"Sprint_7":null
}],
"Requirement": [{
"Sprint_2":null,
"Sprint_3":null,
"Sprint_4":null,
"Sprint_5":1,
"Sprint_6":1,
"Sprint_7":null
}],
"Ready_for_Build": [{
"Sprint_2":null,
"Sprint_3":null,
"Sprint_4":null,
"Sprint_5":4,
"Sprint_6":2,
"Sprint_7":null
}],
"Build": [{
"Sprint_2":null,
"Sprint_3":null,
"Sprint_4":null,
"Sprint_5":12,
"Sprint_6":1,
"Sprint_7":null
}],
"Ready_for_Test": [{
"Sprint_2":null,
"Sprint_3":null,
"Sprint_4":null,
"Sprint_5":4,
"Sprint_6":4,
"Sprint_7":null
}],
"Test": [{
"Sprint_2":null,
"Sprint_3":null,
"Sprint_4":null,
"Sprint_5":5,
"Sprint_6":6,
"Sprint_7":null
}],
"Ready_for_Acceptance": [{
"Sprint_2":null,
"Sprint_3":null,
"Sprint_4":null,
"Sprint_5":3,
"Sprint_6":null,
"Sprint_7":null
}],
"Accepted": [{
"Sprint_2":38,
"Sprint_3":43,
"Sprint_4":57,
"Sprint_5":19,
"Sprint_6":null,
"Sprint_7":null
}],
"Total_Bugs": [{
"Sprint_2":47,
"Sprint_3":39,
"Sprint_4":71,
"Sprint_5":39,
"Sprint_6":null,
"Sprint_7":null
}],
"Bugs_Success": [{
"Sprint_2":37,
"Sprint_3":25,
"Sprint_4":42,
"Sprint_5":11,
"Sprint_6":null,
"Sprint_7":null
}],
"Bugs_In_Progress": [{
"Sprint_2":null,
"Sprint_3":null,
"Sprint_4":7,
"Sprint_5":4,
"Sprint_6":null,
"Sprint_7":null
}]
};
```
Here is a calculation I am using to sum the numbers in various keys:
```
var totDone = obj.Ready_for_Test[0].Sprint_2 + obj.Ready_for_Test[0].Sprint_3 + obj.Ready_for_Test[0].Sprint_4 + obj.Ready_for_Test[0].Sprint_5 + obj.Ready_for_Test[0].Sprint_6 + obj.Ready_for_Test[0].Sprint_7 +
obj.Test[0].Sprint_2 + obj.Test[0].Sprint_3 + obj.Test[0].Sprint_4 + obj.Test[0].Sprint_5 + obj.Test[0].Sprint_6 + obj.Test[0].Sprint_7 +
obj.Ready_for_Acceptance[0].Sprint_2 + obj.Ready_for_Acceptance[0].Sprint_3 + obj.Ready_for_Acceptance[0].Sprint_4 + obj.Ready_for_Acceptance[0].Sprint_5 + obj.Ready_for_Acceptance[0].Sprint_6 + obj.Ready_for_Acceptance[0].Sprint_7 +
obj.Accepted[0].Sprint_2 + obj.Accepted[0].Sprint_3 + obj.Accepted[0].Sprint_4 + obj.Accepted[0].Sprint_5 + obj.Accepted[0].Sprint_6 + obj.Accepted[0].Sprint_7;
console.log(totDone);
```
If my JSON data expands, in order to do further calculations, my algorithm will become very lengthy. Is there a simpler way to run calculations on the data? | 2016/02/08 | [
"https://Stackoverflow.com/questions/35278669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5518272/"
] | You can use [Task Logging Commands](https://github.com/Microsoft/vso-agent-tasks/blob/master/docs/authoring/commands.md) to do this.
>
> To invoke a logging command, simply emit the command via standard
> output. For example, from a PowerShell task:
>
>
> "##vso[task.setvariable variable=testvar;]testvalue"
>
>
> | For Mac, do this :
```
echo '##vso[task.setvariable variable=variableName;]'$variableValue
``` |
57,353,552 | I'm working on bringing linux to a custom Cortex-M7 board with 16 Mb of SDRAM and 64 Mb of Flash. The platform has no-MMU, no shared libraries, FLAT executables.
I'm having problems booting a Busybox system with very simple init.d shell scripts. The system is running out of memory by executing simple shell commands like "[" or "printf". It turns out that everytime one of these commands are executed the system needs to load the FULL, one and only busybox executable (650 Kb on my system).
So the question is: if the system always have to load in memory a huge executable for each command implemented inside busybox, then how is this convenient? I don't get the point of saving some megabytes of cheap and abundant storage while going out of ram extremely fast, but maybe I'm overlooking something.
Is my platform an use case for Busybox? if not, is there anything to conveniently build linux system utilities each on their own executable?
Thanks in advance!
EDIT:
Busybox, according to themselves "**has been written with size-optimization and limited resources in mind**" and so became a sort of unquestioned de-facto standard in embedded systems. But how their statement relates to the forementioned issues on RAM (not storage) constrained systems? I believe this worths some clarification.
Follow up, system details:
The kernel is already compiled for XIP, executing from the 64 Mb external flash. The entire read/write ext3 root filesystem (including busybox binary) now resides on a micro SD card. Busybox executable is using the FLAT format ("bFLT") with load to RAM bit enabled, that bit seems to be causing a new load on a different memory block each time it runs a concurrent command until it exhausts the fitting blocks. The advice to put busybox (the entire /bin, /sbin) on a XIP filesytem is brilliant and it will surely improve the execution speed (of course, this new filesystem will need to reside on the 64 Mb external flash). I never tried a "bFLT" to be executed in place on such a filesystem (nor have an idea if it works) but I'll do my research/testing about that. | 2019/08/05 | [
"https://Stackoverflow.com/questions/57353552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/158099/"
] | TL-DR; Linux has a huge infrastructure and variety of rootfs or boot file systems available. The choice is due to accommodation of different system constraints and end user functions. Busybox is a good choice for the target system, but any software can be misused if a system engineer doesn't spend time to understand it.
---
>
> Is my platform an use case for Busybox?
>
>
>
It is if you take time to minimize the kernel size and `busybox` itself. It is unlikely you need all features in your current `busybox`.
>
> if not, is there anything to conveniently build linux system utilities each on their own executable?
>
>
>
See klibc information below. You can also build [dash with musl](https://aur.archlinux.org/packages/dash-static-musl/), [with buildroot and busybox](https://git.busybox.net/buildroot/commit/?id=9329935402042670058edaf807242351d91f39b1). Many filesystem builders support shared libraries or static binaries. However, there are [many goals](https://stackoverflow.com/questions/17697129/buildroot-package-management) such as package management, and live updates, that a filesystem builder may target.
More Details
------------
You can configure features out of busybox. The idea is that all of the configured features are needed. Therefore you need them all in memory. With busybox, `ls`, `mkdir`, `printf`, etc are all the same binary. So if you run a shell script the one code load is all code loads. The other way, you have many separate binaries and each will take extra memory. You need to minimize Linux to get more RAM and you can take features out of `busybox` to make it smaller. Busybox is like a giant shared library; or more accurately a `shared process`. All code pages are the same.
>
> a custom Cortex-M7 board with 16 Mb of SDRAM and 64 Mb of Flash
>
>
>
>
...
>
> one and only busybox executable (650 Kb on my system)
>
>
>
Obviously 650KB is far less than 16MB. You don't say what the other RAM is used for. For another good alternative look at the [klibc toolsuite](https://en.wikipedia.org/wiki/Klibc). What is not clear is whether the FLASH is NAND/NOR and if you have XIP enabled. Generally, `busybox` would be better with XIP flash and `klibc` would be better (and more limited) for SDRAM only, with some filesystem in flash.
See: [Memory used by relocatable code, PIC, and static linking](https://busybox.net/FAQ.html) in the Busybox FAQ. It is designed to run from Read-only memory which can be a big gain depending on system structure. It probably provides a more rich feature set than klibc as the goal with that project is just to boot some other mount device (a hard drive, SSD etc).
Klibc does not have as much documentation as busybox. It can be either a shared library or statically linked. Each binary will only use the RAM needed for that task with static linking, but this will take more flash space. The binary with klibc are,
```
1. dash 2. chroot 3. dd 4. dmesg 5. mkdir 6. mkfifo
7. mknode 8. pivot_root 9. unmount 10. true 11. false 12. sleep
13. ln 14. ls 15. mv 16. nuke 17. minips 18. cat
19. uname 20. halt 21. kill 22. cpio 23. sync 24. readlink
25. gzip 26. losetup
```
**and that is IT!** No networking, no media players, etc. You can write code to use klibc, but it is a very constrained library and may not have features that you require. Generally it would be limit to disk only tasks. It is great to probe USB for external device to boot from for example.
Busybox can do a lot more. Most klibc static binaries will be under 100kB; with 10-30kB typical. Dash and gzip are larger. However, I think you need to remove configuration items from your kernel as 650KB << 16MB and busybox would be a fine choice for this system even without XIP.
I should also be noted that Linux does 'demand page loading' for code with an MMU system. Even if you don't have swap, code can be kicked out of RAM and reloaded later with a page fault. Your system is no-MMU, so busybox will not perform as well in this case. With an mmu and 'demand page loading' it will do much better.
For severe constraints, you can always code a completely [library free binary](https://stackoverflow.com/questions/20369440/can-start-be-the-thumb-function). This avoids libgcc startup and support infrastructure which you might not need. Generally, this is only good to test a kernel vs. initrd issue and for script/binary that must run in many different library environments.
See also:
* [AXFS](https://en.wikipedia.org/wiki/AXFS) - xip read-only file system.
* [CramFs](https://en.wikipedia.org/wiki/Cramfs) - another xip file system.
* [XIP kernel](https://elinux.org/Kernel_XIP) - the kernel can be huge. Get it out of RAM if possible. Configure with EMBEDDED option if not.
* [nommu.org](https://github.com/nommu/nommu.org) - some information on github
* [elf2flt](https://github.com/uclinux-dev/elf2flt) - Mike Frysingers updates to binutils 2.27-2.31.1
* [fdpic gcc](https://github.com/mickael-guene/fdpic_manifest) - notes from 2016 by mickael-guene.
XIP can only work with ROM, NOR flash and possibly [SPI-NOR](http://events17.linuxfoundation.org/sites/events/files/slides/An%20Introduction%20to%20SPI-NOR%20Subsystem%20-%20v3_0.pdf) MTDs. | The point of BusyBox is that you need to have only one (shared) executable in memory.
You wrote:
>
> It turns out that everytime one of these commands are executed the system needs to load the FULL, one and only busybox executable (650 Kb on my system).
>
>
>
That's not entirely true. For the first command the executable is loaded in memory indeed. But if you're running multiple commands (i.e. multiple BusyBox instances), the executable is not loaded into memory multiple times. A large part of the binary (simply said: all read-only data, such as the executable code and constant data) will be reused. Each additional process only requires some additional memory for its own tasks.
So if a single instance of BusyBox consumes 640 kB of memory, it's possible that 10 instances together only use 1 MB of memory, while 10 unique executables of 200 kB would use 2 MB.
I would recommend to do some realistic tests on your system and check the actual memory consumption. But note that tools such as `ps` or `top` can be a bit misleading or difficult to understand. A lot has been written about that already, and if you would like to know more about that, a good starting point would be [here](https://stackoverflow.com/questions/131303/how-to-measure-actual-memory-usage-of-an-application-or-process). |
353,391 | I have a new install of magento 2.4 and i set it up for a custom domain and HTTPS and now when I go to the / admin panel I get a large Magento logo with no formatting and when I login the backend shows text only and no formatting for any of the panels. I was researching it a little and saw it might be an issue with the document root. I ran the cache clean and reindex commands and it looks the same and think something isn't configured correctly. Any help is appreciated. Thanks!
[](https://i.stack.imgur.com/0QSAA.jpg)
[](https://i.stack.imgur.com/xnNFR.jpg) | 2022/02/23 | [
"https://magento.stackexchange.com/questions/353391",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/103932/"
] | Whenever a patch is run, Magento adds it into the `patch_list` table, so, the next time when you run `setup:upgrade`, it checks if that patch is present in that table, then it skips the patch. So, what you can do, is just manually add `\Magento\Tax\Setup\Patch\Data\UpdateTaxRegionId` into the table. | I guess this issue occurred during `php bin/magento setup:upgrade`
look like you already applied patch earlier and upgrade want to apply it again so, simply you can delete this file
>
> /vendor/magento/module-tax/Setup/Patch/Data/UpdateTaxRegionId.php
>
>
>
or try to upgrade with latest version 2.4.3-p2 this may also fix problem
**Update**
---
If you were upgrading to Adobe Commerce (all deployment methods)/Magneto Open Source version 2.3.5, upgrade to version 2.3.5-p1. Adobe Commerce (all deployment methods)/Magento Open Source version 2.3.5-p1 replaces 2.3.5.
If you were upgrading to Adobe Commerce (all deployment methods)/Magento Open Source version 2.3.4-p1, upgrade to version 2.3.4-p2. Adobe Commerce (all deployment methods)/Magneto Open Source version 2.3.4-p2 replaces version 2.3.4-p1. |
51,344,048 | i'm new to ruby on rails and I am trying to create a custom message for a model's validation failure scenario. Here is the code.
```
class TestModel
include ActiveModel::Model
attr_accessor :attr
validates :attr, presence: true,
format: {with: /\A[A-Za-z].+\z/,
message: -> (value) do
# Do something with value
end
}
end
model = TestModel.new
model.attr = 23242
model.validate
```
However i receive the error
```
ArgumentError: wrong number of arguments (given 2, expected 1)
```
I was following a similar example on the [ruby on rails guide](http://guides.rubyonrails.org/active_record_validations.html) : section 3.3. There is something wrong with defining the message as I have.
I'm using rails 5.
Also, what i want to do with value is get the inverse REGEX.
```
"contains invalid char(s) " +
value.split('').reject{
|e| /\A[A-Za-z].+\z/ =~ e }.join(' ')
``` | 2018/07/14 | [
"https://Stackoverflow.com/questions/51344048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7969928/"
] | If you're going to use a lambda with the `:message` option then your lambda will get *two* arguments. From the [fine guide](http://guides.rubyonrails.org/active_record_validations.html#message):
>
> **3.3 :message**
>
> [...]
>
> A Proc :message value is given two arguments: the object being validated, and a hash with `:model`, `:attribute`, and `:value` key-value pairs.
>
>
>
So you'd say:
```
message: -> (model, data) do
# Do something with model and data here...
end
```
And from [section 2.5](http://guides.rubyonrails.org/active_record_validations.html#format):
>
> **2.5 format**
>
> [...]
>
> Alternatively, you can require that the specified attribute does *not* match the regular expression by using the `:without` option.
>
>
>
If you want the opposite of `:with` then use `:without` instead. | You're not using `message` correctly. You don't need to pass it a block to interpolate the value. Use it like so.
```
require 'active_model'
class TestModel
include ActiveModel::Model
attr_accessor :attr
validates :attr,
presence: true,
format: {with: /\A[A-Za-z].+\z/,
message: "#{value} is wrong" }
end
model = TestModel.new
model.attr = 23242
puts model.validate # false
puts model.errors.full_messages # Attr 23242 is wrong
```
Yes, it's `%{value}` and not `#{value}`
If you do want to use a proc, it accepts two arguments. |
69,935,987 | I have a class of Orders and it has the number of the order, and it has to increase by 1 every time a new order is created.
I tried to use static but it changed the number of all the orders
Any help? | 2021/11/11 | [
"https://Stackoverflow.com/questions/69935987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14121088/"
] | If it is ID generator you need, there is simple solution with combination of static + instance variable
```
public class Order {
private static volatile long nextId = 0L;
private long id;
public Order (){
id = nextId++;
}
}
```
**EDIT**
I'll just leave it here for reference [Is a volatile int in Java thread-safe?](https://stackoverflow.com/questions/7805192/is-a-volatile-int-in-java-thread-safe) | maybe like that?
```
public class Order {
private long id;
public Order (long lastId){
id = lastId++;
}
}
```
so, when you create a new you do `Order order = new Order(otherOrder);` |
20,316,821 | Why doesn't the following work ?
```
app.js
reports/
├── index.js
└── batch.js
```
in `app.js` :
```
app.use('/reports', require('./reports')
```
in `index.js` :
```
var express = require('express');
var batch = require('./batch');
var app = express.createServer();
...
app.use('/batch', batch);
module.exports = app;
```
in `batch.js` :
```
var express = require('express');
module.exports = function() {
var app = express.createServer();
console.log('I am here');
app.get('/', function(req, res) {
console.log('I am there');
});
return app;
};
```
calling `GET /reports/batch` prints `I am here` but doesn't print `I am there`
Can anyone pinpoint me to the problem ?
Thanks | 2013/12/01 | [
"https://Stackoverflow.com/questions/20316821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/599912/"
] | try this:
in app.js :
```
var express = require('express'),
http = require('http'),
path = require('path');
var app = express.createServer();
require('./reports')(app);
```
in reports/index.js :
```
module.exports = function(app){
var batch = require('./batch')(app);
app.use('/batch', batch);
}
```
in batch.js :
```
module.exports = function(app) {
console.log('I am here');
app.get('/', function(req, res) {
console.log('I am there');
});
};
```
Note that you may need to modify the app.get routing as needed. but basically the idea here is instead of calling createServer all the time just keep passing it down the chain from one module to the next.
Hope this helps! | Here is my app.js. It passes db and app to the feature.js. Basically they share the same app variable.
in app.js
```
var express = require('express'),
http = require('http'),
path = require('path'),
mongoose = require('mongoose'),
db = mongoose.connect('mongodb://abc:123@xxxx.mongohq.com:90000/app123423523');
var app = express();
//here you set app properties
require('./routes/feature').with(app, db);
```
in feature.js
```
module.exports.with = function(app, db) {
//do work
}
``` |
20,316,821 | Why doesn't the following work ?
```
app.js
reports/
├── index.js
└── batch.js
```
in `app.js` :
```
app.use('/reports', require('./reports')
```
in `index.js` :
```
var express = require('express');
var batch = require('./batch');
var app = express.createServer();
...
app.use('/batch', batch);
module.exports = app;
```
in `batch.js` :
```
var express = require('express');
module.exports = function() {
var app = express.createServer();
console.log('I am here');
app.get('/', function(req, res) {
console.log('I am there');
});
return app;
};
```
calling `GET /reports/batch` prints `I am here` but doesn't print `I am there`
Can anyone pinpoint me to the problem ?
Thanks | 2013/12/01 | [
"https://Stackoverflow.com/questions/20316821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/599912/"
] | It seems that I have forgotten javascript a little.
I was doing
```
app.use('/batch', batch);
```
`batch` is equal to
```
function() {
var app = express.createServer();
console.log('I am here');
app.get('/', function(req, res) {
console.log('I am there');
});
return app;
};
```
Instead I should have done
```
app.use('/batch', batch());
```
Which equals to what `express.createServer()` returns which is what `app.use` expects to get | Here is my app.js. It passes db and app to the feature.js. Basically they share the same app variable.
in app.js
```
var express = require('express'),
http = require('http'),
path = require('path'),
mongoose = require('mongoose'),
db = mongoose.connect('mongodb://abc:123@xxxx.mongohq.com:90000/app123423523');
var app = express();
//here you set app properties
require('./routes/feature').with(app, db);
```
in feature.js
```
module.exports.with = function(app, db) {
//do work
}
``` |
20,316,821 | Why doesn't the following work ?
```
app.js
reports/
├── index.js
└── batch.js
```
in `app.js` :
```
app.use('/reports', require('./reports')
```
in `index.js` :
```
var express = require('express');
var batch = require('./batch');
var app = express.createServer();
...
app.use('/batch', batch);
module.exports = app;
```
in `batch.js` :
```
var express = require('express');
module.exports = function() {
var app = express.createServer();
console.log('I am here');
app.get('/', function(req, res) {
console.log('I am there');
});
return app;
};
```
calling `GET /reports/batch` prints `I am here` but doesn't print `I am there`
Can anyone pinpoint me to the problem ?
Thanks | 2013/12/01 | [
"https://Stackoverflow.com/questions/20316821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/599912/"
] | try this:
in app.js :
```
var express = require('express'),
http = require('http'),
path = require('path');
var app = express.createServer();
require('./reports')(app);
```
in reports/index.js :
```
module.exports = function(app){
var batch = require('./batch')(app);
app.use('/batch', batch);
}
```
in batch.js :
```
module.exports = function(app) {
console.log('I am here');
app.get('/', function(req, res) {
console.log('I am there');
});
};
```
Note that you may need to modify the app.get routing as needed. but basically the idea here is instead of calling createServer all the time just keep passing it down the chain from one module to the next.
Hope this helps! | It seems that I have forgotten javascript a little.
I was doing
```
app.use('/batch', batch);
```
`batch` is equal to
```
function() {
var app = express.createServer();
console.log('I am here');
app.get('/', function(req, res) {
console.log('I am there');
});
return app;
};
```
Instead I should have done
```
app.use('/batch', batch());
```
Which equals to what `express.createServer()` returns which is what `app.use` expects to get |
12,398,957 | If the following possible?
I wish to move the alert(result) into a function and to dynamically call it.
**Current**
```
$.ajax(this.href, {
success: function (result)
{
alert(result);
AjaxComplete();
}
});
```
**My Attempt - not working**
```
$.ajax(this.href, {
success: function (result)
{
window["MyAlert(result)"]();
AjaxComplete();
}
});
function MyAlert(result)
{
alert(result);
}
```
Is this possible? | 2012/09/13 | [
"https://Stackoverflow.com/questions/12398957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/511438/"
] | Why can't you just do this?
```
MyAlert(result);
```
If `MyAlert` is a part of the `window` object, it's already a global.
Unless you want to call an arbitrary function by name (which isn't really good practice, IMO), which you can do like this:
```
window[function_name_string](argument);
``` | ```
window["MyAlert(result)");
```
is invalid syntax (missmatching `[` and `)`, wrong function name, and not calling it at all, just getting it..). Should be
```
window["MyAlert"](result);
```
if you want to call it like that, but I see no reason why you couldn't just call it normally, as Blender mentioned. |
68,396 | I'm currently writing my thesis in mathematics and in the introductory part I want to give a brief overview over a field I'm not very familiar with. There are some results in the book I'm reading which are stated as exercises for the reader, which I'd like to include as theorems in my thesis. I don't want to prove them, since this part is only meant to give the reader an overview of some basic concepts and to show him the importance of some constructions which I will generalize later (which is the actual bread and butter of the thesis). So how do I deal with this:
* Don't give any citation at all and assume these concepts are well known to anyone working in the field? - I wouldn't give the definition of a vector space in my thesis, so this might be justifiable. However, I wouldn't consider those theorems as basic as the definition of vector spaces...
* Do a heavy amount of googling to find sone sources which prove those theorems? - This might take a considerable amount of time, so I'd like to avoid it. It might also turn out to be impossible, since the phrasing might be different enough in the original sources so that I just won't find them
* Cite the Problem from the book I'm working with? - I don't think I can do this, since the results aren't proved in the reference I would give
Note that none of my results rely on any of these theorems. | 2016/05/09 | [
"https://academia.stackexchange.com/questions/68396",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/8040/"
] | >
> Don't give any citation at all and assume these concepts are well known to anyone working in the field? - I wouldn't give the definition of a vector space in my thesis, so this might be justifiable. However, I wouldn't consider those theorems as basic as the definition of vector spaces...
>
>
>
The general idea for citations is to include a reference is if you would not assume a typical reader of your thesis/paper to know these results. Think: will this reference be useful for someone reading this? For a thesis, one is often a little more liberal with background and references than a paper. Since you yourself don't seem to know (proofs of) these results, I would include a reference, though of course it's your choice.
>
> Do a heavy amount of googling to find sone sources which prove those theorems? - This might take a considerable amount of time, so I'd like to avoid it. It might also turn out to be impossible, since the phrasing might be different enough in the original sources so that I just won't find them
>
>
>
I think this is wrong attitude to take. I understand you may be under time pressure, but you should try to understand everything in your thesis as well as you can, including related work. It's often not feasible to understand proofs of every result you mention (maybe you will many years later), but you should at least know references. Whenever I write a paper (or writing course notes) I spend a long time reviewing literature. In addition to making you feel more comfortable about what you're writing, being familiar with the literature is important for your mathematical education.
What I would do is spend an afternoon skimming through other books/surveys on the field. If it really is something rather basic, there should be another book that goes through this. If that doesn't work, you can try to prove the exercises on your own as well as ask your advisor if s/he knows a reference where these things are proved.
>
> Cite the Problem from the book I'm working with? - I don't think I can do this, since the results aren't proved in the reference I would give
>
>
>
You can, but I agree it's generally nicer to the reader to provide a reference that has an explicit proof.
All of these questions you asked are things that you should be able to ask your advisor, though it's good if you can show some independence by being able to survey the literature on your own. | If it's a fact that needs to be justified but is not relevant enough to devote space in your thesis to proving it in detail, it's better to cite a source that gives the proof, if you can find one. If you can't, I recommend trying to come up with a proof of your own, and writing in your thesis something like
>
> This fact can be found as an exercise in [Textbook, problem 3.14] and can be shown by [1-2 sentence description of the proof strategy].
>
>
> |
68,396 | I'm currently writing my thesis in mathematics and in the introductory part I want to give a brief overview over a field I'm not very familiar with. There are some results in the book I'm reading which are stated as exercises for the reader, which I'd like to include as theorems in my thesis. I don't want to prove them, since this part is only meant to give the reader an overview of some basic concepts and to show him the importance of some constructions which I will generalize later (which is the actual bread and butter of the thesis). So how do I deal with this:
* Don't give any citation at all and assume these concepts are well known to anyone working in the field? - I wouldn't give the definition of a vector space in my thesis, so this might be justifiable. However, I wouldn't consider those theorems as basic as the definition of vector spaces...
* Do a heavy amount of googling to find sone sources which prove those theorems? - This might take a considerable amount of time, so I'd like to avoid it. It might also turn out to be impossible, since the phrasing might be different enough in the original sources so that I just won't find them
* Cite the Problem from the book I'm working with? - I don't think I can do this, since the results aren't proved in the reference I would give
Note that none of my results rely on any of these theorems. | 2016/05/09 | [
"https://academia.stackexchange.com/questions/68396",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/8040/"
] | In mathematics, if you cite a result, you should really be able provide the proof if somebody asks for it. So I would strongly recommend against option 3.
One thing you might consider is writing the author of the textbook, explaining your situation, and asking if he's willing to send you a proof. Then you can cite it as
>
> problem 8.35 in textbook, proof provided by private communication with [author]
>
>
>
even if he would rather not have a proof of the exercise published.
Of course, if he replies "I think I had a proof when I wrote the textbook, but I've forgotten it now," you might need to come up with a proof in some other way.
There is at least one exercise in a textbook whose proof is highly non-trivial, and was an open problem for several years before a journal paper giving the proof was published (and the only indication in the textbook of this is that part (b) of the problem is "optional"). | If it's a fact that needs to be justified but is not relevant enough to devote space in your thesis to proving it in detail, it's better to cite a source that gives the proof, if you can find one. If you can't, I recommend trying to come up with a proof of your own, and writing in your thesis something like
>
> This fact can be found as an exercise in [Textbook, problem 3.14] and can be shown by [1-2 sentence description of the proof strategy].
>
>
> |
7,069,458 | I have a scrollable list on a mobile device. They want people to be able to scroll the list via swiping, and also select a row by tapping.
The catch is combining the two. I don't want a row to be selected if you are actually scrolling the list. Here's what I've found:
Doesn't trigger when scrolling:
* click
* mouseup
Does trigger when scrolling:
* mousedown
* touchstart
* touchend
The simple solution is to just stick with the click event. But what we're finding is that on certain blackberry devices, there is a VERY noticeable lag between touchstart and it then triggering either click or mouseup. This delay is significant enough to make it unusable on those devices.
So that leaves us with the other options. However, with those options, you can scroll the list without triggering the row you touched to start the scroll.
What is the best practice here to resolve this? | 2011/08/15 | [
"https://Stackoverflow.com/questions/7069458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172279/"
] | ```
var touchmoved;
$('button').on('touchend', function(e){
if(touchmoved != true){
// button click action
}
}).on('touchmove', function(e){
touchmoved = true;
}).on('touchstart', function(){
touchmoved = false;
});
``` | I came across this elegant solution that works like a charm using jQuery. My problem was preventing list items from calling their touch start event during scrolling. This should also work for swiping.
1. bind touchstart to each item that will be scrolled or swiped using a class 'listObject'
```
$('.listObject').live('touchstart', touchScroll);
```
2. Then to each item assign a data-object attr defining the function to be called
```
<button class='listObject' data-object=alert('You are alerted !')>Alert Me</button>
```
The following function will effectively differentiate between a tap and scrolling or swiping.
```
function touchScroll(e){
var objTarget = $(event.target);
if(objTarget.attr('data-object')){
var fn = objTarget.attr('data-object'); //function to call if tapped
}
if(!touchEnabled){// default if not touch device
eval(fn);
console.log("clicked", 1);
return;
}
$(e.target).on('touchend', function(e){
eval(fn); //trigger the function
console.log("touchEnd")
$(e.target).off('touchend');
});
$(e.target).on('touchmove', function(e){
$(e.target).off('touchend');
console.log("moved")
});
}
``` |
7,069,458 | I have a scrollable list on a mobile device. They want people to be able to scroll the list via swiping, and also select a row by tapping.
The catch is combining the two. I don't want a row to be selected if you are actually scrolling the list. Here's what I've found:
Doesn't trigger when scrolling:
* click
* mouseup
Does trigger when scrolling:
* mousedown
* touchstart
* touchend
The simple solution is to just stick with the click event. But what we're finding is that on certain blackberry devices, there is a VERY noticeable lag between touchstart and it then triggering either click or mouseup. This delay is significant enough to make it unusable on those devices.
So that leaves us with the other options. However, with those options, you can scroll the list without triggering the row you touched to start the scroll.
What is the best practice here to resolve this? | 2011/08/15 | [
"https://Stackoverflow.com/questions/7069458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172279/"
] | ```
var touchmoved;
$('button').on('touchend', function(e){
if(touchmoved != true){
// button click action
}
}).on('touchmove', function(e){
touchmoved = true;
}).on('touchstart', function(){
touchmoved = false;
});
``` | I use this bit of code so that buttons are only triggered (on touchend) if not being swiped on:
```
var startY;
var yDistance;
function touchHandler(event) {
touch = event.changedTouches[0];
event.preventDefault();
}
$('.button').on("touchstart", touchHandler, true);
$('.button').on("touchmove", touchHandler, true);
$('.button').on("touchstart", function(){
startY = touch.clientY;
});
$('.button').on('touchend', function(){
yDistance = startY - touch.clientY;
if(Math.abs(yDist) < 30){
//button response here, only if user is not swiping
console.log("button pressed")
}
});
``` |
7,069,458 | I have a scrollable list on a mobile device. They want people to be able to scroll the list via swiping, and also select a row by tapping.
The catch is combining the two. I don't want a row to be selected if you are actually scrolling the list. Here's what I've found:
Doesn't trigger when scrolling:
* click
* mouseup
Does trigger when scrolling:
* mousedown
* touchstart
* touchend
The simple solution is to just stick with the click event. But what we're finding is that on certain blackberry devices, there is a VERY noticeable lag between touchstart and it then triggering either click or mouseup. This delay is significant enough to make it unusable on those devices.
So that leaves us with the other options. However, with those options, you can scroll the list without triggering the row you touched to start the scroll.
What is the best practice here to resolve this? | 2011/08/15 | [
"https://Stackoverflow.com/questions/7069458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172279/"
] | Here's what I eventually came up with to allow for a list of items to be scrollable via swipe, but also each item to be 'triggerable' via a tap. In addition, you can still use with a keyboard (using onclick).
I think this is similar to Netlight\_Digital\_Media's answer. I need to study that one a bit more.
```
$(document)
// log the position of the touchstart interaction
.bind('touchstart', function(e){
touchStartPos = $(window).scrollTop();
})
// log the position of the touchend interaction
.bind('touchend', function(e){
// calculate how far the page has moved between
// touchstart and end.
var distance = touchStartPos - $(window).scrollTop();
var $clickableItem; // the item I want to be clickable if it's NOT a swipe
// adding this class for devices that
// will trigger a click event after
// the touchend event finishes. This
// tells the click event that we've
// already done things so don't repeat
$clickableItem.addClass("touched");
if (distance > 20 || distance < -20){
// the distance was more than 20px
// so we're assuming they intended
// to swipe to scroll the list and
// not selecting a row.
} else {
// we'll assume it was a tap
whateverFunctionYouWantToTriggerOnTapOrClick()
}
});
$($clickableItem).live('click',function(e){
// for any non-touch device, we need
// to still apply a click event
// but we'll first check to see
// if there was a previous touch
// event by checking for the class
// that was left by the touch event.
if ($(this).hasClass("touched")){
// this item's event was already triggered via touch
// so we won't call the function and reset this for
// the next touch by removing the class
$(this).removeClass("touched");
} else {
// there wasn't a touch event. We're
// instead using a mouse or keyboard
whateverFunctionYouWantToTriggerOnTapOrClick()
}
});
``` | I came up with this, since i wanted a global event that also can prevent linking dynamically.
So `preventDefault()` must be callable in the event listener, for this the touch event is referenced.
The detection is like most solutions posted here so far. On the end of the touch check if the element is still the same or if we moved some amount.
```js
$('li a').on('ontouchstart' in document.documentElement === true ? 'touchClick' : 'click', handleClick);
if('ontouchstart' in document.documentElement === true) {
var clickedEl = null;
var touchClickEvent = $.Event('touchClick');
var validClick = false;
var pos = null;
var moveTolerance = 15;
$(window).on('touchstart', function(e) {
/* only handle touch with one finger */
if(e.changedTouches.length === 1) {
clickedEl = document.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY);
pos = {x: e.touches[0].clientX, y: e.touches[0].clientY};
validClick = true;
} else {
validClick = false;
}
}).on("touchmove", function(e) {
var currentEl = document.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY);
if(
e.changedTouches.length > 1 ||
(!$(clickedEl).is(currentEl) && !$.contains(clickedEl, currentEl)) ||
(Math.abs(pos.y - e.touches[0].clientY) > moveTolerance && Math.abs(pos.x - e.touches[0].clientX) > moveTolerance)
) {
validClick = false;
}
}).on("touchend", function(e) {
if(validClick) {
/* this allowes calling of preventDefault on the touch chain */
touchClickEvent.originalEvent = e;
/* target is used in jQuery event delegation */
touchClickEvent.target = e.target;
$(clickedEl).trigger(touchClickEvent);
}
});
}
``` |
7,069,458 | I have a scrollable list on a mobile device. They want people to be able to scroll the list via swiping, and also select a row by tapping.
The catch is combining the two. I don't want a row to be selected if you are actually scrolling the list. Here's what I've found:
Doesn't trigger when scrolling:
* click
* mouseup
Does trigger when scrolling:
* mousedown
* touchstart
* touchend
The simple solution is to just stick with the click event. But what we're finding is that on certain blackberry devices, there is a VERY noticeable lag between touchstart and it then triggering either click or mouseup. This delay is significant enough to make it unusable on those devices.
So that leaves us with the other options. However, with those options, you can scroll the list without triggering the row you touched to start the scroll.
What is the best practice here to resolve this? | 2011/08/15 | [
"https://Stackoverflow.com/questions/7069458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172279/"
] | ```
var touchmoved;
$('button').on('touchend', function(e){
if(touchmoved != true){
// button click action
}
}).on('touchmove', function(e){
touchmoved = true;
}).on('touchstart', function(){
touchmoved = false;
});
``` | I came up with this, since i wanted a global event that also can prevent linking dynamically.
So `preventDefault()` must be callable in the event listener, for this the touch event is referenced.
The detection is like most solutions posted here so far. On the end of the touch check if the element is still the same or if we moved some amount.
```js
$('li a').on('ontouchstart' in document.documentElement === true ? 'touchClick' : 'click', handleClick);
if('ontouchstart' in document.documentElement === true) {
var clickedEl = null;
var touchClickEvent = $.Event('touchClick');
var validClick = false;
var pos = null;
var moveTolerance = 15;
$(window).on('touchstart', function(e) {
/* only handle touch with one finger */
if(e.changedTouches.length === 1) {
clickedEl = document.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY);
pos = {x: e.touches[0].clientX, y: e.touches[0].clientY};
validClick = true;
} else {
validClick = false;
}
}).on("touchmove", function(e) {
var currentEl = document.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY);
if(
e.changedTouches.length > 1 ||
(!$(clickedEl).is(currentEl) && !$.contains(clickedEl, currentEl)) ||
(Math.abs(pos.y - e.touches[0].clientY) > moveTolerance && Math.abs(pos.x - e.touches[0].clientX) > moveTolerance)
) {
validClick = false;
}
}).on("touchend", function(e) {
if(validClick) {
/* this allowes calling of preventDefault on the touch chain */
touchClickEvent.originalEvent = e;
/* target is used in jQuery event delegation */
touchClickEvent.target = e.target;
$(clickedEl).trigger(touchClickEvent);
}
});
}
``` |
7,069,458 | I have a scrollable list on a mobile device. They want people to be able to scroll the list via swiping, and also select a row by tapping.
The catch is combining the two. I don't want a row to be selected if you are actually scrolling the list. Here's what I've found:
Doesn't trigger when scrolling:
* click
* mouseup
Does trigger when scrolling:
* mousedown
* touchstart
* touchend
The simple solution is to just stick with the click event. But what we're finding is that on certain blackberry devices, there is a VERY noticeable lag between touchstart and it then triggering either click or mouseup. This delay is significant enough to make it unusable on those devices.
So that leaves us with the other options. However, with those options, you can scroll the list without triggering the row you touched to start the scroll.
What is the best practice here to resolve this? | 2011/08/15 | [
"https://Stackoverflow.com/questions/7069458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172279/"
] | I came up with this, since i wanted a global event that also can prevent linking dynamically.
So `preventDefault()` must be callable in the event listener, for this the touch event is referenced.
The detection is like most solutions posted here so far. On the end of the touch check if the element is still the same or if we moved some amount.
```js
$('li a').on('ontouchstart' in document.documentElement === true ? 'touchClick' : 'click', handleClick);
if('ontouchstart' in document.documentElement === true) {
var clickedEl = null;
var touchClickEvent = $.Event('touchClick');
var validClick = false;
var pos = null;
var moveTolerance = 15;
$(window).on('touchstart', function(e) {
/* only handle touch with one finger */
if(e.changedTouches.length === 1) {
clickedEl = document.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY);
pos = {x: e.touches[0].clientX, y: e.touches[0].clientY};
validClick = true;
} else {
validClick = false;
}
}).on("touchmove", function(e) {
var currentEl = document.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY);
if(
e.changedTouches.length > 1 ||
(!$(clickedEl).is(currentEl) && !$.contains(clickedEl, currentEl)) ||
(Math.abs(pos.y - e.touches[0].clientY) > moveTolerance && Math.abs(pos.x - e.touches[0].clientX) > moveTolerance)
) {
validClick = false;
}
}).on("touchend", function(e) {
if(validClick) {
/* this allowes calling of preventDefault on the touch chain */
touchClickEvent.originalEvent = e;
/* target is used in jQuery event delegation */
touchClickEvent.target = e.target;
$(clickedEl).trigger(touchClickEvent);
}
});
}
``` | jQuery Mobile has a [`.tap()`](http://api.jquerymobile.com/tap/) event which seems to have the behavior you'd expect:
>
> The jQuery Mobile tap event triggers after a quick, complete touch event that occurs on a single target object. It is the gesture equivalent of a standard click event that is triggered on the release state of the touch gesture.
>
>
>
This might not necessarily answer the question, but might be a useful alternative to some. |
7,069,458 | I have a scrollable list on a mobile device. They want people to be able to scroll the list via swiping, and also select a row by tapping.
The catch is combining the two. I don't want a row to be selected if you are actually scrolling the list. Here's what I've found:
Doesn't trigger when scrolling:
* click
* mouseup
Does trigger when scrolling:
* mousedown
* touchstart
* touchend
The simple solution is to just stick with the click event. But what we're finding is that on certain blackberry devices, there is a VERY noticeable lag between touchstart and it then triggering either click or mouseup. This delay is significant enough to make it unusable on those devices.
So that leaves us with the other options. However, with those options, you can scroll the list without triggering the row you touched to start the scroll.
What is the best practice here to resolve this? | 2011/08/15 | [
"https://Stackoverflow.com/questions/7069458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172279/"
] | Here's what I eventually came up with to allow for a list of items to be scrollable via swipe, but also each item to be 'triggerable' via a tap. In addition, you can still use with a keyboard (using onclick).
I think this is similar to Netlight\_Digital\_Media's answer. I need to study that one a bit more.
```
$(document)
// log the position of the touchstart interaction
.bind('touchstart', function(e){
touchStartPos = $(window).scrollTop();
})
// log the position of the touchend interaction
.bind('touchend', function(e){
// calculate how far the page has moved between
// touchstart and end.
var distance = touchStartPos - $(window).scrollTop();
var $clickableItem; // the item I want to be clickable if it's NOT a swipe
// adding this class for devices that
// will trigger a click event after
// the touchend event finishes. This
// tells the click event that we've
// already done things so don't repeat
$clickableItem.addClass("touched");
if (distance > 20 || distance < -20){
// the distance was more than 20px
// so we're assuming they intended
// to swipe to scroll the list and
// not selecting a row.
} else {
// we'll assume it was a tap
whateverFunctionYouWantToTriggerOnTapOrClick()
}
});
$($clickableItem).live('click',function(e){
// for any non-touch device, we need
// to still apply a click event
// but we'll first check to see
// if there was a previous touch
// event by checking for the class
// that was left by the touch event.
if ($(this).hasClass("touched")){
// this item's event was already triggered via touch
// so we won't call the function and reset this for
// the next touch by removing the class
$(this).removeClass("touched");
} else {
// there wasn't a touch event. We're
// instead using a mouse or keyboard
whateverFunctionYouWantToTriggerOnTapOrClick()
}
});
``` | I use this bit of code so that buttons are only triggered (on touchend) if not being swiped on:
```
var startY;
var yDistance;
function touchHandler(event) {
touch = event.changedTouches[0];
event.preventDefault();
}
$('.button').on("touchstart", touchHandler, true);
$('.button').on("touchmove", touchHandler, true);
$('.button').on("touchstart", function(){
startY = touch.clientY;
});
$('.button').on('touchend', function(){
yDistance = startY - touch.clientY;
if(Math.abs(yDist) < 30){
//button response here, only if user is not swiping
console.log("button pressed")
}
});
``` |
7,069,458 | I have a scrollable list on a mobile device. They want people to be able to scroll the list via swiping, and also select a row by tapping.
The catch is combining the two. I don't want a row to be selected if you are actually scrolling the list. Here's what I've found:
Doesn't trigger when scrolling:
* click
* mouseup
Does trigger when scrolling:
* mousedown
* touchstart
* touchend
The simple solution is to just stick with the click event. But what we're finding is that on certain blackberry devices, there is a VERY noticeable lag between touchstart and it then triggering either click or mouseup. This delay is significant enough to make it unusable on those devices.
So that leaves us with the other options. However, with those options, you can scroll the list without triggering the row you touched to start the scroll.
What is the best practice here to resolve this? | 2011/08/15 | [
"https://Stackoverflow.com/questions/7069458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172279/"
] | What you basically want to do is to detect what is a swipe and what is a click.
We may set some conditions:
1. Swipe is when you touch at point `p1`, then move your finger to point `p2` while still having the finger on the screen, then releaseing.
2. A click is when you tap start tapping and end tapping on the same element.
So, if you store the coordinates of where your `touchStart` occured, you can measure the difference at `touchEnd`. If the change is large enough, consider it a swipe, otherwise, consider it a click.
Also, if you want to do it really neat, you can also detect which element you are "hovering" over with your finger during a `touchMove`, and if you're not still at the element on which you started the click, you can run a `clickCancel` method which removes highlights etc.
```
// grab an element which you can click just as an example
var clickable = document.getElementById("clickableItem"),
// set up some variables that we need for later
currentElement,
clickedElement;
// set up touchStart event handler
var onTouchStart = function(e) {
// store which element we're currently clicking on
clickedElement = this;
// listen to when the user moves finger
this.addEventListener("touchMove" onTouchMove);
// add listener to when touch end occurs
this.addEventListener("touchEnd", onTouchEnd);
};
// when the user swipes, update element positions to swipe
var onTouchMove = function(e) {
// ... do your scrolling here
// store current element
currentElement = document.elementFromPoint(x, y);
// if the current element is no longer the same as we clicked from the beginning, remove highlight
if(clickedElement !== currentElement) {
removeHighlight(clickedElement);
}
};
// this is what is executed when the user stops the movement
var onTouchEnd = function(e) {
if(clickedElement === currentElement) {
removeHighlight(clickedElement);
// .... execute click action
}
// clean up event listeners
this.removeEventListener("touchMove" onTouchMove);
this.removeEventListener("touchEnd", onTouchEnd);
};
function addHighlight(element) {
element.className = "highlighted";
}
function removeHighlight(element) {
element.className = "";
}
clickable.addEventListener("touchStart", onTouchStart);
```
Then, you will have to add listeners to you scrollable element also, but there you won't have to worry about what happens if the finger has moved inbetween `touchStart` and `touchEnd`.
```
var scrollable = document.getElementById("scrollableItem");
// set up touchStart event handler
var onTouchStartScrollable = function(e) {
// listen to when the user moves finger
this.addEventListener("touchMove" onTouchMoveScrollable);
// add listener to when touch end occurs
this.addEventListener("touchEnd", onTouchEndScrollable);
};
// when the user swipes, update element positions to swipe
var onTouchMoveScrollable = function(e) {
// ... do your scrolling here
};
// this is what is executed when the user stops the movement
var onTouchEndScrollable = function(e) {
// clean up event listeners
this.removeEventListener("touchMove" onTouchMoveScrollable);
this.removeEventListener("touchEnd", onTouchEndScrollable);
};
scrollable.addEventListener("touchStart", onTouchStartScrollable);
```
// Simon A. | jQuery Mobile has a [`.tap()`](http://api.jquerymobile.com/tap/) event which seems to have the behavior you'd expect:
>
> The jQuery Mobile tap event triggers after a quick, complete touch event that occurs on a single target object. It is the gesture equivalent of a standard click event that is triggered on the release state of the touch gesture.
>
>
>
This might not necessarily answer the question, but might be a useful alternative to some. |
7,069,458 | I have a scrollable list on a mobile device. They want people to be able to scroll the list via swiping, and also select a row by tapping.
The catch is combining the two. I don't want a row to be selected if you are actually scrolling the list. Here's what I've found:
Doesn't trigger when scrolling:
* click
* mouseup
Does trigger when scrolling:
* mousedown
* touchstart
* touchend
The simple solution is to just stick with the click event. But what we're finding is that on certain blackberry devices, there is a VERY noticeable lag between touchstart and it then triggering either click or mouseup. This delay is significant enough to make it unusable on those devices.
So that leaves us with the other options. However, with those options, you can scroll the list without triggering the row you touched to start the scroll.
What is the best practice here to resolve this? | 2011/08/15 | [
"https://Stackoverflow.com/questions/7069458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172279/"
] | What you basically want to do is to detect what is a swipe and what is a click.
We may set some conditions:
1. Swipe is when you touch at point `p1`, then move your finger to point `p2` while still having the finger on the screen, then releaseing.
2. A click is when you tap start tapping and end tapping on the same element.
So, if you store the coordinates of where your `touchStart` occured, you can measure the difference at `touchEnd`. If the change is large enough, consider it a swipe, otherwise, consider it a click.
Also, if you want to do it really neat, you can also detect which element you are "hovering" over with your finger during a `touchMove`, and if you're not still at the element on which you started the click, you can run a `clickCancel` method which removes highlights etc.
```
// grab an element which you can click just as an example
var clickable = document.getElementById("clickableItem"),
// set up some variables that we need for later
currentElement,
clickedElement;
// set up touchStart event handler
var onTouchStart = function(e) {
// store which element we're currently clicking on
clickedElement = this;
// listen to when the user moves finger
this.addEventListener("touchMove" onTouchMove);
// add listener to when touch end occurs
this.addEventListener("touchEnd", onTouchEnd);
};
// when the user swipes, update element positions to swipe
var onTouchMove = function(e) {
// ... do your scrolling here
// store current element
currentElement = document.elementFromPoint(x, y);
// if the current element is no longer the same as we clicked from the beginning, remove highlight
if(clickedElement !== currentElement) {
removeHighlight(clickedElement);
}
};
// this is what is executed when the user stops the movement
var onTouchEnd = function(e) {
if(clickedElement === currentElement) {
removeHighlight(clickedElement);
// .... execute click action
}
// clean up event listeners
this.removeEventListener("touchMove" onTouchMove);
this.removeEventListener("touchEnd", onTouchEnd);
};
function addHighlight(element) {
element.className = "highlighted";
}
function removeHighlight(element) {
element.className = "";
}
clickable.addEventListener("touchStart", onTouchStart);
```
Then, you will have to add listeners to you scrollable element also, but there you won't have to worry about what happens if the finger has moved inbetween `touchStart` and `touchEnd`.
```
var scrollable = document.getElementById("scrollableItem");
// set up touchStart event handler
var onTouchStartScrollable = function(e) {
// listen to when the user moves finger
this.addEventListener("touchMove" onTouchMoveScrollable);
// add listener to when touch end occurs
this.addEventListener("touchEnd", onTouchEndScrollable);
};
// when the user swipes, update element positions to swipe
var onTouchMoveScrollable = function(e) {
// ... do your scrolling here
};
// this is what is executed when the user stops the movement
var onTouchEndScrollable = function(e) {
// clean up event listeners
this.removeEventListener("touchMove" onTouchMoveScrollable);
this.removeEventListener("touchEnd", onTouchEndScrollable);
};
scrollable.addEventListener("touchStart", onTouchStartScrollable);
```
// Simon A. | I did this with a bit of a different work around. It's definitely not very elegant and certainly not suited to most situations, but it worked for me.
I have been using jQuery's toggleSlide() to open and close input divs, firing the slide on touchstart. The problem was that when the user wanted to scroll, the touched div would open up. To stop this from happening, (or to reverse it before the user noticed) I added a touchslide event to the document which would close the last touched div.
In more depth, here is a code snippet:
```
var lastTouched;
document.addEventListener('touchmove',function(){
lastTouched.hide();
});
$('#button').addEventListener('touchstart',function(){
$('#slide').slideToggle();
lastTouched = $('#slide');
});
```
The global variable stores the last touched div, and if the user swipes, the document.touchmove event hides that div. Sometimes you get a flicker of a div poking out but it works for what I need it to, and is simple enough for me to come up with. |
7,069,458 | I have a scrollable list on a mobile device. They want people to be able to scroll the list via swiping, and also select a row by tapping.
The catch is combining the two. I don't want a row to be selected if you are actually scrolling the list. Here's what I've found:
Doesn't trigger when scrolling:
* click
* mouseup
Does trigger when scrolling:
* mousedown
* touchstart
* touchend
The simple solution is to just stick with the click event. But what we're finding is that on certain blackberry devices, there is a VERY noticeable lag between touchstart and it then triggering either click or mouseup. This delay is significant enough to make it unusable on those devices.
So that leaves us with the other options. However, with those options, you can scroll the list without triggering the row you touched to start the scroll.
What is the best practice here to resolve this? | 2011/08/15 | [
"https://Stackoverflow.com/questions/7069458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172279/"
] | Some of these solutions worked for me, but in the end I found that this lightweight library was simpler to setup.
Tocca.js: <https://github.com/GianlucaGuarini/Tocca.js>
It's quite flexible and detects touch as well as swipe, double-tap etc. | I did this with a bit of a different work around. It's definitely not very elegant and certainly not suited to most situations, but it worked for me.
I have been using jQuery's toggleSlide() to open and close input divs, firing the slide on touchstart. The problem was that when the user wanted to scroll, the touched div would open up. To stop this from happening, (or to reverse it before the user noticed) I added a touchslide event to the document which would close the last touched div.
In more depth, here is a code snippet:
```
var lastTouched;
document.addEventListener('touchmove',function(){
lastTouched.hide();
});
$('#button').addEventListener('touchstart',function(){
$('#slide').slideToggle();
lastTouched = $('#slide');
});
```
The global variable stores the last touched div, and if the user swipes, the document.touchmove event hides that div. Sometimes you get a flicker of a div poking out but it works for what I need it to, and is simple enough for me to come up with. |
7,069,458 | I have a scrollable list on a mobile device. They want people to be able to scroll the list via swiping, and also select a row by tapping.
The catch is combining the two. I don't want a row to be selected if you are actually scrolling the list. Here's what I've found:
Doesn't trigger when scrolling:
* click
* mouseup
Does trigger when scrolling:
* mousedown
* touchstart
* touchend
The simple solution is to just stick with the click event. But what we're finding is that on certain blackberry devices, there is a VERY noticeable lag between touchstart and it then triggering either click or mouseup. This delay is significant enough to make it unusable on those devices.
So that leaves us with the other options. However, with those options, you can scroll the list without triggering the row you touched to start the scroll.
What is the best practice here to resolve this? | 2011/08/15 | [
"https://Stackoverflow.com/questions/7069458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172279/"
] | I came up with this, since i wanted a global event that also can prevent linking dynamically.
So `preventDefault()` must be callable in the event listener, for this the touch event is referenced.
The detection is like most solutions posted here so far. On the end of the touch check if the element is still the same or if we moved some amount.
```js
$('li a').on('ontouchstart' in document.documentElement === true ? 'touchClick' : 'click', handleClick);
if('ontouchstart' in document.documentElement === true) {
var clickedEl = null;
var touchClickEvent = $.Event('touchClick');
var validClick = false;
var pos = null;
var moveTolerance = 15;
$(window).on('touchstart', function(e) {
/* only handle touch with one finger */
if(e.changedTouches.length === 1) {
clickedEl = document.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY);
pos = {x: e.touches[0].clientX, y: e.touches[0].clientY};
validClick = true;
} else {
validClick = false;
}
}).on("touchmove", function(e) {
var currentEl = document.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY);
if(
e.changedTouches.length > 1 ||
(!$(clickedEl).is(currentEl) && !$.contains(clickedEl, currentEl)) ||
(Math.abs(pos.y - e.touches[0].clientY) > moveTolerance && Math.abs(pos.x - e.touches[0].clientX) > moveTolerance)
) {
validClick = false;
}
}).on("touchend", function(e) {
if(validClick) {
/* this allowes calling of preventDefault on the touch chain */
touchClickEvent.originalEvent = e;
/* target is used in jQuery event delegation */
touchClickEvent.target = e.target;
$(clickedEl).trigger(touchClickEvent);
}
});
}
``` | I did this with a bit of a different work around. It's definitely not very elegant and certainly not suited to most situations, but it worked for me.
I have been using jQuery's toggleSlide() to open and close input divs, firing the slide on touchstart. The problem was that when the user wanted to scroll, the touched div would open up. To stop this from happening, (or to reverse it before the user noticed) I added a touchslide event to the document which would close the last touched div.
In more depth, here is a code snippet:
```
var lastTouched;
document.addEventListener('touchmove',function(){
lastTouched.hide();
});
$('#button').addEventListener('touchstart',function(){
$('#slide').slideToggle();
lastTouched = $('#slide');
});
```
The global variable stores the last touched div, and if the user swipes, the document.touchmove event hides that div. Sometimes you get a flicker of a div poking out but it works for what I need it to, and is simple enough for me to come up with. |
69,931,297 | I would just like to send a DM to my friend via python code.
This is my code, but it does not work.
Code:
```
import discord
client = discord.Client(token="MY_TOKEN")
async def sendDm():
user = client.get_user("USER_ID")
await user.send("Hello there!")
``` | 2021/11/11 | [
"https://Stackoverflow.com/questions/69931297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15370132/"
] | 1. Your bot might now have the user in its cache. Then use `fetch_user`
instead of `get_user` (`fetch` requests the Discord API instead of
its internal cache):
```py
async def sendDm():
user = await client.fetch_user("USER_ID")
await user.send("Hello there!")
```
2. You can run it with [`on_ready` event](https://discordpy.readthedocs.io/en/latest/api.html?#discord.on_ready):
```py
@client.event
async def on_ready():
user = await client.fetch_user("USER_ID")
await user.send("Hello there!")
```
Copy and paste:
---------------
```py
import discord
client = discord.Client()
@client.event
async def on_ready():
user = await client.fetch_user("USER_ID")
await user.send("Hello there!")
client.run("MY_TOKEN")
``` | So are you trying to do this with a command? If so here is that
```
@bot.command()
async def dm(ctx, user: discord.User = None, *, value = None):
if user == ctx.message.author:
await ctx.send("You can't DM yourself goofy")
else:
await ctx.message.delete()
if user == None:
await ctx.send(f'**{ctx.message.author},** Please mention somebody to DM.')
else:
if value == None:
await ctx.send(f'**{ctx.message.author},** Please send a message to DM.')
else:
` await user.send(value)
``` |
15,376,478 | I want to get the name and picture of a Cub Scout, the Cub Scout details, the awards and details for each award and display these details in a view. Is it best to get each set of details from the server side, pass it back to the client side and display it or get all the information at once?
I would opt for option 2. However, I thought I had better check.
Regards,
Glyn | 2013/03/13 | [
"https://Stackoverflow.com/questions/15376478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965599/"
] | Unless your query is returning some huge dataset, then multiple queries probably aren't necessary. If load times are too slow when you implement your queries, consider paging your results. | When showing a view with all records from db, it is usually a good practice to show minimum data for each row with a link to more details for each row for better user experience and less load time from query.
Now when user click on more details, other detail data of that particular row should be fetched. |
15,376,478 | I want to get the name and picture of a Cub Scout, the Cub Scout details, the awards and details for each award and display these details in a view. Is it best to get each set of details from the server side, pass it back to the client side and display it or get all the information at once?
I would opt for option 2. However, I thought I had better check.
Regards,
Glyn | 2013/03/13 | [
"https://Stackoverflow.com/questions/15376478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965599/"
] | Unless your query is returning some huge dataset, then multiple queries probably aren't necessary. If load times are too slow when you implement your queries, consider paging your results. | I agree that if the size of the information is not that big, probably is a good idea to get it all at once. All depends on your UX and you backend design.
Are you expecting to show the info according to user interactions?,
Are you going to reuse part of that information somewhere else in your app?.
Are you caching query results?
Is you do.. then you might consider to have a few methods to get the information. Regarding your page controller, unless you are not using ajax, you may create a facade (this [pattern](http://en.wikipedia.org/wiki/Facade_pattern) ) to integrate all those partial methods.
Let me know if you have any questions..
Thansk!,
@leo. |
15,376,478 | I want to get the name and picture of a Cub Scout, the Cub Scout details, the awards and details for each award and display these details in a view. Is it best to get each set of details from the server side, pass it back to the client side and display it or get all the information at once?
I would opt for option 2. However, I thought I had better check.
Regards,
Glyn | 2013/03/13 | [
"https://Stackoverflow.com/questions/15376478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965599/"
] | Unless your query is returning some huge dataset, then multiple queries probably aren't necessary. If load times are too slow when you implement your queries, consider paging your results. | Get the benefits of Asynchronous call load as less data as possible on `on-load` and make `Asynchronous calls` when data needed.
Two main reasons to go for `Asynchronous` :
**Reduce the traffic travels between the client and the server.**
**Response time is faster so increases performance and speed.** |
46,078,942 | i want to do like let user to add a new item which user can enter item name, item description, item price and so on. let say the name variable stored candy and i have a candy image in my drawable can i do like R.drawable.name to refer to R.drawable.candy?? Anyone help pls
```
public class item {
String name;
String desc;
double price;
int itemimage;
public item(String name, String desc, double price) {
this.name = name;
this.desc = desc;
this.price = price;
itemimage = R.drawable.name;//my question is here
//i want to have auto define the image of the item for later use
// so i can do like set imageview of this item
//i will have the image have same name with item name
// for example my item name is candy
//then i will have a image at the android drawable named candy
//so in android to define this image is R.drawable.candy
// can i do like R.drawable.name <-- variable store with value candy
// is it same with R.drawable.candy
}
}//end class item
//another class
public class main {
Arraylist<item> itemdatabase = new Arraylist<item>();
Scanner input = new Scanner(System.in);
System.out.print("Enter item name:");
String itemname = input.nextLine();
System.out.print("Enter item desc:");
String itemdesc = input.nextLine();
System.out.print("Enter item price:");
double itemprice = input.nextDouble();
itemdatabase.add(new
item(itemname, itemdesc, itemprice);
}
``` | 2017/09/06 | [
"https://Stackoverflow.com/questions/46078942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8525038/"
] | You can use the [`Resources.getIdentifier()` method](https://developer.android.com/reference/android/content/res/Resources.html#getIdentifier(java.lang.String,%20java.lang.String,%20java.lang.String)). For `R.drawable.candy`, you'd use it like this:
```
int id = getResources().getIdentifier("candy", "drawable", getPackageName());
// now `id` == R.drawable.candy
```
This code assumes you're running inside an `Activity`. If not, you'll need access to a `Context` instance so that you can call `Context.getResources()` and `Context.getPackageName()`. That might look like this:
```
int id = mContext.getResources().getIdentifier("candy", "drawable", mContext.getPackageName());
``` | Answer is No, You can not do like R.drawable.name |
20,349,577 | When I execute the following command in SSMS I get the results I expect -
```
SELECT *
FROM [Event]
WHERE Active = 'True'
AND [Name] LIKE '%P%'
```
i.e. All the Events whose Name contains a P are displayed
However, when I build this command in my WinForms app written in C# I always get an empty datatable.
I am using the following code -
```
string sqlText = "SELECT * " +
"FROM Event " +
"WHERE Active = @Active";
SqlCommand sqlCom = new SqlCommand();
sqlCom.Parameters.Add("@Active", SqlDbType.Bit).Value = active;
if (txtSearchName.Text != null && txtSearchName.Text.Length > 0)
{
sqlText += " AND [Name] LIKE '@Name'";
string value = "%" + txtSearchName.Text + "%";
sqlCom.Parameters.Add("@Name", SqlDbType.VarChar).Value = value;
}
sqlText += " ORDER BY [Date] DESC;";
sqlCom.CommandText = sqlText;
DataTable table = Express.GetTable(sqlCom);
DataView view = new DataView(table);
DataTable show = view.ToTable(true, "ID", "Date", "Name");
dataEventsFound.DataSource = show;
```
Please note Express.GetTable is a method that simply adds a SQLConnection and uses a DataReader to fill and return a DataTable. I do not believe the fault lies in that Method as it is used hundreds of times throughout this and other applications I have written.
I think the error is something to do with the Command Text and the @Name Parameter, but I can't determine exactly what the problem is, and why my DataTable is always empty. | 2013/12/03 | [
"https://Stackoverflow.com/questions/20349577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1109750/"
] | Remove single quote from between `@Name` parameter.
```
sqlText += " AND [Name] LIKE @Name";
``` | After this line : sqlCom.CommandText = sqlText;
You should add this line: sqlCom.ExecuteNonQuery(); |
55,019,779 | This does not work. What am I doing wrong?
The error says x is undefined. I was trying to increment xx by one with an x keypress.
```
xx = int()
yy = int()
zz = int()
print(xx, yy, zz)
b = input("New value:")
if b == x:
then [xx ++ 1]
print(xx, yy, zz)
else :
print(xx, yy, zz)
``` | 2019/03/06 | [
"https://Stackoverflow.com/questions/55019779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11158548/"
] | You can use nth-last-child to solve what you need, see my below edits which solves your issue. More info on nth-last-child here: <https://www.w3schools.com/cssref/sel_nth-last-child.asp>
Thanks
```css
.main{
width:500px;
height: 500px;
border:1px solid blue;
}
.box{
width:300px;
height: 100px;
border:1px solid red;
}
.box:nth-child(odd) {
background: grey;
}
.box:nth-child(even) {
background:green;
}
.box:nth-child(odd) {
background: grey;
}
.box:nth-last-child(2) {
background:green;
}
.box:nth-last-child(1) {
background:grey;
}
```
```html
<div class="main">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
</div>
``` | If you want to do something from the last row, Use `:nth-last-child()`.
```css
.main{
width:500px;
height: 500px;
border:1px solid blue;
}
.box{
width:300px;
height: 100px;
border:1px solid red;
}
.box:nth-last-child(odd) {
background: grey;
}
.box:nth-last-child(even) {
background:green;
}
```
```html
<div class="main">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
</div>
``` |
55,019,779 | This does not work. What am I doing wrong?
The error says x is undefined. I was trying to increment xx by one with an x keypress.
```
xx = int()
yy = int()
zz = int()
print(xx, yy, zz)
b = input("New value:")
if b == x:
then [xx ++ 1]
print(xx, yy, zz)
else :
print(xx, yy, zz)
``` | 2019/03/06 | [
"https://Stackoverflow.com/questions/55019779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11158548/"
] | ```css
.main{
width:500px;
height: 500px;
border:1px solid blue;
}
.box{
width:300px;
height: 100px;
border:1px solid red;
}
.box:nth-child(odd) {
background: grey;
}
.box:nth-child(even) {
background:green;
}
.box:last-child {
background: grey;
}
.box:nth-last-child(2){
background:green;
}
```
```html
<div class="main">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
<div class="box">7</div>
</div>
``` | If you want to do something from the last row, Use `:nth-last-child()`.
```css
.main{
width:500px;
height: 500px;
border:1px solid blue;
}
.box{
width:300px;
height: 100px;
border:1px solid red;
}
.box:nth-last-child(odd) {
background: grey;
}
.box:nth-last-child(even) {
background:green;
}
```
```html
<div class="main">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
</div>
``` |
55,019,779 | This does not work. What am I doing wrong?
The error says x is undefined. I was trying to increment xx by one with an x keypress.
```
xx = int()
yy = int()
zz = int()
print(xx, yy, zz)
b = input("New value:")
if b == x:
then [xx ++ 1]
print(xx, yy, zz)
else :
print(xx, yy, zz)
``` | 2019/03/06 | [
"https://Stackoverflow.com/questions/55019779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11158548/"
] | You can use nth-last-child to solve what you need, see my below edits which solves your issue. More info on nth-last-child here: <https://www.w3schools.com/cssref/sel_nth-last-child.asp>
Thanks
```css
.main{
width:500px;
height: 500px;
border:1px solid blue;
}
.box{
width:300px;
height: 100px;
border:1px solid red;
}
.box:nth-child(odd) {
background: grey;
}
.box:nth-child(even) {
background:green;
}
.box:nth-child(odd) {
background: grey;
}
.box:nth-last-child(2) {
background:green;
}
.box:nth-last-child(1) {
background:grey;
}
```
```html
<div class="main">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
</div>
``` | You can select div using `nth-last-child`.
Try my code-
```css
.main {
width: 500px;
height: 500px;
border: 1px solid blue;
}
.box {
width: 500pxpx;
height: 50px;
border: 1px solid red;
}
.box:nth-last-child(2n+1) {
background: grey;
}
.box:nth-last-child(2n) {
background: green;
}
```
```html
<div class="main">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
</div>
``` |
55,019,779 | This does not work. What am I doing wrong?
The error says x is undefined. I was trying to increment xx by one with an x keypress.
```
xx = int()
yy = int()
zz = int()
print(xx, yy, zz)
b = input("New value:")
if b == x:
then [xx ++ 1]
print(xx, yy, zz)
else :
print(xx, yy, zz)
``` | 2019/03/06 | [
"https://Stackoverflow.com/questions/55019779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11158548/"
] | You can use nth-last-child to solve what you need, see my below edits which solves your issue. More info on nth-last-child here: <https://www.w3schools.com/cssref/sel_nth-last-child.asp>
Thanks
```css
.main{
width:500px;
height: 500px;
border:1px solid blue;
}
.box{
width:300px;
height: 100px;
border:1px solid red;
}
.box:nth-child(odd) {
background: grey;
}
.box:nth-child(even) {
background:green;
}
.box:nth-child(odd) {
background: grey;
}
.box:nth-last-child(2) {
background:green;
}
.box:nth-last-child(1) {
background:grey;
}
```
```html
<div class="main">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
</div>
``` | ```css
.main{
width:500px;
height: 500px;
border:1px solid blue;
}
.box{
width:300px;
height: 100px;
border:1px solid red;
}
.box:nth-child(odd) {
background: grey;
}
.box:nth-child(even) {
background:green;
}
.box:last-child {
background: grey;
}
.box:nth-last-child(2){
background:green;
}
```
```html
<div class="main">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
<div class="box">7</div>
</div>
``` |
55,019,779 | This does not work. What am I doing wrong?
The error says x is undefined. I was trying to increment xx by one with an x keypress.
```
xx = int()
yy = int()
zz = int()
print(xx, yy, zz)
b = input("New value:")
if b == x:
then [xx ++ 1]
print(xx, yy, zz)
else :
print(xx, yy, zz)
``` | 2019/03/06 | [
"https://Stackoverflow.com/questions/55019779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11158548/"
] | ```css
.main{
width:500px;
height: 500px;
border:1px solid blue;
}
.box{
width:300px;
height: 100px;
border:1px solid red;
}
.box:nth-child(odd) {
background: grey;
}
.box:nth-child(even) {
background:green;
}
.box:last-child {
background: grey;
}
.box:nth-last-child(2){
background:green;
}
```
```html
<div class="main">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
<div class="box">7</div>
</div>
``` | You can select div using `nth-last-child`.
Try my code-
```css
.main {
width: 500px;
height: 500px;
border: 1px solid blue;
}
.box {
width: 500pxpx;
height: 50px;
border: 1px solid red;
}
.box:nth-last-child(2n+1) {
background: grey;
}
.box:nth-last-child(2n) {
background: green;
}
```
```html
<div class="main">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
</div>
``` |
18,277,952 | I'll be working on a project that will require a live output of a number of tweets users have hash tagged on Twitter as well as their tweets. Something along the lines of MTV's Twitter Tracker: <http://vma-twittertracker.mtv.com/live/#buzz>.
What intrigued me about this site is how can they constantly make API calls to Twitter without breaching the request limit?
I'd appreciate if anyone could guide me on the most effective way to accomplish this. From the research I've carried out thus far, I presume I will need to use Twitter's Streaming API.
Since there is a chance that the number of tweets output to my page could be in their thousands (AJAX loaded) along with stats on number of retweets/favourites, what would be the most scalable approach within my .NET site? Any examples or guidance would be appreciated. | 2013/08/16 | [
"https://Stackoverflow.com/questions/18277952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1300806/"
] | Check out [Linq2Twitter](http://linqtotwitter.codeplex.com "Linq2Twitter"). It is a great wrapper around the Twitter API, and provides two mechanisms that will help you:
* There is a search function that allows you to search for hash tags, etc, which will limit the amount of data you are getting back
* You have the option to specify getting all the data since a certain tweet ID. You can therefore incrementally search the feed by performing searches and searching, in subsequent calls, from the ID you left off on.
I have used this many times to search the public feed and have not had any issues to date. I think the search function is key not requesting too much. Good luck! | you can look into Storm framework. Below are few links for further reference:-
<http://storm-project.net/>
<https://github.com/nathanmarz/storm> |
18,277,952 | I'll be working on a project that will require a live output of a number of tweets users have hash tagged on Twitter as well as their tweets. Something along the lines of MTV's Twitter Tracker: <http://vma-twittertracker.mtv.com/live/#buzz>.
What intrigued me about this site is how can they constantly make API calls to Twitter without breaching the request limit?
I'd appreciate if anyone could guide me on the most effective way to accomplish this. From the research I've carried out thus far, I presume I will need to use Twitter's Streaming API.
Since there is a chance that the number of tweets output to my page could be in their thousands (AJAX loaded) along with stats on number of retweets/favourites, what would be the most scalable approach within my .NET site? Any examples or guidance would be appreciated. | 2013/08/16 | [
"https://Stackoverflow.com/questions/18277952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1300806/"
] | Check out [Linq2Twitter](http://linqtotwitter.codeplex.com "Linq2Twitter"). It is a great wrapper around the Twitter API, and provides two mechanisms that will help you:
* There is a search function that allows you to search for hash tags, etc, which will limit the amount of data you are getting back
* You have the option to specify getting all the data since a certain tweet ID. You can therefore incrementally search the feed by performing searches and searching, in subsequent calls, from the ID you left off on.
I have used this many times to search the public feed and have not had any issues to date. I think the search function is key not requesting too much. Good luck! | Thanks for all your responses.
It looks like sites such that display a lot of Twitter stats/data use [third party approved providers](https://dev.twitter.com/programs/twitter-certified-products/products#Certified-Data-Products) that have direct access to [Twitter's Firehose API](https://dev.twitter.com/docs/api/1.1/get/statuses/firehose).
I have managed to get in contact with an approved provider to supply us with the feeds of data required (and it ain't cheap!). |
18,170,579 | ```
$qb = $this->doctrine->em->createQueryBuilder()
->from('User','u')
->select('count(u.name)')
->where('u.name = :name')
->setParameter('name', $user->getUsername());
```
When I execute `$qb->getQuery()->getResult()`,
I get this error:
>
> Fatal error: Uncaught exception 'Doctrine\ORM\Query\QueryException' with message 'SELECT count(u.name) FROM User u WHERE u.name = :name' in /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/QueryException.php:39Stack trace:
>
>
> `#0` /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(429): Doctrine\ORM\Query\QueryException::dqlError('SELECT count(u....')
>
>
> `#1` /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(854): Doctrine\ORM\Query\Parser->semanticalError('Class 'User' is...', Array)
>
>
> `#2` /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(1529): Doctrine\ORM\Query\Parser->AbstractSchemaName()
>
>
> `#3` /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(1426): Doctrine\ORM\Query\Parser->RangeVariableDeclaration()
>
>
> `#4` /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(1168): Doctrine\ORM\Query\Parser->IdentificationVariableDeclaration()
>
>
> `#5` /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(757): Doctrine\ORM\Query\Pars in /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/QueryException.php on line 49
>
>
> | 2013/08/11 | [
"https://Stackoverflow.com/questions/18170579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2672010/"
] | the following code works great, just add "Entities\" in the clause from.
```
$qb = $this->doctrine->em->createQueryBuilder()
->select($this->doctrine->em->createQueryBuilder()->expr()->count('u.username'))
->from('Entities\User','u')
->where('u.username = :username')
->setParameter('username', $user->getUsername());
var_dump($qb->getQuery()->getResult());
``` | ```
$qb->$this->doctrine->em->createQueryBuilder()
->select($qb->expr()->count('u.name'))
->from('User','u')
->where('u.name = :name')
->setParameter('name', $user->getUsername());
``` |
18,170,579 | ```
$qb = $this->doctrine->em->createQueryBuilder()
->from('User','u')
->select('count(u.name)')
->where('u.name = :name')
->setParameter('name', $user->getUsername());
```
When I execute `$qb->getQuery()->getResult()`,
I get this error:
>
> Fatal error: Uncaught exception 'Doctrine\ORM\Query\QueryException' with message 'SELECT count(u.name) FROM User u WHERE u.name = :name' in /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/QueryException.php:39Stack trace:
>
>
> `#0` /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(429): Doctrine\ORM\Query\QueryException::dqlError('SELECT count(u....')
>
>
> `#1` /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(854): Doctrine\ORM\Query\Parser->semanticalError('Class 'User' is...', Array)
>
>
> `#2` /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(1529): Doctrine\ORM\Query\Parser->AbstractSchemaName()
>
>
> `#3` /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(1426): Doctrine\ORM\Query\Parser->RangeVariableDeclaration()
>
>
> `#4` /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(1168): Doctrine\ORM\Query\Parser->IdentificationVariableDeclaration()
>
>
> `#5` /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(757): Doctrine\ORM\Query\Pars in /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/QueryException.php on line 49
>
>
> | 2013/08/11 | [
"https://Stackoverflow.com/questions/18170579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2672010/"
] | the following code works great, just add "Entities\" in the clause from.
```
$qb = $this->doctrine->em->createQueryBuilder()
->select($this->doctrine->em->createQueryBuilder()->expr()->count('u.username'))
->from('Entities\User','u')
->where('u.username = :username')
->setParameter('username', $user->getUsername());
var_dump($qb->getQuery()->getResult());
``` | You can use a User::class to define the entity name.
```
$qb = $this->doctrine->em->createQueryBuilder()
->from(User::class,'u')
->select('count(u.name)')
->where('u.name = :name')
->setParameter('name', $user->getUsername());
``` |
20,825,758 | I'm having the following data structure in my Meteor project:
- Users with a set of list-ids that belong to the user (author)
- Lists that actually contain all the data of the list
Now I'm trying to publish all Lists of a user to the client. Here is a simple example:
```js
if (Meteor.isClient) {
Lists = new Meteor.Collection("lists");
Deps.autorun(function() {
Meteor.subscribe("lists");
});
Template.hello.greeting = function () {
return "Test";
};
Template.hello.events({
'click input' : function () {
if (typeof console !== 'undefined')
console.log(Lists.find());
}
});
}
if (Meteor.isServer) {
Lists = new Meteor.Collection("lists");
Meteor.startup(function () {
if ( Meteor.users.find().count() === 0 ) {
Accounts.createUser({ //create new user
username: 'test',
email: 'test@test.com',
password: 'test'
});
//add list to Lists and id of the list to user
var user = Meteor.users.findOne({'emails.address' : 'test@test.com', username : 'test'});
var listid = new Meteor.Collection.ObjectID().valueOf();
Meteor.users.update(user._id, {$addToSet : {lists : listid}});
Lists.insert({_id : listid, data : 'content'});
}
});
Meteor.publish("lists", function(){
var UserListIdsCursor = Meteor.users.find({_id: this.userId}, {limit: 1}).lists;
if(UserListIdsCursor!=undefined){
var UserListIds = UserListIdsCursor.fetch();
return Lists.find({_id : { $in : UserListIds}});
}
});
Meteor.publish("mylists", function(){
return Meteor.users.find({_id: this.userId}, {limit: 1}).lists;
});
//at the moment everything is allowed
Lists.allow({
insert : function(userID)
{
return true;
},
update : function(userID)
{
return true;
},
remove : function(userID)
{
return true;
}
});
}
```
But publishing the Lists doesn't work properly. Any ideas how to fix this? I'm also publishing "mylists" to guarantee that the user has access to the field "lists". | 2013/12/29 | [
"https://Stackoverflow.com/questions/20825758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3123726/"
] | Solution
--------
```
Lists = new Meteor.Collection('lists');
if (Meteor.isClient) {
Tracker.autorun(function() {
if (Meteor.userId()) {
Meteor.subscribe('lists');
Meteor.subscribe('myLists');
}
});
}
if (Meteor.isServer) {
Meteor.startup(function() {
if (Meteor.users.find().count() === 0) {
var user = {
username: 'test',
email: 'test@test.com',
password: 'test'
};
var userId = Accounts.createUser(user);
var listId = Lists.insert({data: 'content'});
Meteor.users.update(userId, {
$addToSet: {lists: listId}
});
}
});
Meteor.publish('lists', function() {
check(this.userId, String);
var lists = Meteor.users.findOne(this.userId).lists;
return Lists.find({_id: {$in: lists}});
});
Meteor.publish('myLists', function() {
check(this.userId, String);
return Meteor.users.find(this.userId, {fields: {lists: 1}});
});
}
```
Changes
-------
1. Declare the `Lists` collection outside of the client and server (no need to declare it twice).
2. Ensure the user is logged in when subscribing. (performance enhancement).
3. When inserting the test user, use the fact that all insert functions return an id (reduces code).
4. Ensure the user is logged in when publishing.
5. Simplified `lists` publish function.
6. Fixed `myLists` publish function. A publish needs to return a cursor, an array of cursors, or a falsy value. You can't return an array of ids (which this code doesn't access anyway because you need to do a `fetch` or a `findOne`). Important note - this publishes another user document which has the `lists` field. On the client it will be merged with the existing user document, so only the logged in user will have `lists`. If you want all users to have the field on the client then I'd recommend just adding it to the user profiles.
Caution: As this is written, if additional list items are appended they will not be published because the `lists` publish function will only be rerun when the user logs in. To make this work properly, you will need a [reactive join](https://stackoverflow.com/questions/20753279/publish-documents-in-a-collection-to-a-meteor-client-depending-on-the-existance/). | Meteor.users.find() returns a cursor of many items but you're trying to access `.lists` with
```
Meteor.users.find({_id: this.userId}, {limit: 1}).lists;
```
You need to use findOne instead.
```
Meteor.users.findOne({_id: this.userId}).lists;
```
Additionally you're running `.fetch()` on an array which is stored in the user collection. If this is an array of .\_id fields you don't need fetch.
You can't also do `.lists` in your second publish because its a cursor you have to check lists client side so just use Meteor.users.find(..) on its own since you can only publish cursors. |
20,825,758 | I'm having the following data structure in my Meteor project:
- Users with a set of list-ids that belong to the user (author)
- Lists that actually contain all the data of the list
Now I'm trying to publish all Lists of a user to the client. Here is a simple example:
```js
if (Meteor.isClient) {
Lists = new Meteor.Collection("lists");
Deps.autorun(function() {
Meteor.subscribe("lists");
});
Template.hello.greeting = function () {
return "Test";
};
Template.hello.events({
'click input' : function () {
if (typeof console !== 'undefined')
console.log(Lists.find());
}
});
}
if (Meteor.isServer) {
Lists = new Meteor.Collection("lists");
Meteor.startup(function () {
if ( Meteor.users.find().count() === 0 ) {
Accounts.createUser({ //create new user
username: 'test',
email: 'test@test.com',
password: 'test'
});
//add list to Lists and id of the list to user
var user = Meteor.users.findOne({'emails.address' : 'test@test.com', username : 'test'});
var listid = new Meteor.Collection.ObjectID().valueOf();
Meteor.users.update(user._id, {$addToSet : {lists : listid}});
Lists.insert({_id : listid, data : 'content'});
}
});
Meteor.publish("lists", function(){
var UserListIdsCursor = Meteor.users.find({_id: this.userId}, {limit: 1}).lists;
if(UserListIdsCursor!=undefined){
var UserListIds = UserListIdsCursor.fetch();
return Lists.find({_id : { $in : UserListIds}});
}
});
Meteor.publish("mylists", function(){
return Meteor.users.find({_id: this.userId}, {limit: 1}).lists;
});
//at the moment everything is allowed
Lists.allow({
insert : function(userID)
{
return true;
},
update : function(userID)
{
return true;
},
remove : function(userID)
{
return true;
}
});
}
```
But publishing the Lists doesn't work properly. Any ideas how to fix this? I'm also publishing "mylists" to guarantee that the user has access to the field "lists". | 2013/12/29 | [
"https://Stackoverflow.com/questions/20825758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3123726/"
] | The real problem here is the schema.
Don't store "this user owns these lists" eg, against the users collection. Store "this list is owned by this user"
By changing your example to include an `ownerId` field on each `List` then publishing becomes easy - and reactive.
It also removes the need for the `myLists` publication, as you can just query client side for your lists.
Edit: If your schema also includes a `userIds` field on each `List` then publishing is also trivial for non-owners.
Solution
--------
```
Lists = new Meteor.Collection('lists');
if (Meteor.isClient) {
Deps.autorun(function() {
if (Meteor.userId()) {
Meteor.subscribe('lists.owner');
Meteor.subscribe('lists.user');
}
});
}
if (Meteor.isServer) {
Lists._ensureIndex('userIds');
Lists._ensureIndex('ownerId');
Meteor.startup(function() {
if (Meteor.users.find().count() === 0) {
var user = {
username: 'test',
email: 'test@test.com',
password: 'test'
};
var userId = Accounts.createUser(user);
var listId = Lists.insert({data: 'content', ownerId: userId});
}
});
//XX- Oplog tailing in 0.7 doesn't support $ operators - split into two publications -
// or change the schema to include the ownerId in the userIds list
Meteor.publish('lists.user', function() {
check(this.userId, String);
return Lists.find({userIds: this.userId});
});
Meteor.publish('lists.owner', function() {
check(this.userId, String);
return Lists.find({ownerId: this.userId});
});
}
``` | Meteor.users.find() returns a cursor of many items but you're trying to access `.lists` with
```
Meteor.users.find({_id: this.userId}, {limit: 1}).lists;
```
You need to use findOne instead.
```
Meteor.users.findOne({_id: this.userId}).lists;
```
Additionally you're running `.fetch()` on an array which is stored in the user collection. If this is an array of .\_id fields you don't need fetch.
You can't also do `.lists` in your second publish because its a cursor you have to check lists client side so just use Meteor.users.find(..) on its own since you can only publish cursors. |
20,825,758 | I'm having the following data structure in my Meteor project:
- Users with a set of list-ids that belong to the user (author)
- Lists that actually contain all the data of the list
Now I'm trying to publish all Lists of a user to the client. Here is a simple example:
```js
if (Meteor.isClient) {
Lists = new Meteor.Collection("lists");
Deps.autorun(function() {
Meteor.subscribe("lists");
});
Template.hello.greeting = function () {
return "Test";
};
Template.hello.events({
'click input' : function () {
if (typeof console !== 'undefined')
console.log(Lists.find());
}
});
}
if (Meteor.isServer) {
Lists = new Meteor.Collection("lists");
Meteor.startup(function () {
if ( Meteor.users.find().count() === 0 ) {
Accounts.createUser({ //create new user
username: 'test',
email: 'test@test.com',
password: 'test'
});
//add list to Lists and id of the list to user
var user = Meteor.users.findOne({'emails.address' : 'test@test.com', username : 'test'});
var listid = new Meteor.Collection.ObjectID().valueOf();
Meteor.users.update(user._id, {$addToSet : {lists : listid}});
Lists.insert({_id : listid, data : 'content'});
}
});
Meteor.publish("lists", function(){
var UserListIdsCursor = Meteor.users.find({_id: this.userId}, {limit: 1}).lists;
if(UserListIdsCursor!=undefined){
var UserListIds = UserListIdsCursor.fetch();
return Lists.find({_id : { $in : UserListIds}});
}
});
Meteor.publish("mylists", function(){
return Meteor.users.find({_id: this.userId}, {limit: 1}).lists;
});
//at the moment everything is allowed
Lists.allow({
insert : function(userID)
{
return true;
},
update : function(userID)
{
return true;
},
remove : function(userID)
{
return true;
}
});
}
```
But publishing the Lists doesn't work properly. Any ideas how to fix this? I'm also publishing "mylists" to guarantee that the user has access to the field "lists". | 2013/12/29 | [
"https://Stackoverflow.com/questions/20825758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3123726/"
] | Solution
--------
```
Lists = new Meteor.Collection('lists');
if (Meteor.isClient) {
Tracker.autorun(function() {
if (Meteor.userId()) {
Meteor.subscribe('lists');
Meteor.subscribe('myLists');
}
});
}
if (Meteor.isServer) {
Meteor.startup(function() {
if (Meteor.users.find().count() === 0) {
var user = {
username: 'test',
email: 'test@test.com',
password: 'test'
};
var userId = Accounts.createUser(user);
var listId = Lists.insert({data: 'content'});
Meteor.users.update(userId, {
$addToSet: {lists: listId}
});
}
});
Meteor.publish('lists', function() {
check(this.userId, String);
var lists = Meteor.users.findOne(this.userId).lists;
return Lists.find({_id: {$in: lists}});
});
Meteor.publish('myLists', function() {
check(this.userId, String);
return Meteor.users.find(this.userId, {fields: {lists: 1}});
});
}
```
Changes
-------
1. Declare the `Lists` collection outside of the client and server (no need to declare it twice).
2. Ensure the user is logged in when subscribing. (performance enhancement).
3. When inserting the test user, use the fact that all insert functions return an id (reduces code).
4. Ensure the user is logged in when publishing.
5. Simplified `lists` publish function.
6. Fixed `myLists` publish function. A publish needs to return a cursor, an array of cursors, or a falsy value. You can't return an array of ids (which this code doesn't access anyway because you need to do a `fetch` or a `findOne`). Important note - this publishes another user document which has the `lists` field. On the client it will be merged with the existing user document, so only the logged in user will have `lists`. If you want all users to have the field on the client then I'd recommend just adding it to the user profiles.
Caution: As this is written, if additional list items are appended they will not be published because the `lists` publish function will only be rerun when the user logs in. To make this work properly, you will need a [reactive join](https://stackoverflow.com/questions/20753279/publish-documents-in-a-collection-to-a-meteor-client-depending-on-the-existance/). | The real problem here is the schema.
Don't store "this user owns these lists" eg, against the users collection. Store "this list is owned by this user"
By changing your example to include an `ownerId` field on each `List` then publishing becomes easy - and reactive.
It also removes the need for the `myLists` publication, as you can just query client side for your lists.
Edit: If your schema also includes a `userIds` field on each `List` then publishing is also trivial for non-owners.
Solution
--------
```
Lists = new Meteor.Collection('lists');
if (Meteor.isClient) {
Deps.autorun(function() {
if (Meteor.userId()) {
Meteor.subscribe('lists.owner');
Meteor.subscribe('lists.user');
}
});
}
if (Meteor.isServer) {
Lists._ensureIndex('userIds');
Lists._ensureIndex('ownerId');
Meteor.startup(function() {
if (Meteor.users.find().count() === 0) {
var user = {
username: 'test',
email: 'test@test.com',
password: 'test'
};
var userId = Accounts.createUser(user);
var listId = Lists.insert({data: 'content', ownerId: userId});
}
});
//XX- Oplog tailing in 0.7 doesn't support $ operators - split into two publications -
// or change the schema to include the ownerId in the userIds list
Meteor.publish('lists.user', function() {
check(this.userId, String);
return Lists.find({userIds: this.userId});
});
Meteor.publish('lists.owner', function() {
check(this.userId, String);
return Lists.find({ownerId: this.userId});
});
}
``` |
50,041,391 | **Use case:** I want to have two collections which have same fields. One collection will have recent data (say 15 days)and other have old data(say last 6 months).
I want to achieve this with a single POJO as it will be easier to do query based on date and then convert it to VOs.
**Bottom line: I want to create 2 collections from 1 POJO.**
Please suggest. | 2018/04/26 | [
"https://Stackoverflow.com/questions/50041391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1971954/"
] | I had the same problem. I don't think it is easily doable because the collection name is set in the `@Document` annotation which sits on your POJO. It is possible to change it dynamically by using SpEL expressions (see e.g. [How To Configure MongoDb Collection Name For a Class in Spring Data](https://stackoverflow.com/questions/12274019/how-to-configure-mongodb-collection-name-for-a-class-in-spring-data)) and there are some examples where this can be used for [multi-tenancy](https://github.com/spring-projects/spring-data-mongodb/issues/1456) or [multiple principles](https://github.com/spring-projects/spring-data-mongodb/issues/2776) but I don't see how to use this at compile time to create two different beans from the same class. To my knowledge that is not possible.
I can offer possible solutions but both are ugly af.
1. This is the workaround I actually used. Create child classes for the document and put the acutal logic into the parent
**Parent class**
```
@Getter
@FieldDefaults(makeFinal=true, level= AccessLevel.PRIVATE)
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@ToString
@EqualsAndHashCode
public class CommonParent {
@Id
@Delegate
HourlySiteWaiterRevenue.Key key;
long count;
@Field(targetType = FieldType.DECIMAL128)
BigDecimal sum;
@CompoundIndex
@Value
public static class Key implements Serializable {
@NonNull UUID entityId;
@NonNull Instant timestamp;
}
}
```
**Actual model for repository**
```
@Document
public class UseThisForRepository extends CommonParent{
public UseThisForRepository(@NonNull @JsonProperty("key") CommonParent.Key key,
@NonNull @JsonProperty("count") long count,
@NonNull @JsonProperty("sum") BigDecimal sum,) {
super(key, count, sum);
}
}
```
The model for the repository exclusively consists of boilerplate code that must be copypasted multiple times just so you can have multiple `@Document` annotations. This will by default use the child class name as collection name but is configurable everywhere.
2. `mongoTemplate` in principle has overloads with the collection name. It is possible to configure the collection name in the `mongoTemplate` (see e.g. <https://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#mongo-template>). It should be possible to have different collection names and use those. However, I can't think of a way how to use this name in the classes Spring autogenerates from the `@Repository` interface. You could overwrite every single repository method in a `RepositoryCustom` implementation but then you could just not use `@Repository` at all. | 1. Considering you have similar POJO
```
@Document(collection = "domain")
public class Domain {
@Id
private long id;
@Indexed(unique = true)
private String name;
private Date createdDate;
//getters and setters
}
```
2. You can write `QueryMethods` in `Repo` to extract conditional data from a POJO
```
public interface DomainRepository extends MongoRepository<Domain, Long> {
Domain findFirstByName(String domain);
List<Domain> findByCreatedDateBetween(Date thresholdDate1, Date thresholdDate2);
}
```
3. Call `QueryMethods` in your controller/methods to get the desired
collections
```
@Autowired
DomainRepository domainRepo;
List<Domain> 15daysOld = domainRepo.findByCreatedDateBetween(15daysOldDate, currentDate);
List<Domain> 6monthsOld = domainRepo.findByCreatedDateBetween(6monthsOldDate, currentDate);
``` |
189,767 | I installed 12.04 xubuntu and latest eclipse. Java is also installed. path is set correctly. but there are two things strange to me.
1. when I double click the eclipse executable, it says cannot find java;
2. create a launcher on the desktop, it says the same thing as above;\*\*
open a terminal, type `eclipse`, it will start eclipse without any error. type `java` in terminal also shows java is installed and available to the system. | 2012/09/17 | [
"https://askubuntu.com/questions/189767",
"https://askubuntu.com",
"https://askubuntu.com/users/91088/"
] | I suspect you need to use update-alternatives to get the links to default locations in order. Your edits to .bashrc aren't applied unless you run in a terminal.
Alternately, you could make a bash script to run your bashrc and then eclipse and use that as your launcher target. | Maybe this question is duplicated and the following link can help:
[How to pin Eclipse to the Unity launcher?](https://askubuntu.com/questions/80013/how-to-pin-eclipse-to-the-unity-launcher) |
226,599 | So I have xml that looks like this:
```html
<todo-list>
<id type="integer">#{id}</id>
<name>#{name}</name>
<description>#{description}</description>
<project-id type="integer">#{project_id}</project-id>
<milestone-id type="integer">#{milestone_id}</milestone-id>
<position type="integer">#{position}</position>
<!-- if user can see private lists -->
<private type="boolean">#{private}</private>
<!-- if the account supports time tracking -->
<tracked type="boolean">#{tracked}</tracked>
<!-- if todo-items are included in the response -->
<todo-items type="array">
<todo-item>
...
</todo-item>
<todo-item>
...
</todo-item>
...
</todo-items>
</todo-list>
```
How would I go about using .NET's serialization library to deserialize this into C# objects?
Currently I'm using reflection and I map between the xml and my objects using the naming conventions. | 2008/10/22 | [
"https://Stackoverflow.com/questions/226599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9401/"
] | Checkout <http://xsd2code.codeplex.com/>
Xsd2Code is a CSharp or Visual Basic Business Entity class Generator from XSD schema. | i had the same questions few years back that how abt mapping xml to C# classes or creating C# classes which are mapped to our XMLs, jst like we do in entity Framework (we map tables to C# classes). I created a framework finally, which can create C# classes out of your XML and these classes can be used to read/write your xml. Have a [look](http://www.stepupframeworks.com/Home/products/xml-object-mapping-xom/) |
226,599 | So I have xml that looks like this:
```html
<todo-list>
<id type="integer">#{id}</id>
<name>#{name}</name>
<description>#{description}</description>
<project-id type="integer">#{project_id}</project-id>
<milestone-id type="integer">#{milestone_id}</milestone-id>
<position type="integer">#{position}</position>
<!-- if user can see private lists -->
<private type="boolean">#{private}</private>
<!-- if the account supports time tracking -->
<tracked type="boolean">#{tracked}</tracked>
<!-- if todo-items are included in the response -->
<todo-items type="array">
<todo-item>
...
</todo-item>
<todo-item>
...
</todo-item>
...
</todo-items>
</todo-list>
```
How would I go about using .NET's serialization library to deserialize this into C# objects?
Currently I'm using reflection and I map between the xml and my objects using the naming conventions. | 2008/10/22 | [
"https://Stackoverflow.com/questions/226599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9401/"
] | Boils down to using xsd.exe from tools in VS:
```
xsd.exe "%xsdFile%" /c /out:"%outDirectory%" /l:"%language%"
```
Then load it with reader and deserializer:
```
public GeneratedClassFromXSD GetObjectFromXML()
{
var settings = new XmlReaderSettings();
var obj = new GeneratedClassFromXSD();
var reader = XmlReader.Create(urlToService, settings);
var serializer = new System.Xml.Serialization.XmlSerializer(typeof(GeneratedClassFromXSD));
obj = (GeneratedClassFromXSD)serializer.Deserialize(reader);
reader.Close();
return obj;
}
``` | Well, you'd have to have classes in your assembly that match, roughly, the XML (property called Private, a collection property called ToDo, etc).
The problem is that **the XML has elements that are invalid for class names**. So you'd have to implement IXmlSerializable in these classes to control how they are serialized to and from XML. You might be able to get away with using some of the xml serialization specific attributes as well, but that depends on your xml's schema.
That's a step above using reflection, but it might not be exactly what you're hoping for. |
226,599 | So I have xml that looks like this:
```html
<todo-list>
<id type="integer">#{id}</id>
<name>#{name}</name>
<description>#{description}</description>
<project-id type="integer">#{project_id}</project-id>
<milestone-id type="integer">#{milestone_id}</milestone-id>
<position type="integer">#{position}</position>
<!-- if user can see private lists -->
<private type="boolean">#{private}</private>
<!-- if the account supports time tracking -->
<tracked type="boolean">#{tracked}</tracked>
<!-- if todo-items are included in the response -->
<todo-items type="array">
<todo-item>
...
</todo-item>
<todo-item>
...
</todo-item>
...
</todo-items>
</todo-list>
```
How would I go about using .NET's serialization library to deserialize this into C# objects?
Currently I'm using reflection and I map between the xml and my objects using the naming conventions. | 2008/10/22 | [
"https://Stackoverflow.com/questions/226599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9401/"
] | Well, you'd have to have classes in your assembly that match, roughly, the XML (property called Private, a collection property called ToDo, etc).
The problem is that **the XML has elements that are invalid for class names**. So you'd have to implement IXmlSerializable in these classes to control how they are serialized to and from XML. You might be able to get away with using some of the xml serialization specific attributes as well, but that depends on your xml's schema.
That's a step above using reflection, but it might not be exactly what you're hoping for. | i had the same questions few years back that how abt mapping xml to C# classes or creating C# classes which are mapped to our XMLs, jst like we do in entity Framework (we map tables to C# classes). I created a framework finally, which can create C# classes out of your XML and these classes can be used to read/write your xml. Have a [look](http://www.stepupframeworks.com/Home/products/xml-object-mapping-xom/) |
226,599 | So I have xml that looks like this:
```html
<todo-list>
<id type="integer">#{id}</id>
<name>#{name}</name>
<description>#{description}</description>
<project-id type="integer">#{project_id}</project-id>
<milestone-id type="integer">#{milestone_id}</milestone-id>
<position type="integer">#{position}</position>
<!-- if user can see private lists -->
<private type="boolean">#{private}</private>
<!-- if the account supports time tracking -->
<tracked type="boolean">#{tracked}</tracked>
<!-- if todo-items are included in the response -->
<todo-items type="array">
<todo-item>
...
</todo-item>
<todo-item>
...
</todo-item>
...
</todo-items>
</todo-list>
```
How would I go about using .NET's serialization library to deserialize this into C# objects?
Currently I'm using reflection and I map between the xml and my objects using the naming conventions. | 2008/10/22 | [
"https://Stackoverflow.com/questions/226599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9401/"
] | Deserialize any object, as long as the type `T` is marked Serializable:
```
function T Deserialize<T>(string serializedResults)
{
var serializer = new XmlSerializer(typeof(T));
using (var stringReader = new StringReader(serializedResults))
return (T)serializer.Deserialize(stringReader);
}
``` | There are a couple different options.
* Visual Studio includes a command line program called xsd.exe. You use that program to create a schema document, and use the program again on the schema document to creates classes you can use with `system.xml.serialization.xmlserializer`
* You might just be able to call Dataset.ReadXml() on it. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.