qid
int64 1
74.7M
| question
stringlengths 0
58.3k
| date
stringlengths 10
10
| metadata
list | response_j
stringlengths 2
48.3k
| response_k
stringlengths 2
40.5k
|
---|---|---|---|---|---|
21,211 |
I have developed a method to process images I use for my research. It's nothing revolutionary but I think it might be useful to others than me, and why not, be worthy of being published somewhere (at least for me to cite when I use it).
As it is outside my primary field of research, nobody in my direct lab vicinity can help evaluating its scientific value or novelty (I did a bit of literature research and didn't find any obvious precedent). Normally I would just put it as an appendix in the first article where I use it, but this one is quite long to describe and completely out of my field. It would thus be off-topic in the journals in which I usually publish.
I though of seeking collaboration from someone in my university who works in signal/image processing, I don't know anyone personally and I foresee possible political issues, authorship quarrels, etc. I would nonetheless like to get some sort of evaluation before submitting to a journal. As an outsider, I wouldn't like to waste an editor's time and make a fool of myself.
I have zero experience submitting to the arXiv, by looking at the website it's not clear how/if there is an active system of feedback, even informal.
**Is it advisable to submit my methods paper there and expect a feedback?**
|
2014/05/20
|
[
"https://academia.stackexchange.com/questions/21211",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/10643/"
] |
There is not much of a "formal feedback" system associated with the arxiv. I say "not much" instead of "none" because the arxiv apparently does do some degree of automatic tracking of citations to its papers. For instance [this arxiv submission](http://arxiv.org/abs/1208.0977) contains a link to a MO post in which my paper is (briefly) mentioned. I had not seen that post before, so that was somewhat interesting. However, I don't know how this system works and it seems to be much less systematic than, say, what google scholar does. In particular, I have 25 arxiv preprints and the arxiv itself lists this kind of citation for very few of them, whereas google scholar lists much more.
In terms of an informal feedback system: yes, the arxiv works very well for that, in the following organic way: for many academic fields and subfields it is by far the one place to put your preprint in order to get the most (and the most interested) people to read it. This includes publication in most journals and the implications this has had on some academic fields are immense. E.g. I hear that in theoretical physics -- a fast-moving field in which it is apparently rare to look up a paper written much more than ten years ago -- pretty much everyone who is anyone uploads their preprints to the arxiv, and as a result theoretical physicists almost never go to the library anymore or look through actual journal papers: they don't need to. My field -- mathematics -- seems to be converging to this kind of phenomenon rather more slowly.
On the other hand, to **expect feedback** may be putting it a bit strongly. The volume of papers uploaded to the arxiv is fast and rapidly increasing. I just looked at the math.NT arxiv submissions, and last night 15 papers were uploaded. I am a number theorist with broad interests, and if these papers came at a rate of one a day or less, I would probably peruse about half of them. But the current volume forces me to be much more selective. The arxiv is great advertising, but all the advertising in the world doesn't guarantee that people will engage with your product rather than the sea of competing products (competing *for their attention*, anyway; they need not be competing with you in the academic sense).
In my experience, I most definitely get enough feedback from my arxiv submissions in order to justify uploading them (although there are arguments to be made for doing so even if you never hear directly from anyone about them). It happens that in the last three weeks or so I have uploaded four arxiv submissions. (Since I have 25 altogether, this is obviously a spike in the upload rate. Some other people do this too. Now that I think about it, from an advertising perspective it would probably be better *not* to do this.) Since then I have received comments on two of the four papers. The two papers that I haven't heard from yet are I think perfectly solid and interesting -- in fact, one of the two concerns the Combinatorial Nullstellensatz so probably has broader appeal than most papers I have written, and the other is a really substantial project that I did jointly with my PhD student -- so the fact that I've gotten no feedback about them seems to be mostly random.
In summary: yes, posting your papers on the arxiv is a great way to get feedback. Will it *guarantee* feedback? No, guaranteed feedback is exactly what you're buying (so to speak) when you submit to a journal. Other than that it seems impossible to guarantee. I would definitely submit to the arxiv and see what happens. If you hear nothing, then you might try sending a few emails to suspected experts which just point to your arxiv preprint. Having an arxiv preprint versus just enclosing a file adds a certain veneer of legitimacy.
|
Other questions are more on topic, but let me add that social media and open access, used wisely, are good tools for increase your audience and get more downloads, and (hopefully) more feedback.
Think about:
* creating a blog, maybe dedicated to your research
* upload your papers in arxiv: this will give us a timestamp, a permalink, and will preserve your paper digitally
* use social media to spread the links
* Use the blog (or the arXiv itself) as a place to discuss your research (maybe, in more laymen terms), receive comments and discuss with interested people.
Social media (used wisely) [do have an impact](http://blogs.lse.ac.uk/impactofsocialsciences/2012/04/19/blog-tweeting-papers-worth-it/), and also [Altmetrics](http://altmetrics.org/manifesto/) are developing. Also, please read [this question](https://academia.stackexchange.com/questions/32367/why-doesnt-arxiv-have-a-comment-section) and related answers.
|
21,211 |
I have developed a method to process images I use for my research. It's nothing revolutionary but I think it might be useful to others than me, and why not, be worthy of being published somewhere (at least for me to cite when I use it).
As it is outside my primary field of research, nobody in my direct lab vicinity can help evaluating its scientific value or novelty (I did a bit of literature research and didn't find any obvious precedent). Normally I would just put it as an appendix in the first article where I use it, but this one is quite long to describe and completely out of my field. It would thus be off-topic in the journals in which I usually publish.
I though of seeking collaboration from someone in my university who works in signal/image processing, I don't know anyone personally and I foresee possible political issues, authorship quarrels, etc. I would nonetheless like to get some sort of evaluation before submitting to a journal. As an outsider, I wouldn't like to waste an editor's time and make a fool of myself.
I have zero experience submitting to the arXiv, by looking at the website it's not clear how/if there is an active system of feedback, even informal.
**Is it advisable to submit my methods paper there and expect a feedback?**
|
2014/05/20
|
[
"https://academia.stackexchange.com/questions/21211",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/10643/"
] |
There is not much of a "formal feedback" system associated with the arxiv. I say "not much" instead of "none" because the arxiv apparently does do some degree of automatic tracking of citations to its papers. For instance [this arxiv submission](http://arxiv.org/abs/1208.0977) contains a link to a MO post in which my paper is (briefly) mentioned. I had not seen that post before, so that was somewhat interesting. However, I don't know how this system works and it seems to be much less systematic than, say, what google scholar does. In particular, I have 25 arxiv preprints and the arxiv itself lists this kind of citation for very few of them, whereas google scholar lists much more.
In terms of an informal feedback system: yes, the arxiv works very well for that, in the following organic way: for many academic fields and subfields it is by far the one place to put your preprint in order to get the most (and the most interested) people to read it. This includes publication in most journals and the implications this has had on some academic fields are immense. E.g. I hear that in theoretical physics -- a fast-moving field in which it is apparently rare to look up a paper written much more than ten years ago -- pretty much everyone who is anyone uploads their preprints to the arxiv, and as a result theoretical physicists almost never go to the library anymore or look through actual journal papers: they don't need to. My field -- mathematics -- seems to be converging to this kind of phenomenon rather more slowly.
On the other hand, to **expect feedback** may be putting it a bit strongly. The volume of papers uploaded to the arxiv is fast and rapidly increasing. I just looked at the math.NT arxiv submissions, and last night 15 papers were uploaded. I am a number theorist with broad interests, and if these papers came at a rate of one a day or less, I would probably peruse about half of them. But the current volume forces me to be much more selective. The arxiv is great advertising, but all the advertising in the world doesn't guarantee that people will engage with your product rather than the sea of competing products (competing *for their attention*, anyway; they need not be competing with you in the academic sense).
In my experience, I most definitely get enough feedback from my arxiv submissions in order to justify uploading them (although there are arguments to be made for doing so even if you never hear directly from anyone about them). It happens that in the last three weeks or so I have uploaded four arxiv submissions. (Since I have 25 altogether, this is obviously a spike in the upload rate. Some other people do this too. Now that I think about it, from an advertising perspective it would probably be better *not* to do this.) Since then I have received comments on two of the four papers. The two papers that I haven't heard from yet are I think perfectly solid and interesting -- in fact, one of the two concerns the Combinatorial Nullstellensatz so probably has broader appeal than most papers I have written, and the other is a really substantial project that I did jointly with my PhD student -- so the fact that I've gotten no feedback about them seems to be mostly random.
In summary: yes, posting your papers on the arxiv is a great way to get feedback. Will it *guarantee* feedback? No, guaranteed feedback is exactly what you're buying (so to speak) when you submit to a journal. Other than that it seems impossible to guarantee. I would definitely submit to the arxiv and see what happens. If you hear nothing, then you might try sending a few emails to suspected experts which just point to your arxiv preprint. Having an arxiv preprint versus just enclosing a file adds a certain veneer of legitimacy.
|
There are some more direct ways that are more effective than waiting for a passenger feedback and they help you gain more confidence in general in the outside field.
1. find the journals in the field of this paper, contact one of their editors
in chief with the same question and disclaimer you have here to seek their
opinion about submitting or otherwise. You get the best feedback from the journal reviewers. They know most people, they are quick in reading and they love reviewing a wide range of work rather than a single topic. generally more open-minded than an average researcher.
2. Look at review board members of those journals who are in
your university and contact them, you can pick up the phone and ask them for this quick favor to direct you to the right direction(area of literature) to look for precedence of the work. Talking over the phone brings them less liability and they can be more frank, open and less political about the work. It also takes less time than drafting a careful email to a stranger.
3. Look up the name of professors who teach this topic in your school or any school nearby and send them the paper for opinion, you can even use their office hours to sit and discuss the relevancy of this "outside" work. Office hours are boring and wasted anyway, it will be a refreshing task if it is not close to exam time(busy time).
4. You can also ask it as a favor (or even paid consulting) from a PhD students of these journal editors/reviewers. PhD students in their later years can be of huge help as they know a lot and they are less committed to non-scientific duties than their professors.
|
21,211 |
I have developed a method to process images I use for my research. It's nothing revolutionary but I think it might be useful to others than me, and why not, be worthy of being published somewhere (at least for me to cite when I use it).
As it is outside my primary field of research, nobody in my direct lab vicinity can help evaluating its scientific value or novelty (I did a bit of literature research and didn't find any obvious precedent). Normally I would just put it as an appendix in the first article where I use it, but this one is quite long to describe and completely out of my field. It would thus be off-topic in the journals in which I usually publish.
I though of seeking collaboration from someone in my university who works in signal/image processing, I don't know anyone personally and I foresee possible political issues, authorship quarrels, etc. I would nonetheless like to get some sort of evaluation before submitting to a journal. As an outsider, I wouldn't like to waste an editor's time and make a fool of myself.
I have zero experience submitting to the arXiv, by looking at the website it's not clear how/if there is an active system of feedback, even informal.
**Is it advisable to submit my methods paper there and expect a feedback?**
|
2014/05/20
|
[
"https://academia.stackexchange.com/questions/21211",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/10643/"
] |
You need to find a way to advertise your work so that people find it on arXiv, use it, then eventually cite it and criticize it.
The main advantages of arXiv are:
* the publication timing. When you submit to some closed review journal or conference, you are months before an official decision. During this time (that can get long), you need a way to disclose properly your work;
* getting a larger audience. Everybody is not on her university's network, or some universities won't have access to all the journals. If your work is on the editor's site only, then more people than you might think will be blocked by the paywall. Furthermore, some people (I know some in Image Processing) will make monthly explorations of arXiv and publish some reading lists on-line, tghus giving you a larger audience.
|
Other questions are more on topic, but let me add that social media and open access, used wisely, are good tools for increase your audience and get more downloads, and (hopefully) more feedback.
Think about:
* creating a blog, maybe dedicated to your research
* upload your papers in arxiv: this will give us a timestamp, a permalink, and will preserve your paper digitally
* use social media to spread the links
* Use the blog (or the arXiv itself) as a place to discuss your research (maybe, in more laymen terms), receive comments and discuss with interested people.
Social media (used wisely) [do have an impact](http://blogs.lse.ac.uk/impactofsocialsciences/2012/04/19/blog-tweeting-papers-worth-it/), and also [Altmetrics](http://altmetrics.org/manifesto/) are developing. Also, please read [this question](https://academia.stackexchange.com/questions/32367/why-doesnt-arxiv-have-a-comment-section) and related answers.
|
21,211 |
I have developed a method to process images I use for my research. It's nothing revolutionary but I think it might be useful to others than me, and why not, be worthy of being published somewhere (at least for me to cite when I use it).
As it is outside my primary field of research, nobody in my direct lab vicinity can help evaluating its scientific value or novelty (I did a bit of literature research and didn't find any obvious precedent). Normally I would just put it as an appendix in the first article where I use it, but this one is quite long to describe and completely out of my field. It would thus be off-topic in the journals in which I usually publish.
I though of seeking collaboration from someone in my university who works in signal/image processing, I don't know anyone personally and I foresee possible political issues, authorship quarrels, etc. I would nonetheless like to get some sort of evaluation before submitting to a journal. As an outsider, I wouldn't like to waste an editor's time and make a fool of myself.
I have zero experience submitting to the arXiv, by looking at the website it's not clear how/if there is an active system of feedback, even informal.
**Is it advisable to submit my methods paper there and expect a feedback?**
|
2014/05/20
|
[
"https://academia.stackexchange.com/questions/21211",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/10643/"
] |
You need to find a way to advertise your work so that people find it on arXiv, use it, then eventually cite it and criticize it.
The main advantages of arXiv are:
* the publication timing. When you submit to some closed review journal or conference, you are months before an official decision. During this time (that can get long), you need a way to disclose properly your work;
* getting a larger audience. Everybody is not on her university's network, or some universities won't have access to all the journals. If your work is on the editor's site only, then more people than you might think will be blocked by the paywall. Furthermore, some people (I know some in Image Processing) will make monthly explorations of arXiv and publish some reading lists on-line, tghus giving you a larger audience.
|
There are some more direct ways that are more effective than waiting for a passenger feedback and they help you gain more confidence in general in the outside field.
1. find the journals in the field of this paper, contact one of their editors
in chief with the same question and disclaimer you have here to seek their
opinion about submitting or otherwise. You get the best feedback from the journal reviewers. They know most people, they are quick in reading and they love reviewing a wide range of work rather than a single topic. generally more open-minded than an average researcher.
2. Look at review board members of those journals who are in
your university and contact them, you can pick up the phone and ask them for this quick favor to direct you to the right direction(area of literature) to look for precedence of the work. Talking over the phone brings them less liability and they can be more frank, open and less political about the work. It also takes less time than drafting a careful email to a stranger.
3. Look up the name of professors who teach this topic in your school or any school nearby and send them the paper for opinion, you can even use their office hours to sit and discuss the relevancy of this "outside" work. Office hours are boring and wasted anyway, it will be a refreshing task if it is not close to exam time(busy time).
4. You can also ask it as a favor (or even paid consulting) from a PhD students of these journal editors/reviewers. PhD students in their later years can be of huge help as they know a lot and they are less committed to non-scientific duties than their professors.
|
21,211 |
I have developed a method to process images I use for my research. It's nothing revolutionary but I think it might be useful to others than me, and why not, be worthy of being published somewhere (at least for me to cite when I use it).
As it is outside my primary field of research, nobody in my direct lab vicinity can help evaluating its scientific value or novelty (I did a bit of literature research and didn't find any obvious precedent). Normally I would just put it as an appendix in the first article where I use it, but this one is quite long to describe and completely out of my field. It would thus be off-topic in the journals in which I usually publish.
I though of seeking collaboration from someone in my university who works in signal/image processing, I don't know anyone personally and I foresee possible political issues, authorship quarrels, etc. I would nonetheless like to get some sort of evaluation before submitting to a journal. As an outsider, I wouldn't like to waste an editor's time and make a fool of myself.
I have zero experience submitting to the arXiv, by looking at the website it's not clear how/if there is an active system of feedback, even informal.
**Is it advisable to submit my methods paper there and expect a feedback?**
|
2014/05/20
|
[
"https://academia.stackexchange.com/questions/21211",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/10643/"
] |
The arXiv is a tool for establishing a presence, but it does not market or disseminate your results. It merely places them in a certain category and presents title, author, and sometimes abstract in a summary fashion, depending on how one uses it. Some researchers get RSS and email updates in their favorite areas about new arXiv submissions, but that should be considered small in number, and not likely to generate interest in your paper.
If you want feedback, you need to advertise your own work, on your webpage, at conferences, at society meetings, and other appropriate venues. You can prepare a short version (abstract or highlight only) and include the URL of the arXiv abstract. Use of arXiv does not indicate peer review, but as there is some endorsement system involved in arXiv submissions, there is also some cachet associated with having the URL.
When you have gotten some people interested in your work, they too can refer to the URL, and this can lead to more publicizing and hopefully direct feedback on your work. It can also lead to others posting their opinions on their blogs or elsewhere, which can be harder to track.
|
Other questions are more on topic, but let me add that social media and open access, used wisely, are good tools for increase your audience and get more downloads, and (hopefully) more feedback.
Think about:
* creating a blog, maybe dedicated to your research
* upload your papers in arxiv: this will give us a timestamp, a permalink, and will preserve your paper digitally
* use social media to spread the links
* Use the blog (or the arXiv itself) as a place to discuss your research (maybe, in more laymen terms), receive comments and discuss with interested people.
Social media (used wisely) [do have an impact](http://blogs.lse.ac.uk/impactofsocialsciences/2012/04/19/blog-tweeting-papers-worth-it/), and also [Altmetrics](http://altmetrics.org/manifesto/) are developing. Also, please read [this question](https://academia.stackexchange.com/questions/32367/why-doesnt-arxiv-have-a-comment-section) and related answers.
|
21,211 |
I have developed a method to process images I use for my research. It's nothing revolutionary but I think it might be useful to others than me, and why not, be worthy of being published somewhere (at least for me to cite when I use it).
As it is outside my primary field of research, nobody in my direct lab vicinity can help evaluating its scientific value or novelty (I did a bit of literature research and didn't find any obvious precedent). Normally I would just put it as an appendix in the first article where I use it, but this one is quite long to describe and completely out of my field. It would thus be off-topic in the journals in which I usually publish.
I though of seeking collaboration from someone in my university who works in signal/image processing, I don't know anyone personally and I foresee possible political issues, authorship quarrels, etc. I would nonetheless like to get some sort of evaluation before submitting to a journal. As an outsider, I wouldn't like to waste an editor's time and make a fool of myself.
I have zero experience submitting to the arXiv, by looking at the website it's not clear how/if there is an active system of feedback, even informal.
**Is it advisable to submit my methods paper there and expect a feedback?**
|
2014/05/20
|
[
"https://academia.stackexchange.com/questions/21211",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/10643/"
] |
The arXiv is a tool for establishing a presence, but it does not market or disseminate your results. It merely places them in a certain category and presents title, author, and sometimes abstract in a summary fashion, depending on how one uses it. Some researchers get RSS and email updates in their favorite areas about new arXiv submissions, but that should be considered small in number, and not likely to generate interest in your paper.
If you want feedback, you need to advertise your own work, on your webpage, at conferences, at society meetings, and other appropriate venues. You can prepare a short version (abstract or highlight only) and include the URL of the arXiv abstract. Use of arXiv does not indicate peer review, but as there is some endorsement system involved in arXiv submissions, there is also some cachet associated with having the URL.
When you have gotten some people interested in your work, they too can refer to the URL, and this can lead to more publicizing and hopefully direct feedback on your work. It can also lead to others posting their opinions on their blogs or elsewhere, which can be harder to track.
|
There are some more direct ways that are more effective than waiting for a passenger feedback and they help you gain more confidence in general in the outside field.
1. find the journals in the field of this paper, contact one of their editors
in chief with the same question and disclaimer you have here to seek their
opinion about submitting or otherwise. You get the best feedback from the journal reviewers. They know most people, they are quick in reading and they love reviewing a wide range of work rather than a single topic. generally more open-minded than an average researcher.
2. Look at review board members of those journals who are in
your university and contact them, you can pick up the phone and ask them for this quick favor to direct you to the right direction(area of literature) to look for precedence of the work. Talking over the phone brings them less liability and they can be more frank, open and less political about the work. It also takes less time than drafting a careful email to a stranger.
3. Look up the name of professors who teach this topic in your school or any school nearby and send them the paper for opinion, you can even use their office hours to sit and discuss the relevancy of this "outside" work. Office hours are boring and wasted anyway, it will be a refreshing task if it is not close to exam time(busy time).
4. You can also ask it as a favor (or even paid consulting) from a PhD students of these journal editors/reviewers. PhD students in their later years can be of huge help as they know a lot and they are less committed to non-scientific duties than their professors.
|
21,211 |
I have developed a method to process images I use for my research. It's nothing revolutionary but I think it might be useful to others than me, and why not, be worthy of being published somewhere (at least for me to cite when I use it).
As it is outside my primary field of research, nobody in my direct lab vicinity can help evaluating its scientific value or novelty (I did a bit of literature research and didn't find any obvious precedent). Normally I would just put it as an appendix in the first article where I use it, but this one is quite long to describe and completely out of my field. It would thus be off-topic in the journals in which I usually publish.
I though of seeking collaboration from someone in my university who works in signal/image processing, I don't know anyone personally and I foresee possible political issues, authorship quarrels, etc. I would nonetheless like to get some sort of evaluation before submitting to a journal. As an outsider, I wouldn't like to waste an editor's time and make a fool of myself.
I have zero experience submitting to the arXiv, by looking at the website it's not clear how/if there is an active system of feedback, even informal.
**Is it advisable to submit my methods paper there and expect a feedback?**
|
2014/05/20
|
[
"https://academia.stackexchange.com/questions/21211",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/10643/"
] |
There are some more direct ways that are more effective than waiting for a passenger feedback and they help you gain more confidence in general in the outside field.
1. find the journals in the field of this paper, contact one of their editors
in chief with the same question and disclaimer you have here to seek their
opinion about submitting or otherwise. You get the best feedback from the journal reviewers. They know most people, they are quick in reading and they love reviewing a wide range of work rather than a single topic. generally more open-minded than an average researcher.
2. Look at review board members of those journals who are in
your university and contact them, you can pick up the phone and ask them for this quick favor to direct you to the right direction(area of literature) to look for precedence of the work. Talking over the phone brings them less liability and they can be more frank, open and less political about the work. It also takes less time than drafting a careful email to a stranger.
3. Look up the name of professors who teach this topic in your school or any school nearby and send them the paper for opinion, you can even use their office hours to sit and discuss the relevancy of this "outside" work. Office hours are boring and wasted anyway, it will be a refreshing task if it is not close to exam time(busy time).
4. You can also ask it as a favor (or even paid consulting) from a PhD students of these journal editors/reviewers. PhD students in their later years can be of huge help as they know a lot and they are less committed to non-scientific duties than their professors.
|
Other questions are more on topic, but let me add that social media and open access, used wisely, are good tools for increase your audience and get more downloads, and (hopefully) more feedback.
Think about:
* creating a blog, maybe dedicated to your research
* upload your papers in arxiv: this will give us a timestamp, a permalink, and will preserve your paper digitally
* use social media to spread the links
* Use the blog (or the arXiv itself) as a place to discuss your research (maybe, in more laymen terms), receive comments and discuss with interested people.
Social media (used wisely) [do have an impact](http://blogs.lse.ac.uk/impactofsocialsciences/2012/04/19/blog-tweeting-papers-worth-it/), and also [Altmetrics](http://altmetrics.org/manifesto/) are developing. Also, please read [this question](https://academia.stackexchange.com/questions/32367/why-doesnt-arxiv-have-a-comment-section) and related answers.
|
55,447,687 |
I recieved this error when I trying to debug a java program with vscode:
```
java.lang.UnsupportedClassVersionError:
test (class file version 52.65535) was compiled with preview features that are unsupported.
This version of the Java Runtime only recognizes preview features for class file version 55.65535
```
Here is launch.json:
```
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Launch) - Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "Debug (Launch)-test",
"request": "launch",
"mainClass": "test"
}
]
}
```
Here is the version of java:
```
java --version:
openjdk 11.0.2 2019-01-15
OpenJDK Runtime Environment (build 11.0.2+9-Ubuntu-3ubuntu118.04.2)
OpenJDK 64-Bit Server VM (build 11.0.2+9-Ubuntu-3ubuntu118.04.2, mixed mode, sharing)
javac --version:
javac 11.0.2
```
This program can run on ubuntu original terminal, but throws error in vscode.
it would be greatful if you can help me out.
|
2019/04/01
|
[
"https://Stackoverflow.com/questions/55447687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11287916/"
] |
In launch.json file, add "vmArgs": "--enable-preview" to your debug configuration.
```
{
...
"vmArgs": "--enable-preview"
}
```
|
Update: after intensive googling I think I found the answer:
**This is due to a mismatch with the code version that's compiling in vscode and the JDK version you're running in your system.**
1. In your VScode, your compiler is trying to compile using (class file version 52.65535), which is **Java 8**, meanwhile your system is running class file version 55.65535 which is **Java 11**. In this case, clean uninstall the Java 11 in your system first, follow the uninstall instructions here: <https://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html#A1096903>
2. After uninstallation, download and install the JDK 8 from oracle:
<https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html>
3. reopen your vscode project, do the following:
4. open your launch.json file, add this line in configuration:
"vmArgs": "--enable-preview"
5. inside your file your want to compile and run, press F1 in vscode and do the following:
* Java: Clean the java language server workspace
* Java: Force Java Compilation
6. Press F5 your code will compile and run!
Reference: <https://www.baeldung.com/java-lang-unsupportedclassversion>
|
55,447,687 |
I recieved this error when I trying to debug a java program with vscode:
```
java.lang.UnsupportedClassVersionError:
test (class file version 52.65535) was compiled with preview features that are unsupported.
This version of the Java Runtime only recognizes preview features for class file version 55.65535
```
Here is launch.json:
```
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Launch) - Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "Debug (Launch)-test",
"request": "launch",
"mainClass": "test"
}
]
}
```
Here is the version of java:
```
java --version:
openjdk 11.0.2 2019-01-15
OpenJDK Runtime Environment (build 11.0.2+9-Ubuntu-3ubuntu118.04.2)
OpenJDK 64-Bit Server VM (build 11.0.2+9-Ubuntu-3ubuntu118.04.2, mixed mode, sharing)
javac --version:
javac 11.0.2
```
This program can run on ubuntu original terminal, but throws error in vscode.
it would be greatful if you can help me out.
|
2019/04/01
|
[
"https://Stackoverflow.com/questions/55447687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11287916/"
] |
In launch.json file, add "vmArgs": "--enable-preview" to your debug configuration.
```
{
...
"vmArgs": "--enable-preview"
}
```
|
The same error on the Intellij idea maven build. correct the JRE version of Maven to the correct version of java.
[](https://i.stack.imgur.com/abR7Z.png)
|
55,447,687 |
I recieved this error when I trying to debug a java program with vscode:
```
java.lang.UnsupportedClassVersionError:
test (class file version 52.65535) was compiled with preview features that are unsupported.
This version of the Java Runtime only recognizes preview features for class file version 55.65535
```
Here is launch.json:
```
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Launch) - Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "Debug (Launch)-test",
"request": "launch",
"mainClass": "test"
}
]
}
```
Here is the version of java:
```
java --version:
openjdk 11.0.2 2019-01-15
OpenJDK Runtime Environment (build 11.0.2+9-Ubuntu-3ubuntu118.04.2)
OpenJDK 64-Bit Server VM (build 11.0.2+9-Ubuntu-3ubuntu118.04.2, mixed mode, sharing)
javac --version:
javac 11.0.2
```
This program can run on ubuntu original terminal, but throws error in vscode.
it would be greatful if you can help me out.
|
2019/04/01
|
[
"https://Stackoverflow.com/questions/55447687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11287916/"
] |
In launch.json file, add "vmArgs": "--enable-preview" to your debug configuration.
```
{
...
"vmArgs": "--enable-preview"
}
```
|
I solved this problem by compiling the class through the terminal itself with javac in the "src" folder and then replacing the ".class file" in the "bin" folder by the ".class file" created in the "src" folder. I believe the problem is in VSCODE, I did the same test in Eclipse and it worked without problems.
Another alternative:
in the configure Java Runtime option of VSCODE, you have the option to choose the Runtime version we can choose which java version we want to use, mine was 19, however, apparently it does not work well, so I changed it to version 17 and everything works perfectly. There is an option to download the latest version of the JDK and it is not in 19 only 17 as shown in this print from the website <https://code.visualstudio.com/assets/docs/java/java-project/download-jdk> .png that is exactly the same as what appears in the program. Until then it was the best alternative I found
|
55,447,687 |
I recieved this error when I trying to debug a java program with vscode:
```
java.lang.UnsupportedClassVersionError:
test (class file version 52.65535) was compiled with preview features that are unsupported.
This version of the Java Runtime only recognizes preview features for class file version 55.65535
```
Here is launch.json:
```
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Launch) - Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "Debug (Launch)-test",
"request": "launch",
"mainClass": "test"
}
]
}
```
Here is the version of java:
```
java --version:
openjdk 11.0.2 2019-01-15
OpenJDK Runtime Environment (build 11.0.2+9-Ubuntu-3ubuntu118.04.2)
OpenJDK 64-Bit Server VM (build 11.0.2+9-Ubuntu-3ubuntu118.04.2, mixed mode, sharing)
javac --version:
javac 11.0.2
```
This program can run on ubuntu original terminal, but throws error in vscode.
it would be greatful if you can help me out.
|
2019/04/01
|
[
"https://Stackoverflow.com/questions/55447687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11287916/"
] |
Update: after intensive googling I think I found the answer:
**This is due to a mismatch with the code version that's compiling in vscode and the JDK version you're running in your system.**
1. In your VScode, your compiler is trying to compile using (class file version 52.65535), which is **Java 8**, meanwhile your system is running class file version 55.65535 which is **Java 11**. In this case, clean uninstall the Java 11 in your system first, follow the uninstall instructions here: <https://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html#A1096903>
2. After uninstallation, download and install the JDK 8 from oracle:
<https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html>
3. reopen your vscode project, do the following:
4. open your launch.json file, add this line in configuration:
"vmArgs": "--enable-preview"
5. inside your file your want to compile and run, press F1 in vscode and do the following:
* Java: Clean the java language server workspace
* Java: Force Java Compilation
6. Press F5 your code will compile and run!
Reference: <https://www.baeldung.com/java-lang-unsupportedclassversion>
|
I solved this problem by compiling the class through the terminal itself with javac in the "src" folder and then replacing the ".class file" in the "bin" folder by the ".class file" created in the "src" folder. I believe the problem is in VSCODE, I did the same test in Eclipse and it worked without problems.
Another alternative:
in the configure Java Runtime option of VSCODE, you have the option to choose the Runtime version we can choose which java version we want to use, mine was 19, however, apparently it does not work well, so I changed it to version 17 and everything works perfectly. There is an option to download the latest version of the JDK and it is not in 19 only 17 as shown in this print from the website <https://code.visualstudio.com/assets/docs/java/java-project/download-jdk> .png that is exactly the same as what appears in the program. Until then it was the best alternative I found
|
55,447,687 |
I recieved this error when I trying to debug a java program with vscode:
```
java.lang.UnsupportedClassVersionError:
test (class file version 52.65535) was compiled with preview features that are unsupported.
This version of the Java Runtime only recognizes preview features for class file version 55.65535
```
Here is launch.json:
```
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Launch) - Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "Debug (Launch)-test",
"request": "launch",
"mainClass": "test"
}
]
}
```
Here is the version of java:
```
java --version:
openjdk 11.0.2 2019-01-15
OpenJDK Runtime Environment (build 11.0.2+9-Ubuntu-3ubuntu118.04.2)
OpenJDK 64-Bit Server VM (build 11.0.2+9-Ubuntu-3ubuntu118.04.2, mixed mode, sharing)
javac --version:
javac 11.0.2
```
This program can run on ubuntu original terminal, but throws error in vscode.
it would be greatful if you can help me out.
|
2019/04/01
|
[
"https://Stackoverflow.com/questions/55447687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11287916/"
] |
The same error on the Intellij idea maven build. correct the JRE version of Maven to the correct version of java.
[](https://i.stack.imgur.com/abR7Z.png)
|
I solved this problem by compiling the class through the terminal itself with javac in the "src" folder and then replacing the ".class file" in the "bin" folder by the ".class file" created in the "src" folder. I believe the problem is in VSCODE, I did the same test in Eclipse and it worked without problems.
Another alternative:
in the configure Java Runtime option of VSCODE, you have the option to choose the Runtime version we can choose which java version we want to use, mine was 19, however, apparently it does not work well, so I changed it to version 17 and everything works perfectly. There is an option to download the latest version of the JDK and it is not in 19 only 17 as shown in this print from the website <https://code.visualstudio.com/assets/docs/java/java-project/download-jdk> .png that is exactly the same as what appears in the program. Until then it was the best alternative I found
|
122,969 |
There are compound words in English like well-known, ill-mannered and so on. The rules tell us that they are spelled with a hyphen (well-known) if they are attributes (attributive adjectives), but without hyphen (well known) if they are predicates (predicative adjectives).
It's all right. But what if they are dictionary entries? I think these words may be present in dictionaries. Will they have a hyphen in this case?
|
2017/03/19
|
[
"https://ell.stackexchange.com/questions/122969",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/51028/"
] |
There're no hard and fast rules whether or not we should hyphenate a compound adjective like well-known/well known. But it's far more common to hyphenate such adjectives if they are used as attributive adjectives and not to hyphenate them when used as predicative adjectives.
The Free Dictionary states:
"Well-known can be spelled with or without a hyphen. You usually spell it with a hyphen in front of a noun and without a hyphen after a verb. For examples:
I took him to a well-known doctor in Harley Street.
The building became very well known."
|
The general rule is that multiword descriptions using adverbs should not be hyphenated. As 'well' is an adverb, it should never be hyphenated in multiword descriptions.
However, if you consider 'well-known' to be one word, then hyphenating it would be correct in either predicate or attributive position.
Considering dictionaries vary on what they consider to be hyphenated words containing 'well' and that hyphens in general are messy and a bit unnatural for some, I personally would recommend never using a hyphen. The grammar still follows general rules for adverbs, you don't have to worry about what a 'well' word is, and it's easier to read.
|
20,314,405 |
So I wrote a header that uses recursion to compute several mathematical functions. Including the cosine function and exponential function( e^x). Now the cosine functions works just fine but e^x produces a segmentation fault even though both use the same recursive procedure. So here is the code from the header file I created "c\_math.h":
```
#define PI 3.141592
static unsigned int n;
................
uint32_t Factorial(unsigned int p)
{
if(p==0){
return(1);
}else if(p>0){
return p*Factorial(p-1);
}
};
double EXP(double x)
{
int N = n;
double F = (double)Factorial(n);
if(n==0){
return (1.0);
}else{
return EXP(x)+(Pow(x,N)/F);
}
}
double cosine(double x)
{
int N = (2*n);
double F = (double)(Factorial(2*n)*(-1^n));
if(n==0){
return(1.0);
}else if(n==1){
return 1+(Pow(x,2)/2);
}else if(n>1){
return cosine(x)+(Pow(x,N)/F);
}
};
double cos(double x){
bool halt = false;
double COS;
n = 0;
while(halt==false){
int N = (2*n);
double F = (double)(Factorial(2*n)*(-1^n));
COS = cosine(x);
if(abs(Pow(x,N)/F)<=0.0001){
halt = true;
}else{
n++;
}
}
return COS;
}
double e(double x){
bool halt = false;
double E;
n = 0;
while(halt==false){
int N = n;
double F = (double)(Factorial(n));
E = EXP(x);
if(abs(Pow(x,N)/F)<=0.0001){
halt = true;
}else{
n++;
}
}
return E;
}
```
The .c file with the main function:
```
include <stdio.h>
#include <cmath.h>
int main()
{
printf("\n");
printf("cos(2.2) = %4.6f\n",cos(2.2));
printf("\n");
printf("e(2.2) = %4.6f\n",e(2.2));
printf("\n");
}
```
After I compile it and then execute from the terminal prompt, the output looks like this:
```
zermacr0yd@DALEK /usr/lib/gcc/x86_64-linux-gnu/4.7.3/include $ ./mathtest
cos(2.2) = -0.588501
Segmentation fault
```
So as you can see the Cosine function works as it should but e^x produces a segmentation fault. Now the function e^x is strictly increasing for x > 0 and strictly decreasing for x < 0, but mathematically the power series should converge for all values of x which means that eventually when the series index n becomes high enough, the value of the nth term should fall below 0.0001. So what is going on here?
|
2013/12/01
|
[
"https://Stackoverflow.com/questions/20314405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1964457/"
] |
All your functions are using a variable `n` which I'm assuming is declared globally but only defined locally in `e`. You should provide a local definition of `n` for each function: `int n = 0;`.
|
```
double EXP(double x) {
/* other code that doesn't change x */
if(n==0) {
return 1.0;
} else {
return EXP(x) + /* other code */;
}
}
```
Let's say we want to calculate EXP(2).
EXP starts running, gets to the second return statement, and calls EXP(2) again.
Which calls EXP(2) again.
Which calls EXP(2) again.
Which calls EXP(2) again. Etc.
Recursion only works if the function eventually stops recursing.
|
20,314,405 |
So I wrote a header that uses recursion to compute several mathematical functions. Including the cosine function and exponential function( e^x). Now the cosine functions works just fine but e^x produces a segmentation fault even though both use the same recursive procedure. So here is the code from the header file I created "c\_math.h":
```
#define PI 3.141592
static unsigned int n;
................
uint32_t Factorial(unsigned int p)
{
if(p==0){
return(1);
}else if(p>0){
return p*Factorial(p-1);
}
};
double EXP(double x)
{
int N = n;
double F = (double)Factorial(n);
if(n==0){
return (1.0);
}else{
return EXP(x)+(Pow(x,N)/F);
}
}
double cosine(double x)
{
int N = (2*n);
double F = (double)(Factorial(2*n)*(-1^n));
if(n==0){
return(1.0);
}else if(n==1){
return 1+(Pow(x,2)/2);
}else if(n>1){
return cosine(x)+(Pow(x,N)/F);
}
};
double cos(double x){
bool halt = false;
double COS;
n = 0;
while(halt==false){
int N = (2*n);
double F = (double)(Factorial(2*n)*(-1^n));
COS = cosine(x);
if(abs(Pow(x,N)/F)<=0.0001){
halt = true;
}else{
n++;
}
}
return COS;
}
double e(double x){
bool halt = false;
double E;
n = 0;
while(halt==false){
int N = n;
double F = (double)(Factorial(n));
E = EXP(x);
if(abs(Pow(x,N)/F)<=0.0001){
halt = true;
}else{
n++;
}
}
return E;
}
```
The .c file with the main function:
```
include <stdio.h>
#include <cmath.h>
int main()
{
printf("\n");
printf("cos(2.2) = %4.6f\n",cos(2.2));
printf("\n");
printf("e(2.2) = %4.6f\n",e(2.2));
printf("\n");
}
```
After I compile it and then execute from the terminal prompt, the output looks like this:
```
zermacr0yd@DALEK /usr/lib/gcc/x86_64-linux-gnu/4.7.3/include $ ./mathtest
cos(2.2) = -0.588501
Segmentation fault
```
So as you can see the Cosine function works as it should but e^x produces a segmentation fault. Now the function e^x is strictly increasing for x > 0 and strictly decreasing for x < 0, but mathematically the power series should converge for all values of x which means that eventually when the series index n becomes high enough, the value of the nth term should fall below 0.0001. So what is going on here?
|
2013/12/01
|
[
"https://Stackoverflow.com/questions/20314405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1964457/"
] |
All your functions are using a variable `n` which I'm assuming is declared globally but only defined locally in `e`. You should provide a local definition of `n` for each function: `int n = 0;`.
|
A no-nonsense implementation of the cosine Taylor series is
```
#include<stdio.h>
#include<math.h>
double cos_taylor(double x) {
double mxx=-x*x, a=1, c=0;
unsigned int k=1;
while(1+a!=1) {
c+=a;
a*=mxx/(k++)/(k++);
}
return c;
}
int main() {
double x;
for(x=-0.5; x<3.2; x+=0.1)
printf(" x=%10.7f \t math.cos(x)=%20.16g \t taylor.cos(x)=%20.16g\n",
x, cos(x), cos_taylor(x));
return 0;
}
```
|
20,314,405 |
So I wrote a header that uses recursion to compute several mathematical functions. Including the cosine function and exponential function( e^x). Now the cosine functions works just fine but e^x produces a segmentation fault even though both use the same recursive procedure. So here is the code from the header file I created "c\_math.h":
```
#define PI 3.141592
static unsigned int n;
................
uint32_t Factorial(unsigned int p)
{
if(p==0){
return(1);
}else if(p>0){
return p*Factorial(p-1);
}
};
double EXP(double x)
{
int N = n;
double F = (double)Factorial(n);
if(n==0){
return (1.0);
}else{
return EXP(x)+(Pow(x,N)/F);
}
}
double cosine(double x)
{
int N = (2*n);
double F = (double)(Factorial(2*n)*(-1^n));
if(n==0){
return(1.0);
}else if(n==1){
return 1+(Pow(x,2)/2);
}else if(n>1){
return cosine(x)+(Pow(x,N)/F);
}
};
double cos(double x){
bool halt = false;
double COS;
n = 0;
while(halt==false){
int N = (2*n);
double F = (double)(Factorial(2*n)*(-1^n));
COS = cosine(x);
if(abs(Pow(x,N)/F)<=0.0001){
halt = true;
}else{
n++;
}
}
return COS;
}
double e(double x){
bool halt = false;
double E;
n = 0;
while(halt==false){
int N = n;
double F = (double)(Factorial(n));
E = EXP(x);
if(abs(Pow(x,N)/F)<=0.0001){
halt = true;
}else{
n++;
}
}
return E;
}
```
The .c file with the main function:
```
include <stdio.h>
#include <cmath.h>
int main()
{
printf("\n");
printf("cos(2.2) = %4.6f\n",cos(2.2));
printf("\n");
printf("e(2.2) = %4.6f\n",e(2.2));
printf("\n");
}
```
After I compile it and then execute from the terminal prompt, the output looks like this:
```
zermacr0yd@DALEK /usr/lib/gcc/x86_64-linux-gnu/4.7.3/include $ ./mathtest
cos(2.2) = -0.588501
Segmentation fault
```
So as you can see the Cosine function works as it should but e^x produces a segmentation fault. Now the function e^x is strictly increasing for x > 0 and strictly decreasing for x < 0, but mathematically the power series should converge for all values of x which means that eventually when the series index n becomes high enough, the value of the nth term should fall below 0.0001. So what is going on here?
|
2013/12/01
|
[
"https://Stackoverflow.com/questions/20314405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1964457/"
] |
Unix or the POSIX standard defines a tool named `bc`, which is a (very basic) multi-precision command line calculator. With it comes a numerical library that provides explicit implementations for exp, cos and sin and others. Study that for efficient, precise algorithms. The manpage, for instance at
<http://www.gnu.org/software/bc/manual/html_mono/bc.html#SEC18>
contains the implementation for `exp(x)` starting at the line `define e(x)`.
Basically, for the Taylor series to work you first have to reduce the argument as close to zero as possible. `bc` mainly uses the technique of halving-and-squaring. For sin and cos the periodicity and symmetry can also be used.
The full bc library can be found at
```
http://code.metager.de/source/xref/gnu/bc/1.06/bc/libmath.b
```
|
```
double EXP(double x) {
/* other code that doesn't change x */
if(n==0) {
return 1.0;
} else {
return EXP(x) + /* other code */;
}
}
```
Let's say we want to calculate EXP(2).
EXP starts running, gets to the second return statement, and calls EXP(2) again.
Which calls EXP(2) again.
Which calls EXP(2) again.
Which calls EXP(2) again. Etc.
Recursion only works if the function eventually stops recursing.
|
20,314,405 |
So I wrote a header that uses recursion to compute several mathematical functions. Including the cosine function and exponential function( e^x). Now the cosine functions works just fine but e^x produces a segmentation fault even though both use the same recursive procedure. So here is the code from the header file I created "c\_math.h":
```
#define PI 3.141592
static unsigned int n;
................
uint32_t Factorial(unsigned int p)
{
if(p==0){
return(1);
}else if(p>0){
return p*Factorial(p-1);
}
};
double EXP(double x)
{
int N = n;
double F = (double)Factorial(n);
if(n==0){
return (1.0);
}else{
return EXP(x)+(Pow(x,N)/F);
}
}
double cosine(double x)
{
int N = (2*n);
double F = (double)(Factorial(2*n)*(-1^n));
if(n==0){
return(1.0);
}else if(n==1){
return 1+(Pow(x,2)/2);
}else if(n>1){
return cosine(x)+(Pow(x,N)/F);
}
};
double cos(double x){
bool halt = false;
double COS;
n = 0;
while(halt==false){
int N = (2*n);
double F = (double)(Factorial(2*n)*(-1^n));
COS = cosine(x);
if(abs(Pow(x,N)/F)<=0.0001){
halt = true;
}else{
n++;
}
}
return COS;
}
double e(double x){
bool halt = false;
double E;
n = 0;
while(halt==false){
int N = n;
double F = (double)(Factorial(n));
E = EXP(x);
if(abs(Pow(x,N)/F)<=0.0001){
halt = true;
}else{
n++;
}
}
return E;
}
```
The .c file with the main function:
```
include <stdio.h>
#include <cmath.h>
int main()
{
printf("\n");
printf("cos(2.2) = %4.6f\n",cos(2.2));
printf("\n");
printf("e(2.2) = %4.6f\n",e(2.2));
printf("\n");
}
```
After I compile it and then execute from the terminal prompt, the output looks like this:
```
zermacr0yd@DALEK /usr/lib/gcc/x86_64-linux-gnu/4.7.3/include $ ./mathtest
cos(2.2) = -0.588501
Segmentation fault
```
So as you can see the Cosine function works as it should but e^x produces a segmentation fault. Now the function e^x is strictly increasing for x > 0 and strictly decreasing for x < 0, but mathematically the power series should converge for all values of x which means that eventually when the series index n becomes high enough, the value of the nth term should fall below 0.0001. So what is going on here?
|
2013/12/01
|
[
"https://Stackoverflow.com/questions/20314405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1964457/"
] |
Unix or the POSIX standard defines a tool named `bc`, which is a (very basic) multi-precision command line calculator. With it comes a numerical library that provides explicit implementations for exp, cos and sin and others. Study that for efficient, precise algorithms. The manpage, for instance at
<http://www.gnu.org/software/bc/manual/html_mono/bc.html#SEC18>
contains the implementation for `exp(x)` starting at the line `define e(x)`.
Basically, for the Taylor series to work you first have to reduce the argument as close to zero as possible. `bc` mainly uses the technique of halving-and-squaring. For sin and cos the periodicity and symmetry can also be used.
The full bc library can be found at
```
http://code.metager.de/source/xref/gnu/bc/1.06/bc/libmath.b
```
|
A no-nonsense implementation of the cosine Taylor series is
```
#include<stdio.h>
#include<math.h>
double cos_taylor(double x) {
double mxx=-x*x, a=1, c=0;
unsigned int k=1;
while(1+a!=1) {
c+=a;
a*=mxx/(k++)/(k++);
}
return c;
}
int main() {
double x;
for(x=-0.5; x<3.2; x+=0.1)
printf(" x=%10.7f \t math.cos(x)=%20.16g \t taylor.cos(x)=%20.16g\n",
x, cos(x), cos_taylor(x));
return 0;
}
```
|
9,156,259 |
I used this code for a button, after that I am in the Contacts Activity:
```
btnPhonebook.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent pb = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(pb, 1);
}
});
```
After that, there is a contact list with many contacts. Now I want that, whenever I clicked to a contact, a dialog is displayed. How can I do that. Could anyone help me because currently I have no issue how to make it. I have tried with this code but it did not work.
```
Dialog dialog = new Dialog(this);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Choose a phone number");
ListView lp = new ListView(this);
lp.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, _listPhoneNumber));
builder.setView(lp);
dialog = builder.create();
```
Also I put the above code in onActivityResult() method.
Thanks in advance.
|
2012/02/06
|
[
"https://Stackoverflow.com/questions/9156259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1189401/"
] |
Instead of using the Built in Intent to display contacts.. why don't you build the List yourself and then do what you plan to do.
**OR**
Did you set your dialog to .show()?
|
If you want to use dialog in contact then you have to make your own custom layout for contact.. See below code for example...
on button click
```
public static final int NUMBER_SELECT = 1;
Intent intent = new Intent(clsBlockNumbers.this,CallLog_Activity.class);
startActivityForResult(intent,NUMBER_SELECT);
```
in the same Activity write/make onActivityResult
```
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
switch(requestCode) {
case NUMBER_SELECT:
if (resultCode == RESULT_OK) {
String number = data.getStringExtra("SelectedNumber");
if(number == null)
{
Toast.makeText(this, "No Record found: ", Toast.LENGTH_LONG).show();
}
else
{
//Your code
}
break;
}
}
}
```
CallLog\_Activity.java
```
package com.demo;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
public class CallLog_Activity extends Activity implements OnItemClickListener
{
ArrayList<String> strAyyNumber,strAyyType,listNumber, strType, strAyyName ;
private CallLogListAdapter adapter ;
CallLog callLog;
String noType;
ListView listCallLog;
private String[] listCallLog_arr={};
Cursor cursor;
String strArr;
TextView tv, tv1, txtEmptyMsg;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.calllog_list);
callLog = new CallLog();
listCallLog = (ListView)findViewById(R.id.list);
strAyyNumber = new ArrayList<String>();
strAyyType = new ArrayList<String>();
strAyyName = new ArrayList<String>();
listNumber = new ArrayList<String>();
strType = new ArrayList<String>();
System.out.println("In Call log list activity");
try
{
final String[] projection = null;
final String selection = null;
final String[] selectionArgs = null;
final String sortOrder = "DATE DESC";
Cursor cursor = this.getContentResolver().query(
Uri.parse("content://call_log/calls"),
projection,
selection,
selectionArgs,
sortOrder);
if (cursor != null)
{
//Loop through the call log.
while (cursor.moveToNext())
{
//Common Call Log Items
String callNumber = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NUMBER));
strAyyNumber.add(callNumber);
String callType = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.TYPE));
strAyyType.add(callType);
String callName = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.CACHED_NAME));
strAyyName.add(callName);
}
for(int i=0;i<strAyyNumber.size();i++)
{
String no = strAyyNumber.get(i).toString();//.concat("\n").concat(strAyyType.get(i).toString());
Log.d("No length ", "No length ::" + no.length());
listNumber.add(no);
}
listCallLog_arr = listNumber.toArray(new String[listNumber.size()]);
Log.d("size", "list listCallLog_arr"+ listCallLog_arr.length);
if(!listNumber.isEmpty())
{
listCallLog.setVisibility(View.VISIBLE);
adapter = new CallLogListAdapter(CallLog_Activity.this,R.layout.calllog_list_row, listCallLog_arr,strAyyNumber,strAyyType,strAyyName);
listCallLog.setAdapter(adapter);
}
else
{
txtEmptyMsg = (TextView)findViewById(R.id.txtEmptyMsg);
txtEmptyMsg.setVisibility(View.VISIBLE);
txtEmptyMsg.setText("No Record found Press Back to Continue");
}
listCallLog.setOnItemClickListener(this);
}
listCallLog.setOnItemClickListener(this);
}
catch(Exception e)
{
e.printStackTrace();
}
}
@Override
public void onItemClick(AdapterView<?> arg0, View v, int position, long id)
{
String o = arg0.getItemAtPosition(position).toString();
Intent returnIntent = new Intent();
StringBuffer sb = new StringBuffer(o);
sb.reverse().setLength(10);
Log.d("Item click", "String buffer"+ sb);
String revercenum = sb.toString().trim();
Log.d("Item click", "revercenum "+ revercenum);
StringBuffer sb1 = new StringBuffer(revercenum);
sb1.reverse();
Log.d("Item click", "sb1 "+ sb1);
String revercenum1 = sb1.toString().trim();
revercenum1.replace("+", "");
Log.d("Item click", "revercenum 1"+ revercenum1);
returnIntent.putExtra("SelectedNumber",revercenum1.replace("+", ""));
setResult(RESULT_OK,returnIntent);
finish();
}
}
```
colllog\_list.xml
```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="@+id/list"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:visibility="gone"
/>
<TextView android:id="@+id/txtEmptyMsg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:textStyle="bold"
android:textSize="25dp"
android:text=""
android:visibility="gone"
/>
</LinearLayout>
```
colllog\_list\_row.xml
```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/txtCallLogName"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:textSize="20dp" android:layout_margin="10dp"
android:layout_weight="1" />
<TextView
android:id="@+id/txtCallLogNumber"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:textSize="20dp" android:layout_weight="1"
android:layout_marginLeft="10dp" android:layout_marginBottom="10dp"
android:layout_marginTop="5dp" android:layout_marginRight="10dp" />
</LinearLayout>
<TextView
android:id="@+id/txtCallLogType"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:textSize="12dp" android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" android:layout_marginRight="10dp"
android:layout_alignParentRight="true" />
</RelativeLayout>
```
CallLogListAdapter.java
```
package com.Demo;
import java.util.ArrayList;
import android.app.Activity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
public class CallLogListAdapter extends ArrayAdapter<Object>
{
private static final String TAG = "CallLogListAdapter";
private LayoutInflater inflater = null;
private int resource;
private Activity activity;
CallLog callLog ;
String[] strTemp;
ArrayList<String> arrayItem = new ArrayList<String>();
ArrayList<String> ayyType = new ArrayList<String>();
ArrayList<String> tempType = new ArrayList<String>();
ArrayList<String> ayyName = new ArrayList<String>();
ArrayList<String> tempName = new ArrayList<String>();
ArrayList<String> tempName1 = new ArrayList<String>();
ArrayList<String> tempNo = new ArrayList<String>();
String strType, strName, strName1, strNo ;
String[] tmpName, tmpName1, tmpNo;
public CallLogListAdapter(Activity activity, int resorce, String[] strTemp, ArrayList<String> arryListNumber, ArrayList<String> arryListType, ArrayList<String> arryListName)
{
super(activity, resorce,strTemp);
this.resource = resorce;
this.activity = activity;
this.strTemp = strTemp;
Log.d("in adapter", "In Adapter");
arrayItem = arryListNumber;
ayyType = arryListType;
ayyName = arryListName;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
Log.d("in adapter", "In get View");
ViewHolder holder;
if (convertView == null)
{
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
convertView = layoutInflater.inflate(resource, parent, false);
holder = new ViewHolder();
holder.txtName = (TextView)convertView.findViewById(R.id.txtCallLogName);
holder.txtNumber = (TextView)convertView.findViewById(R.id.txtCallLogNumber);
holder.txtType = (TextView)convertView.findViewById(R.id.txtCallLogType);
holder.txtName.setVisibility(View.VISIBLE);
try
{
for(int i=0;i<ayyName.size();i++)
{
strName = ayyName.get(i);
Log.d("in get view in ", "Name is: **"+ strName);
tempName.add(strName);
}
tmpName = tempName.toArray(new String[tempName.size()]);
if(tmpName[position] == null)
{
holder.txtName.setVisibility(View.GONE);
}
else
{
holder.txtName.setVisibility(View.VISIBLE);
holder.txtNumber.setTextSize(12);
holder.txtName.setText(""+ tmpName[position]);
}
}
catch (NullPointerException e)
{
e.printStackTrace();
}
for(int i=0;i<arrayItem.size();i++)
{
strNo = arrayItem.get(i);//.toString();
Log.d("in get view in ", "Number is: **"+ strNo);
tempNo.add(strNo);
}
String[] tmpNo = tempNo.toArray(new String[tempNo.size()]);
Log.d("in get view ", "Number is String[]** : "+ tmpNo[position]);
holder.txtNumber.setText(""+ tmpNo[position]);
for(int i=0;i<ayyType.size();i++)
{
strType = ayyType.get(i).toString();
if(strType.equalsIgnoreCase("1"))
{
strType = "Incoming Call";
}
else if(strType.equalsIgnoreCase("2"))
{
strType = "Outgoing Call";
}
else if(strType.equalsIgnoreCase("3"))
{
strType = "Missed Call";
}
tempType.add(strType);
}
String[] tmpType = tempType.toArray(new String[tempType.size()]);
holder.txtType.setText(""+ tmpType[position]);
convertView.setTag(holder);
} else {
holder=(ViewHolder)convertView.getTag();
}
return convertView;
}
public static class ViewHolder
{
private TextView txtNumber, txtType, txtName;
}
}
```
I hope it may be help you.. :)
|
9,156,259 |
I used this code for a button, after that I am in the Contacts Activity:
```
btnPhonebook.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent pb = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(pb, 1);
}
});
```
After that, there is a contact list with many contacts. Now I want that, whenever I clicked to a contact, a dialog is displayed. How can I do that. Could anyone help me because currently I have no issue how to make it. I have tried with this code but it did not work.
```
Dialog dialog = new Dialog(this);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Choose a phone number");
ListView lp = new ListView(this);
lp.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, _listPhoneNumber));
builder.setView(lp);
dialog = builder.create();
```
Also I put the above code in onActivityResult() method.
Thanks in advance.
|
2012/02/06
|
[
"https://Stackoverflow.com/questions/9156259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1189401/"
] |
It is very simple,
```
progDailog = ProgressDialog.show(loginAct,"Process ", "please wait....",true,true);
new Thread ( new Runnable()
{
public void run()
{
// your loading code goes here
}
}).start();
Handler progressHandler = new Handler()
{
public void handleMessage(Message msg1)
{
progDailog.dismiss();
}
}
```
|
If you want to use dialog in contact then you have to make your own custom layout for contact.. See below code for example...
on button click
```
public static final int NUMBER_SELECT = 1;
Intent intent = new Intent(clsBlockNumbers.this,CallLog_Activity.class);
startActivityForResult(intent,NUMBER_SELECT);
```
in the same Activity write/make onActivityResult
```
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
switch(requestCode) {
case NUMBER_SELECT:
if (resultCode == RESULT_OK) {
String number = data.getStringExtra("SelectedNumber");
if(number == null)
{
Toast.makeText(this, "No Record found: ", Toast.LENGTH_LONG).show();
}
else
{
//Your code
}
break;
}
}
}
```
CallLog\_Activity.java
```
package com.demo;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
public class CallLog_Activity extends Activity implements OnItemClickListener
{
ArrayList<String> strAyyNumber,strAyyType,listNumber, strType, strAyyName ;
private CallLogListAdapter adapter ;
CallLog callLog;
String noType;
ListView listCallLog;
private String[] listCallLog_arr={};
Cursor cursor;
String strArr;
TextView tv, tv1, txtEmptyMsg;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.calllog_list);
callLog = new CallLog();
listCallLog = (ListView)findViewById(R.id.list);
strAyyNumber = new ArrayList<String>();
strAyyType = new ArrayList<String>();
strAyyName = new ArrayList<String>();
listNumber = new ArrayList<String>();
strType = new ArrayList<String>();
System.out.println("In Call log list activity");
try
{
final String[] projection = null;
final String selection = null;
final String[] selectionArgs = null;
final String sortOrder = "DATE DESC";
Cursor cursor = this.getContentResolver().query(
Uri.parse("content://call_log/calls"),
projection,
selection,
selectionArgs,
sortOrder);
if (cursor != null)
{
//Loop through the call log.
while (cursor.moveToNext())
{
//Common Call Log Items
String callNumber = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NUMBER));
strAyyNumber.add(callNumber);
String callType = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.TYPE));
strAyyType.add(callType);
String callName = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.CACHED_NAME));
strAyyName.add(callName);
}
for(int i=0;i<strAyyNumber.size();i++)
{
String no = strAyyNumber.get(i).toString();//.concat("\n").concat(strAyyType.get(i).toString());
Log.d("No length ", "No length ::" + no.length());
listNumber.add(no);
}
listCallLog_arr = listNumber.toArray(new String[listNumber.size()]);
Log.d("size", "list listCallLog_arr"+ listCallLog_arr.length);
if(!listNumber.isEmpty())
{
listCallLog.setVisibility(View.VISIBLE);
adapter = new CallLogListAdapter(CallLog_Activity.this,R.layout.calllog_list_row, listCallLog_arr,strAyyNumber,strAyyType,strAyyName);
listCallLog.setAdapter(adapter);
}
else
{
txtEmptyMsg = (TextView)findViewById(R.id.txtEmptyMsg);
txtEmptyMsg.setVisibility(View.VISIBLE);
txtEmptyMsg.setText("No Record found Press Back to Continue");
}
listCallLog.setOnItemClickListener(this);
}
listCallLog.setOnItemClickListener(this);
}
catch(Exception e)
{
e.printStackTrace();
}
}
@Override
public void onItemClick(AdapterView<?> arg0, View v, int position, long id)
{
String o = arg0.getItemAtPosition(position).toString();
Intent returnIntent = new Intent();
StringBuffer sb = new StringBuffer(o);
sb.reverse().setLength(10);
Log.d("Item click", "String buffer"+ sb);
String revercenum = sb.toString().trim();
Log.d("Item click", "revercenum "+ revercenum);
StringBuffer sb1 = new StringBuffer(revercenum);
sb1.reverse();
Log.d("Item click", "sb1 "+ sb1);
String revercenum1 = sb1.toString().trim();
revercenum1.replace("+", "");
Log.d("Item click", "revercenum 1"+ revercenum1);
returnIntent.putExtra("SelectedNumber",revercenum1.replace("+", ""));
setResult(RESULT_OK,returnIntent);
finish();
}
}
```
colllog\_list.xml
```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="@+id/list"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:visibility="gone"
/>
<TextView android:id="@+id/txtEmptyMsg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:textStyle="bold"
android:textSize="25dp"
android:text=""
android:visibility="gone"
/>
</LinearLayout>
```
colllog\_list\_row.xml
```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/txtCallLogName"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:textSize="20dp" android:layout_margin="10dp"
android:layout_weight="1" />
<TextView
android:id="@+id/txtCallLogNumber"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:textSize="20dp" android:layout_weight="1"
android:layout_marginLeft="10dp" android:layout_marginBottom="10dp"
android:layout_marginTop="5dp" android:layout_marginRight="10dp" />
</LinearLayout>
<TextView
android:id="@+id/txtCallLogType"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:textSize="12dp" android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" android:layout_marginRight="10dp"
android:layout_alignParentRight="true" />
</RelativeLayout>
```
CallLogListAdapter.java
```
package com.Demo;
import java.util.ArrayList;
import android.app.Activity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
public class CallLogListAdapter extends ArrayAdapter<Object>
{
private static final String TAG = "CallLogListAdapter";
private LayoutInflater inflater = null;
private int resource;
private Activity activity;
CallLog callLog ;
String[] strTemp;
ArrayList<String> arrayItem = new ArrayList<String>();
ArrayList<String> ayyType = new ArrayList<String>();
ArrayList<String> tempType = new ArrayList<String>();
ArrayList<String> ayyName = new ArrayList<String>();
ArrayList<String> tempName = new ArrayList<String>();
ArrayList<String> tempName1 = new ArrayList<String>();
ArrayList<String> tempNo = new ArrayList<String>();
String strType, strName, strName1, strNo ;
String[] tmpName, tmpName1, tmpNo;
public CallLogListAdapter(Activity activity, int resorce, String[] strTemp, ArrayList<String> arryListNumber, ArrayList<String> arryListType, ArrayList<String> arryListName)
{
super(activity, resorce,strTemp);
this.resource = resorce;
this.activity = activity;
this.strTemp = strTemp;
Log.d("in adapter", "In Adapter");
arrayItem = arryListNumber;
ayyType = arryListType;
ayyName = arryListName;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
Log.d("in adapter", "In get View");
ViewHolder holder;
if (convertView == null)
{
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
convertView = layoutInflater.inflate(resource, parent, false);
holder = new ViewHolder();
holder.txtName = (TextView)convertView.findViewById(R.id.txtCallLogName);
holder.txtNumber = (TextView)convertView.findViewById(R.id.txtCallLogNumber);
holder.txtType = (TextView)convertView.findViewById(R.id.txtCallLogType);
holder.txtName.setVisibility(View.VISIBLE);
try
{
for(int i=0;i<ayyName.size();i++)
{
strName = ayyName.get(i);
Log.d("in get view in ", "Name is: **"+ strName);
tempName.add(strName);
}
tmpName = tempName.toArray(new String[tempName.size()]);
if(tmpName[position] == null)
{
holder.txtName.setVisibility(View.GONE);
}
else
{
holder.txtName.setVisibility(View.VISIBLE);
holder.txtNumber.setTextSize(12);
holder.txtName.setText(""+ tmpName[position]);
}
}
catch (NullPointerException e)
{
e.printStackTrace();
}
for(int i=0;i<arrayItem.size();i++)
{
strNo = arrayItem.get(i);//.toString();
Log.d("in get view in ", "Number is: **"+ strNo);
tempNo.add(strNo);
}
String[] tmpNo = tempNo.toArray(new String[tempNo.size()]);
Log.d("in get view ", "Number is String[]** : "+ tmpNo[position]);
holder.txtNumber.setText(""+ tmpNo[position]);
for(int i=0;i<ayyType.size();i++)
{
strType = ayyType.get(i).toString();
if(strType.equalsIgnoreCase("1"))
{
strType = "Incoming Call";
}
else if(strType.equalsIgnoreCase("2"))
{
strType = "Outgoing Call";
}
else if(strType.equalsIgnoreCase("3"))
{
strType = "Missed Call";
}
tempType.add(strType);
}
String[] tmpType = tempType.toArray(new String[tempType.size()]);
holder.txtType.setText(""+ tmpType[position]);
convertView.setTag(holder);
} else {
holder=(ViewHolder)convertView.getTag();
}
return convertView;
}
public static class ViewHolder
{
private TextView txtNumber, txtType, txtName;
}
}
```
I hope it may be help you.. :)
|
9,156,259 |
I used this code for a button, after that I am in the Contacts Activity:
```
btnPhonebook.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent pb = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(pb, 1);
}
});
```
After that, there is a contact list with many contacts. Now I want that, whenever I clicked to a contact, a dialog is displayed. How can I do that. Could anyone help me because currently I have no issue how to make it. I have tried with this code but it did not work.
```
Dialog dialog = new Dialog(this);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Choose a phone number");
ListView lp = new ListView(this);
lp.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, _listPhoneNumber));
builder.setView(lp);
dialog = builder.create();
```
Also I put the above code in onActivityResult() method.
Thanks in advance.
|
2012/02/06
|
[
"https://Stackoverflow.com/questions/9156259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1189401/"
] |
You cannot show `Dialog` in native Contacts app.
However you can fetch Contacts by yourself and show them in a `ListView` with `CheckBox` and proceed to next step.
[Here](https://stackoverflow.com/a/3888833/593709) is a simplest `ListView` to show contacts. you can edit it by yourself.
|
If you want to use dialog in contact then you have to make your own custom layout for contact.. See below code for example...
on button click
```
public static final int NUMBER_SELECT = 1;
Intent intent = new Intent(clsBlockNumbers.this,CallLog_Activity.class);
startActivityForResult(intent,NUMBER_SELECT);
```
in the same Activity write/make onActivityResult
```
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
switch(requestCode) {
case NUMBER_SELECT:
if (resultCode == RESULT_OK) {
String number = data.getStringExtra("SelectedNumber");
if(number == null)
{
Toast.makeText(this, "No Record found: ", Toast.LENGTH_LONG).show();
}
else
{
//Your code
}
break;
}
}
}
```
CallLog\_Activity.java
```
package com.demo;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
public class CallLog_Activity extends Activity implements OnItemClickListener
{
ArrayList<String> strAyyNumber,strAyyType,listNumber, strType, strAyyName ;
private CallLogListAdapter adapter ;
CallLog callLog;
String noType;
ListView listCallLog;
private String[] listCallLog_arr={};
Cursor cursor;
String strArr;
TextView tv, tv1, txtEmptyMsg;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.calllog_list);
callLog = new CallLog();
listCallLog = (ListView)findViewById(R.id.list);
strAyyNumber = new ArrayList<String>();
strAyyType = new ArrayList<String>();
strAyyName = new ArrayList<String>();
listNumber = new ArrayList<String>();
strType = new ArrayList<String>();
System.out.println("In Call log list activity");
try
{
final String[] projection = null;
final String selection = null;
final String[] selectionArgs = null;
final String sortOrder = "DATE DESC";
Cursor cursor = this.getContentResolver().query(
Uri.parse("content://call_log/calls"),
projection,
selection,
selectionArgs,
sortOrder);
if (cursor != null)
{
//Loop through the call log.
while (cursor.moveToNext())
{
//Common Call Log Items
String callNumber = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NUMBER));
strAyyNumber.add(callNumber);
String callType = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.TYPE));
strAyyType.add(callType);
String callName = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.CACHED_NAME));
strAyyName.add(callName);
}
for(int i=0;i<strAyyNumber.size();i++)
{
String no = strAyyNumber.get(i).toString();//.concat("\n").concat(strAyyType.get(i).toString());
Log.d("No length ", "No length ::" + no.length());
listNumber.add(no);
}
listCallLog_arr = listNumber.toArray(new String[listNumber.size()]);
Log.d("size", "list listCallLog_arr"+ listCallLog_arr.length);
if(!listNumber.isEmpty())
{
listCallLog.setVisibility(View.VISIBLE);
adapter = new CallLogListAdapter(CallLog_Activity.this,R.layout.calllog_list_row, listCallLog_arr,strAyyNumber,strAyyType,strAyyName);
listCallLog.setAdapter(adapter);
}
else
{
txtEmptyMsg = (TextView)findViewById(R.id.txtEmptyMsg);
txtEmptyMsg.setVisibility(View.VISIBLE);
txtEmptyMsg.setText("No Record found Press Back to Continue");
}
listCallLog.setOnItemClickListener(this);
}
listCallLog.setOnItemClickListener(this);
}
catch(Exception e)
{
e.printStackTrace();
}
}
@Override
public void onItemClick(AdapterView<?> arg0, View v, int position, long id)
{
String o = arg0.getItemAtPosition(position).toString();
Intent returnIntent = new Intent();
StringBuffer sb = new StringBuffer(o);
sb.reverse().setLength(10);
Log.d("Item click", "String buffer"+ sb);
String revercenum = sb.toString().trim();
Log.d("Item click", "revercenum "+ revercenum);
StringBuffer sb1 = new StringBuffer(revercenum);
sb1.reverse();
Log.d("Item click", "sb1 "+ sb1);
String revercenum1 = sb1.toString().trim();
revercenum1.replace("+", "");
Log.d("Item click", "revercenum 1"+ revercenum1);
returnIntent.putExtra("SelectedNumber",revercenum1.replace("+", ""));
setResult(RESULT_OK,returnIntent);
finish();
}
}
```
colllog\_list.xml
```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="@+id/list"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:visibility="gone"
/>
<TextView android:id="@+id/txtEmptyMsg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:textStyle="bold"
android:textSize="25dp"
android:text=""
android:visibility="gone"
/>
</LinearLayout>
```
colllog\_list\_row.xml
```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/txtCallLogName"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:textSize="20dp" android:layout_margin="10dp"
android:layout_weight="1" />
<TextView
android:id="@+id/txtCallLogNumber"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:textSize="20dp" android:layout_weight="1"
android:layout_marginLeft="10dp" android:layout_marginBottom="10dp"
android:layout_marginTop="5dp" android:layout_marginRight="10dp" />
</LinearLayout>
<TextView
android:id="@+id/txtCallLogType"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:textSize="12dp" android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" android:layout_marginRight="10dp"
android:layout_alignParentRight="true" />
</RelativeLayout>
```
CallLogListAdapter.java
```
package com.Demo;
import java.util.ArrayList;
import android.app.Activity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
public class CallLogListAdapter extends ArrayAdapter<Object>
{
private static final String TAG = "CallLogListAdapter";
private LayoutInflater inflater = null;
private int resource;
private Activity activity;
CallLog callLog ;
String[] strTemp;
ArrayList<String> arrayItem = new ArrayList<String>();
ArrayList<String> ayyType = new ArrayList<String>();
ArrayList<String> tempType = new ArrayList<String>();
ArrayList<String> ayyName = new ArrayList<String>();
ArrayList<String> tempName = new ArrayList<String>();
ArrayList<String> tempName1 = new ArrayList<String>();
ArrayList<String> tempNo = new ArrayList<String>();
String strType, strName, strName1, strNo ;
String[] tmpName, tmpName1, tmpNo;
public CallLogListAdapter(Activity activity, int resorce, String[] strTemp, ArrayList<String> arryListNumber, ArrayList<String> arryListType, ArrayList<String> arryListName)
{
super(activity, resorce,strTemp);
this.resource = resorce;
this.activity = activity;
this.strTemp = strTemp;
Log.d("in adapter", "In Adapter");
arrayItem = arryListNumber;
ayyType = arryListType;
ayyName = arryListName;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
Log.d("in adapter", "In get View");
ViewHolder holder;
if (convertView == null)
{
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
convertView = layoutInflater.inflate(resource, parent, false);
holder = new ViewHolder();
holder.txtName = (TextView)convertView.findViewById(R.id.txtCallLogName);
holder.txtNumber = (TextView)convertView.findViewById(R.id.txtCallLogNumber);
holder.txtType = (TextView)convertView.findViewById(R.id.txtCallLogType);
holder.txtName.setVisibility(View.VISIBLE);
try
{
for(int i=0;i<ayyName.size();i++)
{
strName = ayyName.get(i);
Log.d("in get view in ", "Name is: **"+ strName);
tempName.add(strName);
}
tmpName = tempName.toArray(new String[tempName.size()]);
if(tmpName[position] == null)
{
holder.txtName.setVisibility(View.GONE);
}
else
{
holder.txtName.setVisibility(View.VISIBLE);
holder.txtNumber.setTextSize(12);
holder.txtName.setText(""+ tmpName[position]);
}
}
catch (NullPointerException e)
{
e.printStackTrace();
}
for(int i=0;i<arrayItem.size();i++)
{
strNo = arrayItem.get(i);//.toString();
Log.d("in get view in ", "Number is: **"+ strNo);
tempNo.add(strNo);
}
String[] tmpNo = tempNo.toArray(new String[tempNo.size()]);
Log.d("in get view ", "Number is String[]** : "+ tmpNo[position]);
holder.txtNumber.setText(""+ tmpNo[position]);
for(int i=0;i<ayyType.size();i++)
{
strType = ayyType.get(i).toString();
if(strType.equalsIgnoreCase("1"))
{
strType = "Incoming Call";
}
else if(strType.equalsIgnoreCase("2"))
{
strType = "Outgoing Call";
}
else if(strType.equalsIgnoreCase("3"))
{
strType = "Missed Call";
}
tempType.add(strType);
}
String[] tmpType = tempType.toArray(new String[tempType.size()]);
holder.txtType.setText(""+ tmpType[position]);
convertView.setTag(holder);
} else {
holder=(ViewHolder)convertView.getTag();
}
return convertView;
}
public static class ViewHolder
{
private TextView txtNumber, txtType, txtName;
}
}
```
I hope it may be help you.. :)
|
9,156,259 |
I used this code for a button, after that I am in the Contacts Activity:
```
btnPhonebook.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent pb = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(pb, 1);
}
});
```
After that, there is a contact list with many contacts. Now I want that, whenever I clicked to a contact, a dialog is displayed. How can I do that. Could anyone help me because currently I have no issue how to make it. I have tried with this code but it did not work.
```
Dialog dialog = new Dialog(this);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Choose a phone number");
ListView lp = new ListView(this);
lp.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, _listPhoneNumber));
builder.setView(lp);
dialog = builder.create();
```
Also I put the above code in onActivityResult() method.
Thanks in advance.
|
2012/02/06
|
[
"https://Stackoverflow.com/questions/9156259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1189401/"
] |
**I Have did this in my application how we can get contact detail from listview ,
using this Data you can Display your dialog.**
```
lv.setClickable(true);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView <? > arg0, View arg1, int position, long arg3) {
Object o = lv.getItemAtPosition(position);
Toast.makeText(getApplicationContext(), o.toString(), Toast.LENGTH_LONG).show();
String infoString = o.toString();
String arr[] = infoString.split(",");
String names[] = arr[1].split("=");
id = Integer.parseInt(names[1]);
System.out.println("info" + id);
db = dh.getReadableDatabase();
String select = "select * from '" + dh.tablename + "' WHERE adb_id='" + id + "' ";
Cursor c = db.rawQuery(select, null);
if (c.moveToFirst()) {
name.setText(c.getString(1));
address.setText(c.getString(2));
contact.setText(c.getString(3));
}
}
});
```
|
If you want to use dialog in contact then you have to make your own custom layout for contact.. See below code for example...
on button click
```
public static final int NUMBER_SELECT = 1;
Intent intent = new Intent(clsBlockNumbers.this,CallLog_Activity.class);
startActivityForResult(intent,NUMBER_SELECT);
```
in the same Activity write/make onActivityResult
```
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
switch(requestCode) {
case NUMBER_SELECT:
if (resultCode == RESULT_OK) {
String number = data.getStringExtra("SelectedNumber");
if(number == null)
{
Toast.makeText(this, "No Record found: ", Toast.LENGTH_LONG).show();
}
else
{
//Your code
}
break;
}
}
}
```
CallLog\_Activity.java
```
package com.demo;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
public class CallLog_Activity extends Activity implements OnItemClickListener
{
ArrayList<String> strAyyNumber,strAyyType,listNumber, strType, strAyyName ;
private CallLogListAdapter adapter ;
CallLog callLog;
String noType;
ListView listCallLog;
private String[] listCallLog_arr={};
Cursor cursor;
String strArr;
TextView tv, tv1, txtEmptyMsg;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.calllog_list);
callLog = new CallLog();
listCallLog = (ListView)findViewById(R.id.list);
strAyyNumber = new ArrayList<String>();
strAyyType = new ArrayList<String>();
strAyyName = new ArrayList<String>();
listNumber = new ArrayList<String>();
strType = new ArrayList<String>();
System.out.println("In Call log list activity");
try
{
final String[] projection = null;
final String selection = null;
final String[] selectionArgs = null;
final String sortOrder = "DATE DESC";
Cursor cursor = this.getContentResolver().query(
Uri.parse("content://call_log/calls"),
projection,
selection,
selectionArgs,
sortOrder);
if (cursor != null)
{
//Loop through the call log.
while (cursor.moveToNext())
{
//Common Call Log Items
String callNumber = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NUMBER));
strAyyNumber.add(callNumber);
String callType = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.TYPE));
strAyyType.add(callType);
String callName = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.CACHED_NAME));
strAyyName.add(callName);
}
for(int i=0;i<strAyyNumber.size();i++)
{
String no = strAyyNumber.get(i).toString();//.concat("\n").concat(strAyyType.get(i).toString());
Log.d("No length ", "No length ::" + no.length());
listNumber.add(no);
}
listCallLog_arr = listNumber.toArray(new String[listNumber.size()]);
Log.d("size", "list listCallLog_arr"+ listCallLog_arr.length);
if(!listNumber.isEmpty())
{
listCallLog.setVisibility(View.VISIBLE);
adapter = new CallLogListAdapter(CallLog_Activity.this,R.layout.calllog_list_row, listCallLog_arr,strAyyNumber,strAyyType,strAyyName);
listCallLog.setAdapter(adapter);
}
else
{
txtEmptyMsg = (TextView)findViewById(R.id.txtEmptyMsg);
txtEmptyMsg.setVisibility(View.VISIBLE);
txtEmptyMsg.setText("No Record found Press Back to Continue");
}
listCallLog.setOnItemClickListener(this);
}
listCallLog.setOnItemClickListener(this);
}
catch(Exception e)
{
e.printStackTrace();
}
}
@Override
public void onItemClick(AdapterView<?> arg0, View v, int position, long id)
{
String o = arg0.getItemAtPosition(position).toString();
Intent returnIntent = new Intent();
StringBuffer sb = new StringBuffer(o);
sb.reverse().setLength(10);
Log.d("Item click", "String buffer"+ sb);
String revercenum = sb.toString().trim();
Log.d("Item click", "revercenum "+ revercenum);
StringBuffer sb1 = new StringBuffer(revercenum);
sb1.reverse();
Log.d("Item click", "sb1 "+ sb1);
String revercenum1 = sb1.toString().trim();
revercenum1.replace("+", "");
Log.d("Item click", "revercenum 1"+ revercenum1);
returnIntent.putExtra("SelectedNumber",revercenum1.replace("+", ""));
setResult(RESULT_OK,returnIntent);
finish();
}
}
```
colllog\_list.xml
```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="@+id/list"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:visibility="gone"
/>
<TextView android:id="@+id/txtEmptyMsg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:textStyle="bold"
android:textSize="25dp"
android:text=""
android:visibility="gone"
/>
</LinearLayout>
```
colllog\_list\_row.xml
```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/txtCallLogName"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:textSize="20dp" android:layout_margin="10dp"
android:layout_weight="1" />
<TextView
android:id="@+id/txtCallLogNumber"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:textSize="20dp" android:layout_weight="1"
android:layout_marginLeft="10dp" android:layout_marginBottom="10dp"
android:layout_marginTop="5dp" android:layout_marginRight="10dp" />
</LinearLayout>
<TextView
android:id="@+id/txtCallLogType"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:textSize="12dp" android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" android:layout_marginRight="10dp"
android:layout_alignParentRight="true" />
</RelativeLayout>
```
CallLogListAdapter.java
```
package com.Demo;
import java.util.ArrayList;
import android.app.Activity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
public class CallLogListAdapter extends ArrayAdapter<Object>
{
private static final String TAG = "CallLogListAdapter";
private LayoutInflater inflater = null;
private int resource;
private Activity activity;
CallLog callLog ;
String[] strTemp;
ArrayList<String> arrayItem = new ArrayList<String>();
ArrayList<String> ayyType = new ArrayList<String>();
ArrayList<String> tempType = new ArrayList<String>();
ArrayList<String> ayyName = new ArrayList<String>();
ArrayList<String> tempName = new ArrayList<String>();
ArrayList<String> tempName1 = new ArrayList<String>();
ArrayList<String> tempNo = new ArrayList<String>();
String strType, strName, strName1, strNo ;
String[] tmpName, tmpName1, tmpNo;
public CallLogListAdapter(Activity activity, int resorce, String[] strTemp, ArrayList<String> arryListNumber, ArrayList<String> arryListType, ArrayList<String> arryListName)
{
super(activity, resorce,strTemp);
this.resource = resorce;
this.activity = activity;
this.strTemp = strTemp;
Log.d("in adapter", "In Adapter");
arrayItem = arryListNumber;
ayyType = arryListType;
ayyName = arryListName;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
Log.d("in adapter", "In get View");
ViewHolder holder;
if (convertView == null)
{
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
convertView = layoutInflater.inflate(resource, parent, false);
holder = new ViewHolder();
holder.txtName = (TextView)convertView.findViewById(R.id.txtCallLogName);
holder.txtNumber = (TextView)convertView.findViewById(R.id.txtCallLogNumber);
holder.txtType = (TextView)convertView.findViewById(R.id.txtCallLogType);
holder.txtName.setVisibility(View.VISIBLE);
try
{
for(int i=0;i<ayyName.size();i++)
{
strName = ayyName.get(i);
Log.d("in get view in ", "Name is: **"+ strName);
tempName.add(strName);
}
tmpName = tempName.toArray(new String[tempName.size()]);
if(tmpName[position] == null)
{
holder.txtName.setVisibility(View.GONE);
}
else
{
holder.txtName.setVisibility(View.VISIBLE);
holder.txtNumber.setTextSize(12);
holder.txtName.setText(""+ tmpName[position]);
}
}
catch (NullPointerException e)
{
e.printStackTrace();
}
for(int i=0;i<arrayItem.size();i++)
{
strNo = arrayItem.get(i);//.toString();
Log.d("in get view in ", "Number is: **"+ strNo);
tempNo.add(strNo);
}
String[] tmpNo = tempNo.toArray(new String[tempNo.size()]);
Log.d("in get view ", "Number is String[]** : "+ tmpNo[position]);
holder.txtNumber.setText(""+ tmpNo[position]);
for(int i=0;i<ayyType.size();i++)
{
strType = ayyType.get(i).toString();
if(strType.equalsIgnoreCase("1"))
{
strType = "Incoming Call";
}
else if(strType.equalsIgnoreCase("2"))
{
strType = "Outgoing Call";
}
else if(strType.equalsIgnoreCase("3"))
{
strType = "Missed Call";
}
tempType.add(strType);
}
String[] tmpType = tempType.toArray(new String[tempType.size()]);
holder.txtType.setText(""+ tmpType[position]);
convertView.setTag(holder);
} else {
holder=(ViewHolder)convertView.getTag();
}
return convertView;
}
public static class ViewHolder
{
private TextView txtNumber, txtType, txtName;
}
}
```
I hope it may be help you.. :)
|
4,703,111 |
I have looked around and still can't find how to list all my tables in a database. is it possible with MySQLi?
Thanks.
|
2011/01/16
|
[
"https://Stackoverflow.com/questions/4703111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/413225/"
] |
There are many ways.
```
SHOW TABLES
```
Is the most simple SQL statement for doing that. You can also take a look at `INFORMATION_SCHEMA.TABLES` if you want to have more details or do some filtering or such.
```
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA LIKE 'your_database';
```
|
I'd try something like:
```
function get_tables()
{
$tableList = array();
$res = mysqli_query($this->conn,"SHOW TABLES");
while($cRow = mysqli_fetch_array($res))
{
$tableList[] = $cRow[0];
}
return $tableList;
}
```
|
4,703,111 |
I have looked around and still can't find how to list all my tables in a database. is it possible with MySQLi?
Thanks.
|
2011/01/16
|
[
"https://Stackoverflow.com/questions/4703111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/413225/"
] |
There are many ways.
```
SHOW TABLES
```
Is the most simple SQL statement for doing that. You can also take a look at `INFORMATION_SCHEMA.TABLES` if you want to have more details or do some filtering or such.
```
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA LIKE 'your_database';
```
|
here is little example
```
class database {
public $connection;
function __construct() {
$this->connection = mysqli_connect(DBHOST,
DBUSER,
DBPASS,
DBNAME) or
die('Database Connection Error: '.mysqli_connect_error());
}
public function close_database() {
return mysqli_close($this->connection);
}
public function query($query) {
$query = mysqli_query($this->connection ,$query) or die($this->show_errors('Query Execution Error: '.mysqli_error($this->connection),'E'));
return $query;
}
public function fetch_assoc($query) {
$query = mysqli_fetch_assoc($query);
return $query;
}
}
$db = new database();
$query = $db->query("SHOW TABLES FROM DATABASENAME");
$db->fetch_assoc($query);
```
|
4,703,111 |
I have looked around and still can't find how to list all my tables in a database. is it possible with MySQLi?
Thanks.
|
2011/01/16
|
[
"https://Stackoverflow.com/questions/4703111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/413225/"
] |
There are many ways.
```
SHOW TABLES
```
Is the most simple SQL statement for doing that. You can also take a look at `INFORMATION_SCHEMA.TABLES` if you want to have more details or do some filtering or such.
```
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA LIKE 'your_database';
```
|
Using PHP 5.5 or later, a simple solution is using PHP's built-in [array\_column()](http://at2.php.net/array_column) function.
```
$link = mysqli_connect(DBHOST, DBUSER, DBPASS, DBNAME);
$listdbtables = array_column($link->query('SHOW TABLES')->fetch_all(),0);
```
|
4,703,111 |
I have looked around and still can't find how to list all my tables in a database. is it possible with MySQLi?
Thanks.
|
2011/01/16
|
[
"https://Stackoverflow.com/questions/4703111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/413225/"
] |
There are many ways.
```
SHOW TABLES
```
Is the most simple SQL statement for doing that. You can also take a look at `INFORMATION_SCHEMA.TABLES` if you want to have more details or do some filtering or such.
```
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA LIKE 'your_database';
```
|
```
$link = mysqli_connect("localhost", "domain_root", "##pwd", "domain_DBname");
$query = mysqli_query($link, "SHOW TABLES IN domain_DBname");
$numrows = mysqli_num_rows($query);
echo "<b>Amount of tables: ".$numrows." and their names:</b>";
while ($row = mysqli_fetch_array($query)) {
echo $row[0]." ";
}
```
|
4,703,111 |
I have looked around and still can't find how to list all my tables in a database. is it possible with MySQLi?
Thanks.
|
2011/01/16
|
[
"https://Stackoverflow.com/questions/4703111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/413225/"
] |
I'd try something like:
```
function get_tables()
{
$tableList = array();
$res = mysqli_query($this->conn,"SHOW TABLES");
while($cRow = mysqli_fetch_array($res))
{
$tableList[] = $cRow[0];
}
return $tableList;
}
```
|
here is little example
```
class database {
public $connection;
function __construct() {
$this->connection = mysqli_connect(DBHOST,
DBUSER,
DBPASS,
DBNAME) or
die('Database Connection Error: '.mysqli_connect_error());
}
public function close_database() {
return mysqli_close($this->connection);
}
public function query($query) {
$query = mysqli_query($this->connection ,$query) or die($this->show_errors('Query Execution Error: '.mysqli_error($this->connection),'E'));
return $query;
}
public function fetch_assoc($query) {
$query = mysqli_fetch_assoc($query);
return $query;
}
}
$db = new database();
$query = $db->query("SHOW TABLES FROM DATABASENAME");
$db->fetch_assoc($query);
```
|
4,703,111 |
I have looked around and still can't find how to list all my tables in a database. is it possible with MySQLi?
Thanks.
|
2011/01/16
|
[
"https://Stackoverflow.com/questions/4703111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/413225/"
] |
I'd try something like:
```
function get_tables()
{
$tableList = array();
$res = mysqli_query($this->conn,"SHOW TABLES");
while($cRow = mysqli_fetch_array($res))
{
$tableList[] = $cRow[0];
}
return $tableList;
}
```
|
```
$link = mysqli_connect("localhost", "domain_root", "##pwd", "domain_DBname");
$query = mysqli_query($link, "SHOW TABLES IN domain_DBname");
$numrows = mysqli_num_rows($query);
echo "<b>Amount of tables: ".$numrows." and their names:</b>";
while ($row = mysqli_fetch_array($query)) {
echo $row[0]." ";
}
```
|
4,703,111 |
I have looked around and still can't find how to list all my tables in a database. is it possible with MySQLi?
Thanks.
|
2011/01/16
|
[
"https://Stackoverflow.com/questions/4703111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/413225/"
] |
Using PHP 5.5 or later, a simple solution is using PHP's built-in [array\_column()](http://at2.php.net/array_column) function.
```
$link = mysqli_connect(DBHOST, DBUSER, DBPASS, DBNAME);
$listdbtables = array_column($link->query('SHOW TABLES')->fetch_all(),0);
```
|
here is little example
```
class database {
public $connection;
function __construct() {
$this->connection = mysqli_connect(DBHOST,
DBUSER,
DBPASS,
DBNAME) or
die('Database Connection Error: '.mysqli_connect_error());
}
public function close_database() {
return mysqli_close($this->connection);
}
public function query($query) {
$query = mysqli_query($this->connection ,$query) or die($this->show_errors('Query Execution Error: '.mysqli_error($this->connection),'E'));
return $query;
}
public function fetch_assoc($query) {
$query = mysqli_fetch_assoc($query);
return $query;
}
}
$db = new database();
$query = $db->query("SHOW TABLES FROM DATABASENAME");
$db->fetch_assoc($query);
```
|
4,703,111 |
I have looked around and still can't find how to list all my tables in a database. is it possible with MySQLi?
Thanks.
|
2011/01/16
|
[
"https://Stackoverflow.com/questions/4703111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/413225/"
] |
```
$link = mysqli_connect("localhost", "domain_root", "##pwd", "domain_DBname");
$query = mysqli_query($link, "SHOW TABLES IN domain_DBname");
$numrows = mysqli_num_rows($query);
echo "<b>Amount of tables: ".$numrows." and their names:</b>";
while ($row = mysqli_fetch_array($query)) {
echo $row[0]." ";
}
```
|
here is little example
```
class database {
public $connection;
function __construct() {
$this->connection = mysqli_connect(DBHOST,
DBUSER,
DBPASS,
DBNAME) or
die('Database Connection Error: '.mysqli_connect_error());
}
public function close_database() {
return mysqli_close($this->connection);
}
public function query($query) {
$query = mysqli_query($this->connection ,$query) or die($this->show_errors('Query Execution Error: '.mysqli_error($this->connection),'E'));
return $query;
}
public function fetch_assoc($query) {
$query = mysqli_fetch_assoc($query);
return $query;
}
}
$db = new database();
$query = $db->query("SHOW TABLES FROM DATABASENAME");
$db->fetch_assoc($query);
```
|
4,703,111 |
I have looked around and still can't find how to list all my tables in a database. is it possible with MySQLi?
Thanks.
|
2011/01/16
|
[
"https://Stackoverflow.com/questions/4703111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/413225/"
] |
Using PHP 5.5 or later, a simple solution is using PHP's built-in [array\_column()](http://at2.php.net/array_column) function.
```
$link = mysqli_connect(DBHOST, DBUSER, DBPASS, DBNAME);
$listdbtables = array_column($link->query('SHOW TABLES')->fetch_all(),0);
```
|
```
$link = mysqli_connect("localhost", "domain_root", "##pwd", "domain_DBname");
$query = mysqli_query($link, "SHOW TABLES IN domain_DBname");
$numrows = mysqli_num_rows($query);
echo "<b>Amount of tables: ".$numrows." and their names:</b>";
while ($row = mysqli_fetch_array($query)) {
echo $row[0]." ";
}
```
|
17,620,691 |
In my project I want to add a lot of new images and delete others and I want to get list of all my drawables in res folder in activity. How do I can get it? Or should I use assests folder and get list of images from there?
|
2013/07/12
|
[
"https://Stackoverflow.com/questions/17620691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2209163/"
] |
I think you're just looking for `HAVING`:
```
select units, count(*)
from old_table
group by units
having count(*) > 2000
```
* [Condensed SQL Fiddle Demo](http://sqlfiddle.com/#!2/d0a958/1)
|
Any where statement that references a value created in the current query needs to be embedded in a subquery.
Instead, you could use:
```
select * from
(
select units, count(*) as count
from old_table
group by units
)
where count > 2000
```
|
267,590 |
When dealing with capacitances <= 1uF ceramic is your choice. When you need more than 10uF it is economically justified to use electrolytic cap shunted with small ceramic one. But in range 1-10uF it is questionable. What do you suggest?
|
2016/11/04
|
[
"https://electronics.stackexchange.com/questions/267590",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/17902/"
] |
Your question is naive in that it doesn't consider what type of capacitor best suits the target application. Consider this: -
[](https://i.stack.imgur.com/fFSgh.png)
So, a 1uF ceramic may not be your best choice if wanting an accurate timing circuit (for instance) or some audio application where the microphonic problems associated with a ceramic capacitor cannot be tolerated. Also, these days, it's quite normal to find ceramics up at 100 uF and I'm sure in a few years time 1000 uF will be possible.
>
> What do you suggest?
>
>
>
Choose a capacitor type that suits the application. If one doesn't exist look at alternatives and if those alternatives look problematic, find a different approach.
Pretty picture taken from [here](http://www.globalspec.com/learnmore/electrical_electronic_components/electronic_components/chip_capacitors).
|
It all comes down to the frequency of interest. Here is a typical frequency response:
[](https://i.stack.imgur.com/8NrCL.png)
You can see that the electrolytic capacitors have the worst performance. Generally they are used for decoupling at low frequencies (kHz range), i.e. They provide power until the supply can react.
Usually, I try to avoid them, unless you need 100uF or more. As to what is the best combination, that unfortunately depends on your requirements. You'll need to have an impedance spec. You can then select the appropriate capacitor combination. Something like this:
[](https://i.stack.imgur.com/RnLmt.gif)
Proper power integrity is a broad subject. As a general rule try to avoid using different capacitor values, as that can lead to resonance. See this [app note](http://www.cypress.com/file/135716/download). Pay particular attention to the plot on page 3.
|
267,590 |
When dealing with capacitances <= 1uF ceramic is your choice. When you need more than 10uF it is economically justified to use electrolytic cap shunted with small ceramic one. But in range 1-10uF it is questionable. What do you suggest?
|
2016/11/04
|
[
"https://electronics.stackexchange.com/questions/267590",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/17902/"
] |
It all comes down to the frequency of interest. Here is a typical frequency response:
[](https://i.stack.imgur.com/8NrCL.png)
You can see that the electrolytic capacitors have the worst performance. Generally they are used for decoupling at low frequencies (kHz range), i.e. They provide power until the supply can react.
Usually, I try to avoid them, unless you need 100uF or more. As to what is the best combination, that unfortunately depends on your requirements. You'll need to have an impedance spec. You can then select the appropriate capacitor combination. Something like this:
[](https://i.stack.imgur.com/RnLmt.gif)
Proper power integrity is a broad subject. As a general rule try to avoid using different capacitor values, as that can lead to resonance. See this [app note](http://www.cypress.com/file/135716/download). Pay particular attention to the plot on page 3.
|
The OP asks about economical aspects of decoupling caps, with focus on 1uF-10uF range. Electrical aspects aside, inspecting one common supplier of components, Digi-Key, shows that a 10uF 10% 6.3V aluminum cap costs 10c in qty 1000, while a 10uF 6.3V ceramic (size 0805) is only 1.5c/1000ea.
However, there are many aspects of being economical. Economically, considering the smaller size and better reliability/longevity/mecahicals of ceramic caps, the ceramic cap seems to be clear winner in the 10uF category. There is one exception though, when a on-board LDO needs some finite ESR for its stability. Then the low-ESR ceramic is very bad, and it is fairly costly to fit any tantalum or aluminum in the place. Or add an explicit ESR of 1-2 Ohms.
So, OP needs to shift the question into into something like 100uF area, or maybe even higher.
|
267,590 |
When dealing with capacitances <= 1uF ceramic is your choice. When you need more than 10uF it is economically justified to use electrolytic cap shunted with small ceramic one. But in range 1-10uF it is questionable. What do you suggest?
|
2016/11/04
|
[
"https://electronics.stackexchange.com/questions/267590",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/17902/"
] |
It all comes down to the frequency of interest. Here is a typical frequency response:
[](https://i.stack.imgur.com/8NrCL.png)
You can see that the electrolytic capacitors have the worst performance. Generally they are used for decoupling at low frequencies (kHz range), i.e. They provide power until the supply can react.
Usually, I try to avoid them, unless you need 100uF or more. As to what is the best combination, that unfortunately depends on your requirements. You'll need to have an impedance spec. You can then select the appropriate capacitor combination. Something like this:
[](https://i.stack.imgur.com/RnLmt.gif)
Proper power integrity is a broad subject. As a general rule try to avoid using different capacitor values, as that can lead to resonance. See this [app note](http://www.cypress.com/file/135716/download). Pay particular attention to the plot on page 3.
|
The choice of ripple reduction caps can be critically defined by the impedance spectrum times(x) the current pulse spectrum='voltage ripple spectrum. This requires you define I(f) and V(f) on a spectrum analyzer, then the choice of caps becomes easier with scattering parameter files from OEM... or by trial and error.
The V(f) spectrum results in the Vpp(t) ripple signal.
This applies to 1A or 100A or any value when high ripple current and low ripple voltage are needed.
Careful attention to series (resonant) and parallel(anti-resonant) interactions with parallel caps . or SRF and PRF, result in an optimum solution.
Normally it is easier to work with admittance spectrum Y(f), as this adds rather than Z(f).
Then where necessary measure ripple current in RMS and compare to rating.
Neglecting these fundamentals in high power SMPS, leads to early failures in production or in the field.
This is supplementary to the other fine answers.
|
267,590 |
When dealing with capacitances <= 1uF ceramic is your choice. When you need more than 10uF it is economically justified to use electrolytic cap shunted with small ceramic one. But in range 1-10uF it is questionable. What do you suggest?
|
2016/11/04
|
[
"https://electronics.stackexchange.com/questions/267590",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/17902/"
] |
Your question is naive in that it doesn't consider what type of capacitor best suits the target application. Consider this: -
[](https://i.stack.imgur.com/fFSgh.png)
So, a 1uF ceramic may not be your best choice if wanting an accurate timing circuit (for instance) or some audio application where the microphonic problems associated with a ceramic capacitor cannot be tolerated. Also, these days, it's quite normal to find ceramics up at 100 uF and I'm sure in a few years time 1000 uF will be possible.
>
> What do you suggest?
>
>
>
Choose a capacitor type that suits the application. If one doesn't exist look at alternatives and if those alternatives look problematic, find a different approach.
Pretty picture taken from [here](http://www.globalspec.com/learnmore/electrical_electronic_components/electronic_components/chip_capacitors).
|
The OP asks about economical aspects of decoupling caps, with focus on 1uF-10uF range. Electrical aspects aside, inspecting one common supplier of components, Digi-Key, shows that a 10uF 10% 6.3V aluminum cap costs 10c in qty 1000, while a 10uF 6.3V ceramic (size 0805) is only 1.5c/1000ea.
However, there are many aspects of being economical. Economically, considering the smaller size and better reliability/longevity/mecahicals of ceramic caps, the ceramic cap seems to be clear winner in the 10uF category. There is one exception though, when a on-board LDO needs some finite ESR for its stability. Then the low-ESR ceramic is very bad, and it is fairly costly to fit any tantalum or aluminum in the place. Or add an explicit ESR of 1-2 Ohms.
So, OP needs to shift the question into into something like 100uF area, or maybe even higher.
|
267,590 |
When dealing with capacitances <= 1uF ceramic is your choice. When you need more than 10uF it is economically justified to use electrolytic cap shunted with small ceramic one. But in range 1-10uF it is questionable. What do you suggest?
|
2016/11/04
|
[
"https://electronics.stackexchange.com/questions/267590",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/17902/"
] |
Your question is naive in that it doesn't consider what type of capacitor best suits the target application. Consider this: -
[](https://i.stack.imgur.com/fFSgh.png)
So, a 1uF ceramic may not be your best choice if wanting an accurate timing circuit (for instance) or some audio application where the microphonic problems associated with a ceramic capacitor cannot be tolerated. Also, these days, it's quite normal to find ceramics up at 100 uF and I'm sure in a few years time 1000 uF will be possible.
>
> What do you suggest?
>
>
>
Choose a capacitor type that suits the application. If one doesn't exist look at alternatives and if those alternatives look problematic, find a different approach.
Pretty picture taken from [here](http://www.globalspec.com/learnmore/electrical_electronic_components/electronic_components/chip_capacitors).
|
The choice of ripple reduction caps can be critically defined by the impedance spectrum times(x) the current pulse spectrum='voltage ripple spectrum. This requires you define I(f) and V(f) on a spectrum analyzer, then the choice of caps becomes easier with scattering parameter files from OEM... or by trial and error.
The V(f) spectrum results in the Vpp(t) ripple signal.
This applies to 1A or 100A or any value when high ripple current and low ripple voltage are needed.
Careful attention to series (resonant) and parallel(anti-resonant) interactions with parallel caps . or SRF and PRF, result in an optimum solution.
Normally it is easier to work with admittance spectrum Y(f), as this adds rather than Z(f).
Then where necessary measure ripple current in RMS and compare to rating.
Neglecting these fundamentals in high power SMPS, leads to early failures in production or in the field.
This is supplementary to the other fine answers.
|
267,590 |
When dealing with capacitances <= 1uF ceramic is your choice. When you need more than 10uF it is economically justified to use electrolytic cap shunted with small ceramic one. But in range 1-10uF it is questionable. What do you suggest?
|
2016/11/04
|
[
"https://electronics.stackexchange.com/questions/267590",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/17902/"
] |
The OP asks about economical aspects of decoupling caps, with focus on 1uF-10uF range. Electrical aspects aside, inspecting one common supplier of components, Digi-Key, shows that a 10uF 10% 6.3V aluminum cap costs 10c in qty 1000, while a 10uF 6.3V ceramic (size 0805) is only 1.5c/1000ea.
However, there are many aspects of being economical. Economically, considering the smaller size and better reliability/longevity/mecahicals of ceramic caps, the ceramic cap seems to be clear winner in the 10uF category. There is one exception though, when a on-board LDO needs some finite ESR for its stability. Then the low-ESR ceramic is very bad, and it is fairly costly to fit any tantalum or aluminum in the place. Or add an explicit ESR of 1-2 Ohms.
So, OP needs to shift the question into into something like 100uF area, or maybe even higher.
|
The choice of ripple reduction caps can be critically defined by the impedance spectrum times(x) the current pulse spectrum='voltage ripple spectrum. This requires you define I(f) and V(f) on a spectrum analyzer, then the choice of caps becomes easier with scattering parameter files from OEM... or by trial and error.
The V(f) spectrum results in the Vpp(t) ripple signal.
This applies to 1A or 100A or any value when high ripple current and low ripple voltage are needed.
Careful attention to series (resonant) and parallel(anti-resonant) interactions with parallel caps . or SRF and PRF, result in an optimum solution.
Normally it is easier to work with admittance spectrum Y(f), as this adds rather than Z(f).
Then where necessary measure ripple current in RMS and compare to rating.
Neglecting these fundamentals in high power SMPS, leads to early failures in production or in the field.
This is supplementary to the other fine answers.
|
10,205,873 |
I try to change my format Datetime on MySQL
T got a table historic with some columns and some all them have this format DATETIME :
```
JJ/MM/AAAA HH:MM
```
I need to change to :
```
AAAA-MM-JJ HH:MM:SS
```
I don't have the variable for SS I would like to take 00.
Example
```
01/12/2012 12:23 > 2012-12-01 12:23:00
```
Thanks
|
2012/04/18
|
[
"https://Stackoverflow.com/questions/10205873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1324059/"
] |
You need to use Format Function for that
For above you can use
```
SELECT DATE_FORMAT([YOURCOLUMNNAME],'%Y-%m-%d %h:%i:%s') from [YOURTABLENAME];
```
For all the conversion you can refer to.
<http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format>
|
use **[date\_format()](http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format)** function
Try below:
```
SELECT date_format(columnname,'%Y-%m-%d %h:%i:%s') as yourdate FROM tablename
```
|
10,205,873 |
I try to change my format Datetime on MySQL
T got a table historic with some columns and some all them have this format DATETIME :
```
JJ/MM/AAAA HH:MM
```
I need to change to :
```
AAAA-MM-JJ HH:MM:SS
```
I don't have the variable for SS I would like to take 00.
Example
```
01/12/2012 12:23 > 2012-12-01 12:23:00
```
Thanks
|
2012/04/18
|
[
"https://Stackoverflow.com/questions/10205873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1324059/"
] |
You need to use Format Function for that
For above you can use
```
SELECT DATE_FORMAT([YOURCOLUMNNAME],'%Y-%m-%d %h:%i:%s') from [YOURTABLENAME];
```
For all the conversion you can refer to.
<http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format>
|
None of the posted answers will work, as your data won't be recognized as a date.
Use string conversion instead:
```
UPDATE tablename SET columnname = CONCAT(SUBSTR(columnname,7,4),'-',SUBSTR(columnname,4,2),'-',SUBSTR(columnname,1,2),SUBSTR(columname,11),':00');
```
Hope this helps
|
163,912 |
In the U.S. GPS system, satellites are identified by the PRN number broadcast by each satellite. This ID is usually visible on most GPS receiver platforms that provide access to individual GPS satellite signal information to identify the broadcasting satellite (e.g., accessible on Android via the GPSStatus.Listener and the GpsSatellite.getPrn() method (<http://goo.gl/QLse3>)).
For other GNSS, there have been an adoption of global PRN/ID values for satellites so apps end up getting globally unique IDs per satellite that don't collide with other GNSS.
For example, according to an [unofficial version of the NMEA 0183 spec (v2.19, Apr 2015)](http://www.catb.org/gpsd/NMEA.txt):
* Russian GLONASS - IDs 65-96 reserved (See also <https://gis.stackexchange.com/a/91629/12198>)
* Japanese QZSS - IDs 193-200 reserved
* Chinese BeiDou - IDs 201-235 reserved
As of April 2015 version of the NMEA 0183 spec above, Galileo isn't mentioned as far as ID reservations.
Is there any industry-standard official mapping between Galileo satellites and PRN/ID values?
**EDIT Aug. 9, 2016**
According to [GPS World](http://gpsworld.com/elliptically-orbiting-galileo-satellites-to-start-broadcasting-navigation-messages/):
>
> According to two Notice Advisories to Galileo Users (NAGUs), the two Galileo satellites launched into elliptical orbits in August 2014, GSAT0201 using PRN code E18 and GSAT0202 using PRN code E14, will start transmitting navigation messages for test purposes this Friday, Aug. 5.
>
>
> The Signal Health Status (SHS) flags will be set to “Test” and the Data Validity Status (DVS) flags will be set to WWG (working without guarantee).
>
>
> The satellites will not be included in the broadcast almanacs.
>
>
>
These PRNs are alphanumeric, while the existing agreed-upon ranges for other GNSS are numeric. I'm looking for the numeric PRNs for Galileo that would complement the other existing known GNSS ranges and that would be available on Android.
If you have an Android device that supports Galileo and you're willing to help identify the ID range, please comment on [this Github issue](https://github.com/barbeau/gpstest/issues/58).
|
2015/09/22
|
[
"https://gis.stackexchange.com/questions/163912",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/12198/"
] |
For Android 6.0.1 (M) and lower, on Qualcomm chipsets the ID range of 301-330 has been identified for Galileo satellites via tests with the [GPSTest app](https://github.com/barbeau/gpstest) on a BQ Aquaris X5+ device (see [this issue](https://github.com/barbeau/gpstest/issues/58)).
For Android 7.0 (N) and higher, Google has added a new API in Android that allows apps to explicitly determine the GNSS type of each satellite for the following GNSS constellations (from <https://developer.android.com/reference/android/location/GnssStatus.html>):
>
> * CONSTELLATION\_BEIDOU
> * CONSTELLATION\_GALILEO
> * CONSTELLATION\_GLONASS
> * CONSTELLATION\_GPS
> * CONSTELLATION\_QZSS
> * CONSTELLATION\_SBAS
>
>
>
The ID of each satellite can also be obtained, and ID ranges are defined in the documentation at <https://developer.android.com/reference/android/location/GnssStatus.html#getSvid(int)>:
>
> **getSvid()**
>
>
> Gets the identification number for the satellite at the specific index.
>
>
> This svid is pseudo-random number for most constellations. It is FCN & OSN number for Glonass.
>
>
> The distinction is made by looking at constellation field [getConstellationType(int)](https://developer.android.com/reference/android/location/GnssStatus.html#getConstellationType(int)).
>
>
> Expected values are in the range of:
>
>
> * GPS: 1-32
> * SBAS: 120-151, 183-192
> * GLONASS: One of: OSN, or FCN+100
> + 1-24 as the orbital slot number (OSN) (preferred, if known)
> + 93-106 as the frequency channel number (FCN) (-7 to +6) plus 100. i.e. encode FCN of -7 as 93, 0 as 100, and +6 as 106
> * QZSS: 193-200
> * Galileo: 1-36
> * Beidou: 1-37
>
>
>
|
From the [IGS Galileo status](http://igs.org/mgex/status-GAL) it appears that there are "standard" PRNs assigned - as of Sep 15, it looks like E followed by the SV ID for the operational satellites. Obviously that could change as satellites are "refreshed". From that same web site, it is also possible that different receivers will report different values for the same satellite.
The Wikipedia articles appear to reference the ["GPSWorld" Almanac](http://gpsworld.com/the-almanac/), which is probably reasonable as an industry source, but not really official in the way that a standard world be. It does match though, so not a big deal.
The PRN does not appear in the official [constellation information](http://www.gsc-europa.eu/system-status/Constellation-Information) or almanac. As such, I think it is probably dubious as a stable identifier. If possible, I'd stick to the satellite identifier.
*Opinion: it looks like PRN just isn't of the same importance in Galileo as it is in the GPS design, where satellite identifiers weren't important.*
|
163,912 |
In the U.S. GPS system, satellites are identified by the PRN number broadcast by each satellite. This ID is usually visible on most GPS receiver platforms that provide access to individual GPS satellite signal information to identify the broadcasting satellite (e.g., accessible on Android via the GPSStatus.Listener and the GpsSatellite.getPrn() method (<http://goo.gl/QLse3>)).
For other GNSS, there have been an adoption of global PRN/ID values for satellites so apps end up getting globally unique IDs per satellite that don't collide with other GNSS.
For example, according to an [unofficial version of the NMEA 0183 spec (v2.19, Apr 2015)](http://www.catb.org/gpsd/NMEA.txt):
* Russian GLONASS - IDs 65-96 reserved (See also <https://gis.stackexchange.com/a/91629/12198>)
* Japanese QZSS - IDs 193-200 reserved
* Chinese BeiDou - IDs 201-235 reserved
As of April 2015 version of the NMEA 0183 spec above, Galileo isn't mentioned as far as ID reservations.
Is there any industry-standard official mapping between Galileo satellites and PRN/ID values?
**EDIT Aug. 9, 2016**
According to [GPS World](http://gpsworld.com/elliptically-orbiting-galileo-satellites-to-start-broadcasting-navigation-messages/):
>
> According to two Notice Advisories to Galileo Users (NAGUs), the two Galileo satellites launched into elliptical orbits in August 2014, GSAT0201 using PRN code E18 and GSAT0202 using PRN code E14, will start transmitting navigation messages for test purposes this Friday, Aug. 5.
>
>
> The Signal Health Status (SHS) flags will be set to “Test” and the Data Validity Status (DVS) flags will be set to WWG (working without guarantee).
>
>
> The satellites will not be included in the broadcast almanacs.
>
>
>
These PRNs are alphanumeric, while the existing agreed-upon ranges for other GNSS are numeric. I'm looking for the numeric PRNs for Galileo that would complement the other existing known GNSS ranges and that would be available on Android.
If you have an Android device that supports Galileo and you're willing to help identify the ID range, please comment on [this Github issue](https://github.com/barbeau/gpstest/issues/58).
|
2015/09/22
|
[
"https://gis.stackexchange.com/questions/163912",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/12198/"
] |
From the [IGS Galileo status](http://igs.org/mgex/status-GAL) it appears that there are "standard" PRNs assigned - as of Sep 15, it looks like E followed by the SV ID for the operational satellites. Obviously that could change as satellites are "refreshed". From that same web site, it is also possible that different receivers will report different values for the same satellite.
The Wikipedia articles appear to reference the ["GPSWorld" Almanac](http://gpsworld.com/the-almanac/), which is probably reasonable as an industry source, but not really official in the way that a standard world be. It does match though, so not a big deal.
The PRN does not appear in the official [constellation information](http://www.gsc-europa.eu/system-status/Constellation-Information) or almanac. As such, I think it is probably dubious as a stable identifier. If possible, I'd stick to the satellite identifier.
*Opinion: it looks like PRN just isn't of the same importance in Galileo as it is in the GPS design, where satellite identifiers weren't important.*
|
Just to provide a comprehensive general answer:
```
'PRN E'n ⇔ 'PRN 'n + 70
```
For example: `PRN E11 = PRN 81`
|
163,912 |
In the U.S. GPS system, satellites are identified by the PRN number broadcast by each satellite. This ID is usually visible on most GPS receiver platforms that provide access to individual GPS satellite signal information to identify the broadcasting satellite (e.g., accessible on Android via the GPSStatus.Listener and the GpsSatellite.getPrn() method (<http://goo.gl/QLse3>)).
For other GNSS, there have been an adoption of global PRN/ID values for satellites so apps end up getting globally unique IDs per satellite that don't collide with other GNSS.
For example, according to an [unofficial version of the NMEA 0183 spec (v2.19, Apr 2015)](http://www.catb.org/gpsd/NMEA.txt):
* Russian GLONASS - IDs 65-96 reserved (See also <https://gis.stackexchange.com/a/91629/12198>)
* Japanese QZSS - IDs 193-200 reserved
* Chinese BeiDou - IDs 201-235 reserved
As of April 2015 version of the NMEA 0183 spec above, Galileo isn't mentioned as far as ID reservations.
Is there any industry-standard official mapping between Galileo satellites and PRN/ID values?
**EDIT Aug. 9, 2016**
According to [GPS World](http://gpsworld.com/elliptically-orbiting-galileo-satellites-to-start-broadcasting-navigation-messages/):
>
> According to two Notice Advisories to Galileo Users (NAGUs), the two Galileo satellites launched into elliptical orbits in August 2014, GSAT0201 using PRN code E18 and GSAT0202 using PRN code E14, will start transmitting navigation messages for test purposes this Friday, Aug. 5.
>
>
> The Signal Health Status (SHS) flags will be set to “Test” and the Data Validity Status (DVS) flags will be set to WWG (working without guarantee).
>
>
> The satellites will not be included in the broadcast almanacs.
>
>
>
These PRNs are alphanumeric, while the existing agreed-upon ranges for other GNSS are numeric. I'm looking for the numeric PRNs for Galileo that would complement the other existing known GNSS ranges and that would be available on Android.
If you have an Android device that supports Galileo and you're willing to help identify the ID range, please comment on [this Github issue](https://github.com/barbeau/gpstest/issues/58).
|
2015/09/22
|
[
"https://gis.stackexchange.com/questions/163912",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/12198/"
] |
For Android 6.0.1 (M) and lower, on Qualcomm chipsets the ID range of 301-330 has been identified for Galileo satellites via tests with the [GPSTest app](https://github.com/barbeau/gpstest) on a BQ Aquaris X5+ device (see [this issue](https://github.com/barbeau/gpstest/issues/58)).
For Android 7.0 (N) and higher, Google has added a new API in Android that allows apps to explicitly determine the GNSS type of each satellite for the following GNSS constellations (from <https://developer.android.com/reference/android/location/GnssStatus.html>):
>
> * CONSTELLATION\_BEIDOU
> * CONSTELLATION\_GALILEO
> * CONSTELLATION\_GLONASS
> * CONSTELLATION\_GPS
> * CONSTELLATION\_QZSS
> * CONSTELLATION\_SBAS
>
>
>
The ID of each satellite can also be obtained, and ID ranges are defined in the documentation at <https://developer.android.com/reference/android/location/GnssStatus.html#getSvid(int)>:
>
> **getSvid()**
>
>
> Gets the identification number for the satellite at the specific index.
>
>
> This svid is pseudo-random number for most constellations. It is FCN & OSN number for Glonass.
>
>
> The distinction is made by looking at constellation field [getConstellationType(int)](https://developer.android.com/reference/android/location/GnssStatus.html#getConstellationType(int)).
>
>
> Expected values are in the range of:
>
>
> * GPS: 1-32
> * SBAS: 120-151, 183-192
> * GLONASS: One of: OSN, or FCN+100
> + 1-24 as the orbital slot number (OSN) (preferred, if known)
> + 93-106 as the frequency channel number (FCN) (-7 to +6) plus 100. i.e. encode FCN of -7 as 93, 0 as 100, and +6 as 106
> * QZSS: 193-200
> * Galileo: 1-36
> * Beidou: 1-37
>
>
>
|
Just to provide a comprehensive general answer:
```
'PRN E'n ⇔ 'PRN 'n + 70
```
For example: `PRN E11 = PRN 81`
|
2,165,267 |
I'm new to jquery, and I have a bit of a problem.
What I need to do is have one div as my main slideshow. That seems straightforward enough.
However, I would like another slideshow div to change next, ( containing a bit of text ).
So the change path would be:
div 1 change, div 2 change,
div 1 change ,div 2 change,
And so on.
Where would I begin if I wanted to do this task before the end of the day ( I guess I'm spending the weekend reading about javascript and jquery )?
|
2010/01/29
|
[
"https://Stackoverflow.com/questions/2165267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13202/"
] |
Using the [jQuery Cycle Plugin](http://malsup.com/jquery/cycle/) you can do something like this:
```
var slide1 = $('.slideshow1');
var slide2 = $('.slideshow2');
slide1.cycle({
after:function(){
slide1.cycle('pause');
slide2.cycle('resume');
}
});
slide2.cycle({
after:function(){
slide2.cycle('pause');
slide1.cycle('resume');
}
}).cycle('pause');
```
Will make sure they always stay in sync even if you pause one of them with a hover or some other way.
|
You might want to check out the [jQuery Cycle](http://malsup.com/jquery/cycle/) plugin (options [here](http://malsup.com/jquery/cycle/options.html)) and try setting it up with differing delays, but the same speed. This way the animations will begin at different times and although they are not stricly synchronous, they appear to be so because of the offsets.
|
31,624,677 |
```
<input name="e_password" id="e_password" type="password" autocomplete="off" />
```
The above is a password field which for some reason, is automatically filled **only in Mozilla (not in Chrome and IE11)**. Obviously it keeps the value field from previous trials. I tried so much to clear this field. The **only** way I can manage it, is through the following:
```
$(document).ready(function(){
$('input:text').val('');
});
```
Unfortunately, the above resets all the other text fields inside the form which is undesirable. Also,
```
$(document).ready(function(){
$('input:password').val('');
});
```
does not work!
Moreover, I tried this:
```
<div class="abc">
<input name="e_password" id="e_password" type="password" autocomplete="off" />
</div>
$(document).ready(function(){
$('.abc input:text').val('');
});
```
Nor, this works...
Of course, I tried the obvious:
```
$('#e_password').val('');
```
which also did not work.
I repeat that the problem exists only in Mozilla. What else may I do?
Thank you
|
2015/07/25
|
[
"https://Stackoverflow.com/questions/31624677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642344/"
] |
I found it!!
```
setTimeout(function(){ $('#e_password').val('');}, 50);
```
Hopefully, the above works. However, I cannot give a satisfactory explanation why this small delay solves the problem...Most probably, it is a Mozilla bug.
|
Pure Javascript:
```
document.getElementById('e_password').value = '';
```
Or using jQuery:
```
$('#e_password').attr('value','');
```
|
31,624,677 |
```
<input name="e_password" id="e_password" type="password" autocomplete="off" />
```
The above is a password field which for some reason, is automatically filled **only in Mozilla (not in Chrome and IE11)**. Obviously it keeps the value field from previous trials. I tried so much to clear this field. The **only** way I can manage it, is through the following:
```
$(document).ready(function(){
$('input:text').val('');
});
```
Unfortunately, the above resets all the other text fields inside the form which is undesirable. Also,
```
$(document).ready(function(){
$('input:password').val('');
});
```
does not work!
Moreover, I tried this:
```
<div class="abc">
<input name="e_password" id="e_password" type="password" autocomplete="off" />
</div>
$(document).ready(function(){
$('.abc input:text').val('');
});
```
Nor, this works...
Of course, I tried the obvious:
```
$('#e_password').val('');
```
which also did not work.
I repeat that the problem exists only in Mozilla. What else may I do?
Thank you
|
2015/07/25
|
[
"https://Stackoverflow.com/questions/31624677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642344/"
] |
I found it!!
```
setTimeout(function(){ $('#e_password').val('');}, 50);
```
Hopefully, the above works. However, I cannot give a satisfactory explanation why this small delay solves the problem...Most probably, it is a Mozilla bug.
|
$("#e\_password").val('') works for me in firefox. Can you try with this ?
```
$("#e_password").attr("value","")
```
|
31,624,677 |
```
<input name="e_password" id="e_password" type="password" autocomplete="off" />
```
The above is a password field which for some reason, is automatically filled **only in Mozilla (not in Chrome and IE11)**. Obviously it keeps the value field from previous trials. I tried so much to clear this field. The **only** way I can manage it, is through the following:
```
$(document).ready(function(){
$('input:text').val('');
});
```
Unfortunately, the above resets all the other text fields inside the form which is undesirable. Also,
```
$(document).ready(function(){
$('input:password').val('');
});
```
does not work!
Moreover, I tried this:
```
<div class="abc">
<input name="e_password" id="e_password" type="password" autocomplete="off" />
</div>
$(document).ready(function(){
$('.abc input:text').val('');
});
```
Nor, this works...
Of course, I tried the obvious:
```
$('#e_password').val('');
```
which also did not work.
I repeat that the problem exists only in Mozilla. What else may I do?
Thank you
|
2015/07/25
|
[
"https://Stackoverflow.com/questions/31624677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642344/"
] |
I found it!!
```
setTimeout(function(){ $('#e_password').val('');}, 50);
```
Hopefully, the above works. However, I cannot give a satisfactory explanation why this small delay solves the problem...Most probably, it is a Mozilla bug.
|
Chrome ignore `autocomplete="off"`
Use `autocomplete="new-password"` in input
|
31,624,677 |
```
<input name="e_password" id="e_password" type="password" autocomplete="off" />
```
The above is a password field which for some reason, is automatically filled **only in Mozilla (not in Chrome and IE11)**. Obviously it keeps the value field from previous trials. I tried so much to clear this field. The **only** way I can manage it, is through the following:
```
$(document).ready(function(){
$('input:text').val('');
});
```
Unfortunately, the above resets all the other text fields inside the form which is undesirable. Also,
```
$(document).ready(function(){
$('input:password').val('');
});
```
does not work!
Moreover, I tried this:
```
<div class="abc">
<input name="e_password" id="e_password" type="password" autocomplete="off" />
</div>
$(document).ready(function(){
$('.abc input:text').val('');
});
```
Nor, this works...
Of course, I tried the obvious:
```
$('#e_password').val('');
```
which also did not work.
I repeat that the problem exists only in Mozilla. What else may I do?
Thank you
|
2015/07/25
|
[
"https://Stackoverflow.com/questions/31624677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642344/"
] |
```
document.getElementById("e_password").value = "";
```
or
```
$('input[type="password"]#e_password').val('');
```
|
$("#e\_password").val('') works for me in firefox. Can you try with this ?
```
$("#e_password").attr("value","")
```
|
31,624,677 |
```
<input name="e_password" id="e_password" type="password" autocomplete="off" />
```
The above is a password field which for some reason, is automatically filled **only in Mozilla (not in Chrome and IE11)**. Obviously it keeps the value field from previous trials. I tried so much to clear this field. The **only** way I can manage it, is through the following:
```
$(document).ready(function(){
$('input:text').val('');
});
```
Unfortunately, the above resets all the other text fields inside the form which is undesirable. Also,
```
$(document).ready(function(){
$('input:password').val('');
});
```
does not work!
Moreover, I tried this:
```
<div class="abc">
<input name="e_password" id="e_password" type="password" autocomplete="off" />
</div>
$(document).ready(function(){
$('.abc input:text').val('');
});
```
Nor, this works...
Of course, I tried the obvious:
```
$('#e_password').val('');
```
which also did not work.
I repeat that the problem exists only in Mozilla. What else may I do?
Thank you
|
2015/07/25
|
[
"https://Stackoverflow.com/questions/31624677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642344/"
] |
I found it!!
```
setTimeout(function(){ $('#e_password').val('');}, 50);
```
Hopefully, the above works. However, I cannot give a satisfactory explanation why this small delay solves the problem...Most probably, it is a Mozilla bug.
|
I may be wrong but I guess it is not a code problem at all !!. It may be the saved passwords in the browser. For example when you open up the page in chrome , just check out the top right of the omnibox and you can click the cross to delete the saved password for that page. I guessed this because you say it comes only in mozilla and not other browsers.
|
31,624,677 |
```
<input name="e_password" id="e_password" type="password" autocomplete="off" />
```
The above is a password field which for some reason, is automatically filled **only in Mozilla (not in Chrome and IE11)**. Obviously it keeps the value field from previous trials. I tried so much to clear this field. The **only** way I can manage it, is through the following:
```
$(document).ready(function(){
$('input:text').val('');
});
```
Unfortunately, the above resets all the other text fields inside the form which is undesirable. Also,
```
$(document).ready(function(){
$('input:password').val('');
});
```
does not work!
Moreover, I tried this:
```
<div class="abc">
<input name="e_password" id="e_password" type="password" autocomplete="off" />
</div>
$(document).ready(function(){
$('.abc input:text').val('');
});
```
Nor, this works...
Of course, I tried the obvious:
```
$('#e_password').val('');
```
which also did not work.
I repeat that the problem exists only in Mozilla. What else may I do?
Thank you
|
2015/07/25
|
[
"https://Stackoverflow.com/questions/31624677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642344/"
] |
Chrome ignore `autocomplete="off"`
Use `autocomplete="new-password"` in input
```
<input type="password" autocomplete="new-password">
```
<https://bugs.chromium.org/p/chromium/issues/detail?id=587466>
|
`autocomplete="off"` must be set for `form` element not `input`
```
<form autocomplete="off">
....
</form>
```
|
31,624,677 |
```
<input name="e_password" id="e_password" type="password" autocomplete="off" />
```
The above is a password field which for some reason, is automatically filled **only in Mozilla (not in Chrome and IE11)**. Obviously it keeps the value field from previous trials. I tried so much to clear this field. The **only** way I can manage it, is through the following:
```
$(document).ready(function(){
$('input:text').val('');
});
```
Unfortunately, the above resets all the other text fields inside the form which is undesirable. Also,
```
$(document).ready(function(){
$('input:password').val('');
});
```
does not work!
Moreover, I tried this:
```
<div class="abc">
<input name="e_password" id="e_password" type="password" autocomplete="off" />
</div>
$(document).ready(function(){
$('.abc input:text').val('');
});
```
Nor, this works...
Of course, I tried the obvious:
```
$('#e_password').val('');
```
which also did not work.
I repeat that the problem exists only in Mozilla. What else may I do?
Thank you
|
2015/07/25
|
[
"https://Stackoverflow.com/questions/31624677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642344/"
] |
```
document.getElementById("e_password").value = "";
```
or
```
$('input[type="password"]#e_password').val('');
```
|
I may be wrong but I guess it is not a code problem at all !!. It may be the saved passwords in the browser. For example when you open up the page in chrome , just check out the top right of the omnibox and you can click the cross to delete the saved password for that page. I guessed this because you say it comes only in mozilla and not other browsers.
|
31,624,677 |
```
<input name="e_password" id="e_password" type="password" autocomplete="off" />
```
The above is a password field which for some reason, is automatically filled **only in Mozilla (not in Chrome and IE11)**. Obviously it keeps the value field from previous trials. I tried so much to clear this field. The **only** way I can manage it, is through the following:
```
$(document).ready(function(){
$('input:text').val('');
});
```
Unfortunately, the above resets all the other text fields inside the form which is undesirable. Also,
```
$(document).ready(function(){
$('input:password').val('');
});
```
does not work!
Moreover, I tried this:
```
<div class="abc">
<input name="e_password" id="e_password" type="password" autocomplete="off" />
</div>
$(document).ready(function(){
$('.abc input:text').val('');
});
```
Nor, this works...
Of course, I tried the obvious:
```
$('#e_password').val('');
```
which also did not work.
I repeat that the problem exists only in Mozilla. What else may I do?
Thank you
|
2015/07/25
|
[
"https://Stackoverflow.com/questions/31624677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642344/"
] |
I found it!!
```
setTimeout(function(){ $('#e_password').val('');}, 50);
```
Hopefully, the above works. However, I cannot give a satisfactory explanation why this small delay solves the problem...Most probably, it is a Mozilla bug.
|
FF is using "change" event when auto-filling (at least in v51).
try something like
```
// if your input is in html
$(document).ready(function(){
/* // if you create input from code like this
$("body").html('<input class="password" type="password" id="e_password">').promise().done(function(){
*/
$("#e_password").on("change", function() { //append this event
$("#e_password").off("change"); //optional, depends on your code
$("#e_password").val(''); //clear
$("#e_password").attr("value",""); //clear #2 (just to be sure)
});
});
```
|
31,624,677 |
```
<input name="e_password" id="e_password" type="password" autocomplete="off" />
```
The above is a password field which for some reason, is automatically filled **only in Mozilla (not in Chrome and IE11)**. Obviously it keeps the value field from previous trials. I tried so much to clear this field. The **only** way I can manage it, is through the following:
```
$(document).ready(function(){
$('input:text').val('');
});
```
Unfortunately, the above resets all the other text fields inside the form which is undesirable. Also,
```
$(document).ready(function(){
$('input:password').val('');
});
```
does not work!
Moreover, I tried this:
```
<div class="abc">
<input name="e_password" id="e_password" type="password" autocomplete="off" />
</div>
$(document).ready(function(){
$('.abc input:text').val('');
});
```
Nor, this works...
Of course, I tried the obvious:
```
$('#e_password').val('');
```
which also did not work.
I repeat that the problem exists only in Mozilla. What else may I do?
Thank you
|
2015/07/25
|
[
"https://Stackoverflow.com/questions/31624677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642344/"
] |
Chrome ignore `autocomplete="off"`
Use `autocomplete="new-password"` in input
```
<input type="password" autocomplete="new-password">
```
<https://bugs.chromium.org/p/chromium/issues/detail?id=587466>
|
$("#e\_password").val('') works for me in firefox. Can you try with this ?
```
$("#e_password").attr("value","")
```
|
31,624,677 |
```
<input name="e_password" id="e_password" type="password" autocomplete="off" />
```
The above is a password field which for some reason, is automatically filled **only in Mozilla (not in Chrome and IE11)**. Obviously it keeps the value field from previous trials. I tried so much to clear this field. The **only** way I can manage it, is through the following:
```
$(document).ready(function(){
$('input:text').val('');
});
```
Unfortunately, the above resets all the other text fields inside the form which is undesirable. Also,
```
$(document).ready(function(){
$('input:password').val('');
});
```
does not work!
Moreover, I tried this:
```
<div class="abc">
<input name="e_password" id="e_password" type="password" autocomplete="off" />
</div>
$(document).ready(function(){
$('.abc input:text').val('');
});
```
Nor, this works...
Of course, I tried the obvious:
```
$('#e_password').val('');
```
which also did not work.
I repeat that the problem exists only in Mozilla. What else may I do?
Thank you
|
2015/07/25
|
[
"https://Stackoverflow.com/questions/31624677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642344/"
] |
Chrome ignore `autocomplete="off"`
Use `autocomplete="new-password"` in input
```
<input type="password" autocomplete="new-password">
```
<https://bugs.chromium.org/p/chromium/issues/detail?id=587466>
|
Chrome ignore `autocomplete="off"`
Use `autocomplete="new-password"` in input
|
41,804,034 |
My problem is im working in prestashop(1.6.1.9) CMS pages, im not allowed to put any script into the cms pages source code.(im not using iframe for this, its not a solution)..
So i have an dropdown menu , where each link on the drop down links to a certain page. I want to use a java-script function to do this.
But because i cant call java-script on the page like this example,
```
<select id="selectdrops" name="newurl" onchange="menu_goto(this.form) ">
<option value="/index.html">Home</option>
<option value="/feedback.html">Feedback</option>
<option value="/links.html">Related Links</option>
</select>
```
i wish to make my javascript focus on the dropdown 'ID' if thats possible?
Removing : **menu\_goto(this.form)** i would like to still accomplish the targeted links by maybe focusing on the select "ID".
My .js looks like this :
```
$(document).ready(function () {
$(document).on('change', '#dropSelectAbout', function (e) {
e.preventDefault();
menu_goto();
});
$(document).ready(function() {
$("a").click(function(event) {
alert(event.target.id);
});
});
});
function menu_goto( menuform )
{
var baseurl = window.document.location.protocol + '//' + window.document.location.host;
selecteditem = menuform.newurl.selectedIndex ;
newurl = menuform.newurl.options[ selecteditem ].value ;
if (newurl.length != 0) {
location.href = baseurl + newurl ;
}
}
```
|
2017/01/23
|
[
"https://Stackoverflow.com/questions/41804034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6295433/"
] |
I suggest making the following changes;
```
$(document).on('change', '#selectdrops', function (e) {
e.preventDefault();
menu_goto(e.target.value);
});
})
function menu_goto( newurl ) {
var baseurl = window.document.location.protocol + '//' + window.document.location.host;
if (newurl.length != 0) {
window.location = baseurl + newurl ;
}
}
```
Removed: (the script below removed because it targets all the < a > tags on the page which creates an pop-up dialog message when links are clicked, so the function on top was only script needed to focus on my dropdown where id="selectdrops" )
```
$(document).ready(function() {
$("a").click(function(event) {
alert(event.target.id);
});
});
```
`e.target.value` will give you the selected option therefore you can pass the value directly into your `menu_goto` function.
`location` does not have a `ref` property therefore use `window.location` if the intention to redirect to the newly constructed url.
|
If you want to redirect on change (not after a button click) you can use this script:
```
$(document).ready(function () {
$(document).on('change', '#selectdrops', function (e) {
e.preventDefault();
menu_goto(this);
});
});
function menu_goto( menuform )
{
if(menuform == null)
return;
newurl = $(menuform).val() ;
if (newurl.length != 0) {
location.href = baseUri + newurl ;
}
}
```
You can use the baseUri variable that Prestashop uses to get the store url. This works better for subdomains.
Then set the links in the select without the / (it's already in the baseUri).
EDIT:
To use a button click:
```
$(document).ready(function () {
$(document).on('click', '#golink', function (e) {
e.preventDefault();
menu_goto();
});
});
function menu_goto()
{
var menuform = $('#selectdrops');
if(menuform == null)
return;
newurl = menuform.val() ;
if (newurl.length != 0) {
location.href = baseUri + newurl ;
}
}
```
in this case the button link to execute must have the id golink.
|
41,804,034 |
My problem is im working in prestashop(1.6.1.9) CMS pages, im not allowed to put any script into the cms pages source code.(im not using iframe for this, its not a solution)..
So i have an dropdown menu , where each link on the drop down links to a certain page. I want to use a java-script function to do this.
But because i cant call java-script on the page like this example,
```
<select id="selectdrops" name="newurl" onchange="menu_goto(this.form) ">
<option value="/index.html">Home</option>
<option value="/feedback.html">Feedback</option>
<option value="/links.html">Related Links</option>
</select>
```
i wish to make my javascript focus on the dropdown 'ID' if thats possible?
Removing : **menu\_goto(this.form)** i would like to still accomplish the targeted links by maybe focusing on the select "ID".
My .js looks like this :
```
$(document).ready(function () {
$(document).on('change', '#dropSelectAbout', function (e) {
e.preventDefault();
menu_goto();
});
$(document).ready(function() {
$("a").click(function(event) {
alert(event.target.id);
});
});
});
function menu_goto( menuform )
{
var baseurl = window.document.location.protocol + '//' + window.document.location.host;
selecteditem = menuform.newurl.selectedIndex ;
newurl = menuform.newurl.options[ selecteditem ].value ;
if (newurl.length != 0) {
location.href = baseurl + newurl ;
}
}
```
|
2017/01/23
|
[
"https://Stackoverflow.com/questions/41804034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6295433/"
] |
I suggest making the following changes;
```
$(document).on('change', '#selectdrops', function (e) {
e.preventDefault();
menu_goto(e.target.value);
});
})
function menu_goto( newurl ) {
var baseurl = window.document.location.protocol + '//' + window.document.location.host;
if (newurl.length != 0) {
window.location = baseurl + newurl ;
}
}
```
Removed: (the script below removed because it targets all the < a > tags on the page which creates an pop-up dialog message when links are clicked, so the function on top was only script needed to focus on my dropdown where id="selectdrops" )
```
$(document).ready(function() {
$("a").click(function(event) {
alert(event.target.id);
});
});
```
`e.target.value` will give you the selected option therefore you can pass the value directly into your `menu_goto` function.
`location` does not have a `ref` property therefore use `window.location` if the intention to redirect to the newly constructed url.
|
You forgot to pass the form as a parameter of the `menu_goto` function (also selector was false. Here is corrected code:
```js
$(document).ready(function() {
$(document).on('change', '#selectdrops', function(e) {
e.preventDefault();
menu_goto(this.form);
});
$(document).ready(function() {
$("a").click(function(event) {
alert(event.target.id);
});
});
});
function menu_goto(menuform) {
var baseurl = window.document.location.protocol + '//' + window.document.location.host;
selecteditem = menuform.newurl.selectedIndex;
newurl = menuform.newurl.options[selecteditem].value;
if (newurl.length != 0) {
location.href = baseurl + newurl;
}
}
```
```html
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<form>
<select id="selectdrops" name="newurl">
<option value="/index.html">Home</option>
<option value="/feedback.html">Feedback</option>
<option value="/links.html">Related Links</option>
</select>
</form>
```
|
73,611,259 |
I made a switch case statement menu with one of the options being System.exit(0);. This is all surrounded by a try, finally that calls the method all of this is in. Would you guys not recommend this style of loop or am I all good?
```
public void Run() {
Scanner myObj = new Scanner(System.in);
int menuInput;
try {
System.out.println(" 1) call something\n"
+"2) quit");
menuInput = myObj.nextInt();
myObj.nextLine();
switch(menuInput) {
case 1:
something();
break;
case 2:
System.exit(0);
break;
}
}catch (Exeption e ){
System.out.println("Something went wrong.");
}finally{
Run();
}
}
```
|
2022/09/05
|
[
"https://Stackoverflow.com/questions/73611259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19924244/"
] |
No.
What you have here is an infinite recursion. Eventually you'd overflow the stack.
Use an actual loop instead:
```
while (true) {
try {
// ...
} catch (Exception e) {
// ...
}
}
```
And you *almost never* want to call `System.exit`. Just `break` the loop instead.
|
Is this legal code? Yes.
Is what you have there recommended? No.
If the method throws an exception it's likely recalling it will throw again. See the quote below.
Calling it again in a tight loop without attempting remedy, at least waiting a recovery and counting failures (3 strikes out?) will just end up in a tight loop of failure and stack overflow here.
So:
Can you identify errors that retrying may work and only retry on those?
You should almost certainly include some kind of 'back-off' wait before retry.
Always (always!) include a maximum retry number after which you accept failure.
In my experience the only kind of failure that may work on retry is 'service unavailable' meaning an intermittent outage.
It may not be relevant, but things like (say) invalid credentials aren't going to fix themselves and ideally you don't resubmit those. That's particularly because you end up locking the account and being in an even worse state and possibly causing issues for others using the valid credential...
The other scenario is (say) file not found and you're using the non-existence of a file as a way of polling for something.
That's a poor design pattern and is a misuse of exception handling.
You should strongly prefer to use some kind for existence check in those cases and not let routine activity get confused with exception handling of issues.
Also if you do retry log each attempt (it may be useful later to see whether things are running smoothly or getting delayed in retry scenarios even if the go through eventually). But always differentiate a 'Warning' when retrying and 'Error' when 'throwing in the towel' and failing.
```
public class Runner {
private static int MAX_RETRIES=3;
private static int BACK_OFF_MILLIS=30000;
public void Run() throws Exception,InterruptedException {
final int TRIES=3;//In reality may be configured.
int trycount=1;
for(;;){
try{
tryRun();
return;
}catch(Exception e){
String message=e.getMessage();
if(trycount>=MAX_RETRIES){
System.out.println("*FAILED*: "+e.getMessage());
throw e;
}
boolean retriable=true;
//Any tests for non-retriable exceptions here...
if(!retriable){
System.out.println("*FAILED*: non-retriable exception - "+e.getMessage());
throw e;
}
++trycount;
System.out.println("Warning: "+e.getMessage()+" retrying "+ trycount+" of "+TRIES);
try {
Thread.sleep(trycount*BACK_OFF_MILLIS);//Some kind of back-off...
}catch(InterruptedException ie){
System.out.println("*FAILED*: Interrupted. Aborting.");
throw ie;
}
continue;
}
}
}
public void tryRun() throws Exception{
//Real workload goes here!
}
}
```
NB: The back-off strategy here is very simplistic. When it comes to outages then it's usually recommended to implement a random element and an increasing back-off like 1 minute, 10 minutes, 25 minutes. But that's a topic in itself.
I'm not sure who really said but this popular quote seems relevant.
>
> The definition of insanity is doing the same thing over and over again
> and expecting different results
>
>
>
|
30,139,698 |
I am a beginner in ruby on rails. I found it quite inconvenience to add route to route.rb manually every time I add a new action or page to controller or the project. So I want to know if there is a way using command line rather than editing the route.rb file?
|
2015/05/09
|
[
"https://Stackoverflow.com/questions/30139698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4309288/"
] |
Adding routes to the routes.rb file from the terminal can be easily achieved with **sed**.
*Install sed using the following command (Ubuntu):*
```
sudo apt get install sed
```
Assuming you are in the root directory of your app, here is the command to add the routes:-
```
sed -i '23iresources :people' config/routes.rb
```
This is what it does:
1. File to add text to is config/routes.rb
2. Line number to insert text to is 23
3. -i is the insert flag: the text will be inserted
4. **resources :people** is what gets added
Now, the route *resources :people* will be inserted on line 23 in *config/routes.rb* file in your Rails app.
|
I don't know about a commandline way to update routes, but you might consider using wildcards instead, that way a single line in your routes file can allow you to access many pages on your site:
<http://guides.rubyonrails.org/routing.html#route-globbing-and-wildcard-segments>
|
30,139,698 |
I am a beginner in ruby on rails. I found it quite inconvenience to add route to route.rb manually every time I add a new action or page to controller or the project. So I want to know if there is a way using command line rather than editing the route.rb file?
|
2015/05/09
|
[
"https://Stackoverflow.com/questions/30139698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4309288/"
] |
I don't know about a commandline way to update routes, but you might consider using wildcards instead, that way a single line in your routes file can allow you to access many pages on your site:
<http://guides.rubyonrails.org/routing.html#route-globbing-and-wildcard-segments>
|
If you do rails generate -h
```
rails generate -h
Please choose a generator below.
Rails:
assets
controller
generator
helper
integration_test
jbuilder
job
mailer
migration
model
resource
scaffold
scaffold_controller
task
```
As you can see there is no generator for routes by default. This is one of the points where rails runs out of its Magic. Of course you can write your generator [Creating and Customizing Rails Generators & Templates](http://guides.rubyonrails.org/generators.html).
But I would recommend, be ready to write code when there isn't a quick default way. Once you become a pro you will quite often see rails magic falling short of the solution your are trying to implement.
|
30,139,698 |
I am a beginner in ruby on rails. I found it quite inconvenience to add route to route.rb manually every time I add a new action or page to controller or the project. So I want to know if there is a way using command line rather than editing the route.rb file?
|
2015/05/09
|
[
"https://Stackoverflow.com/questions/30139698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4309288/"
] |
Adding routes to the routes.rb file from the terminal can be easily achieved with **sed**.
*Install sed using the following command (Ubuntu):*
```
sudo apt get install sed
```
Assuming you are in the root directory of your app, here is the command to add the routes:-
```
sed -i '23iresources :people' config/routes.rb
```
This is what it does:
1. File to add text to is config/routes.rb
2. Line number to insert text to is 23
3. -i is the insert flag: the text will be inserted
4. **resources :people** is what gets added
Now, the route *resources :people* will be inserted on line 23 in *config/routes.rb* file in your Rails app.
|
If you do rails generate -h
```
rails generate -h
Please choose a generator below.
Rails:
assets
controller
generator
helper
integration_test
jbuilder
job
mailer
migration
model
resource
scaffold
scaffold_controller
task
```
As you can see there is no generator for routes by default. This is one of the points where rails runs out of its Magic. Of course you can write your generator [Creating and Customizing Rails Generators & Templates](http://guides.rubyonrails.org/generators.html).
But I would recommend, be ready to write code when there isn't a quick default way. Once you become a pro you will quite often see rails magic falling short of the solution your are trying to implement.
|
24,044 |
Until food can be grown or synthesized reliably and effectively in space, a manned deep space mission needs to bring all of the food with it, or cache some of it ahead of time.
Roughly what would be the mass of "space food" per year per astronaut? Possibly an answer for current supplies used on the ISS would be larger than a supply optimized for absolute minimum weight - I don't know.
For example, if I take 5 Calories per gram (carb/protein/fat mix) and 2500 Calories/day as ballpark figures I get about 200 kg/year, or about 3x the mass of the astronaut per year, but food is not necessarily pure carb/protein/fat. The water content could be ignored here and considered as part of the "make up" water necessary for system losses.
How would that ballpark number compare to reality?
**note:** the answer needs to include some estimate of the "mass overhead" — additional items necessary to contain, maintain, and eat the food; anything that scales with time. Reusable items that don't scale with time (like a heating device or utensil) don't count.
The motivation of the question stems from reading Kate Greene's 2014 Slate.com article [An All-Female Mission to Mars; As a NASA guinea pig, I verified that women would be cheaper to launch than men.](http://www.slate.com/articles/health_and_science/space_20/2014/10/manned_mission_to_mars_female_astronauts_are_cheaper_to_launch_into_outer.html) where the conclusion comes in part from an overall lower caloric requirement.
|
2017/12/15
|
[
"https://space.stackexchange.com/questions/24044",
"https://space.stackexchange.com",
"https://space.stackexchange.com/users/12102/"
] |
So, after a lot of searching after what are the recommended daily intake in terms of nutrient requirements and other stuff, I used a couple of sources to make an average of what is actually needed, and starting from this extrapolated a need.
Here are my basis per day, for the average astronaut (average between male and female need) with a moderate physical activity:
* Proteins: 50 grams
* Fat: 65 grams
* Carbohydrates: 320 grams
* Sugars: 60 grams
* Sodium: 1.5 grams
* Fiber: 25 grams
* Mixed vitamins: 1 gram (wild shot here based on what is needed and could not be provided by the rest of the ingested food)
The sources for these were from an average of several documents, mainly [this document from the European Food Safety Authority](http://onlinelibrary.wiley.com/doi/10.2903/sp.efsa.2017.e15121/pdf), [this document from WHO](http://www.who.int/elena/healthy_diet_fact_sheet_394.pdf) and [this document from UK FDF](http://www.foodlabel.org.uk/label/reference-intakes.aspx). The amounts where chosen with respect for the upper limits proposed by those authorities.
Overall physical activity in space is usually lower than on Earth, since there are no gravity, but there are some forced physical activity to maintain the state of bones and muscles, so I tended to a moderate physical activity.
This should amount to about **10000 kJ** per day (using the 9.4kcal/g for fat, 4.7kcal/g for protein, 3.9kcal/g for carbohydrates and sugar and 2.5kcal/g for fiber). Source for these value are [this document](https://www.nap.edu/read/10490/chapter/7#108).
The bulk of this food amount to a total of **522.5 grams** per day, per astronaut.
Please note this is dry food only.
[This NASA Document](https://www.nasa.gov/vision/earth/everydaylife/jamestown-needs-fs.html) (from the previous answer) gives the information of **120 grams for packaging** for the meals.
The same document also gives a reference value of **710 grams** of food. However, this amount does seem to include some water since most of the food on the ISS is not dried food.
So per year, this gives about **191kg worth of food** and **44kg worth of packaging** (or 235kg overall).
Your ballpark was not that far off, and in the right range. The NASA Document for the ISS gives a bit more (260kg of food per year), but this probably includes wet food.
This estimate could probably be reduced by better controlling the activity of the astronauts and a better control of the environment (a bit hotter than needed to reduce the thermogenesis of the body for example).
---
Small edit to add a bit more information. I fell into the powder food trap and spent the last few days looking for more information.
[Some](http://files.soylent.com/pdf/soylent-release-notes-1-8-en.pdf) [companies](https://www.feedsmartfood.com/products/minisac-cepes) are creating their own mix of powdered food, where you just need to add water. If we don't take into account the impact of food quality on astronauts morale, this could be a viable solution to reduce the weight, since they manage to achieve about 150gr of dry powder per meal. This would take the food weight down to **164kg**. Also, this kind of powdered food is usually packaged in pouches, so this could significantly lighten the load too if we have a 50gr pouch for each day, that would be a total of **18kg** of packaging and a total weight of **182kg**.
|
By searching "ISS food intake" on Google, I found this, which mostly answers you question: <https://www.nasa.gov/vision/earth/everydaylife/jamestown-needs-fs.html>
|
37,231,701 |
My code is getting through the first two testcases, but failing the third one. Can someone help please?
**Link:** <https://www.hackerrank.com/challenges/tag-content-extractor>
**Problem Statement:**
In a tag-based language like XML or HTML, contents are enclosed between a start tag and an end tag. Note that the corresponding end tag starts with a `/`.
Given a string of text in a tag-based language, parse this text and retrieve the contents enclosed within sequences of well-organized tags meeting the following criterion:
1. The name of the start and end tags must be same.
2. Tags can be nested, but content between nested tags is considered not valid
3. Tags can consist of any printable characters.
**Input Format:**
The first line of input contains a single integer, N (the number of lines).
The N subsequent lines each contain a line of text.
**Constraints:**
* `1 <= N <= 100`
* Each line contains a maximum of `10000` printable characters.
* The total number of characters in all test cases will not exceed `1000000`.
**Output Format:**
For each line, print the content enclosed within valid tags.
If a line contains multiple instances of valid content, print out each instance of valid content on a new line; if no valid content is found, print None.
**My code:**
```
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int testCases = Integer.parseInt(in.nextLine());
while(testCases > 0) {
String line = in.nextLine();
char[] A = line.toCharArray();
String tag = "", tag1 = "";
int a1 = 0, b1 = 0;
int a = 0, b = 0;
int flag = 0, end = 0;
a = line.indexOf('<', a1);
b = line.indexOf('>', b1);
//System.out.println("Index of first '<' is " + a);
//System.out.println("Index of first '>' is " + b);
while ((a != -1) && (b != -1) && b < line.lastIndexOf(">")) {
tag = "";
tag1 = "";
//System.out.println("Index of first '<' is " + a);
//System.out.println("Index of first '>' is " + b);
for (int k = a + 1; k < b; k++)
tag = tag + A[k];
//System.out.println("tag is " + tag);
a1 = line.indexOf('<', a + 1);
b1 = line.indexOf('>', b + 1);
if (A[a1+1] == '/') {
//System.out.println("Index of second '<' is " + a1);
//System.out.println("Index of second '>' is " + b1);
for (int k = a1 + 2; k < b1; k++)
tag1 = tag1 + A[k];
if ((!tag.isEmpty()) && (!tag1.isEmpty())) {
if (tag.equals(tag1)) {
if ((b + 1) == a1) {
System.out.println("None");
flag = 1;
} else {
for (int k = b + 1; k < a1; k++)
System.out.print(A[k]);
System.out.println();
flag = 1;
}
} else if (flag == 0) {
System.out.println("None");
flag = 1;
}
}
}
a = a1;
b = b1;
//System.out.println("tag1 is " + tag1);
}
if ((b == -1 || a == -1 || tag1.isEmpty() || tag.isEmpty()) && (flag == 0)) {
System.out.println("None");
}
testCases--;
}
}
}
```
**EDIT : For the test case #3 I'm not able to debug the issue for why that string which is large gets parsed line by line whereas it has to parse the whole paragraph! If it would parse that as a whole then i would get the output right.**
|
2016/05/14
|
[
"https://Stackoverflow.com/questions/37231701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6324361/"
] |
You can get it here:
```
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int testCases = Integer.parseInt(in.nextLine());
while(testCases>0){
String line=in.nextLine();
int cur=0;
boolean none=true;
for(;;){
int start=line.indexOf("<",cur);
if(start<0)break;
int end=line.indexOf(">",start);
if(end<0)break;
String tag=line.substring(start+1,end);
if(tag.length()==0 || tag.charAt(0)=='/'){
cur=end+1;
continue;
}
int brk=line.indexOf("</"+tag+">");
if(brk>=0){
String output=line.substring(end+1,brk);
if(output.length()>0 && output.indexOf("<")<0){
none=false;
System.out.println(output);
}
}
cur=end+1;
}
if(none)System.out.println("None");
testCases--;
}
}
}
```
|
It can be solved easily with the power of **regex**
```
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int testCases = Integer.parseInt(in.nextLine());
String patternString ="<(.+)>([\\w]+[^<]*)</(\\1)>";
Pattern pattern = Pattern.compile(patternString);
while(testCases > 0 ){
String line = in.nextLine();
Matcher matcher = pattern.matcher(line);
boolean found = false;
while (matcher.find()) {
System.out.println(matcher.group(2));
found = true;
}
if (!found) {
System.out.println("None");
}
testCases--;
}
in.close();
}
}
```
|
2,539,964 |
I am trying to prove the following:
$Problem:$ Let $f : X \rightarrow Y$ be a function. Assume that there are $g\_{1} : Y \rightarrow X$ such that $f \circ g\_{1} = i\_{Y}$ and $g\_{1}\circ f = i\_{X}$ and $g\_{2} : Y \rightarrow X$ such that $f \circ g\_{2} = i\_{Y}$ and $g\_{2} \circ f = i\_{X}$. Show that $g\_{1} = g\_{2}$.
I am still trying getting the hang of proving functions, but this is what I have as my attempt so far:
$\textbf{Proof}.$
Let f be surjective and $f \circ g\_{1} = f \circ g\_{2}.$ That is, $g\_{1}(f(x)) = g\_{2}(f(x))$ for all $x \in X$. For every $y \in Y$, there exists $x \in X$ with $f(x) = y$. Therefore, $g\_{1}(y) = g\_{2}(y)$ for all $y \in Y$, or $g\_{1} = g\_{2}$.
Will this suffice as a accepted proof or should I approach it in a different way? Any help is appreciated.
|
2017/11/27
|
[
"https://math.stackexchange.com/questions/2539964",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/482179/"
] |
Actually, you're not doing induction on two variables here at all. You're only doing induction on $y$, while $x$ is assumed to be arbitrary. But, as such, it *is* a good proof!
|
It's subtle but this induction is not doing: Assume true for $x$ and assume true for $y$ then show it is true for $x+1$ and $y+1$.
That would *not* be valid as that proves only for $x$ and $y$ where $x - y = constant$.
BUT this is actually doing something different. It is assuming it is true for $n = x+y$ and showing it is therefore true for $n = (x+y) + 1 = (x+1) + y = x + (y+1)$.
That *is* valid.
====
On second reading, I see Bram28, is correct and this is only an induction on the variable $y$. and not on $x$ at all.
To see that this proof is complete, you should note the base cases (for $y= 1; x\ge 2$ and $y= 2; x\ge 2$)[1] *was* for *any* arbitrary $x$ and not for an $x = 2$. So induction on $x$ is unnecesary.
I'm going to leave my answer up, because I think it illustrates a good point of looking at an induction proof involves carefully evaluating what the variable being inducted upon is; not merely what it looks like.
The poof *could* have been identically done on $x+y \implies x + y+ 1$ (only the framing of the base case would differ).
[1] Both base cases were *omitted* which isn't really fair.
$y=1; f\_{x+y}=f\_{x+1}=1\*f\_x + 1\*f\_{x-1}=f\_2f\_x + f\_1f\_{x-1}=f\_yf\_x + f\_{y+1}f\_x$.
$y=2; f\_{x+y}=f\_{x+2}=f\_{x+1} + f\_x=f\_x + f\_{x-1} + f\_x = 2\*f\_{x} + 1\*f\_{x-1} = f\_3\*f\_x + f\_2\*f\_{x-1} = f\_{y+1}f\_x + f(y)\*f\_{x-1}$.
|
38,466,700 |
I'm trying to make a function that maps table names to Dataframes, my code is:
```
def tableGen(tables: Array[Any], df: DataFrame, sqlContext: SQLContext): Map[String,DataFrame]={
df.registerTempTable("TempTable")
var myMap: Map[String,DataFrame] = Map()
for(i <- tables){
val queryRows = sqlContext.sql(s"SELECT * FROM TempTable WHERE table = '$i'")
queryRows.cache()
myMap += (i.toString -> queryRows.toDF())
}
for((k,v) <- myMap){
printf("Key: %s , Value: %s\n",k,v)
}
myMap
}
```
Although I explicitly state I want my return type to be Map[String,DataFrame] when I go outside of the function and do these:
```
val test: DataFrame = TableMap.get("Company")
test.show()
```
I get a type mismatch error:
```
Error:(41, 39) type mismatch;
found : Option[org.apache.spark.sql.DataFrame]
required: org.apache.spark.sql.DataFrame
val test: DataFrame = TableMap.get("Company")
```
I don't even know what Option[org.apache.spark.sql.DataFrame] is, and I don't know why it converts.
|
2016/07/19
|
[
"https://Stackoverflow.com/questions/38466700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5844146/"
] |
>
> Although I explicitly state I want my return type to be Map[String,DataFrame] when I go outside of the function and do these:
>
>
>
Below I link to the docs of these classes.
[`Map[String,DataFrame]#get(String)`](http://www.scala-lang.org/api/current/index.html#scala.collection.Map@get(key:A):Option[B]) returns an `Option[DataFrame]`. An [`Option[T]`](http://www.scala-lang.org/api/current/#scala.Option) is a type that can contain one of two values `Some[T]` or `None`, None indicates the absence of a value.
You can either do
```
TableMap.get("Company") map { test.show() }
```
To properly deal with Option or you just
```
val test: DataFrame = TableMap("Company")
test.show()
```
To bypass the Option ([Map#apply method](http://www.scala-lang.org/api/current/index.html#scala.collection.Map@apply(key:A):B)). This second one is not recommended because it will just throw a Exception.
|
Based on certain category column, create a map based on this column. In this case the category column is `table`.
```
val categoryCol = col("table")
// category can be type String, Int, ...
val categories = df.select(categoryCol).distinct.collect.map(row => row.get(0))
// result is Map[String, DataFrame]
val dfs = categories.map {
category =>
(category.toString, df.filter(categoryCol === category).cache)
}
.toMap
val companyDF = dfs("Company")
```
|
49,362,202 |
I need help to this select where class from wordpress database:
What I would like to achieve is to display the first 6 newcomer posts/records.
The path to the image, image name, property title, property features (How many Bedrooms and Bathroom etc. there is)
property price and property price unit (if it $ or Danish kroner etc.)
At this link [All properties](http://djsteiner.dk/NewWordpress/properties/) here you can see what i will like to achieve on my front page, just without google map and the sort list and only the 6 first post:
[All properties](http://djsteiner.dk/NewWordpress/properties/)
This are tables: wp\_wpl\_properties, wp\_wpl\_units, wp\_wpl\_items to achieve my goal so i tried to make this select query:
enter code here
```
<?php
global $wpdb;
$results = $wpdb->get_results
("SELECT * FROM wp_wpl_properties,wp_wpl_units,wp_wpl_items
where wp_wpl_properties.price_unit= wp_wpl_units.id and wp_wpl_properties.id= wp_wpl_items.parent_id LIMIT 6;");
foreach ( $results as $result ) {
?>
```
I have attached table files to this question, here:
[wp\_wpl\_units.pdf](http://djsteiner.dk/wp_wpl_items.pdf)
[wp\_wpl\_items.pdf](http://djsteiner.dk/wp_wpl_units.pdf)
[wp\_wpl\_properties (1).sql](http://djsteiner.dk/wp_wpl_properties%20(1).sql)
The code I've made does not make any errors.
My problem is that i get the same record displayed 3 times at the fist columns and the same at the next 3 column, hope this make sens :)
Here is a link to my frontpage: [My frontpage](http://djsteiner.dk/NewWordpress/)
|
2018/03/19
|
[
"https://Stackoverflow.com/questions/49362202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9516236/"
] |
Your current output:
```
"0":{
"questionName":null,
"AnswerHeaders":null,
"AnswersOne":null,
"AnswersTwo":null,
"AnswersThree":null,
"AnswersFour":null,
"Questions":"Vraag ante 11 & Vraag post 33",
"AnteOrPost":null
},
```
Means that `JsonConvert` could not convert your array to json string **OR** it means that you didn't fill your array when serializing.
Make sure your json is properly filled by filling the fields with demo data:
```
AnswerHeaders = new string[] {"one", "two", "three", "four"};
```
and check to see the value when serialized, this will be a good starting point for your inquiry.
|
Found the issue. I was calling the Graphs class 8 times, instead of 1 time. Resulting into 232 strings for the Json. Afterwards I didn't have to give indexes anymore, either.
|
7,985,755 |
From inside a batch file, I would like to test whether I'm running with Administrator/elevated privileges.
The username doesn't change when "Run as Administrator" is selected, so that doesn't work.
If there were a universally available command, which has no effect, but requires administrative privileges, then I could run that and check for an error code in order to test for privileges. So far, I haven't found such a command. The commands I have found seem to return a single, non-specific error code, which could indicate anything, and they're prone to failure for a variety of reasons.
I only care about Windows 7, though support of earlier operating systems would be nice.
|
2011/11/02
|
[
"https://Stackoverflow.com/questions/7985755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/604049/"
] |
I like Rushyo's suggestion of using AT, but this is another option:
```
whoami /groups | findstr /b BUILTIN\Administrators | findstr /c:"Enabled group" && goto :isadministrator
```
This approach would also allow you to distinguish between a non-administrator and a non-elevated administrator if you wanted to. Non-elevated administrators still have BUILTIN\Administrators in the group list but it is not enabled.
However, this will not work on some non-English language systems. Instead, try
```
whoami /groups | findstr /c:" S-1-5-32-544 " | findstr /c:" Enabled group" && goto :isadministrator
```
(This should work on Windows 7 but I'm not sure about earlier versions.)
|
Thanks Torin Darkflight,
Your method is the only one that work for me on Windows 11.
Here's an example script expanding on your post:
```
IF EXIST %SYSTEMROOT%\SYSTEM32\WDI\LOGFILES GOTO :Running_As_An_Admin
ECHO You are NOT an Administrator. This command requires admin rights. & Echo: & Echo Quitting......
@TIMEOUT /T 10
goto :QUIT
:Running_As_An_Admin
Echo Do Admin stuff here!!!
:QUIT
```
|
7,985,755 |
From inside a batch file, I would like to test whether I'm running with Administrator/elevated privileges.
The username doesn't change when "Run as Administrator" is selected, so that doesn't work.
If there were a universally available command, which has no effect, but requires administrative privileges, then I could run that and check for an error code in order to test for privileges. So far, I haven't found such a command. The commands I have found seem to return a single, non-specific error code, which could indicate anything, and they're prone to failure for a variety of reasons.
I only care about Windows 7, though support of earlier operating systems would be nice.
|
2011/11/02
|
[
"https://Stackoverflow.com/questions/7985755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/604049/"
] |
**ADDENDUM**: For Windows 8 this will not work; see [this excellent answer](https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights#11995662) instead.
---
Found this solution here: <http://www.robvanderwoude.com/clevertricks.php>
```
AT > NUL
IF %ERRORLEVEL% EQU 0 (
ECHO you are Administrator
) ELSE (
ECHO you are NOT Administrator. Exiting...
PING 127.0.0.1 > NUL 2>&1
EXIT /B 1
)
```
Assuming that doesn't work and since we're talking Win7 you could use the following in Powershell if that's suitable:
```
$principal = new-object System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent())
$principal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
```
If not (and probably not, since you explicitly proposed batch files) then you could write the above in .NET and return an exit code from an exe based on the result for your batch file to use.
|
If you are running as a user with administrator rights then environment variable SessionName will NOT be defined and you still don't have administrator rights when running a batch file.
You should use "net session" command and look for an error return code of "0" to verify administrator rights.
Example;
- the first echo statement is the bell character
`net session >nul 2>&1
if not %errorlevel%==0 (echo
echo You need to start over and right-click on this file,
echo then select "Run as administrator" to be successfull.
echo.&pause&exit)`
|
7,985,755 |
From inside a batch file, I would like to test whether I'm running with Administrator/elevated privileges.
The username doesn't change when "Run as Administrator" is selected, so that doesn't work.
If there were a universally available command, which has no effect, but requires administrative privileges, then I could run that and check for an error code in order to test for privileges. So far, I haven't found such a command. The commands I have found seem to return a single, non-specific error code, which could indicate anything, and they're prone to failure for a variety of reasons.
I only care about Windows 7, though support of earlier operating systems would be nice.
|
2011/11/02
|
[
"https://Stackoverflow.com/questions/7985755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/604049/"
] |
**ADDENDUM**: For Windows 8 this will not work; see [this excellent answer](https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights#11995662) instead.
---
Found this solution here: <http://www.robvanderwoude.com/clevertricks.php>
```
AT > NUL
IF %ERRORLEVEL% EQU 0 (
ECHO you are Administrator
) ELSE (
ECHO you are NOT Administrator. Exiting...
PING 127.0.0.1 > NUL 2>&1
EXIT /B 1
)
```
Assuming that doesn't work and since we're talking Win7 you could use the following in Powershell if that's suitable:
```
$principal = new-object System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent())
$principal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
```
If not (and probably not, since you explicitly proposed batch files) then you could write the above in .NET and return an exit code from an exe based on the result for your batch file to use.
|
I like Rushyo's suggestion of using AT, but this is another option:
```
whoami /groups | findstr /b BUILTIN\Administrators | findstr /c:"Enabled group" && goto :isadministrator
```
This approach would also allow you to distinguish between a non-administrator and a non-elevated administrator if you wanted to. Non-elevated administrators still have BUILTIN\Administrators in the group list but it is not enabled.
However, this will not work on some non-English language systems. Instead, try
```
whoami /groups | findstr /c:" S-1-5-32-544 " | findstr /c:" Enabled group" && goto :isadministrator
```
(This should work on Windows 7 but I'm not sure about earlier versions.)
|
7,985,755 |
From inside a batch file, I would like to test whether I'm running with Administrator/elevated privileges.
The username doesn't change when "Run as Administrator" is selected, so that doesn't work.
If there were a universally available command, which has no effect, but requires administrative privileges, then I could run that and check for an error code in order to test for privileges. So far, I haven't found such a command. The commands I have found seem to return a single, non-specific error code, which could indicate anything, and they're prone to failure for a variety of reasons.
I only care about Windows 7, though support of earlier operating systems would be nice.
|
2011/11/02
|
[
"https://Stackoverflow.com/questions/7985755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/604049/"
] |
This trick only requires one command: type `net session` into the command prompt.
If you are **NOT an admin**, you get an access is denied message.
```
System error 5 has occurred.
Access is denied.
```
If you **ARE an admin**, you get a different message, the most common being:
```
There are no entries in the list.
```
From [MS Technet](http://technet.microsoft.com/en-us/library/bb490711.aspx):
>
> Used without parameters, net session displays information about all
> sessions with the local computer.
>
>
>
|
Works for Win7 Enterprise and Win10 Enterprise
```
@if DEFINED SESSIONNAME (
@echo.
@echo You must right click to "Run as administrator"
@echo Try again
@echo.
@pause
@goto :EOF
)
```
|
7,985,755 |
From inside a batch file, I would like to test whether I'm running with Administrator/elevated privileges.
The username doesn't change when "Run as Administrator" is selected, so that doesn't work.
If there were a universally available command, which has no effect, but requires administrative privileges, then I could run that and check for an error code in order to test for privileges. So far, I haven't found such a command. The commands I have found seem to return a single, non-specific error code, which could indicate anything, and they're prone to failure for a variety of reasons.
I only care about Windows 7, though support of earlier operating systems would be nice.
|
2011/11/02
|
[
"https://Stackoverflow.com/questions/7985755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/604049/"
] |
**ADDENDUM**: For Windows 8 this will not work; see [this excellent answer](https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights#11995662) instead.
---
Found this solution here: <http://www.robvanderwoude.com/clevertricks.php>
```
AT > NUL
IF %ERRORLEVEL% EQU 0 (
ECHO you are Administrator
) ELSE (
ECHO you are NOT Administrator. Exiting...
PING 127.0.0.1 > NUL 2>&1
EXIT /B 1
)
```
Assuming that doesn't work and since we're talking Win7 you could use the following in Powershell if that's suitable:
```
$principal = new-object System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent())
$principal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
```
If not (and probably not, since you explicitly proposed batch files) then you could write the above in .NET and return an exit code from an exe based on the result for your batch file to use.
|
Here's a simple method I've used on Windows 7 through Windows 10. Basically, I simply use the "IF EXIST" command to check for the Windows\System32\WDI\LogFiles folder. The WDI folder exists on every install of Windows from at least 7 onward, and it requires admin privileges to access. The WDI folder always has a LogFiles folder inside it. So, running "IF EXIST" on the WDI\LogFiles folder will return true if run as admin, and false if not run as admin. This can be used in a batch file to check privilege level, and branch to whichever commands you desire based on that result.
Here's a brief snippet of example code:
```
IF EXIST %SYSTEMROOT%\SYSTEM32\WDI\LOGFILES GOTO GOTADMIN
(Commands for running with normal privileges)
:GOTADMIN
(Commands for running with admin privileges)
```
Keep in mind that this method assumes the default security permissions have not been modified on the WDI folder (which is unlikely to happen in most situations, but please see caveat #2 below). Even in that case, it's simply a matter of modifying the code to check for a different common file/folder that requires admin access (System32\config\SAM may be a good alternate candidate), or you could even create your own specifically for that purpose.
There are two caveats about this method though:
1. Disabling UAC will likely break it through the simple fact that everything would be run as admin anyway.
2. Attempting to open the WDI folder in Windows Explorer and then clicking "Continue" when prompted will add permanent access rights for that user account, thus breaking my method. If this happens, it can be fixed by removing the user account from the WDI folder security permissions. If for any reason the user MUST be able to access the WDI folder with Windows Explorer, then you'd have to modify the code to check a different folder (as mentioned above, creating your own specifically for this purpose may be a good choice).
So, admittedly my method isn't perfect since it can be broken, but it's a relatively quick method that's easy to implement, is equally compatible with all versions of Windows 7, 8 and 10, and provided I stay mindful of the mentioned caveats has been 100% effective for me.
|
7,985,755 |
From inside a batch file, I would like to test whether I'm running with Administrator/elevated privileges.
The username doesn't change when "Run as Administrator" is selected, so that doesn't work.
If there were a universally available command, which has no effect, but requires administrative privileges, then I could run that and check for an error code in order to test for privileges. So far, I haven't found such a command. The commands I have found seem to return a single, non-specific error code, which could indicate anything, and they're prone to failure for a variety of reasons.
I only care about Windows 7, though support of earlier operating systems would be nice.
|
2011/11/02
|
[
"https://Stackoverflow.com/questions/7985755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/604049/"
] |
This trick only requires one command: type `net session` into the command prompt.
If you are **NOT an admin**, you get an access is denied message.
```
System error 5 has occurred.
Access is denied.
```
If you **ARE an admin**, you get a different message, the most common being:
```
There are no entries in the list.
```
From [MS Technet](http://technet.microsoft.com/en-us/library/bb490711.aspx):
>
> Used without parameters, net session displays information about all
> sessions with the local computer.
>
>
>
|
Unfortunately, "S-1-5-32-544" that others have suggested is not proof of elevation.
Windows 10 and higher, a language independent approach is:
```
whoami /groups | find "S-1-16-12288"
```
this is the "High Mandatory Level", which is actually escalated.
Regular command prompt:
```
C:\> whoami /groups | find "S-1-16-12288"
C:\>
```
Administrator command prompt:
```
C:\> whoami /groups | find "S-1-16-12288"
Mandatory Label\High Mandatory Level Label S-1-16-12288
C:\>
```
To use in a .bat file:
```
whoami /groups | find "S-1-16-12288" && set ELEVATED=true || set ELEVATED=false
```
You can also use this from powershell:
```
function is_elevated() {
Param( [String] $ToGroup = "S-1-16-12288" )
return [bool] ( whoami /groups | select-string $ToGroup )
}
```
for example:
```
PS> cd c:/temp
PS> set-content is-elevated.ps1 "return [bool] ( whoami /groups | sls S-1-16-12288 )"
PS> ./is-elevated.ps1
False
PS> start -verb runas powershell.exe
...
PS C:\Windows\system32> cd \temp
PS C:\temp> ./is-elevated.ps1
True
```
|
7,985,755 |
From inside a batch file, I would like to test whether I'm running with Administrator/elevated privileges.
The username doesn't change when "Run as Administrator" is selected, so that doesn't work.
If there were a universally available command, which has no effect, but requires administrative privileges, then I could run that and check for an error code in order to test for privileges. So far, I haven't found such a command. The commands I have found seem to return a single, non-specific error code, which could indicate anything, and they're prone to failure for a variety of reasons.
I only care about Windows 7, though support of earlier operating systems would be nice.
|
2011/11/02
|
[
"https://Stackoverflow.com/questions/7985755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/604049/"
] |
This trick only requires one command: type `net session` into the command prompt.
If you are **NOT an admin**, you get an access is denied message.
```
System error 5 has occurred.
Access is denied.
```
If you **ARE an admin**, you get a different message, the most common being:
```
There are no entries in the list.
```
From [MS Technet](http://technet.microsoft.com/en-us/library/bb490711.aspx):
>
> Used without parameters, net session displays information about all
> sessions with the local computer.
>
>
>
|
A "not-a-one-liner" version of <https://stackoverflow.com/a/38856823/2193477>
```
@echo off
net.exe session 1>NUL 2>NUL || goto :not_admin
echo SUCCESS
goto :eof
:not_admin
echo ERROR: Please run as a local administrator.
exit /b 1
```
|
7,985,755 |
From inside a batch file, I would like to test whether I'm running with Administrator/elevated privileges.
The username doesn't change when "Run as Administrator" is selected, so that doesn't work.
If there were a universally available command, which has no effect, but requires administrative privileges, then I could run that and check for an error code in order to test for privileges. So far, I haven't found such a command. The commands I have found seem to return a single, non-specific error code, which could indicate anything, and they're prone to failure for a variety of reasons.
I only care about Windows 7, though support of earlier operating systems would be nice.
|
2011/11/02
|
[
"https://Stackoverflow.com/questions/7985755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/604049/"
] |
**ADDENDUM**: For Windows 8 this will not work; see [this excellent answer](https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights#11995662) instead.
---
Found this solution here: <http://www.robvanderwoude.com/clevertricks.php>
```
AT > NUL
IF %ERRORLEVEL% EQU 0 (
ECHO you are Administrator
) ELSE (
ECHO you are NOT Administrator. Exiting...
PING 127.0.0.1 > NUL 2>&1
EXIT /B 1
)
```
Assuming that doesn't work and since we're talking Win7 you could use the following in Powershell if that's suitable:
```
$principal = new-object System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent())
$principal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
```
If not (and probably not, since you explicitly proposed batch files) then you could write the above in .NET and return an exit code from an exe based on the result for your batch file to use.
|
Works for Win7 Enterprise and Win10 Enterprise
```
@if DEFINED SESSIONNAME (
@echo.
@echo You must right click to "Run as administrator"
@echo Try again
@echo.
@pause
@goto :EOF
)
```
|
7,985,755 |
From inside a batch file, I would like to test whether I'm running with Administrator/elevated privileges.
The username doesn't change when "Run as Administrator" is selected, so that doesn't work.
If there were a universally available command, which has no effect, but requires administrative privileges, then I could run that and check for an error code in order to test for privileges. So far, I haven't found such a command. The commands I have found seem to return a single, non-specific error code, which could indicate anything, and they're prone to failure for a variety of reasons.
I only care about Windows 7, though support of earlier operating systems would be nice.
|
2011/11/02
|
[
"https://Stackoverflow.com/questions/7985755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/604049/"
] |
Works for Win7 Enterprise and Win10 Enterprise
```
@if DEFINED SESSIONNAME (
@echo.
@echo You must right click to "Run as administrator"
@echo Try again
@echo.
@pause
@goto :EOF
)
```
|
Thanks Torin Darkflight,
Your method is the only one that work for me on Windows 11.
Here's an example script expanding on your post:
```
IF EXIST %SYSTEMROOT%\SYSTEM32\WDI\LOGFILES GOTO :Running_As_An_Admin
ECHO You are NOT an Administrator. This command requires admin rights. & Echo: & Echo Quitting......
@TIMEOUT /T 10
goto :QUIT
:Running_As_An_Admin
Echo Do Admin stuff here!!!
:QUIT
```
|
7,985,755 |
From inside a batch file, I would like to test whether I'm running with Administrator/elevated privileges.
The username doesn't change when "Run as Administrator" is selected, so that doesn't work.
If there were a universally available command, which has no effect, but requires administrative privileges, then I could run that and check for an error code in order to test for privileges. So far, I haven't found such a command. The commands I have found seem to return a single, non-specific error code, which could indicate anything, and they're prone to failure for a variety of reasons.
I only care about Windows 7, though support of earlier operating systems would be nice.
|
2011/11/02
|
[
"https://Stackoverflow.com/questions/7985755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/604049/"
] |
the solution:
```
at >nul
if %ErrorLevel% equ 0 ( echo Administrator ) else ( echo NOT Administrator )
```
does not work under Windows 10
for all versions of Windows can be do so:
```
openfiles >nul 2>&1
if %ErrorLevel% equ 0 ( echo Administrator ) else ( echo NOT Administrator )
```
|
A "not-a-one-liner" version of <https://stackoverflow.com/a/38856823/2193477>
```
@echo off
net.exe session 1>NUL 2>NUL || goto :not_admin
echo SUCCESS
goto :eof
:not_admin
echo ERROR: Please run as a local administrator.
exit /b 1
```
|
3,733,648 |
There are many papers about ranged combat artificial intelligences, like Killzones's ([see this paper](http://www.cgf-ai.com/docs/straatman_remco_killzone_ai.pdf "Killzone")), or Halo. But I've not been able to find much about a fighting IA except for this [work](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.116.592&rep=rep1&type=pdf "Learning to Fight"), which uses neural networs to learn how to fight, which is not exactly what I'm looking for.
Occidental AI in games is heavily focused on FPS, it seems! Does anyone know which techniques are used to implement a decent fighting AI? Hierarchical Finite State Machines? Decision Trees? They could end up being pretty predictable.
|
2010/09/17
|
[
"https://Stackoverflow.com/questions/3733648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/448401/"
] |
In our research labs, we are using AI planning technology for games. AI Planning is used by NASA to build semi-autonomous robots. Planning can produce less predictable behavior than state machines, but planning is a highly complex problem, that is, solving planning problems has a huge computational complexity.
AI Planning is an old but interesting field. Particularly for gaming only recently people have started using planning to run their engines. The expressiveness is still limited in the current implementations, but in theory the expressiveness is limited "only by our imagination".
Russel and Norvig have devoted 4 chapters on AI Planning in their book on Artificial Intelligence. Other related terms you might be interested in are: Markov Decision Processes, Bayesian Networks. These topics are also provided sufficient exposure in this book.
If you are looking for some ready-made engine to easily start using, I guess using AI Planning would be a gross overkill. I don't know of any AI Planning engine for games but we are developing one. If you are interested in the long term, we can talk separately about it.
|
You seem to know already the techniques for planning and executing. Another thing that you need to do is predict the opponent's next move and maximize the expected reward of your response. I wrote a blog article about this: <http://www.masterbaboon.com/2009/05/my-ai-reads-your-mind-and-kicks-your-ass-part-2/> and <http://www.masterbaboon.com/2009/09/my-ai-reads-your-mind-extensions-part-3/> . The game I consider is *very* simple, but I think the main ideas from Bayesian decision theory might be useful for your project.
|
3,733,648 |
There are many papers about ranged combat artificial intelligences, like Killzones's ([see this paper](http://www.cgf-ai.com/docs/straatman_remco_killzone_ai.pdf "Killzone")), or Halo. But I've not been able to find much about a fighting IA except for this [work](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.116.592&rep=rep1&type=pdf "Learning to Fight"), which uses neural networs to learn how to fight, which is not exactly what I'm looking for.
Occidental AI in games is heavily focused on FPS, it seems! Does anyone know which techniques are used to implement a decent fighting AI? Hierarchical Finite State Machines? Decision Trees? They could end up being pretty predictable.
|
2010/09/17
|
[
"https://Stackoverflow.com/questions/3733648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/448401/"
] |
In our research labs, we are using AI planning technology for games. AI Planning is used by NASA to build semi-autonomous robots. Planning can produce less predictable behavior than state machines, but planning is a highly complex problem, that is, solving planning problems has a huge computational complexity.
AI Planning is an old but interesting field. Particularly for gaming only recently people have started using planning to run their engines. The expressiveness is still limited in the current implementations, but in theory the expressiveness is limited "only by our imagination".
Russel and Norvig have devoted 4 chapters on AI Planning in their book on Artificial Intelligence. Other related terms you might be interested in are: Markov Decision Processes, Bayesian Networks. These topics are also provided sufficient exposure in this book.
If you are looking for some ready-made engine to easily start using, I guess using AI Planning would be a gross overkill. I don't know of any AI Planning engine for games but we are developing one. If you are interested in the long term, we can talk separately about it.
|
Another route to consider is the so called `Ghost AI` as described [here](http://www.cp.eng.chula.ac.th/~vishnu/gameProg/papers/wpj_vishnu07.pdf) & [here](http://www.cp.eng.chula.ac.th/~vishnu/gameProg/papers/CGAT_Real%20Time%20Imitaion%20Based%20Learning.pdf). As the name suggests you basically extract rules from actual game play, first paper does it offline and the second extends the methodology for online real time learning.
Check out also the guy's [webpage](http://www.cp.eng.chula.ac.th/~vishnu/), there are a number of other papers on fighting games that are interesting.
|
3,733,648 |
There are many papers about ranged combat artificial intelligences, like Killzones's ([see this paper](http://www.cgf-ai.com/docs/straatman_remco_killzone_ai.pdf "Killzone")), or Halo. But I've not been able to find much about a fighting IA except for this [work](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.116.592&rep=rep1&type=pdf "Learning to Fight"), which uses neural networs to learn how to fight, which is not exactly what I'm looking for.
Occidental AI in games is heavily focused on FPS, it seems! Does anyone know which techniques are used to implement a decent fighting AI? Hierarchical Finite State Machines? Decision Trees? They could end up being pretty predictable.
|
2010/09/17
|
[
"https://Stackoverflow.com/questions/3733648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/448401/"
] |
In our research labs, we are using AI planning technology for games. AI Planning is used by NASA to build semi-autonomous robots. Planning can produce less predictable behavior than state machines, but planning is a highly complex problem, that is, solving planning problems has a huge computational complexity.
AI Planning is an old but interesting field. Particularly for gaming only recently people have started using planning to run their engines. The expressiveness is still limited in the current implementations, but in theory the expressiveness is limited "only by our imagination".
Russel and Norvig have devoted 4 chapters on AI Planning in their book on Artificial Intelligence. Other related terms you might be interested in are: Markov Decision Processes, Bayesian Networks. These topics are also provided sufficient exposure in this book.
If you are looking for some ready-made engine to easily start using, I guess using AI Planning would be a gross overkill. I don't know of any AI Planning engine for games but we are developing one. If you are interested in the long term, we can talk separately about it.
|
I have reverse engineered the routines related to the AI subsystem within the Street Figher II series of games. It does not incorporate any of the techniques mentioned above. It is entirely reactive and involves no planning, learning or goals. Interestingly, there is no "technique weight" system that you mention, either. They don't use global weights for decisions to decide the frequency of attack versus block, for example. When taking apart the routines related to how "difficulty" is made to seem to increase, I did expect to find something like that. Alas, it relates to a number of smaller decisions that could potentially affect those ratios in an emergent way.
|
3,733,648 |
There are many papers about ranged combat artificial intelligences, like Killzones's ([see this paper](http://www.cgf-ai.com/docs/straatman_remco_killzone_ai.pdf "Killzone")), or Halo. But I've not been able to find much about a fighting IA except for this [work](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.116.592&rep=rep1&type=pdf "Learning to Fight"), which uses neural networs to learn how to fight, which is not exactly what I'm looking for.
Occidental AI in games is heavily focused on FPS, it seems! Does anyone know which techniques are used to implement a decent fighting AI? Hierarchical Finite State Machines? Decision Trees? They could end up being pretty predictable.
|
2010/09/17
|
[
"https://Stackoverflow.com/questions/3733648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/448401/"
] |
In our research labs, we are using AI planning technology for games. AI Planning is used by NASA to build semi-autonomous robots. Planning can produce less predictable behavior than state machines, but planning is a highly complex problem, that is, solving planning problems has a huge computational complexity.
AI Planning is an old but interesting field. Particularly for gaming only recently people have started using planning to run their engines. The expressiveness is still limited in the current implementations, but in theory the expressiveness is limited "only by our imagination".
Russel and Norvig have devoted 4 chapters on AI Planning in their book on Artificial Intelligence. Other related terms you might be interested in are: Markov Decision Processes, Bayesian Networks. These topics are also provided sufficient exposure in this book.
If you are looking for some ready-made engine to easily start using, I guess using AI Planning would be a gross overkill. I don't know of any AI Planning engine for games but we are developing one. If you are interested in the long term, we can talk separately about it.
|
<http://www.ice.ci.ritsumei.ac.jp/~ftgaic/index-R.html>
its old but here are some examples
|
3,733,648 |
There are many papers about ranged combat artificial intelligences, like Killzones's ([see this paper](http://www.cgf-ai.com/docs/straatman_remco_killzone_ai.pdf "Killzone")), or Halo. But I've not been able to find much about a fighting IA except for this [work](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.116.592&rep=rep1&type=pdf "Learning to Fight"), which uses neural networs to learn how to fight, which is not exactly what I'm looking for.
Occidental AI in games is heavily focused on FPS, it seems! Does anyone know which techniques are used to implement a decent fighting AI? Hierarchical Finite State Machines? Decision Trees? They could end up being pretty predictable.
|
2010/09/17
|
[
"https://Stackoverflow.com/questions/3733648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/448401/"
] |
You seem to know already the techniques for planning and executing. Another thing that you need to do is predict the opponent's next move and maximize the expected reward of your response. I wrote a blog article about this: <http://www.masterbaboon.com/2009/05/my-ai-reads-your-mind-and-kicks-your-ass-part-2/> and <http://www.masterbaboon.com/2009/09/my-ai-reads-your-mind-extensions-part-3/> . The game I consider is *very* simple, but I think the main ideas from Bayesian decision theory might be useful for your project.
|
Another route to consider is the so called `Ghost AI` as described [here](http://www.cp.eng.chula.ac.th/~vishnu/gameProg/papers/wpj_vishnu07.pdf) & [here](http://www.cp.eng.chula.ac.th/~vishnu/gameProg/papers/CGAT_Real%20Time%20Imitaion%20Based%20Learning.pdf). As the name suggests you basically extract rules from actual game play, first paper does it offline and the second extends the methodology for online real time learning.
Check out also the guy's [webpage](http://www.cp.eng.chula.ac.th/~vishnu/), there are a number of other papers on fighting games that are interesting.
|
3,733,648 |
There are many papers about ranged combat artificial intelligences, like Killzones's ([see this paper](http://www.cgf-ai.com/docs/straatman_remco_killzone_ai.pdf "Killzone")), or Halo. But I've not been able to find much about a fighting IA except for this [work](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.116.592&rep=rep1&type=pdf "Learning to Fight"), which uses neural networs to learn how to fight, which is not exactly what I'm looking for.
Occidental AI in games is heavily focused on FPS, it seems! Does anyone know which techniques are used to implement a decent fighting AI? Hierarchical Finite State Machines? Decision Trees? They could end up being pretty predictable.
|
2010/09/17
|
[
"https://Stackoverflow.com/questions/3733648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/448401/"
] |
You seem to know already the techniques for planning and executing. Another thing that you need to do is predict the opponent's next move and maximize the expected reward of your response. I wrote a blog article about this: <http://www.masterbaboon.com/2009/05/my-ai-reads-your-mind-and-kicks-your-ass-part-2/> and <http://www.masterbaboon.com/2009/09/my-ai-reads-your-mind-extensions-part-3/> . The game I consider is *very* simple, but I think the main ideas from Bayesian decision theory might be useful for your project.
|
<http://www.ice.ci.ritsumei.ac.jp/~ftgaic/index-R.html>
its old but here are some examples
|
3,733,648 |
There are many papers about ranged combat artificial intelligences, like Killzones's ([see this paper](http://www.cgf-ai.com/docs/straatman_remco_killzone_ai.pdf "Killzone")), or Halo. But I've not been able to find much about a fighting IA except for this [work](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.116.592&rep=rep1&type=pdf "Learning to Fight"), which uses neural networs to learn how to fight, which is not exactly what I'm looking for.
Occidental AI in games is heavily focused on FPS, it seems! Does anyone know which techniques are used to implement a decent fighting AI? Hierarchical Finite State Machines? Decision Trees? They could end up being pretty predictable.
|
2010/09/17
|
[
"https://Stackoverflow.com/questions/3733648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/448401/"
] |
I have reverse engineered the routines related to the AI subsystem within the Street Figher II series of games. It does not incorporate any of the techniques mentioned above. It is entirely reactive and involves no planning, learning or goals. Interestingly, there is no "technique weight" system that you mention, either. They don't use global weights for decisions to decide the frequency of attack versus block, for example. When taking apart the routines related to how "difficulty" is made to seem to increase, I did expect to find something like that. Alas, it relates to a number of smaller decisions that could potentially affect those ratios in an emergent way.
|
Another route to consider is the so called `Ghost AI` as described [here](http://www.cp.eng.chula.ac.th/~vishnu/gameProg/papers/wpj_vishnu07.pdf) & [here](http://www.cp.eng.chula.ac.th/~vishnu/gameProg/papers/CGAT_Real%20Time%20Imitaion%20Based%20Learning.pdf). As the name suggests you basically extract rules from actual game play, first paper does it offline and the second extends the methodology for online real time learning.
Check out also the guy's [webpage](http://www.cp.eng.chula.ac.th/~vishnu/), there are a number of other papers on fighting games that are interesting.
|
3,733,648 |
There are many papers about ranged combat artificial intelligences, like Killzones's ([see this paper](http://www.cgf-ai.com/docs/straatman_remco_killzone_ai.pdf "Killzone")), or Halo. But I've not been able to find much about a fighting IA except for this [work](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.116.592&rep=rep1&type=pdf "Learning to Fight"), which uses neural networs to learn how to fight, which is not exactly what I'm looking for.
Occidental AI in games is heavily focused on FPS, it seems! Does anyone know which techniques are used to implement a decent fighting AI? Hierarchical Finite State Machines? Decision Trees? They could end up being pretty predictable.
|
2010/09/17
|
[
"https://Stackoverflow.com/questions/3733648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/448401/"
] |
Another route to consider is the so called `Ghost AI` as described [here](http://www.cp.eng.chula.ac.th/~vishnu/gameProg/papers/wpj_vishnu07.pdf) & [here](http://www.cp.eng.chula.ac.th/~vishnu/gameProg/papers/CGAT_Real%20Time%20Imitaion%20Based%20Learning.pdf). As the name suggests you basically extract rules from actual game play, first paper does it offline and the second extends the methodology for online real time learning.
Check out also the guy's [webpage](http://www.cp.eng.chula.ac.th/~vishnu/), there are a number of other papers on fighting games that are interesting.
|
<http://www.ice.ci.ritsumei.ac.jp/~ftgaic/index-R.html>
its old but here are some examples
|
3,733,648 |
There are many papers about ranged combat artificial intelligences, like Killzones's ([see this paper](http://www.cgf-ai.com/docs/straatman_remco_killzone_ai.pdf "Killzone")), or Halo. But I've not been able to find much about a fighting IA except for this [work](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.116.592&rep=rep1&type=pdf "Learning to Fight"), which uses neural networs to learn how to fight, which is not exactly what I'm looking for.
Occidental AI in games is heavily focused on FPS, it seems! Does anyone know which techniques are used to implement a decent fighting AI? Hierarchical Finite State Machines? Decision Trees? They could end up being pretty predictable.
|
2010/09/17
|
[
"https://Stackoverflow.com/questions/3733648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/448401/"
] |
I have reverse engineered the routines related to the AI subsystem within the Street Figher II series of games. It does not incorporate any of the techniques mentioned above. It is entirely reactive and involves no planning, learning or goals. Interestingly, there is no "technique weight" system that you mention, either. They don't use global weights for decisions to decide the frequency of attack versus block, for example. When taking apart the routines related to how "difficulty" is made to seem to increase, I did expect to find something like that. Alas, it relates to a number of smaller decisions that could potentially affect those ratios in an emergent way.
|
<http://www.ice.ci.ritsumei.ac.jp/~ftgaic/index-R.html>
its old but here are some examples
|
48,374,136 |
My SQLite database stores location data as `latitude` and `longitude` values. I will frequently have to query the database using the following query:
```
SELECT * FROM locations WHERE latitude > 22.2 && latitude < 22.3 && longitude > 50.7 && longitude < 50.8
```
Would a multi-column index on the `latitude` and then the `longitude` help to speed up the queries? [This answer](https://stackoverflow.com/a/799372/1111252) provides the way the query can be carried out with a multi-column index, but the comment accompanying it mentions that it will not work in SQLite.
|
2018/01/22
|
[
"https://Stackoverflow.com/questions/48374136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1111252/"
] |
A2:
```
=ARRAYFORMULA("201800"&text(ROW(A$1:INDEX(B:B,COUNTA(B:B)-1)),"00"))
```
|
You can use formula like this in the 1st Column
```
=if(EQ(B2,),"", A1+1)
```
This will check if column 2 is empty or not if, it isn't then it'll set value of cell just above it plus one.
NOTE : For 1st cell you'll need to set value 20180001 manually and apply this formula to rest of the whole column one cells.
|
48,374,136 |
My SQLite database stores location data as `latitude` and `longitude` values. I will frequently have to query the database using the following query:
```
SELECT * FROM locations WHERE latitude > 22.2 && latitude < 22.3 && longitude > 50.7 && longitude < 50.8
```
Would a multi-column index on the `latitude` and then the `longitude` help to speed up the queries? [This answer](https://stackoverflow.com/a/799372/1111252) provides the way the query can be carried out with a multi-column index, but the comment accompanying it mentions that it will not work in SQLite.
|
2018/01/22
|
[
"https://Stackoverflow.com/questions/48374136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1111252/"
] |
A2:
```
=ARRAYFORMULA("201800"&text(ROW(A$1:INDEX(B:B,COUNTA(B:B)-1)),"00"))
```
|
With *2018* hardcoded in,
```
=text(row(1:1), "\2\0\1\80000")
```
Using the date from column B,
```
=year(B2)&text(COUNTIFS(B$2:B2, ">="&date(year(B2), 1, 1), B$2:B2, "<"&date(year(B2)+1, 1, 1)), "0000")
```
|
35,631,333 |
I am trying to stream a song using SoundCloud api, but apprantly it does not play it in Chrome. However it works on other browsers.
```
SC.initialize({
client_id: '65243ec784b284f1d8a8f950312240fa',
redirect_uri: 'http://example.com/callback'
});
SC.stream('/tracks/293').then(function(player) {
player.play();
});
```
[JSFIDDLE](https://jsfiddle.net/tqmswevp/)
Any idea to make it working in Chrome?
|
2016/02/25
|
[
"https://Stackoverflow.com/questions/35631333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5920683/"
] |
see my solution on the [open Github issue](https://github.com/soundcloud/soundcloud-javascript/issues/39) (code pasted below for convenience).
If you use SoundManager2, then call setup when the dom is ready.
Rather than using the stream function of the SoundCloud api, call SC.get and then create a soundobject in SoundManager using `createSound()`, passing in the stream\_url from the track that you just grabbed.
```
SC.get('/users/711016/tracks').then(function(tracks) {
var sound = soundManager.createSound({
id: 'mySound',
url: tracks[0].stream_url + "?client_id=YOUR_CLIENT_ID",
stream: true
});
sound.play();
});
```
I imagine the api route to the track(s) you are trying to play may be different than mine.
|
This is a [known compatibility issue](https://github.com/soundcloud/soundcloud-javascript/issues/39) due to Chrome's version of Flash. There is little you can do besides disable Flash or play with the different versions of the SDK to see which one works for your specific build of Chrome.
|
35,631,333 |
I am trying to stream a song using SoundCloud api, but apprantly it does not play it in Chrome. However it works on other browsers.
```
SC.initialize({
client_id: '65243ec784b284f1d8a8f950312240fa',
redirect_uri: 'http://example.com/callback'
});
SC.stream('/tracks/293').then(function(player) {
player.play();
});
```
[JSFIDDLE](https://jsfiddle.net/tqmswevp/)
Any idea to make it working in Chrome?
|
2016/02/25
|
[
"https://Stackoverflow.com/questions/35631333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5920683/"
] |
see my solution on the [open Github issue](https://github.com/soundcloud/soundcloud-javascript/issues/39) (code pasted below for convenience).
If you use SoundManager2, then call setup when the dom is ready.
Rather than using the stream function of the SoundCloud api, call SC.get and then create a soundobject in SoundManager using `createSound()`, passing in the stream\_url from the track that you just grabbed.
```
SC.get('/users/711016/tracks').then(function(tracks) {
var sound = soundManager.createSound({
id: 'mySound',
url: tracks[0].stream_url + "?client_id=YOUR_CLIENT_ID",
stream: true
});
sound.play();
});
```
I imagine the api route to the track(s) you are trying to play may be different than mine.
|
As JAL said, this is unfortunately known and there doesn't seem to be a fix out there.
Instead what I would suggest doing is using their widget API to create a custom iFrame (you can make it invisible if you want), and then use the `.load()` method to load whichever track, or tracks you want. You can read about that [here](https://developers.soundcloud.com/docs/api/html5-widget#methods).
The widget API is really nice because it comes with a bunch of event listeners that are very helpful, depending on what you're doing.
|
7,232 |
For all you freelancers out there...
What system do you guys use to keep track of how long a project takes you? I'm currently a 9-5er, but would much prefer to go freelance. To whit, I've got my first hourly gig coming up, and I want to make sure I'm not ripping either them or myself off. I met a guy once who told me that if he works on anything at all (even for an hour) he calls it a day, or at least 3-4 hours (like plumbers and locksmiths). That always seemed kinda shitty to me, but for all I know it's the norm.
I've got a little countdown timer guy that I use when I know I've got a time limit, i.e. I'm grabbing a couple hours of work in between the waves of action that life pushes my way. The problem is that it's notification plays out my compy's main audio outs, and I have my interface switched to software return 7/8 so I sometimes don't notice.
Also, how do you figure out your rates? I know that most of the time it depends on the project budget and other concerns, but do you have a particular calculation method? I was once told to take the amount I'd need to get by if I was doing 40 hours a week, then double it. Is that a fair ask?
Friendliness.
|
2011/04/10
|
[
"https://sound.stackexchange.com/questions/7232",
"https://sound.stackexchange.com",
"https://sound.stackexchange.com/users/845/"
] |
I work with a day / half-day rate system.
Anything that takes me up to 5 hours, I charge half-day. 6 - 10 hours, full day rate. After 10 hours, I sometimes charge a little extra, but not always - it depends on how intense those 12 hours will be...
Generally my half-day rate is somewhere around 3/4 of my full day. For instance, if my day rate was $1000, I might charge between $600 and $750 for a half-day - again, depending on my responsibilities on the project.
If a project comes my way that I know is only going to take an hour or two and will be really easy, I will occasionally negotiate a lower rate than my half-day, but not always. The reason being that if I take a 2 hour long project, chances are I won't be able to book another gig that day - maybe not even a half-day project, so I won't be able to make up the money elsewhere. Essentially, even though it's not taking up all that time, it's still "taking up" the time. A lot of that goes out the window if you're making up your own schedule and not working on a pre-planned production's schedule.
Again, I use discretion. If I know a project really has a tight budget and I want to help them out, I will - as long as I can still pay my bills.
I never work on an hourly schedule, but I know people that do. A lot of my colleagues will use Filemaker Pro or Mac Freelance (or other project management software - Bento is another) to track hours. Works pretty well for them, but you have to make sure to be aware of the clock and not forget to pause it! Something I can see myself forgetting to do...
|
I'm normally on a project for X weeks (16-26) where a week = 50 hours.... only very occasionally do I do hourly rate (eg prepping a trailer) but its fairly rare. My rate varies with scale and budget of the project. I've seen editors who whine if their 'usual' rate gets reduced, but they fail to take into consideration that they may be asking for a higher rate than everyone else on the team, including the DOP and picture editor! But we aren't union in NZ (thank god/jah/buddha) and never will be.
|
7,232 |
For all you freelancers out there...
What system do you guys use to keep track of how long a project takes you? I'm currently a 9-5er, but would much prefer to go freelance. To whit, I've got my first hourly gig coming up, and I want to make sure I'm not ripping either them or myself off. I met a guy once who told me that if he works on anything at all (even for an hour) he calls it a day, or at least 3-4 hours (like plumbers and locksmiths). That always seemed kinda shitty to me, but for all I know it's the norm.
I've got a little countdown timer guy that I use when I know I've got a time limit, i.e. I'm grabbing a couple hours of work in between the waves of action that life pushes my way. The problem is that it's notification plays out my compy's main audio outs, and I have my interface switched to software return 7/8 so I sometimes don't notice.
Also, how do you figure out your rates? I know that most of the time it depends on the project budget and other concerns, but do you have a particular calculation method? I was once told to take the amount I'd need to get by if I was doing 40 hours a week, then double it. Is that a fair ask?
Friendliness.
|
2011/04/10
|
[
"https://sound.stackexchange.com/questions/7232",
"https://sound.stackexchange.com",
"https://sound.stackexchange.com/users/845/"
] |
I work with a day / half-day rate system.
Anything that takes me up to 5 hours, I charge half-day. 6 - 10 hours, full day rate. After 10 hours, I sometimes charge a little extra, but not always - it depends on how intense those 12 hours will be...
Generally my half-day rate is somewhere around 3/4 of my full day. For instance, if my day rate was $1000, I might charge between $600 and $750 for a half-day - again, depending on my responsibilities on the project.
If a project comes my way that I know is only going to take an hour or two and will be really easy, I will occasionally negotiate a lower rate than my half-day, but not always. The reason being that if I take a 2 hour long project, chances are I won't be able to book another gig that day - maybe not even a half-day project, so I won't be able to make up the money elsewhere. Essentially, even though it's not taking up all that time, it's still "taking up" the time. A lot of that goes out the window if you're making up your own schedule and not working on a pre-planned production's schedule.
Again, I use discretion. If I know a project really has a tight budget and I want to help them out, I will - as long as I can still pay my bills.
I never work on an hourly schedule, but I know people that do. A lot of my colleagues will use Filemaker Pro or Mac Freelance (or other project management software - Bento is another) to track hours. Works pretty well for them, but you have to make sure to be aware of the clock and not forget to pause it! Something I can see myself forgetting to do...
|
I agree with Azimuth. Flexibility can keep clients coming back.
Some clients I work with really need an hourly rate. Others I may take on at a project rate with stipulations in contract form at the beginning as to how far over the estimate time they can go before additional charges will apply.
I have also done a half day and full day rate system. For most, I do 24 hour cancellation minimums unless they move the project to an unbooked alternate date. I have had seasons where I will give client "A" a first hold on my time without any obligation but will require full payment whether they cancel or not if that time was challenged and requested by a client "B" and they (client "A") opted to keep that time firmly available to them.
It all depends on the project's/client's needs. The most important thing is to communicate clearly. I always like to discuss their project's needs and vision first, talk about what we both need in order to work together, and put it in writing. It protects the both of you. Communication is key and every project is different.
As far as determining your actual rate, consider the job and compare it to the services available in your area for similar gear access, skill, and experience. Talk to your buddies. You want to come up with a rate that is fair to you, the client, and the market. You don't want to go around undercutting the world all the time. This will just bring down the value of the service and it will make it harder for everyone to make a living.
|
7,232 |
For all you freelancers out there...
What system do you guys use to keep track of how long a project takes you? I'm currently a 9-5er, but would much prefer to go freelance. To whit, I've got my first hourly gig coming up, and I want to make sure I'm not ripping either them or myself off. I met a guy once who told me that if he works on anything at all (even for an hour) he calls it a day, or at least 3-4 hours (like plumbers and locksmiths). That always seemed kinda shitty to me, but for all I know it's the norm.
I've got a little countdown timer guy that I use when I know I've got a time limit, i.e. I'm grabbing a couple hours of work in between the waves of action that life pushes my way. The problem is that it's notification plays out my compy's main audio outs, and I have my interface switched to software return 7/8 so I sometimes don't notice.
Also, how do you figure out your rates? I know that most of the time it depends on the project budget and other concerns, but do you have a particular calculation method? I was once told to take the amount I'd need to get by if I was doing 40 hours a week, then double it. Is that a fair ask?
Friendliness.
|
2011/04/10
|
[
"https://sound.stackexchange.com/questions/7232",
"https://sound.stackexchange.com",
"https://sound.stackexchange.com/users/845/"
] |
I find that there is no catch all answer that works in all situations. Like Colin mentions a good way to go is the Half day/full day billing system, the way Colin describes it is basically how I do it and this works well. On series work I normally charge per episode. In the first few episodes it normally takes longer to cut a show but once you have designed a lot of the signature elements the later episodes of a series become faster to cut since you have a better feel for the world the show takes place in. Finally for a few select clients I will charge by the hour, this is not ideal but sometimes it is the best option to make things work for both sides. If you do work by the hour make sure you have a minimum number of hours you will charge. You don't want to be going out for an hour of work as it will normally not be worth your time.
I find the main thing is to keep the communication lines open with the client and make sure you are both on the same page. Many clients have different projects with different budgets so if you can be flexible you can keep clients coming back.
In terms of rates - that is the trickiest part. Hard to offer advice with out knowing what what exactly you are charging for and what your experience level is. Are you using your own gear or going into a studio to do the work on their gear? SFX editing normally means you are bringing a SFX library to the project as part of your service and that library is an important asset, so normally you would charge more for SFX editing then for dialog or music editing where the client is supplying the material you will be working with. Are you doing any field recording? All these things can effect you rate, so again no one rate can rule them all.
|
I'm normally on a project for X weeks (16-26) where a week = 50 hours.... only very occasionally do I do hourly rate (eg prepping a trailer) but its fairly rare. My rate varies with scale and budget of the project. I've seen editors who whine if their 'usual' rate gets reduced, but they fail to take into consideration that they may be asking for a higher rate than everyone else on the team, including the DOP and picture editor! But we aren't union in NZ (thank god/jah/buddha) and never will be.
|
7,232 |
For all you freelancers out there...
What system do you guys use to keep track of how long a project takes you? I'm currently a 9-5er, but would much prefer to go freelance. To whit, I've got my first hourly gig coming up, and I want to make sure I'm not ripping either them or myself off. I met a guy once who told me that if he works on anything at all (even for an hour) he calls it a day, or at least 3-4 hours (like plumbers and locksmiths). That always seemed kinda shitty to me, but for all I know it's the norm.
I've got a little countdown timer guy that I use when I know I've got a time limit, i.e. I'm grabbing a couple hours of work in between the waves of action that life pushes my way. The problem is that it's notification plays out my compy's main audio outs, and I have my interface switched to software return 7/8 so I sometimes don't notice.
Also, how do you figure out your rates? I know that most of the time it depends on the project budget and other concerns, but do you have a particular calculation method? I was once told to take the amount I'd need to get by if I was doing 40 hours a week, then double it. Is that a fair ask?
Friendliness.
|
2011/04/10
|
[
"https://sound.stackexchange.com/questions/7232",
"https://sound.stackexchange.com",
"https://sound.stackexchange.com/users/845/"
] |
I find that there is no catch all answer that works in all situations. Like Colin mentions a good way to go is the Half day/full day billing system, the way Colin describes it is basically how I do it and this works well. On series work I normally charge per episode. In the first few episodes it normally takes longer to cut a show but once you have designed a lot of the signature elements the later episodes of a series become faster to cut since you have a better feel for the world the show takes place in. Finally for a few select clients I will charge by the hour, this is not ideal but sometimes it is the best option to make things work for both sides. If you do work by the hour make sure you have a minimum number of hours you will charge. You don't want to be going out for an hour of work as it will normally not be worth your time.
I find the main thing is to keep the communication lines open with the client and make sure you are both on the same page. Many clients have different projects with different budgets so if you can be flexible you can keep clients coming back.
In terms of rates - that is the trickiest part. Hard to offer advice with out knowing what what exactly you are charging for and what your experience level is. Are you using your own gear or going into a studio to do the work on their gear? SFX editing normally means you are bringing a SFX library to the project as part of your service and that library is an important asset, so normally you would charge more for SFX editing then for dialog or music editing where the client is supplying the material you will be working with. Are you doing any field recording? All these things can effect you rate, so again no one rate can rule them all.
|
I agree with Azimuth. Flexibility can keep clients coming back.
Some clients I work with really need an hourly rate. Others I may take on at a project rate with stipulations in contract form at the beginning as to how far over the estimate time they can go before additional charges will apply.
I have also done a half day and full day rate system. For most, I do 24 hour cancellation minimums unless they move the project to an unbooked alternate date. I have had seasons where I will give client "A" a first hold on my time without any obligation but will require full payment whether they cancel or not if that time was challenged and requested by a client "B" and they (client "A") opted to keep that time firmly available to them.
It all depends on the project's/client's needs. The most important thing is to communicate clearly. I always like to discuss their project's needs and vision first, talk about what we both need in order to work together, and put it in writing. It protects the both of you. Communication is key and every project is different.
As far as determining your actual rate, consider the job and compare it to the services available in your area for similar gear access, skill, and experience. Talk to your buddies. You want to come up with a rate that is fair to you, the client, and the market. You don't want to go around undercutting the world all the time. This will just bring down the value of the service and it will make it harder for everyone to make a living.
|
7,232 |
For all you freelancers out there...
What system do you guys use to keep track of how long a project takes you? I'm currently a 9-5er, but would much prefer to go freelance. To whit, I've got my first hourly gig coming up, and I want to make sure I'm not ripping either them or myself off. I met a guy once who told me that if he works on anything at all (even for an hour) he calls it a day, or at least 3-4 hours (like plumbers and locksmiths). That always seemed kinda shitty to me, but for all I know it's the norm.
I've got a little countdown timer guy that I use when I know I've got a time limit, i.e. I'm grabbing a couple hours of work in between the waves of action that life pushes my way. The problem is that it's notification plays out my compy's main audio outs, and I have my interface switched to software return 7/8 so I sometimes don't notice.
Also, how do you figure out your rates? I know that most of the time it depends on the project budget and other concerns, but do you have a particular calculation method? I was once told to take the amount I'd need to get by if I was doing 40 hours a week, then double it. Is that a fair ask?
Friendliness.
|
2011/04/10
|
[
"https://sound.stackexchange.com/questions/7232",
"https://sound.stackexchange.com",
"https://sound.stackexchange.com/users/845/"
] |
I'm normally on a project for X weeks (16-26) where a week = 50 hours.... only very occasionally do I do hourly rate (eg prepping a trailer) but its fairly rare. My rate varies with scale and budget of the project. I've seen editors who whine if their 'usual' rate gets reduced, but they fail to take into consideration that they may be asking for a higher rate than everyone else on the team, including the DOP and picture editor! But we aren't union in NZ (thank god/jah/buddha) and never will be.
|
I agree with Azimuth. Flexibility can keep clients coming back.
Some clients I work with really need an hourly rate. Others I may take on at a project rate with stipulations in contract form at the beginning as to how far over the estimate time they can go before additional charges will apply.
I have also done a half day and full day rate system. For most, I do 24 hour cancellation minimums unless they move the project to an unbooked alternate date. I have had seasons where I will give client "A" a first hold on my time without any obligation but will require full payment whether they cancel or not if that time was challenged and requested by a client "B" and they (client "A") opted to keep that time firmly available to them.
It all depends on the project's/client's needs. The most important thing is to communicate clearly. I always like to discuss their project's needs and vision first, talk about what we both need in order to work together, and put it in writing. It protects the both of you. Communication is key and every project is different.
As far as determining your actual rate, consider the job and compare it to the services available in your area for similar gear access, skill, and experience. Talk to your buddies. You want to come up with a rate that is fair to you, the client, and the market. You don't want to go around undercutting the world all the time. This will just bring down the value of the service and it will make it harder for everyone to make a living.
|
9,716,073 |
I have .Net 3.5 WinForms application that require access to the Internet. But my company network uses dynamic proxy settings shown below. All my attempts to retrieve and use this setting got fail.
How to use this proxy in .net application?

|
2012/03/15
|
[
"https://Stackoverflow.com/questions/9716073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/425049/"
] |
Please go through the following link: <http://msdn.microsoft.com/en-us/magazine/cc300743.aspx>
|
By default the .NET framework will use whatever proxy settings setup on the local machine. So what you asked should be done automatically.
Check DefaultProxy setting in your config file .
<http://msdn.microsoft.com/en-us/library/kd3cf2ex%28v=vs.90%29.aspx>
|
9,716,073 |
I have .Net 3.5 WinForms application that require access to the Internet. But my company network uses dynamic proxy settings shown below. All my attempts to retrieve and use this setting got fail.
How to use this proxy in .net application?

|
2012/03/15
|
[
"https://Stackoverflow.com/questions/9716073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/425049/"
] |
Please go through the following link: <http://msdn.microsoft.com/en-us/magazine/cc300743.aspx>
|
But default every HttpWebRequest should automatically be filled out with this information.
See [C# Getting proxy settings from Internet Explorer](https://stackoverflow.com/questions/8808052/c-sharp-getting-proxy-settings-from-internet-explorer)
|
3,678,334 |
I have some 'spaghetti'-style code that is generously saused with Custom tags and Stored procedures calls. Templates include each other, custom tags nested and stored procedures are callind other stored procedures in their place.
Problem is that one template call is hanging somewhere in between. I cannot get any error out and cannot see debug output. What is best way to debug such 'hanging' request with as much detail as possible ?
Thanks!
|
2010/09/09
|
[
"https://Stackoverflow.com/questions/3678334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91088/"
] |
If you are using CF 8+, you can use the Step Debugging tools in Eclipse to step through the code: <http://www.adobe.com/devnet/coldfusion/articles/debugger.html>
If you are using an earlier version, you can use a 3rd party product like Fusion Debug ( <http://www.fusion-debug.com/fd/> ) to do the same thing.
If you are using CF8, you can also use the CF Admin Server Monitor to see where a thread is hanging as well: <http://www.adobe.com/devnet/coldfusion/articles/monitoring_pt1.html>
|
If the built-in debugger is of no use cause the request just hang the other quick way is to just start with a cfabort at the top and keep moving it down until you hit the file causing the request to hang.
|
3,678,334 |
I have some 'spaghetti'-style code that is generously saused with Custom tags and Stored procedures calls. Templates include each other, custom tags nested and stored procedures are callind other stored procedures in their place.
Problem is that one template call is hanging somewhere in between. I cannot get any error out and cannot see debug output. What is best way to debug such 'hanging' request with as much detail as possible ?
Thanks!
|
2010/09/09
|
[
"https://Stackoverflow.com/questions/3678334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91088/"
] |
If the built-in debugger is of no use cause the request just hang the other quick way is to just start with a cfabort at the top and keep moving it down until you hit the file causing the request to hang.
|
Have you looked at the standard coldfusion server log files to see what might be in there?
Have you run the server in a console window so you can see what is appearing in the console as the templates are running (or not as the case might be)?
|
3,678,334 |
I have some 'spaghetti'-style code that is generously saused with Custom tags and Stored procedures calls. Templates include each other, custom tags nested and stored procedures are callind other stored procedures in their place.
Problem is that one template call is hanging somewhere in between. I cannot get any error out and cannot see debug output. What is best way to debug such 'hanging' request with as much detail as possible ?
Thanks!
|
2010/09/09
|
[
"https://Stackoverflow.com/questions/3678334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91088/"
] |
If the built-in debugger is of no use cause the request just hang the other quick way is to just start with a cfabort at the top and keep moving it down until you hit the file causing the request to hang.
|
You could Take jvm thread dumps. You can do from command line or via server monitoring if you have Enterprise 8+
|
3,678,334 |
I have some 'spaghetti'-style code that is generously saused with Custom tags and Stored procedures calls. Templates include each other, custom tags nested and stored procedures are callind other stored procedures in their place.
Problem is that one template call is hanging somewhere in between. I cannot get any error out and cannot see debug output. What is best way to debug such 'hanging' request with as much detail as possible ?
Thanks!
|
2010/09/09
|
[
"https://Stackoverflow.com/questions/3678334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91088/"
] |
If you are using CF 8+, you can use the Step Debugging tools in Eclipse to step through the code: <http://www.adobe.com/devnet/coldfusion/articles/debugger.html>
If you are using an earlier version, you can use a 3rd party product like Fusion Debug ( <http://www.fusion-debug.com/fd/> ) to do the same thing.
If you are using CF8, you can also use the CF Admin Server Monitor to see where a thread is hanging as well: <http://www.adobe.com/devnet/coldfusion/articles/monitoring_pt1.html>
|
CFTrace is a great tool for this. It is native and reports time information as well.
|
3,678,334 |
I have some 'spaghetti'-style code that is generously saused with Custom tags and Stored procedures calls. Templates include each other, custom tags nested and stored procedures are callind other stored procedures in their place.
Problem is that one template call is hanging somewhere in between. I cannot get any error out and cannot see debug output. What is best way to debug such 'hanging' request with as much detail as possible ?
Thanks!
|
2010/09/09
|
[
"https://Stackoverflow.com/questions/3678334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91088/"
] |
If you are using CF 8+, you can use the Step Debugging tools in Eclipse to step through the code: <http://www.adobe.com/devnet/coldfusion/articles/debugger.html>
If you are using an earlier version, you can use a 3rd party product like Fusion Debug ( <http://www.fusion-debug.com/fd/> ) to do the same thing.
If you are using CF8, you can also use the CF Admin Server Monitor to see where a thread is hanging as well: <http://www.adobe.com/devnet/coldfusion/articles/monitoring_pt1.html>
|
Have you looked at the standard coldfusion server log files to see what might be in there?
Have you run the server in a console window so you can see what is appearing in the console as the templates are running (or not as the case might be)?
|
3,678,334 |
I have some 'spaghetti'-style code that is generously saused with Custom tags and Stored procedures calls. Templates include each other, custom tags nested and stored procedures are callind other stored procedures in their place.
Problem is that one template call is hanging somewhere in between. I cannot get any error out and cannot see debug output. What is best way to debug such 'hanging' request with as much detail as possible ?
Thanks!
|
2010/09/09
|
[
"https://Stackoverflow.com/questions/3678334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91088/"
] |
If you are using CF 8+, you can use the Step Debugging tools in Eclipse to step through the code: <http://www.adobe.com/devnet/coldfusion/articles/debugger.html>
If you are using an earlier version, you can use a 3rd party product like Fusion Debug ( <http://www.fusion-debug.com/fd/> ) to do the same thing.
If you are using CF8, you can also use the CF Admin Server Monitor to see where a thread is hanging as well: <http://www.adobe.com/devnet/coldfusion/articles/monitoring_pt1.html>
|
You could Take jvm thread dumps. You can do from command line or via server monitoring if you have Enterprise 8+
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.