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
|
---|---|---|---|---|---|
11,917,086 | I have created a JavaScript function which will return data containing 2 URL's. And I would like to insert these into the HTML code.
e.g. the return URL values are
JavsScript file
```
http://www.domain.com/javascript.js
```
CSS file
```
http://www.domain.com/buttons.css
```
I need to insert these into the code as:
```
<link rel="stylesheet" type="text/css" href="return URL value" />
<script type="text/javascript" src="return URL value"></script>
```
How can I do that?
Thanks | 2012/08/11 | [
"https://Stackoverflow.com/questions/11917086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/511666/"
]
| You can load external css (and also js) files dynamically using javascript. Just create the appropriate `<link>` element using javascript.
```
var url = computeUrl(); /* Obtain url */
var link = document.createElement('link'); /* Create the link element */
link.setAttribute('rel', 'stylesheet'); /* Set the rel attribute */
link.setAttribute('type', 'text/css'); /* Set the type attribute */
link.setAttribute('href', url); /* Set the href to your url */
```
At the moment, we have just created element
```
<link rel="stylesheet" type="text/css" href="your url">
```
And we have stored it in the variable `var link`. It is not over, the `<link>` is not part of the `DOM` yet.
We need to append it
```
var head = document.getElementsByTagName('head')[0]; /* Obtain the <head> element */
head.appendChild(link); /* Append link at the end of head */
```
And it is done.
In the very similar way, you can dynamically add external javascript resource. Just use `<script>` tag instead of `<link>` tag. | You can easily add nodes to the head element using javascript:
```
link=document.createElement('link');
link.href= your_css_href_function();
link.rel='stylesheet';
link.type='text/css';
document.getElementsByTagName('head')[0].appendChild(link);
```
And the same for your javascript tag:
```
script=document.createElement('script');
script.src= your_javascript_src_function();
script.type='text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);
``` |
24,041,113 | When I'm building, VS show error. This is my code:
```
public Composite buildComposite(ComboBox subs, ComboBox bas)
{
int count = 0;
Composite a = new Composite();
if (subs.SelectedItem != null)
{
foreach (Substance d in listSubstance)
{
if (String.Compare(d.notation, subs.Text) == 0)
{
count++;
a.subs = new Substance(d);
break;
}
}
}
if (bas.SelectedItem != null)
{
foreach (Base g in listBase)
{
if (String.Compare(g.notation, bas.Text) == 0)
{
count++;
a.bas = new Base(g);
break;
}
}
}
if (count > 0)
{
a.equilibrium();
a.settypesubs(arrayDefinition);
return a;
}
else
return null;
}
```
This is my error:
>
> Error 1 Inconsistent accessibility: return type 'Project\_HGHTM9.Composite' is less accessible than method 'Project\_HGHTM9.Form1.buildComposite(System.Windows.Forms.ComboBox, System.Windows.Forms.ComboBox)' c:\users\nguyen\documents\visual studio 2013\Projects\Project\_HGHTM9\Project\_HGHTM9\Form1.cs 172 26 Project\_HGHTM9
>
>
> | 2014/06/04 | [
"https://Stackoverflow.com/questions/24041113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3453838/"
]
| Your `Composite` class is not `public`. You can't return a non-public type from a public method.
If you don't specify an accessibility for a non-nested class then `internal` is used by default. Add `public` to your `Composite` class definition:
```
public class Composite
{
...
```
Alternatively, if `buildComposite` doesn't *need* to be `public` (meaning it's only used internally by the form), then you could make the method `private` or `internal` as well:
```
private Composite buildComposite(ComboBox subs, ComboBox bas)
{
....
``` | you are trying to return an instance of class `Composite` from a public method, but `Composite` is not public therefore can't be returned as any calling code cannot know anything about the `Composite` class as it cannot see it.
Make your `Composite` class public.
```
public class Composite{...}
```
or make your method which is returning your `Composite` have the same visibility as your class (probably private):
```
private Composite buildComposite(ComboBox subs, ComboBox bas)
```
Which of these is appropriate will depend on whether you need to call the method (or use the class) from outside your current assembly.
By default a class is usually as 'hidden' as it can be, so private for classes. Read more about the default visibility [here](https://stackoverflow.com/questions/3763612/default-visibility-for-c-sharp-classes-and-members-fields-methods-etc) |
24,041,113 | When I'm building, VS show error. This is my code:
```
public Composite buildComposite(ComboBox subs, ComboBox bas)
{
int count = 0;
Composite a = new Composite();
if (subs.SelectedItem != null)
{
foreach (Substance d in listSubstance)
{
if (String.Compare(d.notation, subs.Text) == 0)
{
count++;
a.subs = new Substance(d);
break;
}
}
}
if (bas.SelectedItem != null)
{
foreach (Base g in listBase)
{
if (String.Compare(g.notation, bas.Text) == 0)
{
count++;
a.bas = new Base(g);
break;
}
}
}
if (count > 0)
{
a.equilibrium();
a.settypesubs(arrayDefinition);
return a;
}
else
return null;
}
```
This is my error:
>
> Error 1 Inconsistent accessibility: return type 'Project\_HGHTM9.Composite' is less accessible than method 'Project\_HGHTM9.Form1.buildComposite(System.Windows.Forms.ComboBox, System.Windows.Forms.ComboBox)' c:\users\nguyen\documents\visual studio 2013\Projects\Project\_HGHTM9\Project\_HGHTM9\Form1.cs 172 26 Project\_HGHTM9
>
>
> | 2014/06/04 | [
"https://Stackoverflow.com/questions/24041113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3453838/"
]
| Your `Composite` class is not `public`. You can't return a non-public type from a public method.
If you don't specify an accessibility for a non-nested class then `internal` is used by default. Add `public` to your `Composite` class definition:
```
public class Composite
{
...
```
Alternatively, if `buildComposite` doesn't *need* to be `public` (meaning it's only used internally by the form), then you could make the method `private` or `internal` as well:
```
private Composite buildComposite(ComboBox subs, ComboBox bas)
{
....
``` | Your custom type, Composite, is currently less accessible than your method buildComposite. For other classes to see this public method, they must also have public access to the Composite class/struct. |
24,041,113 | When I'm building, VS show error. This is my code:
```
public Composite buildComposite(ComboBox subs, ComboBox bas)
{
int count = 0;
Composite a = new Composite();
if (subs.SelectedItem != null)
{
foreach (Substance d in listSubstance)
{
if (String.Compare(d.notation, subs.Text) == 0)
{
count++;
a.subs = new Substance(d);
break;
}
}
}
if (bas.SelectedItem != null)
{
foreach (Base g in listBase)
{
if (String.Compare(g.notation, bas.Text) == 0)
{
count++;
a.bas = new Base(g);
break;
}
}
}
if (count > 0)
{
a.equilibrium();
a.settypesubs(arrayDefinition);
return a;
}
else
return null;
}
```
This is my error:
>
> Error 1 Inconsistent accessibility: return type 'Project\_HGHTM9.Composite' is less accessible than method 'Project\_HGHTM9.Form1.buildComposite(System.Windows.Forms.ComboBox, System.Windows.Forms.ComboBox)' c:\users\nguyen\documents\visual studio 2013\Projects\Project\_HGHTM9\Project\_HGHTM9\Form1.cs 172 26 Project\_HGHTM9
>
>
> | 2014/06/04 | [
"https://Stackoverflow.com/questions/24041113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3453838/"
]
| Your `Composite` class is not `public`. You can't return a non-public type from a public method.
If you don't specify an accessibility for a non-nested class then `internal` is used by default. Add `public` to your `Composite` class definition:
```
public class Composite
{
...
```
Alternatively, if `buildComposite` doesn't *need* to be `public` (meaning it's only used internally by the form), then you could make the method `private` or `internal` as well:
```
private Composite buildComposite(ComboBox subs, ComboBox bas)
{
....
``` | if `Composite` was defined in unreachable/unmodifiable code like `class Composite`, you could try making `buildComposite` as internal. Like
`internal Composite buildComposite(ComboBox subs, ComboBox bas)`. This way it is still more accessible by making the method *private*. |
24,041,113 | When I'm building, VS show error. This is my code:
```
public Composite buildComposite(ComboBox subs, ComboBox bas)
{
int count = 0;
Composite a = new Composite();
if (subs.SelectedItem != null)
{
foreach (Substance d in listSubstance)
{
if (String.Compare(d.notation, subs.Text) == 0)
{
count++;
a.subs = new Substance(d);
break;
}
}
}
if (bas.SelectedItem != null)
{
foreach (Base g in listBase)
{
if (String.Compare(g.notation, bas.Text) == 0)
{
count++;
a.bas = new Base(g);
break;
}
}
}
if (count > 0)
{
a.equilibrium();
a.settypesubs(arrayDefinition);
return a;
}
else
return null;
}
```
This is my error:
>
> Error 1 Inconsistent accessibility: return type 'Project\_HGHTM9.Composite' is less accessible than method 'Project\_HGHTM9.Form1.buildComposite(System.Windows.Forms.ComboBox, System.Windows.Forms.ComboBox)' c:\users\nguyen\documents\visual studio 2013\Projects\Project\_HGHTM9\Project\_HGHTM9\Form1.cs 172 26 Project\_HGHTM9
>
>
> | 2014/06/04 | [
"https://Stackoverflow.com/questions/24041113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3453838/"
]
| you are trying to return an instance of class `Composite` from a public method, but `Composite` is not public therefore can't be returned as any calling code cannot know anything about the `Composite` class as it cannot see it.
Make your `Composite` class public.
```
public class Composite{...}
```
or make your method which is returning your `Composite` have the same visibility as your class (probably private):
```
private Composite buildComposite(ComboBox subs, ComboBox bas)
```
Which of these is appropriate will depend on whether you need to call the method (or use the class) from outside your current assembly.
By default a class is usually as 'hidden' as it can be, so private for classes. Read more about the default visibility [here](https://stackoverflow.com/questions/3763612/default-visibility-for-c-sharp-classes-and-members-fields-methods-etc) | Your custom type, Composite, is currently less accessible than your method buildComposite. For other classes to see this public method, they must also have public access to the Composite class/struct. |
24,041,113 | When I'm building, VS show error. This is my code:
```
public Composite buildComposite(ComboBox subs, ComboBox bas)
{
int count = 0;
Composite a = new Composite();
if (subs.SelectedItem != null)
{
foreach (Substance d in listSubstance)
{
if (String.Compare(d.notation, subs.Text) == 0)
{
count++;
a.subs = new Substance(d);
break;
}
}
}
if (bas.SelectedItem != null)
{
foreach (Base g in listBase)
{
if (String.Compare(g.notation, bas.Text) == 0)
{
count++;
a.bas = new Base(g);
break;
}
}
}
if (count > 0)
{
a.equilibrium();
a.settypesubs(arrayDefinition);
return a;
}
else
return null;
}
```
This is my error:
>
> Error 1 Inconsistent accessibility: return type 'Project\_HGHTM9.Composite' is less accessible than method 'Project\_HGHTM9.Form1.buildComposite(System.Windows.Forms.ComboBox, System.Windows.Forms.ComboBox)' c:\users\nguyen\documents\visual studio 2013\Projects\Project\_HGHTM9\Project\_HGHTM9\Form1.cs 172 26 Project\_HGHTM9
>
>
> | 2014/06/04 | [
"https://Stackoverflow.com/questions/24041113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3453838/"
]
| you are trying to return an instance of class `Composite` from a public method, but `Composite` is not public therefore can't be returned as any calling code cannot know anything about the `Composite` class as it cannot see it.
Make your `Composite` class public.
```
public class Composite{...}
```
or make your method which is returning your `Composite` have the same visibility as your class (probably private):
```
private Composite buildComposite(ComboBox subs, ComboBox bas)
```
Which of these is appropriate will depend on whether you need to call the method (or use the class) from outside your current assembly.
By default a class is usually as 'hidden' as it can be, so private for classes. Read more about the default visibility [here](https://stackoverflow.com/questions/3763612/default-visibility-for-c-sharp-classes-and-members-fields-methods-etc) | if `Composite` was defined in unreachable/unmodifiable code like `class Composite`, you could try making `buildComposite` as internal. Like
`internal Composite buildComposite(ComboBox subs, ComboBox bas)`. This way it is still more accessible by making the method *private*. |
6,969,482 | I got a side bar (fixed on the right side) which is made with 3 images, `Top.png`, `Mid.png`, `Bot.png`. I was wondering if there is a way to load those 3 images during runtime and create/merging into a new one (`sideBar.png`), without saving it to the HD.
The point is, as I don't know the height of the screen, I am placing the Mid image as many times as it is needed to fill the space between the `Top.png` and the `Bot.png`.
Using:
* Javascript
* HTML 5
* CSS 3
EDITED:
and the CSS, its the same for all 3 parts... it only changes the url, name and position:
```
$("#Mid").animate({right: "-230px",}, 500 );
$("#Top").animate({right: "-230px",}, 500 );
$("#Bot").animate({right: "-230px",}, 500 );
#Bot {
position: absolute;
top:495;
right:0;
width: 230px;
height: 35px;
background-image: url(/images/Bot.png);
}
``` | 2011/08/06 | [
"https://Stackoverflow.com/questions/6969482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/882271/"
]
| This seems truly unnecessary. I'd recommend using CSS attribute `repeat-y` and building your HTML and CSS structures in such a way the images will mesh. This is not the purpose of JavaScript. | You haven't shown the HTML markup, but I'm guessing you should put the three images in a container div and animate the container div with one animation, not three. Then, there will not be anything out of sync during the animation. |
65,291 | Remove the custom design tab from magento category edit page. | 2015/04/30 | [
"https://magento.stackexchange.com/questions/65291",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/24066/"
]
| First of all i am asuming you know how to create module [If not please check [This](https://stackoverflow.com/questions/576908/how-to-create-a-simple-hello-world-module-in-magento) ]
You can remove a tab using the method `Mage_Adminhtml_Block_Widget_Tabs::removeTab()`. Every edit page in Magento (admin side) is actually child block of `Mage_Adminhtml_Block_Widget_Tabs` block class.
To remove tab you have to create extension for that and obsever
```
adminhtml_catalog_category_tabs
```
As a start up
```
File : app\code\community\Keyur\RemoveCategoryTab\etc\config.xml
<config>
<modules>
<Keyur_RemoveCategoryTab>
<version>1.0.0</version>
</Keyur_RemoveCategoryTab>
</modules>
<global>
<models>
<keyur_RemoveCategoryTab>
<class>keyur_RemoveCategoryTab_Model</class>
</keyur_RemoveCategoryTab>
</models>
</global>
<adminhtml>
<events>
<adminhtml_catalog_category_tabs>
<observers>
<remove_category_product_tab_from_edit_page>
<class>keyur_RemoveCategoryTab/observer</class>
<method>removeUnwantedCategoryTabs</method>
</remove_category_product_tab_from_edit_page>
</observers>
</adminhtml_catalog_category_tabs>
</events>
</adminhtml>
</config>
```
Now create observer file
```
File : app\code\community\Keyur\RemoveCategoryTab\Model\Observer.php
class Keyur_RemoveCategoryTab_Model_Observer
{
public function removeUnwantedCategoryTabs(Varien_Event_Observer $observer)
{
$tabs = $observer->getEvent()->getTabs();
$tabs->removeTab('group_6');
return $this;
}
```
}
Where `group_6` is tab id [You can check by inspecting element

And see the magic.
Let me know if you have any query | Not the best but simple way, use below property in your CSS :
```
#category_info_tabs > li:nth-child(3) {
display: none;
}
``` |
15,899 | In school, our teacher requires us to put a ⇔ sign on the left of our equations, when we do a tranformation on the equation. Usually, I use an `align` context to format multiple transformations of an equation, but I don't know, how to add that extra sign on the left. In the best case, want them to be all align on the same line, like in this image:

Now, how can I do this in (La)TeX? | 2011/04/15 | [
"https://tex.stackexchange.com/questions/15899",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/4595/"
]
| ```
\documentclass{article}
\usepackage{amsmath}
\def\LRA{\Leftrightarrow\mkern40mu}
\pagestyle{empty}
\begin{document}
\begin{alignat}{2}
\LRA && A + B &= C + D \\
\LRA && C + D + F &= Y + K \\
\LRA && E &= F \\
&& X &= Z
\end{alignat}
\end{document}
```
 | Here's one with eplain:
```
\input eplain
\leftdisplays % instead of displays being centered, align them at left
$$ \leqalignno{% sets the last column on the left (despite given at right)
2x^2+bx+c&=0\cr
x^2+{b\over x}x&=-{c\over2}&\Leftrightarrow\cr
x^2+{b\over x}x+{b^2\over4x^2}&={b^2-4xc}&\Leftrightarrow\cr
\Bigl(x+{b\over 2x}\Bigr)^2&={b^2-4xc\over4x^2}&\Leftrightarrow\cr
x+{b\over 2x}&={\pm\sqrt{b^2-4xc}\over2x}&\Leftrightarrow\cr
} $$
\bye
```
 |
9,739,754 | Anyone have the problem with Undo operation (Cmd + Z) in Xcode?
When I am edit my Objective-C code with Undo operation, some symbols are not correctly edited.
For instance:
was {
with Undo {{
XCode 4.2.1 | 2012/03/16 | [
"https://Stackoverflow.com/questions/9739754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/744144/"
]
| I have Xcode 4.3.2, which still has severe problems with undo/redo -- it will usually crash after one or two redo! Just before it crashes, it will usually do some nonsense edit.
---
*Added*:
I have experimented with the tip by Walt to turn off line numbers. However, I have not seen any significant drop in crash frequency. However, going slowly seems to at least reduce the crash frequency, but it is absolutely no guarantee -- it may crash even after an extremely simply small undo.
(I usually get anywhere from 1 to a dozen crashes a day, but since I try to avoid undo, especially several consecutive undo, the crash frequency has dropped somewhat.)
A crash may come on either undo or redo, with a slightly higher crash frequency for redo. Sometimes the crash comes after just a simple paste with no preceding undo/redo.
I have also experimented with changing font scheme to a very simple one, but it does not help.
My only tip would be: when you see that e.g a paste, or entered text, is inserted at the wrong place, try to save (or ignore that step), then chose Revert Document. Sometimes that trick works, sometimes not (and if not, it will crash). Sometimes it has helped by switching to another file and then back.
Also, if you want to undo just to inspect what the previous thing was, save before the undo, then, rather than redo, it may be slightly safer to Revert Document (but it is by no means any guarantee).
After a refactor, the window's fonts often look garbled. In this case, it has always helped to switch to another file and then back.
Hmm, is this Apple Quality? Steve's adherence to perfection? | they fixed this partially in Xcode 4.3.1, it doesn't occur that often anymore |
9,739,754 | Anyone have the problem with Undo operation (Cmd + Z) in Xcode?
When I am edit my Objective-C code with Undo operation, some symbols are not correctly edited.
For instance:
was {
with Undo {{
XCode 4.2.1 | 2012/03/16 | [
"https://Stackoverflow.com/questions/9739754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/744144/"
]
| I have XCode 4.3.2 and I have exactly the same problem. This is a serious bug in XCode 4.3.2 especially because of the nonsense edit that it tossed around in various places in the code file that is being edited before XCode 4.3.2 crashes. | they fixed this partially in Xcode 4.3.1, it doesn't occur that often anymore |
9,739,754 | Anyone have the problem with Undo operation (Cmd + Z) in Xcode?
When I am edit my Objective-C code with Undo operation, some symbols are not correctly edited.
For instance:
was {
with Undo {{
XCode 4.2.1 | 2012/03/16 | [
"https://Stackoverflow.com/questions/9739754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/744144/"
]
| I have the same issue with Xcode 4.3.2, specifically the screen starts going garbled and if you are showing line numbers in your editor those will get messed up to then click somewhere else and *crash*.
Few quick helpful tips I have found:
1. Option-Command-S *before* you Command-Z (Save All) [in case it crashes you don't lose work]
2. If you do undo and you see it's messing up, open up another text file, then click back on the messed up file and it's now all better.
I sure hope Apple fixes this fast! | they fixed this partially in Xcode 4.3.1, it doesn't occur that often anymore |
9,739,754 | Anyone have the problem with Undo operation (Cmd + Z) in Xcode?
When I am edit my Objective-C code with Undo operation, some symbols are not correctly edited.
For instance:
was {
with Undo {{
XCode 4.2.1 | 2012/03/16 | [
"https://Stackoverflow.com/questions/9739754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/744144/"
]
| I have Xcode 4.3.2, which still has severe problems with undo/redo -- it will usually crash after one or two redo! Just before it crashes, it will usually do some nonsense edit.
---
*Added*:
I have experimented with the tip by Walt to turn off line numbers. However, I have not seen any significant drop in crash frequency. However, going slowly seems to at least reduce the crash frequency, but it is absolutely no guarantee -- it may crash even after an extremely simply small undo.
(I usually get anywhere from 1 to a dozen crashes a day, but since I try to avoid undo, especially several consecutive undo, the crash frequency has dropped somewhat.)
A crash may come on either undo or redo, with a slightly higher crash frequency for redo. Sometimes the crash comes after just a simple paste with no preceding undo/redo.
I have also experimented with changing font scheme to a very simple one, but it does not help.
My only tip would be: when you see that e.g a paste, or entered text, is inserted at the wrong place, try to save (or ignore that step), then chose Revert Document. Sometimes that trick works, sometimes not (and if not, it will crash). Sometimes it has helped by switching to another file and then back.
Also, if you want to undo just to inspect what the previous thing was, save before the undo, then, rather than redo, it may be slightly safer to Revert Document (but it is by no means any guarantee).
After a refactor, the window's fonts often look garbled. In this case, it has always helped to switch to another file and then back.
Hmm, is this Apple Quality? Steve's adherence to perfection? | I have XCode 4.3.2 and I have exactly the same problem. This is a serious bug in XCode 4.3.2 especially because of the nonsense edit that it tossed around in various places in the code file that is being edited before XCode 4.3.2 crashes. |
9,739,754 | Anyone have the problem with Undo operation (Cmd + Z) in Xcode?
When I am edit my Objective-C code with Undo operation, some symbols are not correctly edited.
For instance:
was {
with Undo {{
XCode 4.2.1 | 2012/03/16 | [
"https://Stackoverflow.com/questions/9739754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/744144/"
]
| I have Xcode 4.3.2, which still has severe problems with undo/redo -- it will usually crash after one or two redo! Just before it crashes, it will usually do some nonsense edit.
---
*Added*:
I have experimented with the tip by Walt to turn off line numbers. However, I have not seen any significant drop in crash frequency. However, going slowly seems to at least reduce the crash frequency, but it is absolutely no guarantee -- it may crash even after an extremely simply small undo.
(I usually get anywhere from 1 to a dozen crashes a day, but since I try to avoid undo, especially several consecutive undo, the crash frequency has dropped somewhat.)
A crash may come on either undo or redo, with a slightly higher crash frequency for redo. Sometimes the crash comes after just a simple paste with no preceding undo/redo.
I have also experimented with changing font scheme to a very simple one, but it does not help.
My only tip would be: when you see that e.g a paste, or entered text, is inserted at the wrong place, try to save (or ignore that step), then chose Revert Document. Sometimes that trick works, sometimes not (and if not, it will crash). Sometimes it has helped by switching to another file and then back.
Also, if you want to undo just to inspect what the previous thing was, save before the undo, then, rather than redo, it may be slightly safer to Revert Document (but it is by no means any guarantee).
After a refactor, the window's fonts often look garbled. In this case, it has always helped to switch to another file and then back.
Hmm, is this Apple Quality? Steve's adherence to perfection? | I have the same issue with Xcode 4.3.2, specifically the screen starts going garbled and if you are showing line numbers in your editor those will get messed up to then click somewhere else and *crash*.
Few quick helpful tips I have found:
1. Option-Command-S *before* you Command-Z (Save All) [in case it crashes you don't lose work]
2. If you do undo and you see it's messing up, open up another text file, then click back on the messed up file and it's now all better.
I sure hope Apple fixes this fast! |
9,739,754 | Anyone have the problem with Undo operation (Cmd + Z) in Xcode?
When I am edit my Objective-C code with Undo operation, some symbols are not correctly edited.
For instance:
was {
with Undo {{
XCode 4.2.1 | 2012/03/16 | [
"https://Stackoverflow.com/questions/9739754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/744144/"
]
| I have Xcode 4.3.2, which still has severe problems with undo/redo -- it will usually crash after one or two redo! Just before it crashes, it will usually do some nonsense edit.
---
*Added*:
I have experimented with the tip by Walt to turn off line numbers. However, I have not seen any significant drop in crash frequency. However, going slowly seems to at least reduce the crash frequency, but it is absolutely no guarantee -- it may crash even after an extremely simply small undo.
(I usually get anywhere from 1 to a dozen crashes a day, but since I try to avoid undo, especially several consecutive undo, the crash frequency has dropped somewhat.)
A crash may come on either undo or redo, with a slightly higher crash frequency for redo. Sometimes the crash comes after just a simple paste with no preceding undo/redo.
I have also experimented with changing font scheme to a very simple one, but it does not help.
My only tip would be: when you see that e.g a paste, or entered text, is inserted at the wrong place, try to save (or ignore that step), then chose Revert Document. Sometimes that trick works, sometimes not (and if not, it will crash). Sometimes it has helped by switching to another file and then back.
Also, if you want to undo just to inspect what the previous thing was, save before the undo, then, rather than redo, it may be slightly safer to Revert Document (but it is by no means any guarantee).
After a refactor, the window's fonts often look garbled. In this case, it has always helped to switch to another file and then back.
Hmm, is this Apple Quality? Steve's adherence to perfection? | Go slowly when using Undo/Redo. I've noticed that it crashes more when I'm hitting Command-Z many times quickly.
Try turning off the line numbers in Xcode preferences. That seems to have improved things on my Mac.
Preferences -> "Text Editing" tab -> "Editing" subtab
uncheck the "Line Numbers" button
From the look of the crash logs, it may be some kind of combination of undoing/redoing (editing) causing the view to scroll or the layout to change dramatically.
From my crash logs:
UNCAUGHT EXCEPTION (NSInternalInconsistencyException): -[DVTLayoutManager \_fillLayoutHoleForCharacterRange:desiredNumberOfLines:isSoft:] *\** attempted layout while textStorage is editing. It is not valid to cause the layoutManager to do layout while the textStorage is editing (ie the textStorage has been sent a beginEditing message without a matching endEditing.) |
9,739,754 | Anyone have the problem with Undo operation (Cmd + Z) in Xcode?
When I am edit my Objective-C code with Undo operation, some symbols are not correctly edited.
For instance:
was {
with Undo {{
XCode 4.2.1 | 2012/03/16 | [
"https://Stackoverflow.com/questions/9739754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/744144/"
]
| I have XCode 4.3.2 and I have exactly the same problem. This is a serious bug in XCode 4.3.2 especially because of the nonsense edit that it tossed around in various places in the code file that is being edited before XCode 4.3.2 crashes. | Go slowly when using Undo/Redo. I've noticed that it crashes more when I'm hitting Command-Z many times quickly.
Try turning off the line numbers in Xcode preferences. That seems to have improved things on my Mac.
Preferences -> "Text Editing" tab -> "Editing" subtab
uncheck the "Line Numbers" button
From the look of the crash logs, it may be some kind of combination of undoing/redoing (editing) causing the view to scroll or the layout to change dramatically.
From my crash logs:
UNCAUGHT EXCEPTION (NSInternalInconsistencyException): -[DVTLayoutManager \_fillLayoutHoleForCharacterRange:desiredNumberOfLines:isSoft:] *\** attempted layout while textStorage is editing. It is not valid to cause the layoutManager to do layout while the textStorage is editing (ie the textStorage has been sent a beginEditing message without a matching endEditing.) |
9,739,754 | Anyone have the problem with Undo operation (Cmd + Z) in Xcode?
When I am edit my Objective-C code with Undo operation, some symbols are not correctly edited.
For instance:
was {
with Undo {{
XCode 4.2.1 | 2012/03/16 | [
"https://Stackoverflow.com/questions/9739754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/744144/"
]
| I have the same issue with Xcode 4.3.2, specifically the screen starts going garbled and if you are showing line numbers in your editor those will get messed up to then click somewhere else and *crash*.
Few quick helpful tips I have found:
1. Option-Command-S *before* you Command-Z (Save All) [in case it crashes you don't lose work]
2. If you do undo and you see it's messing up, open up another text file, then click back on the messed up file and it's now all better.
I sure hope Apple fixes this fast! | Go slowly when using Undo/Redo. I've noticed that it crashes more when I'm hitting Command-Z many times quickly.
Try turning off the line numbers in Xcode preferences. That seems to have improved things on my Mac.
Preferences -> "Text Editing" tab -> "Editing" subtab
uncheck the "Line Numbers" button
From the look of the crash logs, it may be some kind of combination of undoing/redoing (editing) causing the view to scroll or the layout to change dramatically.
From my crash logs:
UNCAUGHT EXCEPTION (NSInternalInconsistencyException): -[DVTLayoutManager \_fillLayoutHoleForCharacterRange:desiredNumberOfLines:isSoft:] *\** attempted layout while textStorage is editing. It is not valid to cause the layoutManager to do layout while the textStorage is editing (ie the textStorage has been sent a beginEditing message without a matching endEditing.) |
25,119,380 | I have crated a dialog activity which pops up when my application receives a message from the cloud, prompting the user to take an action (pressing yes/no). But if there are to notifications in the same time, the new dialog intent overlaps the first, and if the user selects either yes/no, a 3rd activity is started and the first dialog is lost.
Is there a way of checking if my dialog intent is already started? So I can get back to the first dialog before starting the 3rd activity which displays the full message?
Regards! | 2014/08/04 | [
"https://Stackoverflow.com/questions/25119380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2483101/"
]
| According to [the plugin github page](https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/wiki/Configuring-the-jvm-that-the-jmeter-process-runs-in), you set the JVM options via the project configuration file, like this:
```
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
<configuration>
<jMeterProcessJVMSettings>
<xms>1024</xms>
<xmx>1024</xmx>
<arguments>
<argument>-Xprof</argument>
<argument>-Xfuture</argument>
</arguments>
</jMeterProcessJVMSettings>
</configuration>
</execution>
</executions>
</plugin>
``` | Typical reason for StackOverflowError is bad recursive call, increasing heap won't help. Do you use any scripting or looping in your test plan? If so, inspect it carefully to detect any nested calls or loops. |
1,881,600 | Can i use if else under a check constraint.
Can i use check constraint using a variable
need xplanation with eg. | 2009/12/10 | [
"https://Stackoverflow.com/questions/1881600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/203262/"
]
| You cannot use `IF/ELSE`, but you can use inline conditionals: `CASE WHEN` | Your question is a bit vague. What are you trying to do with the IF...ELSE? Check constraints aren't processed code, they're part of the table definition - there is no control flow and no variables. You can use a user-defined function in check constraints, which may be what you're after, but it's hard to tell from your question. |
8,249,256 | in Ie I am getting a javascript error:
'Style' is null or not an object
lightbox-resize.js
Line 33
char 6
code 0
This realates to the following page:
<http://www.nickypellegrino.com/blog/>
I can figure out what is causing this issue. The page (and the lightbox) works fine in firefox/chrome - but not in IE.
There is also another error being thrown about prototype.js, and I don't know what that is either :P | 2011/11/23 | [
"https://Stackoverflow.com/questions/8249256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/735369/"
]
| The problem stems from the collision between Prototype and jQuery over the symbol "$". You're going to have to make one or the other of them relinquish it.
With jQuery, you do it like this:
```
jQuery.noConflict();
```
right after including the library:
```
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js'></script>
<script>jQuery.noConflict();</script>
```
Once you've done that, all the code that expects "$" to mean "jQuery" will have to explicitly use the global name "jQuery" instead of "$".
A better solution would probably be to find a way to avoid using two large JavaScript frameworks on the same page. Both of them have large ecosystems, so it's very likely you can find the tools you need and only rely on one of them. | You are using prototype.js and jQuery without using jQuery's [noConflict()](http://api.jquery.com/jQuery.noConflict/), what results in a conflict when using `$()` |
29,933,386 | I have a large mysqldump (4+ gigs), and we have an archive type table which [suffers from this bug](http://bugs.mysql.com/bug.php?id=37182) Net result is that I need to reset the AUTO\_INCREMENT counter to zero. Did manage to do the replacement, but it was ugly, involving splitting the file into smaller chunks, then grepping to find the table, looking to see the number I wanted to change and then using `sed` on the original file to replace just that match on the auto increment. Like I said, horrible, but it worked.
So - I have tried to decipher multiline sed and didn't get that far. What I want to do is to seek to the table name I'm interested in, and then from that point find the next `AUTO_INCREMENT=` , and then match the number in it, and make it zero. Here's the table: (assume there is scads of data before this point, and after it)
```
DROP TABLE IF EXISTS `archive_exported_problems`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `archive_exported_problems` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`export_id` int(11) DEFAULT NULL,
`problem_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=ARCHIVE AUTO_INCREMENT=478 DEFAULT CHARSET=latin1;
```
What I want to do, is to (automatically) scan the file until it matches
```
(?:CREATE TABLE `archive_exported_problems).*?AUTO_INCREMENT=(\d+)
```
(regex which seems to work) and then replace the capture group with 0
I assume this is possible - any help most appreciated! | 2015/04/29 | [
"https://Stackoverflow.com/questions/29933386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/435817/"
]
| If `perl` is an option then it is easier using `DOTALL` flag in `perl` like this:
```
perl -00 -pe
's/(?s)(CREATE TABLE `archive_exported_problems`.*?AUTO_INCREMENT)=\d+/$1=0/' file.sql
DROP TABLE IF EXISTS `archive_exported_problems`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `archive_exported_problems` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`export_id` int(11) DEFAULT NULL,
`problem_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=ARCHIVE AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
```
Options used are:
```
-00 # slurps whole file
(?s) # enable DOTALL flag for regex
``` | Consider this:
```
$ sed -r '/CREATE TABLE `archive_exported_problems`/,/AUTO_INCREMENT=/ {s/(AUTO_INCREMENT)=[[:digit:]]+/\1=0/;}' file
DROP TABLE IF EXISTS `archive_exported_problems`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `archive_exported_problems` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`export_id` int(11) DEFAULT NULL,
`problem_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=ARCHIVE AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
```
For Mac OSX (BSD), try:
```
$ sed -E -e '/CREATE TABLE `archive_exported_problems`/,/AUTO_INCREMENT=/ {s/(AUTO_INCREMENT)=[[:digit:]]+/\1=0/;}' file
```
### How it works
* `/CREATE TABLE`archive\_exported\_problems`/, /AUTO_INCREMENT=/`
This restricts the subsequent commands to ranges on lines that start with a line containing `CREATE TABLE 'archive_exported_problems'` and end with a line containing `AUTO_INCREMENT=`.
* `s/(AUTO_INCREMENT)=[[:digit:]]+/\1=0/`
This performs the substitution that you wanted.
### Limitation
This approach assumes that the `CREATE TABLE` phrase and the `AUTO_INCREMENT=` phrase will never be on the same line. If that is not true, we need to make some minor changes. |
10,634,340 | I'm trying to implement the new Windows 7 taskbar progress bar. I managed to get it to work with TBPF\_NORMAL state using the following code:
```
CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&taskbarList));
HRESULT c = taskbarList->SetProgressState(hWnd, TBPF_NORMAL);
if (c != S_OK) MessageBox("ERROR");
taskbarList->SetProgressValue(hWnd, 5, 10);
```
However if I try the exact same code with TBPF\_INDETERMINATE, it doesn't display anything and there's no error either:
```
CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&taskbarList));
HRESULT c = taskbarList->SetProgressState(hWnd, TBPF_INDETERMINATE);
if (c != S_OK) MessageBox("ERROR");
```
Does anybody know what could be causing this problem? | 2012/05/17 | [
"https://Stackoverflow.com/questions/10634340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/561309/"
]
| Okay, it looks like it was a problem with the configuration of my system. I post the answer here because it's not obvious why one progress bar animation would work but not another.
In System Properties / Performance Options, I had "Animations in the taskbar and Start Menu" disabled. This option apparently disables the "indeterminate" animation but not the regular one. By re-enabling the option, the indeterminate animation works. | This happened to me too. In the code, I have a Form A that shows a Form B (which Form B in the OnLoad event calls SetProgressState) and after that Form A calls the method Close to itself, and when it was in Indeterminate mode it didn't show anything!
Surpringsly, if I close first Form A and then show Form B, the problem is solved!
I hope this can help somebody having a headache with this. |
679,099 | ```
say -v Alex "Hello"
```
Is there a way to change the speed of speech like there is in the speech settings of *System Preferences* -> *Date & Time* -> *Clock* -> *Customize Voice*?
 | 2013/11/22 | [
"https://superuser.com/questions/679099",
"https://superuser.com",
"https://superuser.com/users/94704/"
]
| Yes, there is. The command
```
say -v Alex "Hello" -r 200
```
will cause the voice Alex say "Hello" at a rate of 200 words/minute. | There is also an [embedded speech command](https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/SpeechSynthesisProgrammingGuide/FineTuning/FineTuning.html#//apple_ref/doc/uid/TP40004365-CH5-SW3) for changing the rate:
```
say '[[rate 200]] hello'
``` |
679,099 | ```
say -v Alex "Hello"
```
Is there a way to change the speed of speech like there is in the speech settings of *System Preferences* -> *Date & Time* -> *Clock* -> *Customize Voice*?
 | 2013/11/22 | [
"https://superuser.com/questions/679099",
"https://superuser.com",
"https://superuser.com/users/94704/"
]
| Yes, there is. The command
```
say -v Alex "Hello" -r 200
```
will cause the voice Alex say "Hello" at a rate of 200 words/minute. | FWIW: I'm on Big Sur and the `-r`/`--rate` is simply ignored. However, the embedded command as described by [@lri](https://superuser.com/users/69039/lri) still works.
P.S. I see in an earlier comment that 10.13 also had that issue. Well... |
679,099 | ```
say -v Alex "Hello"
```
Is there a way to change the speed of speech like there is in the speech settings of *System Preferences* -> *Date & Time* -> *Clock* -> *Customize Voice*?
 | 2013/11/22 | [
"https://superuser.com/questions/679099",
"https://superuser.com",
"https://superuser.com/users/94704/"
]
| There is also an [embedded speech command](https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/SpeechSynthesisProgrammingGuide/FineTuning/FineTuning.html#//apple_ref/doc/uid/TP40004365-CH5-SW3) for changing the rate:
```
say '[[rate 200]] hello'
``` | FWIW: I'm on Big Sur and the `-r`/`--rate` is simply ignored. However, the embedded command as described by [@lri](https://superuser.com/users/69039/lri) still works.
P.S. I see in an earlier comment that 10.13 also had that issue. Well... |
19,117,738 | I am working on ROR apps and Mongo DB , App has two controller :
1) Portfolio --- All method related to admin.
2) Target ---- All actions which are used for public display of data.
Now I want to put a log in page into my website so only login users can see views related to portfolio ? How can I do that. Any lead will be appreciated. | 2013/10/01 | [
"https://Stackoverflow.com/questions/19117738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/793806/"
]
| You should check the [devise](https://github.com/plataformatec/devise) gem. | If you don't want an administrator panel, you can just use Devise:
<https://github.com/plataformatec/devise>
You can then use `user_signed_in?` to control what is shown to the user. In other words:
```
<% if user_signed_in? %>
Only signed in users can see this message!
<% end %>
``` |
19,117,738 | I am working on ROR apps and Mongo DB , App has two controller :
1) Portfolio --- All method related to admin.
2) Target ---- All actions which are used for public display of data.
Now I want to put a log in page into my website so only login users can see views related to portfolio ? How can I do that. Any lead will be appreciated. | 2013/10/01 | [
"https://Stackoverflow.com/questions/19117738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/793806/"
]
| I would look into either RailsAdmin:
<https://github.com/sferik/rails_admin>
Or try ActiveAdmin:
<https://github.com/gregbell/active_admin>
They both include Devise, as suggested by grotori, and give you admin panel functionality out of the box.
If you're using Mongoid, you'd also want to look at:
<https://github.com/elia/activeadmin-mongoid>
RailsAdmin also supports Mongoid by default. | If you don't want an administrator panel, you can just use Devise:
<https://github.com/plataformatec/devise>
You can then use `user_signed_in?` to control what is shown to the user. In other words:
```
<% if user_signed_in? %>
Only signed in users can see this message!
<% end %>
``` |
68,240,571 | I have this DF: `Columns: df=pd.DataFrame(columns=["a","b","c","d","e","f","g"])`
and this : `data=["a:42","b:43","c:22","d:41","a:21","b:14" ,"c:12","e:14" ,"f:7","a:0" ,"d:1","f:3","a:6" ,"b:0","c:9","g:8" ]`
I need
```
for d in data:
spli=d.split(":")
colum=spli[0]
value=spli[1]
df[colum] = value
```
waiting for this result
```
["a" "b" "c" "d" "e" "f" "g" ]
42 43 22 41 nan nan nan
21 14 12 nan 14 7 nan
0 nan nan 1 nan 3 nan
6 0 9 nan nan nan 8
``` | 2021/07/03 | [
"https://Stackoverflow.com/questions/68240571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11172101/"
]
| `.loc` can help you here:
```
last_c = 'z' # Enter some ordinally large string
r = -1
for x in data:
c,v = x.split(':')
if c <= last_c:
r += 1
df.loc[r,c] = v
last_c = c
a b c d e f g
0 42 43 22 41 NaN NaN NaN
1 21 14 12 NaN 14 7 NaN
2 0 NaN NaN 1 NaN 3 NaN
3 6 0 9 NaN NaN NaN 8
4 NaN 14 9 NaN NaN NaN NaN
```
I added an additional line to show a new line (row) starting with something other than `'a'`. | Is it posible to convert your data to a list of dictionary like:
```
data = [{"a":42,"b":43,"c":22,"d":41},
{"a":21,"b":14 ,"c":12,"e":14 ,"f":7},
{"a":0 ,"d":1,"f":3},
{"a":6 ,"b":0,"c":9,"g":8}]
```
Then, you can create a dataframe by:
```
df=pd.DataFrame(data).
``` |
68,240,571 | I have this DF: `Columns: df=pd.DataFrame(columns=["a","b","c","d","e","f","g"])`
and this : `data=["a:42","b:43","c:22","d:41","a:21","b:14" ,"c:12","e:14" ,"f:7","a:0" ,"d:1","f:3","a:6" ,"b:0","c:9","g:8" ]`
I need
```
for d in data:
spli=d.split(":")
colum=spli[0]
value=spli[1]
df[colum] = value
```
waiting for this result
```
["a" "b" "c" "d" "e" "f" "g" ]
42 43 22 41 nan nan nan
21 14 12 nan 14 7 nan
0 nan nan 1 nan 3 nan
6 0 9 nan nan nan 8
``` | 2021/07/03 | [
"https://Stackoverflow.com/questions/68240571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11172101/"
]
| You need a non-empty df to set a column to a certain value. You can create a new df for a row with all nans, and then set column values. You can test whether you need a new row by comparing the numeric value of a, b, c ... with ord(). Append the df\_row to the master df for each new row, and once at the end of the loop. Here's one way to do it:
```
df = pd.DataFrame(columns=["a", "b", "c", "d", "e", "f", "g"])
data = ["a:42", "b:43", "c:22", "d:41", "a:21", "b:14", "c:12", "e:14", "f:7", "a:0", "d:1", "f:3", "a:6", "b:0", "c:9", "g:8"]
df_this_row = pd.DataFrame([[np.NAN, np.NAN, np.NAN, np.NAN, np.NAN, np.NAN, np.NAN]], columns=["a", "b", "c", "d", "e", "f", "g"])
first_col, first_val = data[0].split(':')
df_this_row[first_col] = int(first_val)
for i in range(1, len(data)):
col, val = data[i].split(':')
prev_col = data[i-1].split(':')[0]
if ord(col) <= ord(prev_col):
# you are in next row, eg f was previous col, and you have col b
df = df.append(df_this_row)
df_this_row = pd.DataFrame([[np.NAN, np.NAN, np.NAN, np.NAN, np.NAN, np.NAN, np.NAN]], columns=["a", "b", "c", "d", "e", "f", "g"])
df_this_row[col] = int(val)
df = df.append(df_this_row).reset_index(drop=True)
print(df)
# a b c d e f g
# 0 42 43 22 41 NaN NaN NaN
# 1 21 14 12 NaN 14 7 NaN
# 2 0 NaN NaN 1 NaN 3 NaN
# 3 6 0 9 NaN NaN NaN 8
``` | Is it posible to convert your data to a list of dictionary like:
```
data = [{"a":42,"b":43,"c":22,"d":41},
{"a":21,"b":14 ,"c":12,"e":14 ,"f":7},
{"a":0 ,"d":1,"f":3},
{"a":6 ,"b":0,"c":9,"g":8}]
```
Then, you can create a dataframe by:
```
df=pd.DataFrame(data).
``` |
2,194,289 | What I am looking for is a tool that easily or automatically sends coldfusion error messages to their system.
Then I can use the web-based interface, to manage priorities, track who fixed what and so forth.
But I want to use this to help us deal with errors better, but also to show the importance of a bug tracking system to my fellow works.
System Requirements: Apache, Windows, Coldfusion 8 Standard, Sql Server 2005.
Financial Requirements: Free or Open Source
Goal Or Purpose: To encourage my fellow workers to want and use a bug tracking system.
Does this re-write make more sense?
Thanks
Craig | 2010/02/03 | [
"https://Stackoverflow.com/questions/2194289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191899/"
]
| A lot of good information from everyone, and I really do appreciate the efforts given. But not the answer i was looking for. Which maybe means, that what i want does not exist, yet.
So i may have to roll my own solution...Or maybe integrate with another existing app...
Thank You all. | We use [HopToad](http://www.hoptoadapp.com/pages/home). There is another bug-tracking app called [LightHouse](http://lighthouseapp.com/) that integrates with HopToad so you can easily create a [bug] ticket from an incoming exception. HopToad has an API of which there are many clients, you want the CF based one:
<http://github.com/timblair/coldfusion-hoptoad-notifier>
Even if you dont use HopToad and you end up using a different service or roll your own, if you needed to write your own API client you could leverage the code or pattern(s) of the above HopToad client. |
2,194,289 | What I am looking for is a tool that easily or automatically sends coldfusion error messages to their system.
Then I can use the web-based interface, to manage priorities, track who fixed what and so forth.
But I want to use this to help us deal with errors better, but also to show the importance of a bug tracking system to my fellow works.
System Requirements: Apache, Windows, Coldfusion 8 Standard, Sql Server 2005.
Financial Requirements: Free or Open Source
Goal Or Purpose: To encourage my fellow workers to want and use a bug tracking system.
Does this re-write make more sense?
Thanks
Craig | 2010/02/03 | [
"https://Stackoverflow.com/questions/2194289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191899/"
]
| I'm surprised no one mentioned LighthousePro (<http://lighthousepro.riaforge.org>). Open source - 100% free - and ColdFusion. As the author I'm a bit biased though. :) | We use [HopToad](http://www.hoptoadapp.com/pages/home). There is another bug-tracking app called [LightHouse](http://lighthouseapp.com/) that integrates with HopToad so you can easily create a [bug] ticket from an incoming exception. HopToad has an API of which there are many clients, you want the CF based one:
<http://github.com/timblair/coldfusion-hoptoad-notifier>
Even if you dont use HopToad and you end up using a different service or roll your own, if you needed to write your own API client you could leverage the code or pattern(s) of the above HopToad client. |
2,194,289 | What I am looking for is a tool that easily or automatically sends coldfusion error messages to their system.
Then I can use the web-based interface, to manage priorities, track who fixed what and so forth.
But I want to use this to help us deal with errors better, but also to show the importance of a bug tracking system to my fellow works.
System Requirements: Apache, Windows, Coldfusion 8 Standard, Sql Server 2005.
Financial Requirements: Free or Open Source
Goal Or Purpose: To encourage my fellow workers to want and use a bug tracking system.
Does this re-write make more sense?
Thanks
Craig | 2010/02/03 | [
"https://Stackoverflow.com/questions/2194289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191899/"
]
| I have been heavily using this type of a setup for several years by email only, and the last 3 years with a Bug Tracking Software.
I must say, the bug tracking software has made my life so much more peaceful. Nothing is left, forgotten, or slips through the cracks. It's easy to find trends in errors, and remember "all the times" it happened.
Our setup is like this:
**1) Coldfusion + Appropriate framework with error reporting** - It doesn't matter what you use. I have used Fusebox extensively and am making the transition to ColdBox. Both are very capable, in addition to Mach-II, FW/1, Model-Glue, etc. The key part you have to find in them is their ability to catch "onError", usualy in the application CFC.
**2) Custom OnError Script** - Wherever an error occurs, you want to capture the maximum amount of information about that error and email it in. What we do is, when an error occurs, we log the user out with a message of "oops, log in again". Before logging them out, the application captures the error and emails it to Fogbugz. Along with it, at the top we include the CGI variables for the IP address, browser being used, etc. Over time you will find the things you need to add.
**3) Routing in Fogbugz.** A 2 user version of Fogbugz is free, and hosted online. There are two main ways to submit bugs. One is to email one in at a time. So if an error happens 2000 times, you get 2000 emails, and 2000 cases. Not always the best to link them together, etc. They have a feature called BugzScout, which is essentially an HTTP address that you do a form post to with cfform with all of the same information you would have put into the email. There's plenty of documentation on this and something I've always wanted to get around to. I had a scenario of 2000 emails for the first time happen a few weeks ago so I'll be switching over to this.
Hope that helps. Share what you ended up doing and why so we all can learn too! | There are few in CF411 list: [Bug Tracking/Defect Tracking/Trouble Ticket/Help Desk Tools Written in CFML](http://www.carehart.org/cf411/#bugcfml) |
2,194,289 | What I am looking for is a tool that easily or automatically sends coldfusion error messages to their system.
Then I can use the web-based interface, to manage priorities, track who fixed what and so forth.
But I want to use this to help us deal with errors better, but also to show the importance of a bug tracking system to my fellow works.
System Requirements: Apache, Windows, Coldfusion 8 Standard, Sql Server 2005.
Financial Requirements: Free or Open Source
Goal Or Purpose: To encourage my fellow workers to want and use a bug tracking system.
Does this re-write make more sense?
Thanks
Craig | 2010/02/03 | [
"https://Stackoverflow.com/questions/2194289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191899/"
]
| Wiki has a list of issue tracking software, maybe this list could help.
<http://en.wikipedia.org/wiki/Comparison_of_issue_tracking_systems>
You may be able to find a hosted service and use either email or web services to create the ticket using onError. With that said, a simple issue tracking app could be created for your site using the same DB used to drive the content. 2 or 3 tables would take care of the data storage and you're already using CF so the application layer is already there.
HTH. | We use [HopToad](http://www.hoptoadapp.com/pages/home). There is another bug-tracking app called [LightHouse](http://lighthouseapp.com/) that integrates with HopToad so you can easily create a [bug] ticket from an incoming exception. HopToad has an API of which there are many clients, you want the CF based one:
<http://github.com/timblair/coldfusion-hoptoad-notifier>
Even if you dont use HopToad and you end up using a different service or roll your own, if you needed to write your own API client you could leverage the code or pattern(s) of the above HopToad client. |
2,194,289 | What I am looking for is a tool that easily or automatically sends coldfusion error messages to their system.
Then I can use the web-based interface, to manage priorities, track who fixed what and so forth.
But I want to use this to help us deal with errors better, but also to show the importance of a bug tracking system to my fellow works.
System Requirements: Apache, Windows, Coldfusion 8 Standard, Sql Server 2005.
Financial Requirements: Free or Open Source
Goal Or Purpose: To encourage my fellow workers to want and use a bug tracking system.
Does this re-write make more sense?
Thanks
Craig | 2010/02/03 | [
"https://Stackoverflow.com/questions/2194289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191899/"
]
| I'm surprised no one mentioned LighthousePro (<http://lighthousepro.riaforge.org>). Open source - 100% free - and ColdFusion. As the author I'm a bit biased though. :) | A lot of bug tracking software will expose SOAP methods for entering data into them.
For example, we used Axosoft's OnTime and that exposed some WSDL pages that I consumed in my application. I was told that Jira did as well. |
2,194,289 | What I am looking for is a tool that easily or automatically sends coldfusion error messages to their system.
Then I can use the web-based interface, to manage priorities, track who fixed what and so forth.
But I want to use this to help us deal with errors better, but also to show the importance of a bug tracking system to my fellow works.
System Requirements: Apache, Windows, Coldfusion 8 Standard, Sql Server 2005.
Financial Requirements: Free or Open Source
Goal Or Purpose: To encourage my fellow workers to want and use a bug tracking system.
Does this re-write make more sense?
Thanks
Craig | 2010/02/03 | [
"https://Stackoverflow.com/questions/2194289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191899/"
]
| A lot of good information from everyone, and I really do appreciate the efforts given. But not the answer i was looking for. Which maybe means, that what i want does not exist, yet.
So i may have to roll my own solution...Or maybe integrate with another existing app...
Thank You all. | A lot of bug tracking software will expose SOAP methods for entering data into them.
For example, we used Axosoft's OnTime and that exposed some WSDL pages that I consumed in my application. I was told that Jira did as well. |
2,194,289 | What I am looking for is a tool that easily or automatically sends coldfusion error messages to their system.
Then I can use the web-based interface, to manage priorities, track who fixed what and so forth.
But I want to use this to help us deal with errors better, but also to show the importance of a bug tracking system to my fellow works.
System Requirements: Apache, Windows, Coldfusion 8 Standard, Sql Server 2005.
Financial Requirements: Free or Open Source
Goal Or Purpose: To encourage my fellow workers to want and use a bug tracking system.
Does this re-write make more sense?
Thanks
Craig | 2010/02/03 | [
"https://Stackoverflow.com/questions/2194289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191899/"
]
| Wiki has a list of issue tracking software, maybe this list could help.
<http://en.wikipedia.org/wiki/Comparison_of_issue_tracking_systems>
You may be able to find a hosted service and use either email or web services to create the ticket using onError. With that said, a simple issue tracking app could be created for your site using the same DB used to drive the content. 2 or 3 tables would take care of the data storage and you're already using CF so the application layer is already there.
HTH. | A lot of bug tracking software will expose SOAP methods for entering data into them.
For example, we used Axosoft's OnTime and that exposed some WSDL pages that I consumed in my application. I was told that Jira did as well. |
2,194,289 | What I am looking for is a tool that easily or automatically sends coldfusion error messages to their system.
Then I can use the web-based interface, to manage priorities, track who fixed what and so forth.
But I want to use this to help us deal with errors better, but also to show the importance of a bug tracking system to my fellow works.
System Requirements: Apache, Windows, Coldfusion 8 Standard, Sql Server 2005.
Financial Requirements: Free or Open Source
Goal Or Purpose: To encourage my fellow workers to want and use a bug tracking system.
Does this re-write make more sense?
Thanks
Craig | 2010/02/03 | [
"https://Stackoverflow.com/questions/2194289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191899/"
]
| Wiki has a list of issue tracking software, maybe this list could help.
<http://en.wikipedia.org/wiki/Comparison_of_issue_tracking_systems>
You may be able to find a hosted service and use either email or web services to create the ticket using onError. With that said, a simple issue tracking app could be created for your site using the same DB used to drive the content. 2 or 3 tables would take care of the data storage and you're already using CF so the application layer is already there.
HTH. | There are few in CF411 list: [Bug Tracking/Defect Tracking/Trouble Ticket/Help Desk Tools Written in CFML](http://www.carehart.org/cf411/#bugcfml) |
2,194,289 | What I am looking for is a tool that easily or automatically sends coldfusion error messages to their system.
Then I can use the web-based interface, to manage priorities, track who fixed what and so forth.
But I want to use this to help us deal with errors better, but also to show the importance of a bug tracking system to my fellow works.
System Requirements: Apache, Windows, Coldfusion 8 Standard, Sql Server 2005.
Financial Requirements: Free or Open Source
Goal Or Purpose: To encourage my fellow workers to want and use a bug tracking system.
Does this re-write make more sense?
Thanks
Craig | 2010/02/03 | [
"https://Stackoverflow.com/questions/2194289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191899/"
]
| A lot of good information from everyone, and I really do appreciate the efforts given. But not the answer i was looking for. Which maybe means, that what i want does not exist, yet.
So i may have to roll my own solution...Or maybe integrate with another existing app...
Thank You all. | I really like Fogbugz from the makers of Stack Overflow. For one user it's quite reasonably priced. I enter some bugs manually and have others emailed in. |
2,194,289 | What I am looking for is a tool that easily or automatically sends coldfusion error messages to their system.
Then I can use the web-based interface, to manage priorities, track who fixed what and so forth.
But I want to use this to help us deal with errors better, but also to show the importance of a bug tracking system to my fellow works.
System Requirements: Apache, Windows, Coldfusion 8 Standard, Sql Server 2005.
Financial Requirements: Free or Open Source
Goal Or Purpose: To encourage my fellow workers to want and use a bug tracking system.
Does this re-write make more sense?
Thanks
Craig | 2010/02/03 | [
"https://Stackoverflow.com/questions/2194289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191899/"
]
| A lot of good information from everyone, and I really do appreciate the efforts given. But not the answer i was looking for. Which maybe means, that what i want does not exist, yet.
So i may have to roll my own solution...Or maybe integrate with another existing app...
Thank You all. | Hard question to answer not knowing what kind of restrictions are there? Do you have any permissions to install anything? Also most bug-tracking systems require some kind of database support.
I have a suggestion. You can put in place a basic bug-tracking system, that just allows people to create tickets, and allows you/someone else to close it.
More Windows based tools are mentioned here
[Good open-source bug tracking / issue tracking sofware for Windows](https://stackoverflow.com/questions/870776/looking-for-good-open-source-bug-tracking-sofware-for-windows)
Any reason why coldfusion specifically? |
12,018,811 | I want to create a multipage PDF report using *iReport*.
When I'm designing in *iReport* it crosses A4 page size. If I increase page height, it prints out empty space in the page. How can I create a multi-page report?
The resulting report:
 | 2012/08/18 | [
"https://Stackoverflow.com/questions/12018811",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1097733/"
]
| I am using bellow code and its works perfect for me. You may also try this code.
```
<detail>
<band height="802" splitType="Stretch">
// page 1 design here
</band>
<band height="802" splitType="Stretch">
// page 2 design here
</band>
<band height="802" splitType="Stretch">
// page 3 design here
</band>
</detail>
```
[](https://i.stack.imgur.com/dRS9W.jpg)
Please Note: i set all margin as 0
[](https://i.stack.imgur.com/uyGfT.jpg) | In common properties of main report there is page setup option. There you provide the page dimensions which you want in your output. Also ignore pagination flag should be set to false |
9,947,718 | >
> **Possible Duplicate:**
>
> [VS2005 C# Programmatically change connection string contained in app.config](https://stackoverflow.com/questions/63546/vs2005-c-sharp-programmatically-change-connection-string-contained-in-app-config)
>
>
>
I have created a WinForms project in my PC using C#, and would like to deploy the project to other pc's, but I need to change the connection string in the app.config in order to connect the sql sever database in other pc's, and I want the users to configure the connection string.
How can I accomplish this? | 2012/03/30 | [
"https://Stackoverflow.com/questions/9947718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1286824/"
]
| If you've created a settings file for your project, there will be a class that represents the properties in a type-safe manner. This is typically something like `TiddleBits.Properties.Settings.Default`, where *TwiddleBits* is your assembly name.
If you haven't created a settings file for your project, do it. It vastly simplifies working with configuration files.
Once the class exists, you can read and write properties just like any other class. Just remember to save your changes once you've finished assigning properties, or they'll be discarded. | You can tell the users to edit the app.config, or you can provide a UI and use the ConfigurationManager to edit the app.config at runtime.
[Edit app config at runtime](http://itsmebhavin.wordpress.com/2012/02/08/edit-app-config-at-runtime-c/)
[Update app.config system.net setting at runtime](https://stackoverflow.com/questions/980440/update-app-config-system-net-setting-at-runtime) |
9,947,718 | >
> **Possible Duplicate:**
>
> [VS2005 C# Programmatically change connection string contained in app.config](https://stackoverflow.com/questions/63546/vs2005-c-sharp-programmatically-change-connection-string-contained-in-app-config)
>
>
>
I have created a WinForms project in my PC using C#, and would like to deploy the project to other pc's, but I need to change the connection string in the app.config in order to connect the sql sever database in other pc's, and I want the users to configure the connection string.
How can I accomplish this? | 2012/03/30 | [
"https://Stackoverflow.com/questions/9947718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1286824/"
]
| If you've created a settings file for your project, there will be a class that represents the properties in a type-safe manner. This is typically something like `TiddleBits.Properties.Settings.Default`, where *TwiddleBits* is your assembly name.
If you haven't created a settings file for your project, do it. It vastly simplifies working with configuration files.
Once the class exists, you can read and write properties just like any other class. Just remember to save your changes once you've finished assigning properties, or they'll be discarded. | Like others have said creating your own config file is the way to go. Here is some code that may help
Just create an app.config file in VS and put it in the same directory as dll. It will look something like this.
```
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="YourThing" value="Something" />
</appSettings>
</configuration>
```
Then you can load it lke this.
```
string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string configFile = System.IO.Path.Combine(appPath, "App.config");
ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
configFileMap.ExeConfigFilename = configFile;
System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
```
You can then read values like this.
```
config.AppSettings.Settings["YourThing"].Value;
```
And Save Values like this.
```
config.AppSettings.Settings["YourThing"].Value = "New Value";
config.Save();
``` |
9,947,718 | >
> **Possible Duplicate:**
>
> [VS2005 C# Programmatically change connection string contained in app.config](https://stackoverflow.com/questions/63546/vs2005-c-sharp-programmatically-change-connection-string-contained-in-app-config)
>
>
>
I have created a WinForms project in my PC using C#, and would like to deploy the project to other pc's, but I need to change the connection string in the app.config in order to connect the sql sever database in other pc's, and I want the users to configure the connection string.
How can I accomplish this? | 2012/03/30 | [
"https://Stackoverflow.com/questions/9947718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1286824/"
]
| If you've created a settings file for your project, there will be a class that represents the properties in a type-safe manner. This is typically something like `TiddleBits.Properties.Settings.Default`, where *TwiddleBits* is your assembly name.
If you haven't created a settings file for your project, do it. It vastly simplifies working with configuration files.
Once the class exists, you can read and write properties just like any other class. Just remember to save your changes once you've finished assigning properties, or they'll be discarded. | Modify the app config from code.
<http://chiragrdarji.wordpress.com/2008/09/25/how-to-change-appconfig-file-run-time-using-c/> |
9,947,718 | >
> **Possible Duplicate:**
>
> [VS2005 C# Programmatically change connection string contained in app.config](https://stackoverflow.com/questions/63546/vs2005-c-sharp-programmatically-change-connection-string-contained-in-app-config)
>
>
>
I have created a WinForms project in my PC using C#, and would like to deploy the project to other pc's, but I need to change the connection string in the app.config in order to connect the sql sever database in other pc's, and I want the users to configure the connection string.
How can I accomplish this? | 2012/03/30 | [
"https://Stackoverflow.com/questions/9947718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1286824/"
]
| You can tell the users to edit the app.config, or you can provide a UI and use the ConfigurationManager to edit the app.config at runtime.
[Edit app config at runtime](http://itsmebhavin.wordpress.com/2012/02/08/edit-app-config-at-runtime-c/)
[Update app.config system.net setting at runtime](https://stackoverflow.com/questions/980440/update-app-config-system-net-setting-at-runtime) | Modify the app config from code.
<http://chiragrdarji.wordpress.com/2008/09/25/how-to-change-appconfig-file-run-time-using-c/> |
9,947,718 | >
> **Possible Duplicate:**
>
> [VS2005 C# Programmatically change connection string contained in app.config](https://stackoverflow.com/questions/63546/vs2005-c-sharp-programmatically-change-connection-string-contained-in-app-config)
>
>
>
I have created a WinForms project in my PC using C#, and would like to deploy the project to other pc's, but I need to change the connection string in the app.config in order to connect the sql sever database in other pc's, and I want the users to configure the connection string.
How can I accomplish this? | 2012/03/30 | [
"https://Stackoverflow.com/questions/9947718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1286824/"
]
| Like others have said creating your own config file is the way to go. Here is some code that may help
Just create an app.config file in VS and put it in the same directory as dll. It will look something like this.
```
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="YourThing" value="Something" />
</appSettings>
</configuration>
```
Then you can load it lke this.
```
string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string configFile = System.IO.Path.Combine(appPath, "App.config");
ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
configFileMap.ExeConfigFilename = configFile;
System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
```
You can then read values like this.
```
config.AppSettings.Settings["YourThing"].Value;
```
And Save Values like this.
```
config.AppSettings.Settings["YourThing"].Value = "New Value";
config.Save();
``` | Modify the app config from code.
<http://chiragrdarji.wordpress.com/2008/09/25/how-to-change-appconfig-file-run-time-using-c/> |
17,017,818 | i'm not able to display the images to another page. The images are taken from json. So i'm trying to pass the image url of the selected item of a listbox into a navigagtion query string.The variable i'm trying to pass the data is showing as null.Plese provide me with solution. Thanks
Here the code of the first page:
```
private void ImageList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var lbi = (sender as ListBox).SelectedItem;
if (e.AddedItems.Count > 0)
{
Uri targetPage = new Uri("/DisplayPhoto.xaml?selectedItem="+ lbi.ToString(),UriKind.RelativeOrAbsolute);
NavigationService.Navigate(targetPage);
}
((ListBox)sender).SelectedIndex = -1;
}
```
Code of the second page:
```
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
string selectedIndex = "";
if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex))
{
Uri uri = new Uri(selectedIndex, UriKind.Absolute);
var img = new Image();
img.Source = new BitmapImage(uri);
img.Height = 400;
img.Width = 400;
listBox1.Items.Add(img);
}
base.OnNavigatedTo(e);
}
``` | 2013/06/10 | [
"https://Stackoverflow.com/questions/17017818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2194823/"
]
| You can use UIButton instead of UIImageView in tableview cell. Use following code for getting single and double tap.
```
//add target for your UITableViewCell's button
[aBtnThumbObj addTarget:self action:@selector(btnThumbClickDouble:) forControlEvents:UIControlEventTouchDownRepeat];
[aBtnThumbObj addTarget:self action:@selector(btnThumbClickSingle:) forControlEvents:UIControlEventTouchUpInside];
-(void)btnThumbClickSingle:(UIButton*)sender
{
[self performSelector:@selector(singleTapOnButtonSelector:) withObject:sender afterDelay:0.2];
}
-(void)btnThumbClickDouble:(UIButton*)sender
{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(singleTapOnButtonSelector:) object:sender];
//Your implementation for double tap
}
-(void)singleTapOnButtonSelector:(UIButton*)sender
{
//Your implementation for single tap
}
``` | You can set selection style for your cell as
```
cell.selectionStyle = UITableViewCellSelectionStyleNone;
```
And then just don't implement your -tableViewDidSelectRowAtIndexPath method |
17,017,818 | i'm not able to display the images to another page. The images are taken from json. So i'm trying to pass the image url of the selected item of a listbox into a navigagtion query string.The variable i'm trying to pass the data is showing as null.Plese provide me with solution. Thanks
Here the code of the first page:
```
private void ImageList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var lbi = (sender as ListBox).SelectedItem;
if (e.AddedItems.Count > 0)
{
Uri targetPage = new Uri("/DisplayPhoto.xaml?selectedItem="+ lbi.ToString(),UriKind.RelativeOrAbsolute);
NavigationService.Navigate(targetPage);
}
((ListBox)sender).SelectedIndex = -1;
}
```
Code of the second page:
```
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
string selectedIndex = "";
if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex))
{
Uri uri = new Uri(selectedIndex, UriKind.Absolute);
var img = new Image();
img.Source = new BitmapImage(uri);
img.Height = 400;
img.Width = 400;
listBox1.Items.Add(img);
}
base.OnNavigatedTo(e);
}
``` | 2013/06/10 | [
"https://Stackoverflow.com/questions/17017818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2194823/"
]
| You can use UIButton instead of UIImageView in tableview cell. Use following code for getting single and double tap.
```
//add target for your UITableViewCell's button
[aBtnThumbObj addTarget:self action:@selector(btnThumbClickDouble:) forControlEvents:UIControlEventTouchDownRepeat];
[aBtnThumbObj addTarget:self action:@selector(btnThumbClickSingle:) forControlEvents:UIControlEventTouchUpInside];
-(void)btnThumbClickSingle:(UIButton*)sender
{
[self performSelector:@selector(singleTapOnButtonSelector:) withObject:sender afterDelay:0.2];
}
-(void)btnThumbClickDouble:(UIButton*)sender
{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(singleTapOnButtonSelector:) object:sender];
//Your implementation for double tap
}
-(void)singleTapOnButtonSelector:(UIButton*)sender
{
//Your implementation for single tap
}
``` | These two lines of code work for me:
```
tapGesture.cancelsTouchesInView = YES;
tapGesture.delaysTouchesBegan = YES;
``` |
17,017,818 | i'm not able to display the images to another page. The images are taken from json. So i'm trying to pass the image url of the selected item of a listbox into a navigagtion query string.The variable i'm trying to pass the data is showing as null.Plese provide me with solution. Thanks
Here the code of the first page:
```
private void ImageList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var lbi = (sender as ListBox).SelectedItem;
if (e.AddedItems.Count > 0)
{
Uri targetPage = new Uri("/DisplayPhoto.xaml?selectedItem="+ lbi.ToString(),UriKind.RelativeOrAbsolute);
NavigationService.Navigate(targetPage);
}
((ListBox)sender).SelectedIndex = -1;
}
```
Code of the second page:
```
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
string selectedIndex = "";
if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex))
{
Uri uri = new Uri(selectedIndex, UriKind.Absolute);
var img = new Image();
img.Source = new BitmapImage(uri);
img.Height = 400;
img.Width = 400;
listBox1.Items.Add(img);
}
base.OnNavigatedTo(e);
}
``` | 2013/06/10 | [
"https://Stackoverflow.com/questions/17017818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2194823/"
]
| You can set selection style for your cell as
```
cell.selectionStyle = UITableViewCellSelectionStyleNone;
```
And then just don't implement your -tableViewDidSelectRowAtIndexPath method | These two lines of code work for me:
```
tapGesture.cancelsTouchesInView = YES;
tapGesture.delaysTouchesBegan = YES;
``` |
4,505,103 | I'm wondering if there is a way to calculate arrangements for this problem without enumerating all possibilities.
There are 4 work-pieces that 4 guys A, B, C, D work on during a single day. At the end of the day each person transfers his assigned work-piece to another person. Each person works on only 1 work-piece during a day. How many arrangements of transfer are possible?
E.g. A can transfer his workpiece to C (AC), or A can transfer it to B, or A can transfer it to D, but A can't transfer it to A.
One arrangement is:
```
AC (A transfers to C)
BD (B transfers to D)
CA
DB
```
For the purposes of this question the order of transfer (e.g. whether AC is written in line above BD) doesn't matter, and the above arrangement is considered same as: `CA, BD, DB, AC`. | 2022/08/03 | [
"https://math.stackexchange.com/questions/4505103",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/1083422/"
]
| These are all the permutations of a set with 4 elements without fixed points. For a set with $n$ elements see: [Fixed-point-free permutations](https://math.stackexchange.com/questions/41949/fixed-point-free-permutations) or the many equations for it ($!n$) on wikipedia <https://en.wikipedia.org/wiki/Derangement>. | Alternative approach:
Person-A can transfer to anyone of three people.
So, there will be an initial factor of $(3)$.
Now, you can assume, without loss of generality, that Person-A transfers to Person-B.
Now, there are 3 people that Person-B might transfer to:
* If Person-B transfers to Person-A, then the transfers are set, since Person-C and Person-D must then exchange.
* If Person-B transfers to Person-C, then Person-C must transfer to Person-D (or else no one is transferring to Person-D).
* Similarly, if Person-B transfers to Person-D, then Person-D must transfer to Person-C.
Therefore, if you know that Person-A transferred to Person-B, then there are $(3)$ possible ways that the transfers can be completed.
Therefore, the total number of satisfying groups of transfers is
$$3 \times 3.$$ |
220,282 | In [agar.io](http://agar.io), sources of mass are abundant. The little pellets of nutrition spawn frequently. The problem is that there are no places for mass to go - which it must do otherwise the game would run out of space. Even when people log out, their cell remains stationary until it is eaten. I'm assuming then that mass must be lost in one of the following situations:
* When splitting (via space)
* When popped (via a spike)
Is this the case? If so, how much of my total mass is lost when this happens? | 2015/05/21 | [
"https://gaming.stackexchange.com/questions/220282",
"https://gaming.stackexchange.com",
"https://gaming.stackexchange.com/users/3610/"
]
| Thanks to [Ardaozkal](https://gaming.stackexchange.com/users/87186/ardaozkal) his comment I was able to do some research.
There are a couple of reasons why the game never runs out of space,
* When just going around not collecting any orbs you seem to lose a bit off mass. The amount of mass you lose seems to be bigger if you have a lot.
* When pressing `W` you shoot out a bit off mass, picking it back up will not give you back the amount you lost.
*Splitting up or hitting a spike does not seem to make you lose anything other then your shape.* | You eject 13 mass every time you press w or, on the mobile version, click the target button, but your cell loses 18 mass, so self feeding, or ejecting mass and then eating it again, will cause you to lose mass, not stay the same. You can eat viruses when you are split into 16 pieces, and you gain 100 mass every time you eat a virus, even if you aren't split into 16 pieces. You can eat viruses by having 2 cells that can eat the virus and running one of them into the virus, so you end up with 16 cells, and you can then go around eating viruses, but you have to be careful, since other players can eat your smaller pieces, and then eat you completely. You can make new viruses by ejecting seven times into an existing virus, and a new one will be shot out in the opposite direction of the last pellet you shot out. This is very useful for splitting bigger players so that you can eat them. Try using keyword skins, which means entering a name like Earth, which will give you a Earth skin. There are a lot more of these keyword skins, and you can make your own skin it the store or other places. It costs 90 DNA, though, so try to save up. Hope this helps! |
3,759 | I'd like to ask how to download all the files from a single category or article on a Wikimedia project, more specifically Wikimedia Commons in an automated manner (i.e., I just want to run a single script to get this result and not have to download them all manually myself from my browser), but I'm wondering if this would be better asked at SuperUser SE as I'm on 64 bit Windows 7 or here. | 2015/02/24 | [
"https://webapps.meta.stackexchange.com/questions/3759",
"https://webapps.meta.stackexchange.com",
"https://webapps.meta.stackexchange.com/users/42104/"
]
| As a member of both communities, I think that kind of question would be better suited for Super User. Wikimedia Commons isn't a webapp *per se*, and you're asking about how to download files to the computer, which places your question more in SU's domain.
Please note that your question is more likely to be answered if you describe some of the research you have done about this problem; "gimme teh codez" posts are generally frowned upon. | The [Wikimedia Commons Help Desk](http://commons.wikimedia.org/wiki/Commons:Help_desk) is probably a better place to ask. You're guaranteed to be able to interact with experts on the software there.
If you're bound and determined to ask on a Stack Exchange site, then I think this one or [Super User](http://superuser.com) are appropriate; I just don't know that you'll get the answer you need.
Stack Exchange sites are great, but sometimes you really need to go to the source. |
43,626,512 | I currently have this tab view which I followed from [this](http://www.truiton.com/2015/06/android-tabs-example-fragments-viewpager/) tutorial. Everything works fine until I noticed that the `onCreateView` is not called on any of the tab. I've looked around here and there for solution but I still can't solve.
Here is my code:
`activity_pref_main_container.xml`
```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/main_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PrefActivityMain">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@id/tab_layout"/>
</RelativeLayout>
```
`PrefMainActivity.class`
```
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pref_main_container);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.preference_title);
setSupportActionBar(toolbar);
new PrefActivityListAsync(this,this,specialization).execute();
new PrefActivityListAsync(this,this,position).execute();
new PrefActivityListAsync(this,this,type).execute();
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText("Specialization"));
tabLayout.addTab(tabLayout.newTab().setText("Position"));
tabLayout.addTab(tabLayout.newTab().setText("Type"));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
final PrefAdapter adapter = new PrefAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
viewPager.setOffscreenPageLimit(2);
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
```
`PrefAdapder.class`
```
public class PrefAdapter extends FragmentPagerAdapter {
int mNumOfTabs;
public PrefAdapter(FragmentManager fm, int NumOfTabs) {
super(fm);
this.mNumOfTabs = NumOfTabs;
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
PrefActivitySpecialization tab1 = new PrefActivitySpecialization();
return tab1;
case 1:
PrefActivityPosition tab2 = new PrefActivityPosition();
return tab2;
case 2:
PrefActivityType tab3 = new PrefActivityType();
return tab3;
default:
return null;
}
}
@Override
public int getCount() {
return 0;
}
}
```
one out of three fragment class
`PrefActivitySpecialization.class`
```
public class PrefActivitySpecialization extends
android.support.v4.app.Fragment {
private ArrayList<DataPrefSpecialization> dataPrefSpecializationArrayList;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
container, Bundle savedInstanceState) {
View view =
inflater.inflate(R.layout.activity_pref_specialization_container, container,
false);
dataPrefSpecializationArrayList = ((PrefActivityMain)
getActivity()).getDataPrefSpecialization();
for(int i = 0; i < dataPrefSpecializationArrayList.size(); i++){
Log.d("Check Specialization
",dataPrefSpecializationArrayList.get(i).getName());
}
return inflater.inflate(R.layout.activity_pref_specialization_container, container, false);
}
}
``` | 2017/04/26 | [
"https://Stackoverflow.com/questions/43626512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6541772/"
]
| >
> public PrefAdapter(FragmentManager fm, int NumOfTabs)
>
>
>
You must declare Count No **NumOfTabs**
>
> int getCount ()-> How many items are in the data set represented by this
> Adapter.
>
>
>
```
@Override
public int getCount()
{
return mNumOfTabs;
}
```
***Do not***'
```
return inflater.inflate(R.layout.activity_pref_specialization_container, container, false);
```
***Do***
```
return view ;
``` | Your `getCount()` method is returning 0; |
43,626,512 | I currently have this tab view which I followed from [this](http://www.truiton.com/2015/06/android-tabs-example-fragments-viewpager/) tutorial. Everything works fine until I noticed that the `onCreateView` is not called on any of the tab. I've looked around here and there for solution but I still can't solve.
Here is my code:
`activity_pref_main_container.xml`
```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/main_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PrefActivityMain">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@id/tab_layout"/>
</RelativeLayout>
```
`PrefMainActivity.class`
```
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pref_main_container);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.preference_title);
setSupportActionBar(toolbar);
new PrefActivityListAsync(this,this,specialization).execute();
new PrefActivityListAsync(this,this,position).execute();
new PrefActivityListAsync(this,this,type).execute();
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText("Specialization"));
tabLayout.addTab(tabLayout.newTab().setText("Position"));
tabLayout.addTab(tabLayout.newTab().setText("Type"));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
final PrefAdapter adapter = new PrefAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
viewPager.setOffscreenPageLimit(2);
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
```
`PrefAdapder.class`
```
public class PrefAdapter extends FragmentPagerAdapter {
int mNumOfTabs;
public PrefAdapter(FragmentManager fm, int NumOfTabs) {
super(fm);
this.mNumOfTabs = NumOfTabs;
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
PrefActivitySpecialization tab1 = new PrefActivitySpecialization();
return tab1;
case 1:
PrefActivityPosition tab2 = new PrefActivityPosition();
return tab2;
case 2:
PrefActivityType tab3 = new PrefActivityType();
return tab3;
default:
return null;
}
}
@Override
public int getCount() {
return 0;
}
}
```
one out of three fragment class
`PrefActivitySpecialization.class`
```
public class PrefActivitySpecialization extends
android.support.v4.app.Fragment {
private ArrayList<DataPrefSpecialization> dataPrefSpecializationArrayList;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
container, Bundle savedInstanceState) {
View view =
inflater.inflate(R.layout.activity_pref_specialization_container, container,
false);
dataPrefSpecializationArrayList = ((PrefActivityMain)
getActivity()).getDataPrefSpecialization();
for(int i = 0; i < dataPrefSpecializationArrayList.size(); i++){
Log.d("Check Specialization
",dataPrefSpecializationArrayList.get(i).getName());
}
return inflater.inflate(R.layout.activity_pref_specialization_container, container, false);
}
}
``` | 2017/04/26 | [
"https://Stackoverflow.com/questions/43626512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6541772/"
]
| You should make changes at two place:
1) Change
```
@Override
public int getCount() {
return 0;
}
```
to
```
@Override
public int getCount() {
return mNumOfTabs;
}
```
2) Change
```
return inflater.inflate(R.layout.activity_pref_specialization_container, container, false);
```
to
```
return view;
``` | >
> public PrefAdapter(FragmentManager fm, int NumOfTabs)
>
>
>
You must declare Count No **NumOfTabs**
>
> int getCount ()-> How many items are in the data set represented by this
> Adapter.
>
>
>
```
@Override
public int getCount()
{
return mNumOfTabs;
}
```
***Do not***'
```
return inflater.inflate(R.layout.activity_pref_specialization_container, container, false);
```
***Do***
```
return view ;
``` |
43,626,512 | I currently have this tab view which I followed from [this](http://www.truiton.com/2015/06/android-tabs-example-fragments-viewpager/) tutorial. Everything works fine until I noticed that the `onCreateView` is not called on any of the tab. I've looked around here and there for solution but I still can't solve.
Here is my code:
`activity_pref_main_container.xml`
```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/main_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PrefActivityMain">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@id/tab_layout"/>
</RelativeLayout>
```
`PrefMainActivity.class`
```
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pref_main_container);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.preference_title);
setSupportActionBar(toolbar);
new PrefActivityListAsync(this,this,specialization).execute();
new PrefActivityListAsync(this,this,position).execute();
new PrefActivityListAsync(this,this,type).execute();
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText("Specialization"));
tabLayout.addTab(tabLayout.newTab().setText("Position"));
tabLayout.addTab(tabLayout.newTab().setText("Type"));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
final PrefAdapter adapter = new PrefAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
viewPager.setOffscreenPageLimit(2);
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
```
`PrefAdapder.class`
```
public class PrefAdapter extends FragmentPagerAdapter {
int mNumOfTabs;
public PrefAdapter(FragmentManager fm, int NumOfTabs) {
super(fm);
this.mNumOfTabs = NumOfTabs;
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
PrefActivitySpecialization tab1 = new PrefActivitySpecialization();
return tab1;
case 1:
PrefActivityPosition tab2 = new PrefActivityPosition();
return tab2;
case 2:
PrefActivityType tab3 = new PrefActivityType();
return tab3;
default:
return null;
}
}
@Override
public int getCount() {
return 0;
}
}
```
one out of three fragment class
`PrefActivitySpecialization.class`
```
public class PrefActivitySpecialization extends
android.support.v4.app.Fragment {
private ArrayList<DataPrefSpecialization> dataPrefSpecializationArrayList;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
container, Bundle savedInstanceState) {
View view =
inflater.inflate(R.layout.activity_pref_specialization_container, container,
false);
dataPrefSpecializationArrayList = ((PrefActivityMain)
getActivity()).getDataPrefSpecialization();
for(int i = 0; i < dataPrefSpecializationArrayList.size(); i++){
Log.d("Check Specialization
",dataPrefSpecializationArrayList.get(i).getName());
}
return inflater.inflate(R.layout.activity_pref_specialization_container, container, false);
}
}
``` | 2017/04/26 | [
"https://Stackoverflow.com/questions/43626512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6541772/"
]
| >
> public PrefAdapter(FragmentManager fm, int NumOfTabs)
>
>
>
You must declare Count No **NumOfTabs**
>
> int getCount ()-> How many items are in the data set represented by this
> Adapter.
>
>
>
```
@Override
public int getCount()
{
return mNumOfTabs;
}
```
***Do not***'
```
return inflater.inflate(R.layout.activity_pref_specialization_container, container, false);
```
***Do***
```
return view ;
``` | There is another (possibly easier) way to connect the view pager with the tab layout-
First, in your `PrefAdapter` class, override the `getPageTitle()` method and return your tab titles for the respective tab positions from there.
In your `PrefMainActivity` class, remove all the lines like-
`tabLayout.addTab(...)`
Add the following line instead-
`tabLayout.setupWithViewPager(viewPager);` |
43,626,512 | I currently have this tab view which I followed from [this](http://www.truiton.com/2015/06/android-tabs-example-fragments-viewpager/) tutorial. Everything works fine until I noticed that the `onCreateView` is not called on any of the tab. I've looked around here and there for solution but I still can't solve.
Here is my code:
`activity_pref_main_container.xml`
```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/main_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PrefActivityMain">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@id/tab_layout"/>
</RelativeLayout>
```
`PrefMainActivity.class`
```
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pref_main_container);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.preference_title);
setSupportActionBar(toolbar);
new PrefActivityListAsync(this,this,specialization).execute();
new PrefActivityListAsync(this,this,position).execute();
new PrefActivityListAsync(this,this,type).execute();
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText("Specialization"));
tabLayout.addTab(tabLayout.newTab().setText("Position"));
tabLayout.addTab(tabLayout.newTab().setText("Type"));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
final PrefAdapter adapter = new PrefAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
viewPager.setOffscreenPageLimit(2);
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
```
`PrefAdapder.class`
```
public class PrefAdapter extends FragmentPagerAdapter {
int mNumOfTabs;
public PrefAdapter(FragmentManager fm, int NumOfTabs) {
super(fm);
this.mNumOfTabs = NumOfTabs;
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
PrefActivitySpecialization tab1 = new PrefActivitySpecialization();
return tab1;
case 1:
PrefActivityPosition tab2 = new PrefActivityPosition();
return tab2;
case 2:
PrefActivityType tab3 = new PrefActivityType();
return tab3;
default:
return null;
}
}
@Override
public int getCount() {
return 0;
}
}
```
one out of three fragment class
`PrefActivitySpecialization.class`
```
public class PrefActivitySpecialization extends
android.support.v4.app.Fragment {
private ArrayList<DataPrefSpecialization> dataPrefSpecializationArrayList;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
container, Bundle savedInstanceState) {
View view =
inflater.inflate(R.layout.activity_pref_specialization_container, container,
false);
dataPrefSpecializationArrayList = ((PrefActivityMain)
getActivity()).getDataPrefSpecialization();
for(int i = 0; i < dataPrefSpecializationArrayList.size(); i++){
Log.d("Check Specialization
",dataPrefSpecializationArrayList.get(i).getName());
}
return inflater.inflate(R.layout.activity_pref_specialization_container, container, false);
}
}
``` | 2017/04/26 | [
"https://Stackoverflow.com/questions/43626512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6541772/"
]
| You should make changes at two place:
1) Change
```
@Override
public int getCount() {
return 0;
}
```
to
```
@Override
public int getCount() {
return mNumOfTabs;
}
```
2) Change
```
return inflater.inflate(R.layout.activity_pref_specialization_container, container, false);
```
to
```
return view;
``` | Your `getCount()` method is returning 0; |
43,626,512 | I currently have this tab view which I followed from [this](http://www.truiton.com/2015/06/android-tabs-example-fragments-viewpager/) tutorial. Everything works fine until I noticed that the `onCreateView` is not called on any of the tab. I've looked around here and there for solution but I still can't solve.
Here is my code:
`activity_pref_main_container.xml`
```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/main_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PrefActivityMain">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@id/tab_layout"/>
</RelativeLayout>
```
`PrefMainActivity.class`
```
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pref_main_container);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.preference_title);
setSupportActionBar(toolbar);
new PrefActivityListAsync(this,this,specialization).execute();
new PrefActivityListAsync(this,this,position).execute();
new PrefActivityListAsync(this,this,type).execute();
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText("Specialization"));
tabLayout.addTab(tabLayout.newTab().setText("Position"));
tabLayout.addTab(tabLayout.newTab().setText("Type"));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
final PrefAdapter adapter = new PrefAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
viewPager.setOffscreenPageLimit(2);
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
```
`PrefAdapder.class`
```
public class PrefAdapter extends FragmentPagerAdapter {
int mNumOfTabs;
public PrefAdapter(FragmentManager fm, int NumOfTabs) {
super(fm);
this.mNumOfTabs = NumOfTabs;
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
PrefActivitySpecialization tab1 = new PrefActivitySpecialization();
return tab1;
case 1:
PrefActivityPosition tab2 = new PrefActivityPosition();
return tab2;
case 2:
PrefActivityType tab3 = new PrefActivityType();
return tab3;
default:
return null;
}
}
@Override
public int getCount() {
return 0;
}
}
```
one out of three fragment class
`PrefActivitySpecialization.class`
```
public class PrefActivitySpecialization extends
android.support.v4.app.Fragment {
private ArrayList<DataPrefSpecialization> dataPrefSpecializationArrayList;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
container, Bundle savedInstanceState) {
View view =
inflater.inflate(R.layout.activity_pref_specialization_container, container,
false);
dataPrefSpecializationArrayList = ((PrefActivityMain)
getActivity()).getDataPrefSpecialization();
for(int i = 0; i < dataPrefSpecializationArrayList.size(); i++){
Log.d("Check Specialization
",dataPrefSpecializationArrayList.get(i).getName());
}
return inflater.inflate(R.layout.activity_pref_specialization_container, container, false);
}
}
``` | 2017/04/26 | [
"https://Stackoverflow.com/questions/43626512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6541772/"
]
| Your `getCount()` method is returning 0; | There is another (possibly easier) way to connect the view pager with the tab layout-
First, in your `PrefAdapter` class, override the `getPageTitle()` method and return your tab titles for the respective tab positions from there.
In your `PrefMainActivity` class, remove all the lines like-
`tabLayout.addTab(...)`
Add the following line instead-
`tabLayout.setupWithViewPager(viewPager);` |
43,626,512 | I currently have this tab view which I followed from [this](http://www.truiton.com/2015/06/android-tabs-example-fragments-viewpager/) tutorial. Everything works fine until I noticed that the `onCreateView` is not called on any of the tab. I've looked around here and there for solution but I still can't solve.
Here is my code:
`activity_pref_main_container.xml`
```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/main_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PrefActivityMain">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@id/tab_layout"/>
</RelativeLayout>
```
`PrefMainActivity.class`
```
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pref_main_container);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.preference_title);
setSupportActionBar(toolbar);
new PrefActivityListAsync(this,this,specialization).execute();
new PrefActivityListAsync(this,this,position).execute();
new PrefActivityListAsync(this,this,type).execute();
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText("Specialization"));
tabLayout.addTab(tabLayout.newTab().setText("Position"));
tabLayout.addTab(tabLayout.newTab().setText("Type"));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
final PrefAdapter adapter = new PrefAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
viewPager.setOffscreenPageLimit(2);
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
```
`PrefAdapder.class`
```
public class PrefAdapter extends FragmentPagerAdapter {
int mNumOfTabs;
public PrefAdapter(FragmentManager fm, int NumOfTabs) {
super(fm);
this.mNumOfTabs = NumOfTabs;
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
PrefActivitySpecialization tab1 = new PrefActivitySpecialization();
return tab1;
case 1:
PrefActivityPosition tab2 = new PrefActivityPosition();
return tab2;
case 2:
PrefActivityType tab3 = new PrefActivityType();
return tab3;
default:
return null;
}
}
@Override
public int getCount() {
return 0;
}
}
```
one out of three fragment class
`PrefActivitySpecialization.class`
```
public class PrefActivitySpecialization extends
android.support.v4.app.Fragment {
private ArrayList<DataPrefSpecialization> dataPrefSpecializationArrayList;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
container, Bundle savedInstanceState) {
View view =
inflater.inflate(R.layout.activity_pref_specialization_container, container,
false);
dataPrefSpecializationArrayList = ((PrefActivityMain)
getActivity()).getDataPrefSpecialization();
for(int i = 0; i < dataPrefSpecializationArrayList.size(); i++){
Log.d("Check Specialization
",dataPrefSpecializationArrayList.get(i).getName());
}
return inflater.inflate(R.layout.activity_pref_specialization_container, container, false);
}
}
``` | 2017/04/26 | [
"https://Stackoverflow.com/questions/43626512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6541772/"
]
| You should make changes at two place:
1) Change
```
@Override
public int getCount() {
return 0;
}
```
to
```
@Override
public int getCount() {
return mNumOfTabs;
}
```
2) Change
```
return inflater.inflate(R.layout.activity_pref_specialization_container, container, false);
```
to
```
return view;
``` | There is another (possibly easier) way to connect the view pager with the tab layout-
First, in your `PrefAdapter` class, override the `getPageTitle()` method and return your tab titles for the respective tab positions from there.
In your `PrefMainActivity` class, remove all the lines like-
`tabLayout.addTab(...)`
Add the following line instead-
`tabLayout.setupWithViewPager(viewPager);` |
53,407,728 | I need to create a runnable jar file that will be operated in Batch mode.
During development I need to use following api/frameworks apache-poi,hibernate,Spring etc.
So,I prefer to go with maven:
Please find below my maven file:
```
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mypackage</groupId>
<artifactId>myartifact</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.17.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>fully.qualified.classpath.Main</mainClass>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
```
I am running the maven build from eclipse as `clean package`.
Build completes successfully.But in the generated jar all the dependent jar
is not present [spring/hibernate/poi] etc.
We need to run this jar as `java -jar jarname` from command prompt/console. | 2018/11/21 | [
"https://Stackoverflow.com/questions/53407728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3945085/"
]
| Consider using [Maven Shade Plugin](https://maven.apache.org/plugins/maven-shade-plugin/).
>
> This plugin provides the capability to package the artifact in an uber-jar, including its dependencies
>
>
>
Spring framework can do similar thing for you. [Generate sample project](https://start.spring.io/) and check its `pom` file. | `maven-jar-plugin` provides the capability to build jars without dependencies.
To create jar with all it's dependencies you can use `maven-assembly-plugin` or `maven-shade-plugin`. Below is `maven-assembly-plugin` configuration in `pom.xml`:
```
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>
fully.qualified.classpath.Main
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
```
More information: [executable-jar-with-maven](https://www.baeldung.com/executable-jar-with-maven) |
53,407,728 | I need to create a runnable jar file that will be operated in Batch mode.
During development I need to use following api/frameworks apache-poi,hibernate,Spring etc.
So,I prefer to go with maven:
Please find below my maven file:
```
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mypackage</groupId>
<artifactId>myartifact</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.17.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>5.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>fully.qualified.classpath.Main</mainClass>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
```
I am running the maven build from eclipse as `clean package`.
Build completes successfully.But in the generated jar all the dependent jar
is not present [spring/hibernate/poi] etc.
We need to run this jar as `java -jar jarname` from command prompt/console. | 2018/11/21 | [
"https://Stackoverflow.com/questions/53407728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3945085/"
]
| Consider using [Maven Shade Plugin](https://maven.apache.org/plugins/maven-shade-plugin/).
>
> This plugin provides the capability to package the artifact in an uber-jar, including its dependencies
>
>
>
Spring framework can do similar thing for you. [Generate sample project](https://start.spring.io/) and check its `pom` file. | Try this out inside your pom.xml file:
```
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes/lib</outputDirectory>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
``` |
24,933,989 | I have to add text for example `<meta tag...>` in my project in all files "\*\*.html\*" after "\*`<title>title page</title>*` text.
For Example:
```
.....blablalbalblala
<title>title page</title>
**<meta... tag/>** //inserted text
.....
```
I know how to find \*.html files with text ... but how to add text after this tag? | 2014/07/24 | [
"https://Stackoverflow.com/questions/24933989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3459112/"
]
| * Search for all occurrences of `</title>`
* In the Search view, remove all matches that you don't want to replace
* Invoke the context menu, choose `Replace All...`
* Replace your matches with `</title><meta... tag/>`
If you want the meta tag to be placed on a new line, you can search with the checkbox for `Regular expression` enabled. Then you can replace with `</title>\n <meta... tag/>`
You can then also reference matches from your search:
* searching for `<tile>([^<]+)</title>`
* and replacing with `\0\n<meta \1/>`
* will e.g. change `<title>abcd</title` into
<title>abcd</title>
<meta abcd/> | If you'are using Linux, you can open a terminal, going in your project dir and do:
```
A="<meta tag...>"
B="</title>"
awk -v "pattern=$A" '{print} /^$B/ && !x {print A; x=1}' filename > tmp
cat tmp > filename
rm tmp
```
if you want to apply to all your file, make a script, say "addMeta":
```
#!/bin/bash
cd $1
A="<meta tag...>"
B="</title>"
for file in $(find -name "*.html"); do
awk -v "pattern=$A" '{print} /^$B/ && !x {print A; x=1}' ${file} > tmp
cat tmp > ${file}
rm tmp
done
```
And then you can:
```
chmod +x addMeta
./addMeta ~/workspace/Project
```
Script is to prefer to ctrl+F and Replace **IF** you have to do this modify to many files. |
24,933,989 | I have to add text for example `<meta tag...>` in my project in all files "\*\*.html\*" after "\*`<title>title page</title>*` text.
For Example:
```
.....blablalbalblala
<title>title page</title>
**<meta... tag/>** //inserted text
.....
```
I know how to find \*.html files with text ... but how to add text after this tag? | 2014/07/24 | [
"https://Stackoverflow.com/questions/24933989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3459112/"
]
| Refer images. Select your **project** in package explorer, I selected package. Press `Ctrl`+`H`

Note down the number of **search hits** after searching. In below picture it is present below the view toolbar. Here it is 3.

**Replace hits**(in below picture it is above the **Replace** **Replace** text box i.e 3) must match the **search hit** shown in above picture.
 | If you'are using Linux, you can open a terminal, going in your project dir and do:
```
A="<meta tag...>"
B="</title>"
awk -v "pattern=$A" '{print} /^$B/ && !x {print A; x=1}' filename > tmp
cat tmp > filename
rm tmp
```
if you want to apply to all your file, make a script, say "addMeta":
```
#!/bin/bash
cd $1
A="<meta tag...>"
B="</title>"
for file in $(find -name "*.html"); do
awk -v "pattern=$A" '{print} /^$B/ && !x {print A; x=1}' ${file} > tmp
cat tmp > ${file}
rm tmp
done
```
And then you can:
```
chmod +x addMeta
./addMeta ~/workspace/Project
```
Script is to prefer to ctrl+F and Replace **IF** you have to do this modify to many files. |
57,414,633 | Is there a way/policy using which I can deny all users except one who can invoke an API endpoint at AWS API Gateway?
Policy currently used:
```
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::account_id:user/user-name"
},
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:region:account_id:api_to_be_invoked/*/*"
}
]
}
```
I applied the above policy at the API Gateway's Resource Policy and deployed it, but then, just to test, I tried using another admin user's access and secret key to POST through Postman, and it still successfully did, which I do not want.
Any help? | 2019/08/08 | [
"https://Stackoverflow.com/questions/57414633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5536733/"
]
| ```
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"NotPrincipal": {
"AWS":
[ "arn:aws:iam::account_id:user/user-name",
"arn:aws:iam::account_id:root"
]
},
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:region:account_id:api_to_be_invoked/*/*"
}
]
}
``` | Did you try to use **IAM Policies Conditions**?
I haven't tried it in a production environment but it should fulfil your need.
```
{"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:region:account_id:api_to_be_invoked/*/*",
"Condition": {
"StringNotEquals" : {
"aws:username" : "your_user_name"
}
}
}
]}
```
Please let me know if this answer helped. |
4,940,982 | My goal is to use a [Greasemonkey-style user script](http://www.chromium.org/developers/design-documents/user-scripts) in Google Chrome to enable remembering of passwords on a specific form that has the `autocomplete="off"` attribute set.
Chrome's developer tools indicate that `autocomplete="on"` is being successfully set by the script, but this does not have the expected effect of allowing the storage of passwords on the form.
Why doesn't this work?
---
Example
-------
Chrome offers to remember passwords entered on this test page (Expected):
```
<html><body><form action="">
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" name="submit" value="Log In" />
</form></body></html>
```
Chrome does not offer to remember passwords entered on this test page (Expected):
```
<html><body><form action="">
<input type="text" name="username" />
<input type="password" name="password" autocomplete="off" />
<input type="submit" name="submit" value="Log In" />
</form></body></html>
```
Chrome's *Inspect Element* tool reveals a successful modification of the above test page by the user script (Expected):
```
<html><head></head><body><form action="" autocomplete="on">
<input type="text" name="username" autocomplete="on">
<input type="password" name="password" autocomplete="on">
<input type="submit" name="submit" value="Log In">
</form></body></html>
```
Chrome still does not offer to remember passwords after this modification (Unexpected). | 2011/02/09 | [
"https://Stackoverflow.com/questions/4940982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/507177/"
]
| One of my favorite jQuery form validation plugins has to be [Happy.js](http://happyjs.com/). It's very lightweight and extensible, and requires very little effort to get working. | The standard way to validate with jQuery is to just use the [jQuery validation plugin](http://docs.jquery.com/Plugins/validation). It's widely used, regularly maintained, easy to use and mature. There's no point in rewriting something that's already been done. You can obviously use this plugin to control form submission. |
332,095 | I am running a MacBook Pro Early 2015 13" on High Sierra 10.13.5, and keep getting the "X disk cannot be ejected because one or more programs might be using it" message, when apparently there is no program using that disk (not even Dropbox, Preview).
It happens sometimes when I try ejecting an external thunderbolt Drive, and always when ejecting any .sparseimages
I only managed to "solve" this issue and be able to eject the disks by going into Terminal and "respringing" Finder:
```
killall Finder
```
However, I find this solution really inconvenient considering how often I use External Drives and disk images.
I would appreciate if anyone knows any other possible cause or solution, or if my solution is better than forcing the disk to eject.
Edit: After checking what processes were running, it seems there are "cloudd", "diskimage" and "QuickLookUIService" processes using a video file from the sparsedisk that are preventing me from ejecting the mounted sparseimage.
Thanks | 2018/07/26 | [
"https://apple.stackexchange.com/questions/332095",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/292129/"
]
| Often when a drive is plugged in Spotlight begins to index the entire drive. While this is occurring Spotlight is "using" the drive and therefore can't be ejected.
Try adding a Spotlight exception:
1. System Preferences>Spotlight>Privacy
2. `+`
3. Select your drive
4. `Choose` | You should download the **Mountain** app. It gives you better control over all mounted volumes. It has been able to unmount or mount disks that I seem to have no control over. It's $6 from the [developer site.](https://appgineers.de). Before spending the money I would read about it at that site to ensure it does all you want. |
6,820,694 | I have a controller `games` and a method:
```
def index
@games = Game.all
end
def set_game
@current_game = Game.find(params[:set_game])
end
```
In my view I have:
```
<%= form_tag("/games") do %>
<% @games.each do |g| %>
<%= radio_button_tag(:game_id, g.id) %>
<%= label_tag(:game_name, g.name) %><br>
<% end %>
<%= submit_tag "Confirm" %>
<% end %>
```
Routes:
```
resources :games
match 'games', :to => 'game#index'
```
How can I make this form work for my `set_game` method?
Thanks. | 2011/07/25 | [
"https://Stackoverflow.com/questions/6820694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/854569/"
]
| ```
<%= form_tag(set_game_games_path) do %>
...
<% end %>
#routes.rb
resources :games do
collection do
get '/set_game', :as => :set_game
end
end
``` | That's an example of a custom route:
```
match "customroute" => "controller#action", :as => "customroutename"
```
This can be then accessed with "customroutename\_url" in your views. If you want to create a custom route for your set\_game action, for example, it would be
```
match "setgame" => "games#set_game", :as => "setgame"
```
Then you can do
```
<%= form_tag setgame_url %>
...
<% end %>
```
You can read more about custom routes here: <http://guides.rubyonrails.org/routing.html#non-resourceful-routes> |
12,016,725 | >
> **Possible Duplicate:**
>
> [Using jQuery to test if an input has focus](https://stackoverflow.com/questions/967096/using-jquery-to-test-if-an-input-has-focus)
>
>
>
I need to check if a particular textbox has the focus or not using jQuery. So my code is like this, but it is not working:
```
if (document.getElementById("lastname").focus = true) {
alert("hello");
}
```
My use-case is this: I have a textbox which should be shown or hidden when the `#lastname` textbox gains or loses focus. However, if the `#lastname` textbox loses the focus to the other textbox, the latter should remain visible until it loses focus as well.
Any help will be appreciated. | 2012/08/18 | [
"https://Stackoverflow.com/questions/12016725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/853575/"
]
| ```
if (document.getElementById("lastname").focus == true) {
alert("hello");
}
```
Check with == , using = is an assignment | Try this
```
var status = $('#lastname').is(":focus");
alert(status);//false or true
``` |
12,016,725 | >
> **Possible Duplicate:**
>
> [Using jQuery to test if an input has focus](https://stackoverflow.com/questions/967096/using-jquery-to-test-if-an-input-has-focus)
>
>
>
I need to check if a particular textbox has the focus or not using jQuery. So my code is like this, but it is not working:
```
if (document.getElementById("lastname").focus = true) {
alert("hello");
}
```
My use-case is this: I have a textbox which should be shown or hidden when the `#lastname` textbox gains or loses focus. However, if the `#lastname` textbox loses the focus to the other textbox, the latter should remain visible until it loses focus as well.
Any help will be appreciated. | 2012/08/18 | [
"https://Stackoverflow.com/questions/12016725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/853575/"
]
| ```
if ($("#lastname").is(':focus')) {
alert("hello");
}
```
[jQuery docs for `:focus`](http://api.jquery.com/focus-selector/)
[jQuery docs for `.is()`](http://api.jquery.com/is/)
---
**Update:**
To show/hide an element when the field gains/loses focus use the `focusin` and `focusout` events handlers:
```
$(document).ready(function() {
$('#lastname').focusin(function() {
$(hidden-element).show();
}).add(hidden-element).focusout(function() {
if ( !$(hidden-element).is(':focus') ) {
$(hidden-element).hide();
}
});
});
//where hidden-element is a reference to or selector for your hidden text field
``` | ```
<script type="text/javascript" language="javascript">
function check() {
if ($(document.activeElement).attr("id") === "element_name") {
alert('checkbox is focused');
}
}
</script>
``` |
12,016,725 | >
> **Possible Duplicate:**
>
> [Using jQuery to test if an input has focus](https://stackoverflow.com/questions/967096/using-jquery-to-test-if-an-input-has-focus)
>
>
>
I need to check if a particular textbox has the focus or not using jQuery. So my code is like this, but it is not working:
```
if (document.getElementById("lastname").focus = true) {
alert("hello");
}
```
My use-case is this: I have a textbox which should be shown or hidden when the `#lastname` textbox gains or loses focus. However, if the `#lastname` textbox loses the focus to the other textbox, the latter should remain visible until it loses focus as well.
Any help will be appreciated. | 2012/08/18 | [
"https://Stackoverflow.com/questions/12016725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/853575/"
]
| ```
if ($("#lastname").is(':focus')) {
alert("hello");
}
```
[jQuery docs for `:focus`](http://api.jquery.com/focus-selector/)
[jQuery docs for `.is()`](http://api.jquery.com/is/)
---
**Update:**
To show/hide an element when the field gains/loses focus use the `focusin` and `focusout` events handlers:
```
$(document).ready(function() {
$('#lastname').focusin(function() {
$(hidden-element).show();
}).add(hidden-element).focusout(function() {
if ( !$(hidden-element).is(':focus') ) {
$(hidden-element).hide();
}
});
});
//where hidden-element is a reference to or selector for your hidden text field
``` | ```
$("#lastname").focus(function(){
alert("lastname has focus");
});
``` |
12,016,725 | >
> **Possible Duplicate:**
>
> [Using jQuery to test if an input has focus](https://stackoverflow.com/questions/967096/using-jquery-to-test-if-an-input-has-focus)
>
>
>
I need to check if a particular textbox has the focus or not using jQuery. So my code is like this, but it is not working:
```
if (document.getElementById("lastname").focus = true) {
alert("hello");
}
```
My use-case is this: I have a textbox which should be shown or hidden when the `#lastname` textbox gains or loses focus. However, if the `#lastname` textbox loses the focus to the other textbox, the latter should remain visible until it loses focus as well.
Any help will be appreciated. | 2012/08/18 | [
"https://Stackoverflow.com/questions/12016725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/853575/"
]
| ```
$("#lastname").focus(function(){
alert("lastname has focus");
});
``` | ```
<script type="text/javascript" language="javascript">
function check() {
if ($(document.activeElement).attr("id") === "element_name") {
alert('checkbox is focused');
}
}
</script>
``` |
12,016,725 | >
> **Possible Duplicate:**
>
> [Using jQuery to test if an input has focus](https://stackoverflow.com/questions/967096/using-jquery-to-test-if-an-input-has-focus)
>
>
>
I need to check if a particular textbox has the focus or not using jQuery. So my code is like this, but it is not working:
```
if (document.getElementById("lastname").focus = true) {
alert("hello");
}
```
My use-case is this: I have a textbox which should be shown or hidden when the `#lastname` textbox gains or loses focus. However, if the `#lastname` textbox loses the focus to the other textbox, the latter should remain visible until it loses focus as well.
Any help will be appreciated. | 2012/08/18 | [
"https://Stackoverflow.com/questions/12016725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/853575/"
]
| ```
if ($("#lastname").is(':focus')) {
alert("hello");
}
```
[jQuery docs for `:focus`](http://api.jquery.com/focus-selector/)
[jQuery docs for `.is()`](http://api.jquery.com/is/)
---
**Update:**
To show/hide an element when the field gains/loses focus use the `focusin` and `focusout` events handlers:
```
$(document).ready(function() {
$('#lastname').focusin(function() {
$(hidden-element).show();
}).add(hidden-element).focusout(function() {
if ( !$(hidden-element).is(':focus') ) {
$(hidden-element).hide();
}
});
});
//where hidden-element is a reference to or selector for your hidden text field
``` | You can try jQuery's [:focus](http://api.jquery.com/focus-selector/) selector. Or you can always add a class and check for that class. |
12,016,725 | >
> **Possible Duplicate:**
>
> [Using jQuery to test if an input has focus](https://stackoverflow.com/questions/967096/using-jquery-to-test-if-an-input-has-focus)
>
>
>
I need to check if a particular textbox has the focus or not using jQuery. So my code is like this, but it is not working:
```
if (document.getElementById("lastname").focus = true) {
alert("hello");
}
```
My use-case is this: I have a textbox which should be shown or hidden when the `#lastname` textbox gains or loses focus. However, if the `#lastname` textbox loses the focus to the other textbox, the latter should remain visible until it loses focus as well.
Any help will be appreciated. | 2012/08/18 | [
"https://Stackoverflow.com/questions/12016725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/853575/"
]
| ```
if ($("#lastname").is(':focus')) {
alert("hello");
}
```
[jQuery docs for `:focus`](http://api.jquery.com/focus-selector/)
[jQuery docs for `.is()`](http://api.jquery.com/is/)
---
**Update:**
To show/hide an element when the field gains/loses focus use the `focusin` and `focusout` events handlers:
```
$(document).ready(function() {
$('#lastname').focusin(function() {
$(hidden-element).show();
}).add(hidden-element).focusout(function() {
if ( !$(hidden-element).is(':focus') ) {
$(hidden-element).hide();
}
});
});
//where hidden-element is a reference to or selector for your hidden text field
``` | ```
if (document.getElementById("lastname").focus == true) {
alert("hello");
}
```
Check with == , using = is an assignment |
12,016,725 | >
> **Possible Duplicate:**
>
> [Using jQuery to test if an input has focus](https://stackoverflow.com/questions/967096/using-jquery-to-test-if-an-input-has-focus)
>
>
>
I need to check if a particular textbox has the focus or not using jQuery. So my code is like this, but it is not working:
```
if (document.getElementById("lastname").focus = true) {
alert("hello");
}
```
My use-case is this: I have a textbox which should be shown or hidden when the `#lastname` textbox gains or loses focus. However, if the `#lastname` textbox loses the focus to the other textbox, the latter should remain visible until it loses focus as well.
Any help will be appreciated. | 2012/08/18 | [
"https://Stackoverflow.com/questions/12016725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/853575/"
]
| ```
$("#lastname").focus(function(){
alert("lastname has focus");
});
``` | You can try jQuery's [:focus](http://api.jquery.com/focus-selector/) selector. Or you can always add a class and check for that class. |
12,016,725 | >
> **Possible Duplicate:**
>
> [Using jQuery to test if an input has focus](https://stackoverflow.com/questions/967096/using-jquery-to-test-if-an-input-has-focus)
>
>
>
I need to check if a particular textbox has the focus or not using jQuery. So my code is like this, but it is not working:
```
if (document.getElementById("lastname").focus = true) {
alert("hello");
}
```
My use-case is this: I have a textbox which should be shown or hidden when the `#lastname` textbox gains or loses focus. However, if the `#lastname` textbox loses the focus to the other textbox, the latter should remain visible until it loses focus as well.
Any help will be appreciated. | 2012/08/18 | [
"https://Stackoverflow.com/questions/12016725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/853575/"
]
| ```
$("#lastname").focus(function(){
alert("lastname has focus");
});
``` | Try this
```
var status = $('#lastname').is(":focus");
alert(status);//false or true
``` |
12,016,725 | >
> **Possible Duplicate:**
>
> [Using jQuery to test if an input has focus](https://stackoverflow.com/questions/967096/using-jquery-to-test-if-an-input-has-focus)
>
>
>
I need to check if a particular textbox has the focus or not using jQuery. So my code is like this, but it is not working:
```
if (document.getElementById("lastname").focus = true) {
alert("hello");
}
```
My use-case is this: I have a textbox which should be shown or hidden when the `#lastname` textbox gains or loses focus. However, if the `#lastname` textbox loses the focus to the other textbox, the latter should remain visible until it loses focus as well.
Any help will be appreciated. | 2012/08/18 | [
"https://Stackoverflow.com/questions/12016725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/853575/"
]
| ```
if (document.getElementById("lastname").focus == true) {
alert("hello");
}
```
Check with == , using = is an assignment | You can try jQuery's [:focus](http://api.jquery.com/focus-selector/) selector. Or you can always add a class and check for that class. |
12,016,725 | >
> **Possible Duplicate:**
>
> [Using jQuery to test if an input has focus](https://stackoverflow.com/questions/967096/using-jquery-to-test-if-an-input-has-focus)
>
>
>
I need to check if a particular textbox has the focus or not using jQuery. So my code is like this, but it is not working:
```
if (document.getElementById("lastname").focus = true) {
alert("hello");
}
```
My use-case is this: I have a textbox which should be shown or hidden when the `#lastname` textbox gains or loses focus. However, if the `#lastname` textbox loses the focus to the other textbox, the latter should remain visible until it loses focus as well.
Any help will be appreciated. | 2012/08/18 | [
"https://Stackoverflow.com/questions/12016725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/853575/"
]
| ```
if (document.getElementById("lastname").focus == true) {
alert("hello");
}
```
Check with == , using = is an assignment | ```
<script type="text/javascript" language="javascript">
function check() {
if ($(document.activeElement).attr("id") === "element_name") {
alert('checkbox is focused');
}
}
</script>
``` |
9,073 | **A bit of backstory**
My parents are separated and my Dad has a long-term partner who he has been with for over 10 years now. She (my Dad's partner, let's call her Eve) has a close group of friends who she sees on a regular basis. One of Eve's close friends (let's call her Annie) works at the same place as me, in different departments but we occasionally see each other at lunchtime.
Someone in my family, Adam, has a mental health condition which sometimes means the way they behave is not the most polite, can come across as rude etc. I mention this because it has caused issues in the past. Eve has found Adam's behaviour to be 'unacceptable', has told my Dad, who has then told Adam which has caused a lot of grief and loss of trust. I think this goes to demonstrate how sensitive Eve can sometimes be about a person's perceived behaviour, which is why I want to avoid as much as possible any conflict.
**My Problem**
Adam had recently been going through a 'down period', whereby I mean their mental health was not in good shape for several reasons. I would talk to my (our) Dad about this when I would see him. Sometimes Eve would be there too, but I felt like there was no reason not to trust her with the information. In essence, Adam was not sure if he wanted to go on a family holiday because he wasn't feeling great, I felt it was important to tell them because they would need to be aware and available had that been the case.
So, on a couple of occasions at work, I have bumped into to Annie at lunchtime and she has asked me about a specific 'event' that either myself or Adam would have discussed with my Dad. My Dad may have discussed this with Eve which I don't see a problem with unless it was explicitly stated to be confidential between my Dad and Adam. I do however take issue with this for several reasons:
1. The information I shared with them, was shared with confidence that it would be private between those present. It was not explicitly stated but I definitely would expect that to be the case.
2. I hardly know Annie. She is a lovely person but we are not close and she isn't a close family friend. On the contrary, she is only friends with Eve, not my family and certainly not someone who I would divulge such personal information to.
3. When Eve and Annie normally see each other it is with a large group of friends. So if Annie knows about this then it is likely that everyone else present at the time also knows. People who I don't even know. And who knows who else could have been told.
As nice as Annie is, and as much as I like her, it is not her (or any of Eve's other friends') business to know the inner workings of my family or Adam's personal information and I need to make sure that Eve doesn't do this sort of thing again.
This has only happened twice. With the example that I mentioned above and with another example.
As mentioned earlier Eve has a tendency to be very sensitive about matters such as these. How can I go about asking her not to share such information? In the meantime, I know that I can refrain from saying anything with her present, but I know that I **do** need to tell my Dad important things. But then I would have to tell him explicitly not to share this with Eve which raises the same problem.
This is especially important to me because if Adam were to find out about how Eve had been 'spreading his secrets' it would cause a lot of conflicts and unnecessary grief in our family.
How can I make Eve know that she can not be spreading personal family information such as this with strangers?
Thanks for any help. | 2018/01/12 | [
"https://interpersonal.stackexchange.com/questions/9073",
"https://interpersonal.stackexchange.com",
"https://interpersonal.stackexchange.com/users/9257/"
]
| This is a tough one. There are no guarantees Eve will honor your request. Usually, people who spread information to others, whether you consider it gossiping or not don't realize it's a big deal and if this is how they are they will keep doing it.
**Approach Eve and tell her what her friend Annie mentioned/asked about Adam.** Ask her calmly to not share your family's private matters (e.g stuff about Adam) to anyone even Annie. You could explain what you said in your question about both Eve and Annie discussing such matters around other women who might also spread the information and so on. Depending on your relationship with Eve you could politely tell her that you don't like that this is causing problems to Adam and you wish she stopped the behavior.
>
> Eve, I'd appreciate it if you kept our family matters/Adam's personal
> problems private from now on. Can I please count on you that anything
> me or dad discuss with you will remain confidential?
>
>
>
You could elaborate more about the importance of confidentiality in discussing someone's mental health. Adam hasn't agreed nor given permission and he feels uncomfortable to the point his health is affected.
Keep in mind that even if Eve respects your request in theory she could still tell Annie and ask her not to mention anything to you from now on...
If you feel this is really damaging to Adam ask for your dad's help. Either don't talk about Adam when Eve is around or involve your dad in a solution by mentioning what happened with Annie. Is he able to convince Eve that she needs to keep your family's matters private?
If after asking Eve she keeps spreading information e.g about Adam, confront Eve and tell her that it has made it difficult for you to trust her and you won't be sharing personal information again. You could ask your dad to do the same but he's been with Eve for many years and it's hard to exclude her from information involving the family. | Tell Eve what you told us. There's no need to ask her to stop sharing information, merely to mention the outcome of sharing the information (ie, Adam may be upset) and that she should discuss it with Adam so he knows what she's shared, who she's shared it with, and what he'd like her to do in the future.
>
> Eve, Annie has approached me at work a few times to discuss sensitive family information, for instance Adam's mental health. I understand she's your friend and perhaps you need someone to talk to about this, but I'm concerned that if Adam knew his mental health was being discussed with others outside the three of us, even in confidence, it would be very upsetting to him.
>
>
> I'll tell Annie directly that I don't want to discuss personal family matters with her. I'd appreciate it if you would discuss this with Adam, letting him know what you've shared with others and why. I want to avoid him finding out later from someone else that his information may have spread further than he'd prefer, and he may have specific desires for how and with whom to share this information.
>
>
> |
34,929,461 | Im using this script for delete all C/C++ comments with sed:
<http://sed.sourceforge.net/grabbag/scripts/remccoms3.sed>
```
sed -i -f remccoms3.sed Myfile.cpp
```
But this script duplicate all the lines, example:
```
/*-------------------------------------------------------------------------------
This file is part of MyProject.
Author Worvast
#-------------------------------------------------------------------------------*/
#include <fstream>
#include <sstream>
//Other files
#include "Data.h"
#include "utility.h"
// Open input file
std::ifstream input_file;
```
Its converted to:
```
#include <fstream>
#include <fstream>
#include <sstream>
#include <sstream>
#include "Data.h"
#include "Data.h"
#include "utility.h"
#include "utility.h"
std::ifstream input_file;
std::ifstream input_file;
```
And to be honest I do not understand SED both to understand where is the error. Any idea or solution to this problem? | 2016/01/21 | [
"https://Stackoverflow.com/questions/34929461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1308617/"
]
| The intended command line to run that `sed` script is `/bin/sed -nf` (from the shebang line).
Your command (`sed -i -f remccoms3.sed`) leaves out the `-n` argument.
The `-n` argument to `sed` is
>
> -n, --quiet, --silent
>
>
> suppress automatic printing of pattern space
>
>
>
so without that you get the normal printing *and* the script's printing. | Don't use that script. Its cute and some people may find it interesting as a mental exercise but it's buggy (as it says itself it's been `bugfixed to some extent`!), absurdly complicated and a completely inappropriate application for sed.
To remove comments from all versions of C or C++ code just use the script at <https://stackoverflow.com/a/13062682/1745001> and pass the appropriate C or C++ version to `gcc` as one of it's arguments.
Also if you want to retain blank lines instead of having them removed (I first wrote this tool for counting NCSL so removing blank lines was desirable) along with the comments then just tweak the sed to make them not look like blank lines to gcc:
```
$ cat decomment.sh
[ $# -eq 2 ] && arg="$1" || arg=""
eval file="\$$#"
sed 's/a/aA/g;s/__/aB/g;s/#/aC/g;s/^[[:space:]]*$/aD/' "$file" |
gcc -P -E $arg - |
sed 's/aD//;s/aC/#/g;s/aB/__/g;s/aA/a/g'
$ ./decomment.sh file
#include <fstream>
#include <sstream>
#include "Data.h"
#include "utility.h"
std::ifstream input_file;
```
or if you have an ANSI C version input file where comments cannot start with `//`, just tell the tool that:
```
$ ./decomment.sh -ansi file
#include <fstream>
#include <sstream>
//Other files
#include "Data.h"
#include "utility.h"
// Open input file
std::ifstream input_file;
```
Here's an example of a C construct (the trigraph `??/` means `\`) that the enormous sed script won't handle correctly but the small sed+gcc script will handle just fine because `gcc` includes a parser for the language, not a bunch of regexp estimations for it:
```
$ cat tst.c
//C hello world example
#include <stdio.h>
/??/
* This is a comment using trigraphs */
int main()
{
printf("Hello world\n");
return 0;
}
```
.
```
$ ./remccoms3.sed tst.c
#include <stdio.h>
/??/
* This is a comment using trigraphs */
int main()
{
printf("Hello world\n");
return 0;
}
```
.
```
$ ./decomment.sh -trigraphs tst.c
#include <stdio.h>
int main()
{
printf("Hello world\n");
return 0;
}
``` |
16,942,531 | I have an array that I want to export to a CSV file, now I know that there is a fputcsv function but I am using version 5.0.4 of PHP so this isn't an option for me.
Is there an alternative method I can use? | 2013/06/05 | [
"https://Stackoverflow.com/questions/16942531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2441000/"
]
| You can use a polyfill for this. write your code as if you where on a system that supports `fputcsv` From comments within the php block (with some slight framing code) but include this
(copied and slightly modified from <http://www.php.net/manual/en/function.fputcsv.php#56827>)
```
<?php
if (!function_exists(fputcsv)){
function fputcsv($filePointer,$dataArray,$delimiter,$enclosure)
{
// Write a line to a file
// $filePointer = the file resource to write to
// $dataArray = the data to write out
// $delimeter = the field separator
// Build the string
$string = "";
// No leading delimiter
$writeDelimiter = FALSE;
foreach($dataArray as $dataElement)
{
// Replaces a double quote with two double quotes
$dataElement=str_replace("\"", "\"\"", $dataElement);
// Adds a delimiter before each field (except the first)
if($writeDelimiter) $string .= $delimiter;
// Encloses each field with $enclosure and adds it to the string
$string .= $enclosure . $dataElement . $enclosure;
// Delimiters are used every time except the first.
$writeDelimiter = TRUE;
} // end foreach($dataArray as $dataElement)
// Append new line
$string .= "\n";
// Write the string to the file
fwrite($filePointer,$string);
}
}
?>
``` | I took the solution from @Orangepill and refactored / simplified it in a couple of ways. This may also become handy if you want every field to be enclosed which is not the case in the default php implementation.
```php
function fputcsv_custom($handle, $fields, $delimiter = ",", $enclosure = '"', $escape_char = "\\") {
$field_arr = [];
foreach($fields as $field) {
$field_arr[] = $enclosure . str_replace($enclosure, $escape_char . $enclosure, $field) . $enclosure;
}
fwrite($handle, implode($delimiter, $field_arr) . "\n");
}
``` |
16,942,531 | I have an array that I want to export to a CSV file, now I know that there is a fputcsv function but I am using version 5.0.4 of PHP so this isn't an option for me.
Is there an alternative method I can use? | 2013/06/05 | [
"https://Stackoverflow.com/questions/16942531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2441000/"
]
| Assuming you have a `$Data` array, which contains individual arrays for each registry (or line), you may try this:
```
$Delimiter = '"';
$Separator = ','
foreach($Data as $Line)
{
fwrite($File, $Delimiter.
implode($Delimiter.$Separator.$Delimiter, $Line).$Delimiter."\n");
}
```
Where `$File` is the handle for your file. Put in `$Delimiter`, the character you want to put around each field, and in `$Separator`, the character to use between fields. | I took the solution from @Orangepill and refactored / simplified it in a couple of ways. This may also become handy if you want every field to be enclosed which is not the case in the default php implementation.
```php
function fputcsv_custom($handle, $fields, $delimiter = ",", $enclosure = '"', $escape_char = "\\") {
$field_arr = [];
foreach($fields as $field) {
$field_arr[] = $enclosure . str_replace($enclosure, $escape_char . $enclosure, $field) . $enclosure;
}
fwrite($handle, implode($delimiter, $field_arr) . "\n");
}
``` |
9,629,900 | This works fine in Firefox and Chrome, but not in IE:
CSS
```
.tablehead th{
border-bottom: 1px solid #C2C2C2;
color: #FFFFFF; background-color:#000058;
font-size: 13px; font-family:calibri!important;
font-weight: 700;
}
.tab_head th.tab_space {
padding-left: 5px;
}
.redtab_head th {
/* Mozilla: */
background: -moz-linear-gradient(top, #C80000, #9F0101);
/* Chrome, Safari:*/
background: -webkit-gradient(linear,
left top, left bottom, from(#C80000), to(#9F0101));
border-bottom: 1px solid #C2C2C2;
color: #FFFFFF;
font-size: 13px;
font-weight: 700;
}
#pls-play { cursor:pointer; }
/*.tb1hide {
table-layout:fixed!important;
}
*/
.box {
text-overflow:clip!important;
overflow:hidden!important;
white-space:nowrap!important; table-layout:fixed!important;
-o-text-overflow: clip!important;
}
*html .box {
width: expression( document.body.clientWidth > 124 ? "124px" : "auto" ); /* sets max-width for IE */
}
```
HTML
```
<table width="94%" cellpadding="2" cellspacing="1" class="tablehead" id="pls-batting">
<thead>
<tr class="tab_head" align="right" >
<th width="44" align="center"><span style="text-transform:lowercase;">q te</span>.R </th>
<th width="212" align="left" class="tab_space">tester</th>
<th width="54" align="center">tes</th>
<th width="34" align="center"> tes</th>
<th width="34" align="center" >tes</th>
<th width="34" align="center">te</th>
<th width="34" align="center">tes</th>
<th width="44" align="center">tes</span>.L</th>
<th width="34" align="center"> tes</th>
<th width="34" align="center" >tes</th>
<th width="34" align="center">tes</th>
<th width="34" align="center">tes</th>
</tr>
</thead>
<tbody>
<tr>
<td width="44" align="left" ><span style="display:none;">11</span>
<select name="psvsr_select" class="psvsr_sel_class" id="psvsr_select111904" style="width:40px;" >
<option value=""> </option>
<option>codeup</option>
<option>codeup</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="senddown">Send Down</option>
</select></td>
<td align="left" class="box tb1hide" style="max-width: 124px;">dfjbdsjbfhjb bdshfbdshbfhb jasbdfhbasdhjb
<input type="hidden" name="psb_playerId" value="/111904/" /></td>
<td width="54" align="left" valign="top" >OF</td>
<td align="center" valign="top" ><span style="display:none;" id="r_hr1_hid">3</span>
<input name="r_hr1" type="text" class="txt_fid" id="r_hr1" onBlur="return chk_txtval(this.value,'r_hr1',0,3,'tbl1')" onKeyUp="return chk_txtval(this.value,'r_hr1',0,3,'tbl1')" maxlength="1" value="3" onfocus="return selectText(this);" ></td>
<td align="center" valign="top" ><span style="display:none;" id="r_bnt1_hid">3</span>
<input name="r_bnt1" type="text" class="txt_fid" id="r_bnt1" onBlur="return chk_txtval(this.value,'r_bnt1',0,4,'tbl1')" onKeyUp="return chk_txtval(this.value,'r_bnt1',0,4,'tbl1')" maxlength="1" value="3" onfocus="selectText(this);" ></td>
<td align="center" valign="top" ><span style="display:none;" id="r_ph1_hid">3</span>
<input name="r_ph1" type="text" class="txt_fid" id="r_ph1" onBlur="return chk_txtval(this.value,'r_ph1',0,5,'tbl1')" onKeyUp="return chk_txtval(this.value,'r_ph1',0,5,'tbl1')" value="3" onfocus="selectText(this);" ></td>
<td align="center" valign="top" ><span style="display:none;" id="r_run1_hid">3</span>
<input name="r_run1" type="text" class="txt_fid" id="r_run1" onBlur="return chk_txtval(this.value,'r_run11',0,6,'tbl1')" onKeyUp="return chk_txtval(this.value,'r_run11',0,6,'tbl1')" maxlength="1" value="3" onfocus="selectText(this);" ></td>
<td width="44" align="left" ><span style="display:none;">11</span>
<select name="psvsl_select" class="psvsl_sel_class" id="psvsl_select111904" style="width:40px;" >
<option value=""></option>
<option value="lineup" >Lineup</option>
<option value="bench" >Bench</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="senddown">Send Down</option>
</select></td>
<td align="center" valign="top" ><span style="display:none;" id="l_hr1_hid">3</span>
<input name="l_hr1" type="text" class="txt_fid" id="l_hr1" onBlur="return chk_txtval(this.value,'l_hr1',0,8,'tbl1')" onKeyUp="return chk_txtval(this.value,'l_hr1',0,8,'tbl1')" maxlength="1" value="3" onfocus="selectText(this);" ></td>
<td align="center" valign="top" ><span style="display:none;" id="l_bnt1_hid">3</span>
<input name="l_bnt1" type="text" class="txt_fid" id="l_bnt1" onBlur="return chk_txtval(this.value,'l_bnt1',0,9,'tbl1')" onKeyUp="return chk_txtval(this.value,'l_bnt1',0,9,'tbl1')" maxlength="1" value="3" onfocus="selectText(this);" ></td>
<td align="center" valign="top" ><span style="display:none;" id="l_ph1_hid">3</span>
<input name="l_ph1" type="text" class="txt_fid" id="l_ph1" onBlur="return chk_txtval(this.value,'l_ph1',0,10,'tbl1')" onKeyUp="return chk_txtval(this.value,'l_ph1',0,10,'tbl1')" maxlength="1" value="3" onfocus="selectText(this);" ></td>
<td align="center" valign="top" ><span style="display:none;" id="l_run1_hid">3</span>
<input name="l_run1" type="text" class="txt_fid" id="l_run1" onBlur="return chk_txtval(this.value,'l_run1',0,11,'tbl1')" onKeyUp="return chk_txtval(this.value,'l_run1',0,11,'tbl1')" maxlength="1" value="3" onfocus="selectText(this);" ></td>
</tr>
<tr>
<td width="44" align="left" ><span style="display:none;">11</span>
<select name="psvsr_select" class="psvsr_sel_class" id="psvsr_select111904" style="width:40px;" >
<option value=""> </option>
<option>codeup</option>
<option>codeup</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="senddown">Send Down</option>
</select></td>
<td align="left" class="box tb1hide" style="max-width: 124px;">dfjbdsjbfhjb bdshfbdshbfhb jasbdfhbasdhjb
<input type="hidden" name="psb_playerId" value="/111904/" /></td>
<td width="54" align="left" valign="top" >OF</td>
<td align="center" valign="top" ><span style="display:none;" id="r_hr1_hid">3</span>
<input name="r_hr1" type="text" class="txt_fid" id="r_hr1" onBlur="return chk_txtval(this.value,'r_hr1',0,3,'tbl1')" onKeyUp="return chk_txtval(this.value,'r_hr1',0,3,'tbl1')" maxlength="1" value="3" onfocus="return selectText(this);" ></td>
<td align="center" valign="top" ><span style="display:none;" id="r_bnt1_hid">3</span>
<input name="r_bnt1" type="text" class="txt_fid" id="r_bnt1" onBlur="return chk_txtval(this.value,'r_bnt1',0,4,'tbl1')" onKeyUp="return chk_txtval(this.value,'r_bnt1',0,4,'tbl1')" maxlength="1" value="3" onfocus="selectText(this);" ></td>
<td align="center" valign="top" ><span style="display:none;" id="r_ph1_hid">3</span>
<input name="r_ph1" type="text" class="txt_fid" id="r_ph1" onBlur="return chk_txtval(this.value,'r_ph1',0,5,'tbl1')" onKeyUp="return chk_txtval(this.value,'r_ph1',0,5,'tbl1')" value="3" onfocus="selectText(this);" ></td>
<td align="center" valign="top" ><span style="display:none;" id="r_run1_hid">3</span>
<input name="r_run1" type="text" class="txt_fid" id="r_run1" onBlur="return chk_txtval(this.value,'r_run11',0,6,'tbl1')" onKeyUp="return chk_txtval(this.value,'r_run11',0,6,'tbl1')" maxlength="1" value="3" onfocus="selectText(this);" ></td>
<td width="44" align="left" ><span style="display:none;">11</span>
<select name="psvsl_select" class="psvsl_sel_class" id="psvsl_select111904" style="width:40px;" >
<option value=""></option>
<option value="lineup" >Lineup</option>
<option value="bench" >Bench</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="senddown">Send Down</option>
</select></td>
<td align="center" valign="top" ><span style="display:none;" id="l_hr1_hid">3</span>
<input name="l_hr1" type="text" class="txt_fid" id="l_hr1" onBlur="return chk_txtval(this.value,'l_hr1',0,8,'tbl1')" onKeyUp="return chk_txtval(this.value,'l_hr1',0,8,'tbl1')" maxlength="1" value="3" onfocus="selectText(this);" ></td>
<td align="center" valign="top" ><span style="display:none;" id="l_bnt1_hid">3</span>
<input name="l_bnt1" type="text" class="txt_fid" id="l_bnt1" onBlur="return chk_txtval(this.value,'l_bnt1',0,9,'tbl1')" onKeyUp="return chk_txtval(this.value,'l_bnt1',0,9,'tbl1')" maxlength="1" value="3" onfocus="selectText(this);" ></td>
<td align="center" valign="top" ><span style="display:none;" id="l_ph1_hid">3</span>
<input name="l_ph1" type="text" class="txt_fid" id="l_ph1" onBlur="return chk_txtval(this.value,'l_ph1',0,10,'tbl1')" onKeyUp="return chk_txtval(this.value,'l_ph1',0,10,'tbl1')" maxlength="1" value="3" onfocus="selectText(this);" ></td>
<td align="center" valign="top" ><span style="display:none;" id="l_run1_hid">3</span>
<input name="l_run1" type="text" class="txt_fid" id="l_run1" onBlur="return chk_txtval(this.value,'l_run1',0,11,'tbl1')" onKeyUp="return chk_txtval(this.value,'l_run1',0,11,'tbl1')" maxlength="1" value="3" onfocus="selectText(this);" ></td>
</tr>
</tbody>
</table>
``` | 2012/03/09 | [
"https://Stackoverflow.com/questions/9629900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1101236/"
]
| I was able to get it working with the following:
```
table{
table-layout: fixed;
}
``` | How about stripping this down a bit to see if the issue is with the property in IE or something else. Does the following work?
### HTML:
```
<table class="tablehead" id="pls-batting">
<thead>
<tr class="tab_head" id="pls-play">
<th># vs.R</th><th class="tab_space">PLAYER</th>
</tr>
</thead>
<tbody>
<tr class="oddrow player-10-5544" id="111904">
<td>11</td>
<td class="box tb1hide" style="max-width: 124px;">Cameron, Mike (FLA)fdgdsgfdtertwet dgfs aesfaesrf</td>
</tr>
</tbody>
</table>
```
### CSS:
```
.tablehead th{
border-bottom: 1px solid #C2C2C2;
color: #FFFFFF; background-color:#000058;
font-size: 13px; font-family:calibri!important;
font-weight: 700;
}
.tab_head th.tab_space {
padding-left: 5px;
}
.box {
text-overflow:clip!important;
overflow:hidden!important;
white-space:nowrap!important; table-layout:fixed!important;
-o-text-overflow: clip!important;
}
*html .box {
width: expression( document.body.clientWidth > 124 ? "124px" : "auto" ); /* sets max-width for IE */
}
```
It's hard to determine in it's built-out state what's relevant and what isn't, with the inline styles, onmousehovers, etc. One of these could be at fault, but best to start with the stuff that is supposed to be working to make sure it is.
My guess is that the expression isn't working, but that's just a guess. |
52,568,087 | I have a flag "active" in mysql database for users, this column is boolean type. From admin account I want to create a select options to select True/False if user is activated or not.
So in my form for user's information editing/creating I have:
```
<div class="form-group{{ $errors->has('active') ? ' has-error' : '' }}">
<label>Is user active?</label>
<select class="form-control" name="active" id="active">
@if (old('active') == $user->active)
<option value="1" selected>True</option>
@else
<option value="0">False</option>
@endif
</select>
</div>
```
The problem is it's only displaying "True" no "false" option if user is activated by PHPMyAdmin parameter changing or "False" option if user i deactivated the same way as above. Please help to understand how to list all options (True/False) and select by default the option previously selected so edit should work. | 2018/09/29 | [
"https://Stackoverflow.com/questions/52568087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9542556/"
]
| Try changing your HTML to the following:
```
<div class="form-group{{ $errors->has('active') ? ' has-error' : '' }}">
<label>Is user active?</label>
<select class="form-control" name="active" id="active">
<option value="1" @if (old('active') == 1) selected @endif>True</option>
<option value="0" @if (old('active') == 0) selected @endif>False</option>
</select>
</div>
```
You should check for the value that was selected before by the user. And then use that value to choose the value. However, in the answer, I am not setting the default value which you should take care of. | ```
<div class="form-group{{ $errors->has('active') ? ' has-error' : '' }}">
<label>Is user active?</label>
<select class="form-control" name="active" id="active">
<option value="1" {{ old('active') ? 'selected' }}>True</option>
<option value="0" {{ !old('active') ? 'selected' }}>False</option>
</select>
</div>
``` |
74,256,644 | I am new to programming in C and I am doing some activities for my first year in CS. The following activity consists of calculating the sum of squares of the digits of a user input number and the output should be as follows:
```none
Number: 1234
n=1234; sum=16
n=123; sum=25
n=12; sum=29
n=1; sum=30
Result: 30
```
I have got it for the most part, the thing that I don't understand is how to store a value in a variable, update said variable and print the result, all whilst being inside a loop.
This is what I came up with:
```
int main() {
int num,i,sum=0,result,square;
printf("Calculate the sum of the square of the digits of a number\n" );
printf("Number:");
scanf("%d", &num);
i=0;
while(num>i)
{
sum=num%10;
square=sum*sum;
printf("\nn=%d; sum= %d",num,square);
num=num/10;
}
result=sum;
printf("\nResult: %d",sum);
return 0;
}
```
How can I sum the square of the digits all together and print them as the example given? | 2022/10/30 | [
"https://Stackoverflow.com/questions/74256644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20374015/"
]
| Write something like the following
```
int digit = num % 10;
square = digit * digit;
sum += square;
printf("\n=%d; sum= %d", num, sum );
```
Pay attention to that the variable i is redundant:
```
i=0;
while(num>i)
```
just write
```
while ( num != 0 )
```
Also introducing the variable `result` is redundant and does not make sense because it is used nowhere. | You need a variable, keeping track of the input number (num), a variable keeping track of the sum ('sum') and a variable with the current digit (digit). Every iteration, you can calculate the digit, square it and add it to the sum. The `a += b` operation is equivalent to `a = a + b`, in case you are wondering. The same is for `a /= b`. Also a concept you can use (but don't have to), is implicit boolean conversion. When using a comparison (like num != 0 or num > 0) you can replace it with the number itself. In C, 0 equals false and everything else equals true.
```
#include <stdio.h>
int main() {
int num, sum = 0;
printf("Calculate the sum of the square of the digits of a number\n" );
printf("Number:");
scanf("%d", &num);
while (num) { // is equal to num != 0
int digit = num % 10;
sum += digit * digit;
printf(" n=%d; sum= %d\n", num, sum);
num /= 10;
}
printf("Result: %d\n", sum);
return 0;
}
```
EDIT:
Some people prefer to use `num != 0` or `num > 0`, because it is more readable. You should stick to it too for the start, until you are paid to confuse your coworkers. |
896,555 | Today I tried several times to install Ubuntu but I have some GPU problems.
I have a bootable stick. When I boot in UEFI mode all its normal but the installer isn't able to install the boot loader.
When I boot in leagacy mode I'm able to install Ubuntu but only when I unplug my GPU GTX 1070.
When I don't do that, I get an this initialization error from the installer:
```
3.021954] nouveau 0000:01:00.0: unknown chipset (134000a1)
```
I installed Ubuntu normally without the GPU. I installed the drivers, rebooted, shut down, pluggeed in the GPU and tried to boot but it got stuck at:
```
/dev/mapper/isw_bdifbbjbai_Raid0p3: clean, 191449/8855552 files, 1677252/34500448 blocks
```
What should I do? When I unplug the GPU I can boot easily, but I need my GPU! :D
My PC has a GTX 1070 GPU, i7 4790K CPU, and two hard drives:
* 250 GB M.2 SSD, which contains Windows 10 and its boot loader.
* 2 TB RAID-0 WD, with 1,85 TB for Windows 10 files and 150GB where I installed Ubuntu and its boot loader. | 2017/03/24 | [
"https://askubuntu.com/questions/896555",
"https://askubuntu.com",
"https://askubuntu.com/users/669390/"
]
| I had a similar problem with my GTX 1080 when installing Ubuntu 16.04. It seems that 16.04 does not support the latest Nvidia GPUs. I finally managed to install Ubuntu 16.04 along side with Windows 10 dual boot with my GTX 1080 unplugged. What I did is as follow.
1. Before you install Ubuntu, go to BIOS setting and disable the GTX GPU. You may need to go through the BIOS settings for sometime to find the right option (something like IGX?).
2. Note that before you reboot, you need to switch your monitor's cable to the motherboard video output, since after reboot, the GTX GPU would be disabled and you would not see anything.
3. After that, choose the install media with UEFI, and go through the installation procedure as usual. The display should be alright.
4. At the position where it asks on which device you want the Ubuntu installed, choose manual setting (the `something else` button?). And make partitions as you like. But remember to choose the whole device (i.e. `/dev/sda` or `/dev/sdb`) to install grub. DO NOT choose something like `/dev/sda1`.
5. After the installation finished, reboot without changing graphical output device.
6. When you are in your newly installed Ubuntu, open a terminal and install the appropriate Nvidia driver. You may check [this question](https://askubuntu.com/questions/795547/ubuntu-16-04-unable-to-boot-with-gtx-1080) for more details. It's basically `sudo add-apt-repository ppa:graphics-drivers/ppa` `sudo apt-get update` and find the right driver for you. Check [this](https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa) also.
7. Finally, reboot and change the graphical output device back to your GPU and everything should work normal. You can type `nvidia-smi` in a terminal to check if the driver is working.
One of my friend tried to install Nvidia driver from Ubuntu system setting. You may look into that as well. As for me, the above procedure works fine. | **1. Make sure that your GRUB is set right:**
---------------------------------------------
**a.For Non UEFI**, Download boot-repair-disk <https://sourceforge.net/projects/boot-repair-cd/files/> and repair the grub maybe is not installed on the GNU/Linux partition, do a repair just to be sure.
**b.For UEFI** see <http://howtoubuntu.org/how-to-repair-restore-reinstall-grub-2-with-a-ubuntu-live-cd>.
**2. Use the latest Nvidia Proprietary Drivers IF the Free-Open-Source-Drivers not working like it should:**
------------------------------------------------------------------------------------------------------------
Go to <https://www.nvidia.com/Download/index.aspx?lang=en-us> and **download the latest Proprietary drivers** according to your Nvidia card.
Then press **Ctrl+Alt+F1**
Type your username and password
```
sudo service lightdm stop
```
`cd /home/YoUrUsErNaMe/Downloads` (or anywhere that is the Nvidia \*.run file that you have downloaded)
`sudo sh NVIDIA-Linux-x86*`(Or type `sudo sh NVIDIA-` and **press Tab** and then **Enter**)
**Choose yes to:** Automaticly nvidia drivers to stop nouveau (default driver)
```
sudo shutdown -r now
```
---
---
IF you see bad resolution is totally OK nouveau was disabled by Nvidia.
-----------------------------------------------------------------------
Press **Ctrl+Alt+F1**
Type your username and password
`cd /home/YoUrUsErNaMe/Downloads` (or anywere that is the Nvidia \*.run file that you have downloaded)
```
sudo service lightdm stop
```
`cd /home/YoUrUsErNaMe/Downloads` (or anywere that is the Nvidia \*.run file that you have downloaded)
`sudo sh NVIDIA-Linux-x86*` (Or type `sudo sh NVIDIA-` and **press Tab** and then **Enter**)
```
sudo shutdown -r now
```
Hope it helps. |
896,555 | Today I tried several times to install Ubuntu but I have some GPU problems.
I have a bootable stick. When I boot in UEFI mode all its normal but the installer isn't able to install the boot loader.
When I boot in leagacy mode I'm able to install Ubuntu but only when I unplug my GPU GTX 1070.
When I don't do that, I get an this initialization error from the installer:
```
3.021954] nouveau 0000:01:00.0: unknown chipset (134000a1)
```
I installed Ubuntu normally without the GPU. I installed the drivers, rebooted, shut down, pluggeed in the GPU and tried to boot but it got stuck at:
```
/dev/mapper/isw_bdifbbjbai_Raid0p3: clean, 191449/8855552 files, 1677252/34500448 blocks
```
What should I do? When I unplug the GPU I can boot easily, but I need my GPU! :D
My PC has a GTX 1070 GPU, i7 4790K CPU, and two hard drives:
* 250 GB M.2 SSD, which contains Windows 10 and its boot loader.
* 2 TB RAID-0 WD, with 1,85 TB for Windows 10 files and 150GB where I installed Ubuntu and its boot loader. | 2017/03/24 | [
"https://askubuntu.com/questions/896555",
"https://askubuntu.com",
"https://askubuntu.com/users/669390/"
]
| Thanks for you answers but in the meantime I fixed my problem by installing Ubuntu 17.04 beta 2. I was able to install it without any problems.
The driver I installed with the help of the blog post [Installing Nvidia's Proprietary GTX 1070 and 1080 Driver in Ubuntu 16.04. How to Get Around The "out of range" Error and a Guide to Do a Realtime monitoring of your GPU](https://www.abiraf.com/blog/installing-nvidias-proprietary-gtx-1070-and-1080-driver-in-ubuntu-1604-how-to-get-around-the-out-of-range-error-and-a-guide-to-do-a-realtime-monitoring-of-your-gpu).
Once 17.04 is installed, the driver may be installed (as that blog post says) by running:
```
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-367
``` | **1. Make sure that your GRUB is set right:**
---------------------------------------------
**a.For Non UEFI**, Download boot-repair-disk <https://sourceforge.net/projects/boot-repair-cd/files/> and repair the grub maybe is not installed on the GNU/Linux partition, do a repair just to be sure.
**b.For UEFI** see <http://howtoubuntu.org/how-to-repair-restore-reinstall-grub-2-with-a-ubuntu-live-cd>.
**2. Use the latest Nvidia Proprietary Drivers IF the Free-Open-Source-Drivers not working like it should:**
------------------------------------------------------------------------------------------------------------
Go to <https://www.nvidia.com/Download/index.aspx?lang=en-us> and **download the latest Proprietary drivers** according to your Nvidia card.
Then press **Ctrl+Alt+F1**
Type your username and password
```
sudo service lightdm stop
```
`cd /home/YoUrUsErNaMe/Downloads` (or anywhere that is the Nvidia \*.run file that you have downloaded)
`sudo sh NVIDIA-Linux-x86*`(Or type `sudo sh NVIDIA-` and **press Tab** and then **Enter**)
**Choose yes to:** Automaticly nvidia drivers to stop nouveau (default driver)
```
sudo shutdown -r now
```
---
---
IF you see bad resolution is totally OK nouveau was disabled by Nvidia.
-----------------------------------------------------------------------
Press **Ctrl+Alt+F1**
Type your username and password
`cd /home/YoUrUsErNaMe/Downloads` (or anywere that is the Nvidia \*.run file that you have downloaded)
```
sudo service lightdm stop
```
`cd /home/YoUrUsErNaMe/Downloads` (or anywere that is the Nvidia \*.run file that you have downloaded)
`sudo sh NVIDIA-Linux-x86*` (Or type `sudo sh NVIDIA-` and **press Tab** and then **Enter**)
```
sudo shutdown -r now
```
Hope it helps. |
896,555 | Today I tried several times to install Ubuntu but I have some GPU problems.
I have a bootable stick. When I boot in UEFI mode all its normal but the installer isn't able to install the boot loader.
When I boot in leagacy mode I'm able to install Ubuntu but only when I unplug my GPU GTX 1070.
When I don't do that, I get an this initialization error from the installer:
```
3.021954] nouveau 0000:01:00.0: unknown chipset (134000a1)
```
I installed Ubuntu normally without the GPU. I installed the drivers, rebooted, shut down, pluggeed in the GPU and tried to boot but it got stuck at:
```
/dev/mapper/isw_bdifbbjbai_Raid0p3: clean, 191449/8855552 files, 1677252/34500448 blocks
```
What should I do? When I unplug the GPU I can boot easily, but I need my GPU! :D
My PC has a GTX 1070 GPU, i7 4790K CPU, and two hard drives:
* 250 GB M.2 SSD, which contains Windows 10 and its boot loader.
* 2 TB RAID-0 WD, with 1,85 TB for Windows 10 files and 150GB where I installed Ubuntu and its boot loader. | 2017/03/24 | [
"https://askubuntu.com/questions/896555",
"https://askubuntu.com",
"https://askubuntu.com/users/669390/"
]
| I had a similar problem with my GTX 1080 when installing Ubuntu 16.04. It seems that 16.04 does not support the latest Nvidia GPUs. I finally managed to install Ubuntu 16.04 along side with Windows 10 dual boot with my GTX 1080 unplugged. What I did is as follow.
1. Before you install Ubuntu, go to BIOS setting and disable the GTX GPU. You may need to go through the BIOS settings for sometime to find the right option (something like IGX?).
2. Note that before you reboot, you need to switch your monitor's cable to the motherboard video output, since after reboot, the GTX GPU would be disabled and you would not see anything.
3. After that, choose the install media with UEFI, and go through the installation procedure as usual. The display should be alright.
4. At the position where it asks on which device you want the Ubuntu installed, choose manual setting (the `something else` button?). And make partitions as you like. But remember to choose the whole device (i.e. `/dev/sda` or `/dev/sdb`) to install grub. DO NOT choose something like `/dev/sda1`.
5. After the installation finished, reboot without changing graphical output device.
6. When you are in your newly installed Ubuntu, open a terminal and install the appropriate Nvidia driver. You may check [this question](https://askubuntu.com/questions/795547/ubuntu-16-04-unable-to-boot-with-gtx-1080) for more details. It's basically `sudo add-apt-repository ppa:graphics-drivers/ppa` `sudo apt-get update` and find the right driver for you. Check [this](https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa) also.
7. Finally, reboot and change the graphical output device back to your GPU and everything should work normal. You can type `nvidia-smi` in a terminal to check if the driver is working.
One of my friend tried to install Nvidia driver from Ubuntu system setting. You may look into that as well. As for me, the above procedure works fine. | Thanks for you answers but in the meantime I fixed my problem by installing Ubuntu 17.04 beta 2. I was able to install it without any problems.
The driver I installed with the help of the blog post [Installing Nvidia's Proprietary GTX 1070 and 1080 Driver in Ubuntu 16.04. How to Get Around The "out of range" Error and a Guide to Do a Realtime monitoring of your GPU](https://www.abiraf.com/blog/installing-nvidias-proprietary-gtx-1070-and-1080-driver-in-ubuntu-1604-how-to-get-around-the-out-of-range-error-and-a-guide-to-do-a-realtime-monitoring-of-your-gpu).
Once 17.04 is installed, the driver may be installed (as that blog post says) by running:
```
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-367
``` |
65,056 | I am having trouble inserting pictures into my latex document at a specific point. Currently I have the two figure environments in the text but they are printed at the back of the document, after the bibliography. Am I missing something?
The pictures are both supposed to be full page-sized rather than a traditional smaller figure or float. I might be wrong in using the figure environment in this case, but I am not sure.
```
\documentclass[12pt, a4paper, twoside]{article}
\usepackage[margin=1in,bindingoffset=15.5mm,heightrounded]{geometry}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\begin{document}
I have some text here. Then pics.
\newpage
\begin{figure}[ht!]
\centering
\includegraphics[scale=0.75, angle=90, width=\textwidth]{hamlet.jpg}
\caption{cool picture}
\end{figure}
\newpage
\begin{figure}[ht!]
\centering
\includegraphics[scale=0.75, angle=270, width=\textwidth]{kinglear.jpg}
\caption{cool picture 2}
\end{figure}
\newpage
some more text here
\end{document}
``` | 2012/07/28 | [
"https://tex.stackexchange.com/questions/65056",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/14865/"
]
| Since the images must go at a specific position, it's not convenient to use a floating environment; you can use `\captionof` from the [`capt-of`](http://www.ctan.org/pkg/capt-of) or [`caption`](http://www.ctan.org/pkg/caption) packages to give your figures a caption:
```
\documentclass[12pt, a4paper, twoside]{article}
\usepackage[margin=1in,bindingoffset=15.5mm,heightrounded]{geometry}
\usepackage[T1]{fontenc}
\usepackage[demo]{graphicx}
\usepackage{caption}
\begin{document}
I have some text here. Then pics.
\clearpage
{
\centering
\includegraphics[scale=0.75, angle=90, width=\textwidth]{hamlet.jpg}
\captionof{figure}{cool picture}
\clearpage
\includegraphics[scale=0.75, angle=270, width=\textwidth]{kinglear.jpg}
\captionof{figure}{cool picture 2}
}
\clearpage
some more text here
\end{document}
```
The `demo` option for `graphicx` simply replaces actual figures with black rectangles; do *not* use that option in your actual document.
Depending on how tou are controlling the size for the images, you could additionally wrap each image and its caption using a `minipage` to prevent an undesired page break; something like
```
\clearpage
\noindent\begin{minipage}{\textwidth}
\centering
\includegraphics[scale=0.75, angle=90, width=\textwidth]{hamlet.jpg}
\captionof{figure}{cool picture}
\end{minipage}
\clearpage
\noindent\begin{minipage}{\textwidth}
\centering
\includegraphics[scale=0.75, angle=270, width=\textwidth]{kinglear.jpg}
\captionof{figure}{cool picture 2}
\end{minipage}
\clearpage
``` | You're not doing anything wrong by using the `figure` environment. Since you mention that the figures are meant to take up a full page, you could load the `afterpage` package and use its `\afterpage` command to defer typesetting the figures until the next page break occurs anyway; this will relieve you from having to figure out when to issue a `\newpage` or `\clearpage` command. Here's what I'd do:
```
\documentclass[12pt, a4paper, twoside]{article}
\usepackage[margin=1in,bindingoffset=15.5mm,heightrounded]{geometry}
\usepackage[T1]{fontenc}
\usepackage[demo]{graphicx} % delete 'demo' option in real document
\usepackage{afterpage}
\begin{document}
I have some text here. Then pics. some more text here
\afterpage{
\clearpage % flush any pending floats
\begin{figure}[p] % use [p], not [ht!]
\centering
\includegraphics[scale=0.75, angle=90, width=\textwidth]{hamlet.jpg}
\caption{cool picture}
\end{figure}
\clearpage
\begin{figure}[p] % use [p], not [ht!]
\centering
\includegraphics[scale=0.75, angle=270, width=\textwidth]{kinglear.jpg}
\caption{cool picture 2}
\end{figure}
\clearpage % force both floats to be typeset
} % end of scope of \afterpage instruction
some more text here
% this may or may not be typeset on the page prior to
% the two floats-only pages, depending on how much
% space was left on the page when \afterpage is
% encountered.
\end{document}
``` |
74,310,316 | I'm learning C++ and I want to know if there is a way you can use variables defined in a class's constructor in a member function. I've tried looking online and in my textbook but I can't find a definitive answer. For example:
```
class Item {
public:
Item(std::string str) {
std::string text = str;
int pos = -1;
}
void increment() {
// how would I reference pos here?
pos++;
}
};
```
Thanks in advance! | 2022/11/03 | [
"https://Stackoverflow.com/questions/74310316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15150535/"
]
| >
> I want to know if there is a way you can use variables defined in a class's constructor in a member function.
>
>
>
No, you can't. Variables defined in the constructor goes out of scope at the end of the constructor.
The normal way is to initialize *member variables* in the constructor. These can then be accessed in the member functions:
```cpp
class Item {
public:
Item(std::string str) : // colon starts the member initializer list
text(std::move(str)),
pos{-1}
{
// empty constructor body
}
void increment() {
pos++; // now you can access `pos`
}
private:
// member variables
std::string text;
int pos;
};
``` | You need to turn `text` and `pos` into private data members of the `Item` class.
*Private* because, if declared public, they could be easily overwritten making, for instance, redundant the `increment()` function, which is an undesirable side effect.
```
class Item {
public:
Item(std::string str): text{str}, pos{-1} {}
void increment() {
pos++;
}
/* text and pos are now private data members, hence need 'get' functions
in order to access their current value */
std::string& getText() {
return text;
}
int getPos() {
return pos;
}
private:
// text and pos made private members
std::string text;
int pos;
};
``` |
10,483,888 | I am trying to create a table on MySQL using an SQL script and the MySQL database keeps on giving me error 150. I've tried the following code in both Navicat and MySQL Workbench and both give an 150 error.
It appears that this is a foreign key problem but i cant actually see what the problem with my code is and was wondering if more expereinced DB users would have any inkling to the problem?
```
SET FOREIGN_KEY_CHECKS=0;
CREATE TABLE `network_invites` (
`invite_ID` int(11) NOT NULL AUTO_INCREMENT,
`invite_From` int(11) NOT NULL,
`invite_Network` int(11) NOT NULL,
`invite_NetCreator` int(11) NOT NULL,
`invite_Message` varchar(256) NOT NULL,
`invite_Date` date DEFAULT NULL,
PRIMARY KEY (`invite_ID`),
KEY `invite_From` (`invite_From`),
KEY `invite_Network` (`invite_Network`),
KEY `invite_NetCreator` (`invite_NetCreator`),
CONSTRAINT `network_invites_ibfk_1` FOREIGN KEY (`invite_From`) REFERENCES `users` (`user_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `network_invites_ibfk_2` FOREIGN KEY (`invite_Network`) REFERENCES `networks` (`network_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `network_invites_ibfk_3` FOREIGN KEY (`invite_NetCreator`) REFERENCES `networks` (`network_Creator`) ON DELETE CASCADE ON UPDATE CASCADE
)ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=latin1;
```
I cant see what the FK problem is, those fields do exist on the DB and they are of the same datatype.
Thanks for any help. | 2012/05/07 | [
"https://Stackoverflow.com/questions/10483888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1152304/"
]
| Replace the if statement with a case statement. You cant use the if in a query like that. | ```
Declare @Type varchar
if((select tn.notification_type from tbl_Notification tn) = 1)
begin
set @Type= 'WORK FLOW'
print 'status '+ CAST(@type AS nvarchar(58))
end
``` |
10,483,888 | I am trying to create a table on MySQL using an SQL script and the MySQL database keeps on giving me error 150. I've tried the following code in both Navicat and MySQL Workbench and both give an 150 error.
It appears that this is a foreign key problem but i cant actually see what the problem with my code is and was wondering if more expereinced DB users would have any inkling to the problem?
```
SET FOREIGN_KEY_CHECKS=0;
CREATE TABLE `network_invites` (
`invite_ID` int(11) NOT NULL AUTO_INCREMENT,
`invite_From` int(11) NOT NULL,
`invite_Network` int(11) NOT NULL,
`invite_NetCreator` int(11) NOT NULL,
`invite_Message` varchar(256) NOT NULL,
`invite_Date` date DEFAULT NULL,
PRIMARY KEY (`invite_ID`),
KEY `invite_From` (`invite_From`),
KEY `invite_Network` (`invite_Network`),
KEY `invite_NetCreator` (`invite_NetCreator`),
CONSTRAINT `network_invites_ibfk_1` FOREIGN KEY (`invite_From`) REFERENCES `users` (`user_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `network_invites_ibfk_2` FOREIGN KEY (`invite_Network`) REFERENCES `networks` (`network_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `network_invites_ibfk_3` FOREIGN KEY (`invite_NetCreator`) REFERENCES `networks` (`network_Creator`) ON DELETE CASCADE ON UPDATE CASCADE
)ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=latin1;
```
I cant see what the FK problem is, those fields do exist on the DB and they are of the same datatype.
Thanks for any help. | 2012/05/07 | [
"https://Stackoverflow.com/questions/10483888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1152304/"
]
| To elaborate on Namphibian's answer, which is accurate:
```
SELECT
@Type = (CASE tn.Notification_Type
WHEN 1 THEN 'WORK FLOW'
ELSE 'SOMETHING ELSE'
END)
FROM tbl_Notification tn
```
You also won't be able to do the print in the SQL query like that, you'd have to do it afterwards or in some sort of looping situation. | Replace the if statement with a case statement. You cant use the if in a query like that. |
10,483,888 | I am trying to create a table on MySQL using an SQL script and the MySQL database keeps on giving me error 150. I've tried the following code in both Navicat and MySQL Workbench and both give an 150 error.
It appears that this is a foreign key problem but i cant actually see what the problem with my code is and was wondering if more expereinced DB users would have any inkling to the problem?
```
SET FOREIGN_KEY_CHECKS=0;
CREATE TABLE `network_invites` (
`invite_ID` int(11) NOT NULL AUTO_INCREMENT,
`invite_From` int(11) NOT NULL,
`invite_Network` int(11) NOT NULL,
`invite_NetCreator` int(11) NOT NULL,
`invite_Message` varchar(256) NOT NULL,
`invite_Date` date DEFAULT NULL,
PRIMARY KEY (`invite_ID`),
KEY `invite_From` (`invite_From`),
KEY `invite_Network` (`invite_Network`),
KEY `invite_NetCreator` (`invite_NetCreator`),
CONSTRAINT `network_invites_ibfk_1` FOREIGN KEY (`invite_From`) REFERENCES `users` (`user_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `network_invites_ibfk_2` FOREIGN KEY (`invite_Network`) REFERENCES `networks` (`network_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `network_invites_ibfk_3` FOREIGN KEY (`invite_NetCreator`) REFERENCES `networks` (`network_Creator`) ON DELETE CASCADE ON UPDATE CASCADE
)ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=latin1;
```
I cant see what the FK problem is, those fields do exist on the DB and they are of the same datatype.
Thanks for any help. | 2012/05/07 | [
"https://Stackoverflow.com/questions/10483888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1152304/"
]
| To elaborate on Namphibian's answer, which is accurate:
```
SELECT
@Type = (CASE tn.Notification_Type
WHEN 1 THEN 'WORK FLOW'
ELSE 'SOMETHING ELSE'
END)
FROM tbl_Notification tn
```
You also won't be able to do the print in the SQL query like that, you'd have to do it afterwards or in some sort of looping situation. | ```
Declare @Type varchar
if((select tn.notification_type from tbl_Notification tn) = 1)
begin
set @Type= 'WORK FLOW'
print 'status '+ CAST(@type AS nvarchar(58))
end
``` |
33,416,021 | I have been using Mendeley's Microsoft Word plugin to easily reference papers in my Mendeley Desktop library.
However, I've noticed that the IEEE format for the bibliography/citation is incorrect with regards to referencing conference proceedings and theses.
On the IEEE citation guide: <http://www.ieee.org/documents/ieeecitationref.pdf>
It shows that the city of the conference should be included in the citation of a conference paper. However, Mendeley's IEEE CSL file does not include this detail.
```
<macro name="event">
<choose>
<if type="paper-conference speech" match="any">
<choose>
<!-- Published Conference Paper -->
<if variable="container-title">
<group delimiter=", ">
<group delimiter=" ">
<text term="in"/>
<text variable="container-title" font-style="italic"/>
</group>
<text variable="event-place"/>
</group>
```
Should be changed to:
```
<macro name="event">
<choose>
<if type="paper-conference speech" match="any">
<choose>
<!-- Published Conference Paper -->
<if variable="container-title">
<group delimiter=", ">
<group delimiter=" ">
<text term="in"/>
<text variable="container-title" font-style="italic"/>
</group>
<text variable="publisher-place"/>
</group>
```
Since event-place is not a keyword that maps to the "city" field in Mendeley; the correct variable is "publisher-place". | 2015/10/29 | [
"https://Stackoverflow.com/questions/33416021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4421492/"
]
| Two options, use this formatted one that I just made, or follow the steps I did to make this change in the CSL Visual Editor.
**Just use the corrected file**
1. While in Mendeley Desktop, go to View menu, "Citation Style ->" and click "More Styles..."
2. Click on the tab "Get More Styles", and enter the following link into the "Download Style:" text box, then click Download
<http://csl.mendeley.com/styles/451326401/ieee-CS-edited>
Done!
**Make your own corrections**
1. While in Mendeley Desktop, go to View menu, "Citation Style ->" and click "More Styles..."
2. Right Click on IEEE and choose "Copy Style Link"
3. Open up a web browser, and paste the link and hit enter, it should download a file called "ieee.csl"
4. Open up a web browser that isn't Chrome, as this doesn't work in Chrome, and go to the page <http://csl.mendeley.com/visualEditor/>
5. Login using your Mendeley credentials
6. Click on the "Visual editor" tab at the top if it's not already selected.
7. Hover over "Style" and choose "Load Style..."
8. Browse and select the "ieee.csl" file that was downloaded earlier.
9. Under "STYLE INFO" and "Info", rename the Title to something new.
10. Navigate to the following
`BIBLIOGRAPHY`
`->Layout`
`-->Conditional`
`--->Else-of paper-conference OR...`
`---->Group`
`----->event (macro)`
`------>Conditional`
`------->If paper-conference OR speech`
`-------->Conditional`
`--------->If container-title`
`--------->Group`
`----------->event-place (variable)`
11. Click on event-place (variable) and in the editable section to the right, change the variable from "event-place" to "publisher-place"
12. Then go back to the Style menu and choose "Save Style As..."
13. Save this style, and it should automatically add it to your Mendeley Desktop
Done! | Mendeley does not show the thesis citations correctly in IEEE format. It should be like this:
[1] J. K. Author, “Title of thesis,” M.S. thesis, Abbrev. Dept., Abbrev. Univ., City of Univ., Abbrev. State, year.
[2] J. K. Author, “Title of dissertation,” Ph.D. dissertation, Abbrev. Dept., Abbrev. Univ., City of Univ., Abbrev. State,
year.
However, the thesis type and department name are not showing!! |
49,111,567 | I have following data frames such as
```
dummy_ts_1 <- data.frame(Date=as.Date(c("1990-03-31","1990-06-30","1990-09-30","1990-12-31","1991-03-31","1991-06-30","1991-09-30","1991-12-31","1992-03-31","1992-06-30")),
GDP=c(100,200,300,400,500,600,700,800,900,1000))
dummy_ts_2 <- data.frame(Date=as.Date(c("1980-01-31","1980-04-30","1980-07-31","1980-10-31","1981-01-31","1981-04-30","1981-07-31","1981-10-31","1982-01-31","1982-04-30")),
GDP=c(150,160,250,247,300,400,500,600,700,1000))
```
and I need fill out previous months within the same quarter (data.table::quarter(dummy\_ts\_1)) equally so the desired output should look like
```
> dummy_ts_1
Date GDP
1990-01-31 33.33333
1990-02-31 33.33333
1990-03-31 33.33333
1990-04-30 66.66667
1990-05-30 66.66667
1990-06-30 66.66667
1990-07-30 100
1990-08-30 100
1990-09-30 100
1990-10-31 133.3333
1990-11-31 133.3333
1990-12-31 133.3333
```
Is there any simple way, how to achieve desired output? Thank you for any of your advice. | 2018/03/05 | [
"https://Stackoverflow.com/questions/49111567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8758767/"
]
| Assuming that your `tags = ['hansel, gretel', 'cappuccetto, rosso, lupo', 'signore, anelli, gollum', 'blade,runner', 'pinocchio', 'incredibili']` after your `fetchall()` your can achieve your result with this:
```
lista_tags = []
for entry in tags:
lista_tags += entry.split(",")
```
The output will be:
```
['hansel', ' gretel', 'cappuccetto', ' rosso', ' lupo', 'signore', ' anelli', ' gollum', 'blade', 'runner', 'pinocchio', 'incredibili']
``` | >
> List is a collection of value so you are append value in `lista_tags` so you get all value
>
>
>
`for i in tags:
lista_tags.append(i)`
>
> if you want to get single value by accessing them using "key"
> `lista_tags[1]`
> it will give you single value
>
>
> |
2,316 | There are some hadith listing Mubah actions that involve khayr. These are; flirting with the spouse, horse racing and marksmanship. I would like to know if marksmanship encompasses javelin throwing or not. Maybe someone can find and check the Arabic original of the hadith and share here the meaning(s) of the word used.
This might not look so important, but I believe if we could shift our Mubah activities to the ones mentioned in the hadith, we would kill two birds with one stone.
>
> It has been narrated on the authority of Ibn Amir who said: I heard
> the Messenger of Allah (may peace be upon him) say-and he was
> delivering a sermon from the pulpit: Prepare to meet them with as much
> strength as you can afford. Beware, strength consists in archery.
> Beware, strength consists in archery. Beware, strength consists in
> archery. (Muslim, Book #020, Hadith #4711)
>
>
> Narrated Salama bin Al-Akwa: The Prophet passed by some people of the
> tribe of Bani Aslam who were practicing archery. The Prophet said, "O
> Bani Ismail ! Practice archery as your father Isma'il was a great
> archer. Keep on throwing arrows and I am with Bani so-and-so." So one
> of the parties ceased throwing. Allah's Apostle said, "Why do you not
> throw?" They replied, "How should we throw while you are with them
> (i.e. on their side)?" On that the Prophet said, "Throw, and I am with
> all of you." (Bukhari, Book #52, Hadith #148)
>
>
> Narrated Salama bin Al-Akwa: The Prophet passed by some persons of the
> tribe of Aslam practicing archery (i.e. the throwing of arrows)
> Allah's Apostle said, "O offspring of Ishmael! Practice archery (i.e.
> arrow throwing) as your father was a great archer (i.e.
> arrow-thrower). I am with (on the side of) the son of so-and-so-."
> Hearing that, one of the two teams stopped throwing. Allah's Apostle
> asked them, ' Why are you not throwing?" They replied, "O Allah's
> Apostle! How shall we throw when you are with the opposite team?" He
> said, "Throw, for I am with you all." (Bukhari, Book #55, Hadith #592)
>
>
> Narrated Salama: Allah's Apostle passed by some people from the tribe
> of Aslam practicing archery. He said, "O children of Ishmael! Throw
> (arrows), for your father was an archer. I am on the side of Bani
> so-and-so," meaning one of the two teams. The other team stopped
> throwing, whereupon the Prophet said, "What has happened to them?"
> They replied, "How shall we throw while you are with Bani so-and-so?"
> He said, "Throw for I am with all of you." (Bukhari, Book #56, Hadith #710)
>
>
>
Edit: The word "throwing" is used, so I am not sure what exactly it means. | 2012/08/24 | [
"https://islam.stackexchange.com/questions/2316",
"https://islam.stackexchange.com",
"https://islam.stackexchange.com/users/-1/"
]
| The Arabic word *rimaya* رماية literally means *throwing*, but when it is unqualified it is used as a synonym for *shooting*, which at the time meant archery. In modern usage this has been extended to marksmanship in firearms.
But getting back to the hadith itself, looking at the context we can deduce that the *throwing* in question is of the martial kind (i.e. to aid in war). So at the time of the prophet that meant archery, since it was one of the most effective weapons of war at the time.
Applying this hadith in modern times, we find that archery (and javelin throwing) are no longer contemporary battle skills. So we have to assume that it now encompasses their modern equivalent, which is (as I stated earlier) firearm marksmanship. | Perhaps it becomes clear if we look at Volume 5, Book 58, Number 156:
>
> Talha was a strong, experienced archer who used to keep his arrow bow strong and well stretched. On that day he broke two or three arrow bows.
>
>
>
This seems to make it clear that this is referring to regular bow-based archery, suggesting that "throw" in the translation is being used simply to describe the flight of the arrow (which might more familiarly termed: to "loose" an arrow). |
64,039,448 | I was implementing the Oauth2.0 authentication using Google. I used react-google-login npm on the frontend to authenticate the user using Google Oauth2.0. I successfully created the CLient-id and secret under google cloud platform for my project, along with the URI as needed.
The frontend is running on default localhost:3000 and backend (node/express) running on localhost:9001 with proxy enabled on frontend to redirect the request to backend.
I was able to authenticate using Google more than 2 dozen times last night as i was working on the backend siginIn contoller. I was also able to add the user to my Mongodb after successful authentication from Google.
All of a sudden, i was getting CORS error which is a bit strange as none of the code or Google configs were changed.
My Google config looks as follows.[](https://i.stack.imgur.com/xkgHp.png)
My code on the frontend is still successfully redirecting the user to Google for authentication. Its also generating the right google credentials.
SignIn Component Code snippet passing the info to responseGoogle which resides in withLogin HOC Parent Component.
```
<GoogleLogin
clientId={GOOGLE_CLIENT_ID}
buttonText="Google"
render={(renderProps) => (
<button onClick={renderProps.onClick} style={customStyle}>
<img className="googleBtn" src={googleIcon} alt="GMAIL ICON" />
</button>
)}
onSuccess={responseGoogle}
onFailure={responseGoogle}
cookiePolicy={"single_host_origin"}
/>
```
withLogin HOC Parent Component dispatching the info to Redux thunk.
```
const responseGoogle = (res) => setGoogleResp(res);
useEffect(() => {
googleResp?.error &&
setValues({ ...values, serverError: "GOOGLE LOGIN FAILED" });
googleResp?.tokenId && dispatchGoogleSignInDataToBackend()
}, [googleResp]);
const dispatchGoogleSignInDataToBackend=async ()=>{
const data=await dispatch(allActions.googleSignInAction(googleResp,whoLoggedIn));
if (data.error) {
setValues({ ...values, serverError: data.error, success: false });
} else {
const {
email,
name,
_id,
role,
listOfEmailOfAllClientsForLawyerLogin,
} = data.userCred;
saveJwtToLocalStorage(
data.token,
{ name, email, _id, role, listOfEmailOfAllClientsForLawyerLogin },
() => {
setValues({
email,
serverError: false,
success: true,
});
}
);
}
}
```
I am sending the appropriate CORS header in the request to the backend.
```
export const dataHeaders = {
"Access-Control-Allow-Origin": "*",
"Content-Type": "application/json",
"Access-Control-Allow-Headers" :"*"
};
```
Redux thunk code:-
```
export const googleSignInAction=(googleResp,whoLoggedIn)=>{
console.log("Login Success: currentUser:", googleResp);
return async (dispatch) => {
dispatch({ type: SIGNIN_LOADING });
try {
const response = await axios.post(
`${API_URL}/googlesignin`,
{
googleResp,
whoLoggedIn
},
{
headers: dataHeaders,
}
);
console.log("response inside googleSignInAction", response);
// CHANGED COZ OF ESLINT WARNING.
if (
response.status === 201 &&
Object.keys(response.data).includes("token") &&
Object.keys(response.data).includes("userCred")
) {
dispatch({ type: SIGNIN_SUCCESS, data: response.data });
return response.data;
} else {
dispatch({ type: SIGNIN_FAILED });
}
} catch (error) {
dispatch({ type: SIGNIN_FAILED });
return error.response.data;
}
};
}
```
API URL Points to following:-
```
export const API_URL="http://localhost:9001/api";
```
No request is reaching the backend because of CORS error.
Frontend receiving the Correct Response from Google Post authentication.
[](https://i.stack.imgur.com/z4NYY.png)
Errors on the Frontend.
[](https://i.stack.imgur.com/Yx0O5.png)
[](https://i.stack.imgur.com/h7B0i.png) | 2020/09/24 | [
"https://Stackoverflow.com/questions/64039448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10407808/"
]
| Browsers will first send a pre-flight request to check CORS. In your backend code, you have to allow the front-end host and port. In this case localhost:3000.
The reason you are getting the cors error is bacause its on two different ports.
But if proper cors response is given by backend (port 9000), it will resolve. | [](https://i.stack.imgur.com/OY7HY.png)Clearing the browser cookies and cache made everything work again. googlesignin is working without cors error. I have added following line of code to serve all static files from backend to frontend.
```
app.use(express.static(path.join(__dirname, '../frontend/public')));
``` |
66,524,661 | Here I check the installed version of pip
`py -m pip --version`
```
pip 21.0.1 from C:\Users\hp\AppData\Local\Programs\Python\Python39\lib\site-packages\pip (python 3.9)
```
Now I try to run a pip command
`pip install pip --target $HOME\\.pyenv`
```
pip: The term 'pip' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
``` | 2021/03/08 | [
"https://Stackoverflow.com/questions/66524661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/865220/"
]
| Add the scripts folder to PATH
`C:\Users\hp\AppData\Local\Programs\Python\Python39\Scripts`
or
`C:\Python39\Scripts`
(depending on how you have installed python locate and add python/scripts folder) | Just use on the terminal:
```
py -m pip install
```
followed by the library you want to install. It tends to work. |
661,360 | This questions regards to doing force calculation using vectors. This image here should display my problem [](https://i.stack.imgur.com/SjXc5.jpg).
In basic newtonian physics, the normal force = force of gravity \* cosine (angle of inclination). $$F\_N = F\_G \times \cos{\theta}$$
To be clearer:
$$F\_N = (x\_G, y\_G) \times \cos{\theta}$$ $$F\_N = (0, 9.8) \times \cos{\theta}$$ $$F\_N = (0, 9.8\cos{\theta})$$
The problem is not calculating this value but representing it as a 2D vector format. How is the **x-component** of $F\_N = 0$, when the diagram (according to the direction of where the $F\_N$ is pointing) clearly shows that the **x-component** should have a value? I believe I have messed up my calculations. Could someone please help me? Thanks in advance!
EDIT:
The **x-component** of $F\_N$ should have a value other than $0$, otherwise, if it was = 0, it would be pointing straight up or down. This does not seem to be occurring in my calculations. | 2021/08/25 | [
"https://physics.stackexchange.com/questions/661360",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/310668/"
]
| In standard cosmology, the answer to the bolded question is "yes", while the answer to the second one is "no".
There is a way to define an absolute reference frame, in that any observer can measure the dipole moment of CMB radiation and determine the velocity with which they are moving through it (see section 2.1 in [this Planck paper](http://arxiv.org/abs/1807.06205), for example).
What this means is that the universe is not invariant with respect to Lorentz boosts, but it *is* ([at large enough scales](https://en.wikipedia.org/wiki/Cosmological_principle)) invariant with respect to rotations and shifts, so there is no center or preferential direction to speak of.
The existence of this "preferential" frame does not invalidate the general principle of relativity --- physics can be described in other frames just as well if we do a coordinate transformation. However, this particular one is interesting in that we can unambiguously refer to it from anywhere in the universe. | Is there a well-defined “speed relative to the universe" and is there a well-defined "central point" of the universe are 2 different questions.
As far as central point is concerned, there is indeed no such point.
Speed relative to the universe is also strictly not well-defined, but the frame of the cosmic background radiation is sometimes considered as some kind of stationary rest frame of the universe, relative to which other events can be described. But this is not a "privileged" frame of reference, just a convenient frame of reference to describe any kind of events anywhere in the universe. |
661,360 | This questions regards to doing force calculation using vectors. This image here should display my problem [](https://i.stack.imgur.com/SjXc5.jpg).
In basic newtonian physics, the normal force = force of gravity \* cosine (angle of inclination). $$F\_N = F\_G \times \cos{\theta}$$
To be clearer:
$$F\_N = (x\_G, y\_G) \times \cos{\theta}$$ $$F\_N = (0, 9.8) \times \cos{\theta}$$ $$F\_N = (0, 9.8\cos{\theta})$$
The problem is not calculating this value but representing it as a 2D vector format. How is the **x-component** of $F\_N = 0$, when the diagram (according to the direction of where the $F\_N$ is pointing) clearly shows that the **x-component** should have a value? I believe I have messed up my calculations. Could someone please help me? Thanks in advance!
EDIT:
The **x-component** of $F\_N$ should have a value other than $0$, otherwise, if it was = 0, it would be pointing straight up or down. This does not seem to be occurring in my calculations. | 2021/08/25 | [
"https://physics.stackexchange.com/questions/661360",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/310668/"
]
| In standard cosmology, the answer to the bolded question is "yes", while the answer to the second one is "no".
There is a way to define an absolute reference frame, in that any observer can measure the dipole moment of CMB radiation and determine the velocity with which they are moving through it (see section 2.1 in [this Planck paper](http://arxiv.org/abs/1807.06205), for example).
What this means is that the universe is not invariant with respect to Lorentz boosts, but it *is* ([at large enough scales](https://en.wikipedia.org/wiki/Cosmological_principle)) invariant with respect to rotations and shifts, so there is no center or preferential direction to speak of.
The existence of this "preferential" frame does not invalidate the general principle of relativity --- physics can be described in other frames just as well if we do a coordinate transformation. However, this particular one is interesting in that we can unambiguously refer to it from anywhere in the universe. | >
> Is there any sort of Absolute Universal (as in of-the-universe) Frame of Reference?
>
>
>
Sometimes the [CMB](https://en.wikipedia.org/wiki/Cosmic_microwave_background#CMBR_dipole_anisotropy) is considered to be a stationary frame of reference for the universe. But as per this link, one should not consider the CMB as the "single absolute frame of reference" for the universe. We can do things like measure the speed of astronomical objects, like galaxies, relative to the CMB.
>
> the expansion of the Universe doesn't have a central point ... it's not expanding "away from a point" ... everything is just expanding away from everything else uniformly?
>
>
>
This is true. The expansion of the universe is not happening from a point, but instead it is happening everywhere.
The idea of "a fixed "central" point of the universe" lacks a coherent definition according to standard cosmological models. |
661,360 | This questions regards to doing force calculation using vectors. This image here should display my problem [](https://i.stack.imgur.com/SjXc5.jpg).
In basic newtonian physics, the normal force = force of gravity \* cosine (angle of inclination). $$F\_N = F\_G \times \cos{\theta}$$
To be clearer:
$$F\_N = (x\_G, y\_G) \times \cos{\theta}$$ $$F\_N = (0, 9.8) \times \cos{\theta}$$ $$F\_N = (0, 9.8\cos{\theta})$$
The problem is not calculating this value but representing it as a 2D vector format. How is the **x-component** of $F\_N = 0$, when the diagram (according to the direction of where the $F\_N$ is pointing) clearly shows that the **x-component** should have a value? I believe I have messed up my calculations. Could someone please help me? Thanks in advance!
EDIT:
The **x-component** of $F\_N$ should have a value other than $0$, otherwise, if it was = 0, it would be pointing straight up or down. This does not seem to be occurring in my calculations. | 2021/08/25 | [
"https://physics.stackexchange.com/questions/661360",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/310668/"
]
| Is there a well-defined “speed relative to the universe" and is there a well-defined "central point" of the universe are 2 different questions.
As far as central point is concerned, there is indeed no such point.
Speed relative to the universe is also strictly not well-defined, but the frame of the cosmic background radiation is sometimes considered as some kind of stationary rest frame of the universe, relative to which other events can be described. But this is not a "privileged" frame of reference, just a convenient frame of reference to describe any kind of events anywhere in the universe. | >
> Is there any sort of Absolute Universal (as in of-the-universe) Frame of Reference?
>
>
>
Sometimes the [CMB](https://en.wikipedia.org/wiki/Cosmic_microwave_background#CMBR_dipole_anisotropy) is considered to be a stationary frame of reference for the universe. But as per this link, one should not consider the CMB as the "single absolute frame of reference" for the universe. We can do things like measure the speed of astronomical objects, like galaxies, relative to the CMB.
>
> the expansion of the Universe doesn't have a central point ... it's not expanding "away from a point" ... everything is just expanding away from everything else uniformly?
>
>
>
This is true. The expansion of the universe is not happening from a point, but instead it is happening everywhere.
The idea of "a fixed "central" point of the universe" lacks a coherent definition according to standard cosmological models. |
2,402,433 | As we use "default" keyword as a access specifier, and it can be used in switch statements as well with complete different purpose, So i was curious that is there any other keywords in java which can be used in more then one purposes | 2010/03/08 | [
"https://Stackoverflow.com/questions/2402433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241717/"
]
| Something no one else has mentioned yet: the **class** keyword has two different uses.
Declaring a class:
```
class Test{};
```
and indicating a class literal:
```
Class<Test> testClass = Test.class;
``` | The "extends" keyword can be for single inheritance (either implementation or "pure abstract class" aka "interface inheritance" in Java).
The "extends" keyword can also be used for multiple (interface) inheritance.
The ones who always argue that Java doesn't support multiple inheritance will hence have a hard time arguing that "extends" in those two cases is doing exactly the same thing.
Now I'm in the other camp: I consider that multiple interface inheritance is multiple inheritance and that implementation inheritance is just an OOP detail (that doesn't exist at the OOA/OOD level) and hence I consider that "extends" is really doing the same thing in both case and that hence my answer doesn't answer the question :)
But it's an interesting keyword nonetheless :) |
2,402,433 | As we use "default" keyword as a access specifier, and it can be used in switch statements as well with complete different purpose, So i was curious that is there any other keywords in java which can be used in more then one purposes | 2010/03/08 | [
"https://Stackoverflow.com/questions/2402433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241717/"
]
| The "default" in the case of access modifier isn't a keyword - you don't write:
`default void doSomething()`
However, when specifying the default value of an attribute of annotations - it is.
```
switch (a) {
default: something();
}
```
and
```
public @interface MyAnnotation {
boolean bool() default true;
}
```
That, together with `final` as pointed out by Jon Skeet seems to cover everything. Perhaps except the "overloaded" `for` keyword:
`for (initializer; condition; step)` and `for (Type element : collection)` | The "extends" keyword can be for single inheritance (either implementation or "pure abstract class" aka "interface inheritance" in Java).
The "extends" keyword can also be used for multiple (interface) inheritance.
The ones who always argue that Java doesn't support multiple inheritance will hence have a hard time arguing that "extends" in those two cases is doing exactly the same thing.
Now I'm in the other camp: I consider that multiple interface inheritance is multiple inheritance and that implementation inheritance is just an OOP detail (that doesn't exist at the OOA/OOD level) and hence I consider that "extends" is really doing the same thing in both case and that hence my answer doesn't answer the question :)
But it's an interesting keyword nonetheless :) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.