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 |
|---|---|---|---|---|---|
56,888,106 | I get this error message:
TS2339: Property 'ITEMS' does not exist on type 'DataModel[]'
I'm working in IONIC/ANGULAR and doing a reactive Form with a model and getting data from HTTP.
**There is the model (model.ts):**
```
export class DataModel {
public ITEMS: any[];
constructor(public NAME: string, public... | 2019/07/04 | [
"https://Stackoverflow.com/questions/56888106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11244704/"
] | since you defined `public dbData: DataModel[]` as an array you should treat it as one.
My guess is you meant to define it as `public dbData: DataModel`, then it will work when you call `this.dbData.ITEMS.forEach(element => {`
Here is the full change:
```
export class Form2Page implements OnInit, OnDestroy {
obsSub... | Ther is the source code with the error you can see in the code in red.
[Source Code with the error](https://stackblitz.com/edit/angular-form-jbdioli) |
56,888,106 | I get this error message:
TS2339: Property 'ITEMS' does not exist on type 'DataModel[]'
I'm working in IONIC/ANGULAR and doing a reactive Form with a model and getting data from HTTP.
**There is the model (model.ts):**
```
export class DataModel {
public ITEMS: any[];
constructor(public NAME: string, public... | 2019/07/04 | [
"https://Stackoverflow.com/questions/56888106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11244704/"
] | dbData is a `DataModel[]` , you access it as `this.dbData.ITEMS` which for sure doesn't exists. so either you have to
```
dbData : DataModel;
this.dbData.ITEMS...
```
or
```
dbData : DataModel[];
this.dbData.forEach(dbItem => {
dbItem.ITEMS...
})
```
also I noticed `DataModel` has an array inside, I guess ... | Ther is the source code with the error you can see in the code in red.
[Source Code with the error](https://stackblitz.com/edit/angular-form-jbdioli) |
17,195,812 | I have `div`'s inside a `div`
```
<div id="out" align="center">
<div id="in1" align="left">111</div>
<div id="in2" align="left">aaaaaaaaaaaaaaaaaaaaaa</div>
<div id="in3" align="left">bbbb</div>
<div id="in4" align="left">6516519191</div>
<div id="in5" align="left">apple</div>
<div ... | 2013/06/19 | [
"https://Stackoverflow.com/questions/17195812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2479886/"
] | You can by inserting another (outer) container div.
* Outer div container: width 100% and centered text alignment;
* Inner div container: inline-block and left text alignment
CSS
```
#outerContainer {
width: 100%;
text-align: center;
}
#innerContainer {
display: inline-block;
text-align: left;
}
``... | Set the outer `width:100%;`
Or define the inner width otherwise
CSS
---
```
.abc{
float:left;
width:100%;
}
```
HTML
----
```
<div id="out" align="center">
<div id="in1" class="abc">111</div>
<div id="in2" class="abc">aaaaaaaaaaaaaaaaaaaaaa</div>
<div id="in3" class="abc">bbbb</div>
<div id... |
17,195,812 | I have `div`'s inside a `div`
```
<div id="out" align="center">
<div id="in1" align="left">111</div>
<div id="in2" align="left">aaaaaaaaaaaaaaaaaaaaaa</div>
<div id="in3" align="left">bbbb</div>
<div id="in4" align="left">6516519191</div>
<div id="in5" align="left">apple</div>
<div ... | 2013/06/19 | [
"https://Stackoverflow.com/questions/17195812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2479886/"
] | First, there is no "align" attribute for div's.
The information you are providing looks like tabular data. In that case, a table should be used, not div's. | Set the outer `width:100%;`
Or define the inner width otherwise
CSS
---
```
.abc{
float:left;
width:100%;
}
```
HTML
----
```
<div id="out" align="center">
<div id="in1" class="abc">111</div>
<div id="in2" class="abc">aaaaaaaaaaaaaaaaaaaaaa</div>
<div id="in3" class="abc">bbbb</div>
<div id... |
72,025,062 | Ques: From the following tables, write a SQL query to find those employees who work in a department where the employee’s first name contains the letter 'T'. Return employee ID, first name and last name.
link to the question <https://www.w3resource.com/sql-exercises/sql-subqueries-exercise-14.php>
First, one using SEL... | 2022/04/27 | [
"https://Stackoverflow.com/questions/72025062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16555991/"
] | This might work for you (GNU sed):
```
sed -sE '/^\s*<(Name|SNPID|PoweredBy|RegKey)>(.*)<\/\1>\s*$/{s//\1:\2/;H}
$!d;g;/PoweredBy:Kontakt/!d
s/Name:([^\n]*)(.*)/\2\n\1/
s/SNPID:([^\n]*)(.*)/\2|\1/
s/RegKey:([^\n]*)(.*)/\2|\1/
s/.*\n//' file ...
```
Use the options `-s` to... | Using `sed`
```
$ sed -n '/Name\|SNPID\|RegKey/{s/[^>]*>\([^<]*\).*/\1/;H;d};G;s/\n/ | /g;/^ |/{s/^ | \+| //p}' input_file
Mystica | 547 | Best Service - Mystica
``` |
72,025,062 | Ques: From the following tables, write a SQL query to find those employees who work in a department where the employee’s first name contains the letter 'T'. Return employee ID, first name and last name.
link to the question <https://www.w3resource.com/sql-exercises/sql-subqueries-exercise-14.php>
First, one using SEL... | 2022/04/27 | [
"https://Stackoverflow.com/questions/72025062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16555991/"
] | Highly recommeded: Don't try to parse xml with anything other than a proper xml parser. For that you can use either xmlstarlet [edited to reflect @Reino's comment below:
```
xml sel -T -t -m "//ProductHints//Product[PoweredBy="Kontakt"]" -v //SNPID/. --nl -v //Name/. --nl -v //RegKey/. --nl your_file.xml
```
or, eve... | Using `sed`
```
$ sed -n '/Name\|SNPID\|RegKey/{s/[^>]*>\([^<]*\).*/\1/;H;d};G;s/\n/ | /g;/^ |/{s/^ | \+| //p}' input_file
Mystica | 547 | Best Service - Mystica
``` |
72,025,062 | Ques: From the following tables, write a SQL query to find those employees who work in a department where the employee’s first name contains the letter 'T'. Return employee ID, first name and last name.
link to the question <https://www.w3resource.com/sql-exercises/sql-subqueries-exercise-14.php>
First, one using SEL... | 2022/04/27 | [
"https://Stackoverflow.com/questions/72025062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16555991/"
] | This might work for you (GNU sed):
```
sed -sE '/^\s*<(Name|SNPID|PoweredBy|RegKey)>(.*)<\/\1>\s*$/{s//\1:\2/;H}
$!d;g;/PoweredBy:Kontakt/!d
s/Name:([^\n]*)(.*)/\2\n\1/
s/SNPID:([^\n]*)(.*)/\2|\1/
s/RegKey:([^\n]*)(.*)/\2|\1/
s/.*\n//' file ...
```
Use the options `-s` to... | ### 1. Locating required files using `find` and `grep`
```
grep -l "PoweredBy>Kontakt" $(find . -name "*.xml")
```
Validate you get the correct file list.
### 2. Extracting data, and formating data from required files using `awk`
This `awk` script, process only the required files one by one.
```
awk -F"[><]" '
... |
72,025,062 | Ques: From the following tables, write a SQL query to find those employees who work in a department where the employee’s first name contains the letter 'T'. Return employee ID, first name and last name.
link to the question <https://www.w3resource.com/sql-exercises/sql-subqueries-exercise-14.php>
First, one using SEL... | 2022/04/27 | [
"https://Stackoverflow.com/questions/72025062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16555991/"
] | Highly recommeded: Don't try to parse xml with anything other than a proper xml parser. For that you can use either xmlstarlet [edited to reflect @Reino's comment below:
```
xml sel -T -t -m "//ProductHints//Product[PoweredBy="Kontakt"]" -v //SNPID/. --nl -v //Name/. --nl -v //RegKey/. --nl your_file.xml
```
or, eve... | ### 1. Locating required files using `find` and `grep`
```
grep -l "PoweredBy>Kontakt" $(find . -name "*.xml")
```
Validate you get the correct file list.
### 2. Extracting data, and formating data from required files using `awk`
This `awk` script, process only the required files one by one.
```
awk -F"[><]" '
... |
6,640,397 | If we put 15 in the root, what would be the process of heapify?
```
85
/\
/ \
/ \
55 70
/\ /\
/ \ / \
22 33 30 65
/\ /
14 15 15
```
What should be the way to delete 85 from the Heap? | 2011/07/10 | [
"https://Stackoverflow.com/questions/6640397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/159072/"
] | If you delete 85 and replace it with 15, you turn the semi-heap back into a heap by downheaping, i.e. the 15 at the root will "sink" along the path of larger children. In this case it will swap with 70 then with 65.
Edit: because we are always swapping with the larger child, it ensures we end up with a valid heap (e.g... | To add you put the new value as last (right to 20 in your example), and then you try to fix the heap, that is compare it with his parent, if it is larger the swap and compare again until no swap is needed (or you get to root)
In order to delete you remove you replace the last object (15 in you example) and fix the hea... |
6,640,397 | If we put 15 in the root, what would be the process of heapify?
```
85
/\
/ \
/ \
55 70
/\ /\
/ \ / \
22 33 30 65
/\ /
14 15 15
```
What should be the way to delete 85 from the Heap? | 2011/07/10 | [
"https://Stackoverflow.com/questions/6640397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/159072/"
] | As you are always swapping it with the larger of the two (heap property means that the parent is always larger than its children):
```
15
/\
/ \
/ \
55 70
/\ /\
/ \ / \
22 33 30 65
/\
14 15
70
... | To add you put the new value as last (right to 20 in your example), and then you try to fix the heap, that is compare it with his parent, if it is larger the swap and compare again until no swap is needed (or you get to root)
In order to delete you remove you replace the last object (15 in you example) and fix the hea... |
6,640,397 | If we put 15 in the root, what would be the process of heapify?
```
85
/\
/ \
/ \
55 70
/\ /\
/ \ / \
22 33 30 65
/\ /
14 15 15
```
What should be the way to delete 85 from the Heap? | 2011/07/10 | [
"https://Stackoverflow.com/questions/6640397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/159072/"
] | As you are always swapping it with the larger of the two (heap property means that the parent is always larger than its children):
```
15
/\
/ \
/ \
55 70
/\ /\
/ \ / \
22 33 30 65
/\
14 15
70
... | If you delete 85 and replace it with 15, you turn the semi-heap back into a heap by downheaping, i.e. the 15 at the root will "sink" along the path of larger children. In this case it will swap with 70 then with 65.
Edit: because we are always swapping with the larger child, it ensures we end up with a valid heap (e.g... |
6,640,397 | If we put 15 in the root, what would be the process of heapify?
```
85
/\
/ \
/ \
55 70
/\ /\
/ \ / \
22 33 30 65
/\ /
14 15 15
```
What should be the way to delete 85 from the Heap? | 2011/07/10 | [
"https://Stackoverflow.com/questions/6640397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/159072/"
] | If you delete 85 and replace it with 15, you turn the semi-heap back into a heap by downheaping, i.e. the 15 at the root will "sink" along the path of larger children. In this case it will swap with 70 then with 65.
Edit: because we are always swapping with the larger child, it ensures we end up with a valid heap (e.g... | To delete 85 which is root here.
1. You can replace with the last leaf (**15**).
2. Heapify Again [link to build heap](https://www.tutorialspoint.com/design_and_analysis_of_algorithms/design_and_analysis_of_algorithms_heapify_method.htm) |
6,640,397 | If we put 15 in the root, what would be the process of heapify?
```
85
/\
/ \
/ \
55 70
/\ /\
/ \ / \
22 33 30 65
/\ /
14 15 15
```
What should be the way to delete 85 from the Heap? | 2011/07/10 | [
"https://Stackoverflow.com/questions/6640397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/159072/"
] | As you are always swapping it with the larger of the two (heap property means that the parent is always larger than its children):
```
15
/\
/ \
/ \
55 70
/\ /\
/ \ / \
22 33 30 65
/\
14 15
70
... | To delete 85 which is root here.
1. You can replace with the last leaf (**15**).
2. Heapify Again [link to build heap](https://www.tutorialspoint.com/design_and_analysis_of_algorithms/design_and_analysis_of_algorithms_heapify_method.htm) |
87,600 | If Ravenloft is a demiplane, and a demiplane is an extradimensional space, can spells that create extradimensional spaces (like *rope trick*) be cast while in the realm? | 2016/09/06 | [
"https://rpg.stackexchange.com/questions/87600",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/31237/"
] | Yes.
>
> The Mad Mage of Mount Baratok has *Mordenkainen's magnificent mansion* prepared and can successfully cast it.
>
>
>
The demiplane created by a spell like *Mordenkainen's magnificent mansion* (PHB. p. 261) still follows the same rules regarding planar travel, so while you can create and enter an extrad... | Is there any reason why you think it can't?
Rope Trick says:
>
> At the
> upper end of the rope, an invisible entrance opens to an
> extradimensional space that lasts until the spell ends.
>
>
>
There is no reason if, having entered that extradimensional space, that I couldn't cast rope trick *again* and cli... |
87,600 | If Ravenloft is a demiplane, and a demiplane is an extradimensional space, can spells that create extradimensional spaces (like *rope trick*) be cast while in the realm? | 2016/09/06 | [
"https://rpg.stackexchange.com/questions/87600",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/31237/"
] | Yes you can,
Spoilers for rules not plot ahead...
Page 24 in Curse of Strahd indicates the specifics but the properties of the Demiplane of Dread (Barovia/Ravenloft) indicates that such extradimensional constructs as created via Demiplane or Mordenkainen's Magnificent Mansion are subject to the same warping rules as... | Yes.
>
> The Mad Mage of Mount Baratok has *Mordenkainen's magnificent mansion* prepared and can successfully cast it.
>
>
>
The demiplane created by a spell like *Mordenkainen's magnificent mansion* (PHB. p. 261) still follows the same rules regarding planar travel, so while you can create and enter an extrad... |
87,600 | If Ravenloft is a demiplane, and a demiplane is an extradimensional space, can spells that create extradimensional spaces (like *rope trick*) be cast while in the realm? | 2016/09/06 | [
"https://rpg.stackexchange.com/questions/87600",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/31237/"
] | Yes you can,
Spoilers for rules not plot ahead...
Page 24 in Curse of Strahd indicates the specifics but the properties of the Demiplane of Dread (Barovia/Ravenloft) indicates that such extradimensional constructs as created via Demiplane or Mordenkainen's Magnificent Mansion are subject to the same warping rules as... | Is there any reason why you think it can't?
Rope Trick says:
>
> At the
> upper end of the rope, an invisible entrance opens to an
> extradimensional space that lasts until the spell ends.
>
>
>
There is no reason if, having entered that extradimensional space, that I couldn't cast rope trick *again* and cli... |
2,562,298 | I need to read a file in PHP, but I only know the end of the filename, so I need to serch the file in a given directory using wildcards: \*filename.wav and then return it to the browser.
Is there a function to do that? or I need to get all the files in the directory and then search one by one?
Thanks for all the comme... | 2010/04/01 | [
"https://Stackoverflow.com/questions/2562298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/135754/"
] | Take a look at the [glob()](http://php.net/manual/en/function.glob.php) function
For example if you wanted to get every file matching `*abc.xyz` in the subdirectory `dir`
```
$matches = glob('./dir/*abc.xyz');
```
Note that glob isn't recursive and will only search a single directory and not all sub directories. | In addition to [Yacoby's answer](https://stackoverflow.com/questions/2562298/php-how-to-search-a-file-using-wildcards/2562299#2562299), I would like to add that a new **[`GlobIterator`](http://fr2.php.net/globiterator)** class has been added to PHP >= 5.3.
It allows one to use wildcards, the same way as [`glob()`](htt... |
31,509,401 | I'm using class enum.Enum in order to create a variable with selected members.
The main reason is to enable other developers in my team to use the same convention by selecting one of several permitted members for variable.
I would like to create a Boolean variable in the same way, enabling other developers to select ... | 2015/07/20 | [
"https://Stackoverflow.com/questions/31509401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3370773/"
] | ```
boolean_enum = Enum('boolean_enum', [('True', True), ('False', False)])
```
Checkout the documentation of this API: <https://docs.python.org/3/library/enum.html#functional-api>
If you just specify 'True False' for the names parameter, they will be assigned automatic enumerated values (1,2) which is not what you ... | Nowadays (python 3.6+) this could be much more conveniently achieved by using `enum.Flag`:
```
from enum import Flag
class Boolean(Flag):
TRUE = True
FALSE = False
```
An added benefit of `enum.Flag` over `enum.Enum` is that it supports (and is closed under) bit-wise operators (`&,|,~`) from the get-go:
``... |
18,945,696 | I am trying to split a string like: abc|aa||
When I use the regular string.split I am required to provide a regular expression.
I tried to do the following :
string.split("|")
string.split("\|")
string.split("/|")
string.split("\Q|\E")
Non of them work.....
Does anyone know how to make it work? | 2013/09/22 | [
"https://Stackoverflow.com/questions/18945696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2017912/"
] | I don't know how you tried, but
```
public static void main(String[] args) {
String a= "abc|aa||";
String split = Pattern.quote("|");
System.out.println(split);
System.out.println(Arrays.toString(a.split(split)));
}
```
prints out
```
\Q|\E
[abc, aa]
```
effectively splitting on `|`. The `\Q ... ... | using a double backslash is required because the backslash is also a special character. So you need to escape the escape character. i.e. \
\| |
18,945,696 | I am trying to split a string like: abc|aa||
When I use the regular string.split I am required to provide a regular expression.
I tried to do the following :
string.split("|")
string.split("\|")
string.split("/|")
string.split("\Q|\E")
Non of them work.....
Does anyone know how to make it work? | 2013/09/22 | [
"https://Stackoverflow.com/questions/18945696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2017912/"
] | using a double backslash is required because the backslash is also a special character. So you need to escape the escape character. i.e. \
\| | `|` is a special character hence you need to escape it using slashes. Try using
`string.split("\\|")` |
18,945,696 | I am trying to split a string like: abc|aa||
When I use the regular string.split I am required to provide a regular expression.
I tried to do the following :
string.split("|")
string.split("\|")
string.split("/|")
string.split("\Q|\E")
Non of them work.....
Does anyone know how to make it work? | 2013/09/22 | [
"https://Stackoverflow.com/questions/18945696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2017912/"
] | using a double backslash is required because the backslash is also a special character. So you need to escape the escape character. i.e. \
\| | `|` is a special character for the regular expression, thus it must be escaped e.g. `\|`
The backslash `\` is a special character in Java, thus it must also be escaped
As a result, must do the following to achieve the desired effect.
```
string.split("\\|")
``` |
18,945,696 | I am trying to split a string like: abc|aa||
When I use the regular string.split I am required to provide a regular expression.
I tried to do the following :
string.split("|")
string.split("\|")
string.split("/|")
string.split("\Q|\E")
Non of them work.....
Does anyone know how to make it work? | 2013/09/22 | [
"https://Stackoverflow.com/questions/18945696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2017912/"
] | using a double backslash is required because the backslash is also a special character. So you need to escape the escape character. i.e. \
\| | All of the following patterns split it all right: `"\\Q|\\E"` `"\\|"` `"[|]"` of course the latter two are preferrable |
18,945,696 | I am trying to split a string like: abc|aa||
When I use the regular string.split I am required to provide a regular expression.
I tried to do the following :
string.split("|")
string.split("\|")
string.split("/|")
string.split("\Q|\E")
Non of them work.....
Does anyone know how to make it work? | 2013/09/22 | [
"https://Stackoverflow.com/questions/18945696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2017912/"
] | I don't know how you tried, but
```
public static void main(String[] args) {
String a= "abc|aa||";
String split = Pattern.quote("|");
System.out.println(split);
System.out.println(Arrays.toString(a.split(split)));
}
```
prints out
```
\Q|\E
[abc, aa]
```
effectively splitting on `|`. The `\Q ... ... | `|` is a special character hence you need to escape it using slashes. Try using
`string.split("\\|")` |
18,945,696 | I am trying to split a string like: abc|aa||
When I use the regular string.split I am required to provide a regular expression.
I tried to do the following :
string.split("|")
string.split("\|")
string.split("/|")
string.split("\Q|\E")
Non of them work.....
Does anyone know how to make it work? | 2013/09/22 | [
"https://Stackoverflow.com/questions/18945696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2017912/"
] | I don't know how you tried, but
```
public static void main(String[] args) {
String a= "abc|aa||";
String split = Pattern.quote("|");
System.out.println(split);
System.out.println(Arrays.toString(a.split(split)));
}
```
prints out
```
\Q|\E
[abc, aa]
```
effectively splitting on `|`. The `\Q ... ... | `|` is a special character for the regular expression, thus it must be escaped e.g. `\|`
The backslash `\` is a special character in Java, thus it must also be escaped
As a result, must do the following to achieve the desired effect.
```
string.split("\\|")
``` |
18,945,696 | I am trying to split a string like: abc|aa||
When I use the regular string.split I am required to provide a regular expression.
I tried to do the following :
string.split("|")
string.split("\|")
string.split("/|")
string.split("\Q|\E")
Non of them work.....
Does anyone know how to make it work? | 2013/09/22 | [
"https://Stackoverflow.com/questions/18945696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2017912/"
] | I don't know how you tried, but
```
public static void main(String[] args) {
String a= "abc|aa||";
String split = Pattern.quote("|");
System.out.println(split);
System.out.println(Arrays.toString(a.split(split)));
}
```
prints out
```
\Q|\E
[abc, aa]
```
effectively splitting on `|`. The `\Q ... ... | All of the following patterns split it all right: `"\\Q|\\E"` `"\\|"` `"[|]"` of course the latter two are preferrable |
9,011,738 | I'm making a REST call and receiving this XML back:
```
<replacement><![CDATA[this is & ampersand]]></replacement>
```
I've substringed out the bit that I really care about:
```
this is & ampersand
```
How do I now decode this snippet into (I'm not using yaws):
```
this is & ampersand
``` | 2012/01/25 | [
"https://Stackoverflow.com/questions/9011738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/742195/"
] | It's most likely because of the integer cast. Depending on your inputs, the results can be close and appear to have the same result because of rounding during the integer cast. Use double in your function instead. | You're going to get a lot of error due to the fact that you're using `int` everywhere. `float` or `double` would be a better choice. This alone could explain why you're getting the same results despite entering different values. For example, `int flow=0.25*x` would give the same value for `flow` for all x where x > -4 ... |
9,011,738 | I'm making a REST call and receiving this XML back:
```
<replacement><![CDATA[this is & ampersand]]></replacement>
```
I've substringed out the bit that I really care about:
```
this is & ampersand
```
How do I now decode this snippet into (I'm not using yaws):
```
this is & ampersand
``` | 2012/01/25 | [
"https://Stackoverflow.com/questions/9011738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/742195/"
] | It's most likely because of the integer cast. Depending on your inputs, the results can be close and appear to have the same result because of rounding during the integer cast. Use double in your function instead. | You are doing floating point arithmetic and returning the result to int. I would change variables to floats or doubles were needed. |
9,011,738 | I'm making a REST call and receiving this XML back:
```
<replacement><![CDATA[this is & ampersand]]></replacement>
```
I've substringed out the bit that I really care about:
```
this is & ampersand
```
How do I now decode this snippet into (I'm not using yaws):
```
this is & ampersand
``` | 2012/01/25 | [
"https://Stackoverflow.com/questions/9011738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/742195/"
] | It's most likely because of the integer cast. Depending on your inputs, the results can be close and appear to have the same result because of rounding during the integer cast. Use double in your function instead. | To get accurate result, you need `float` or `double` type.
Please try this:
```
#include <stdio.h>
#include <math.h>
double PI = 3.14;
double flowRateFormula(float, float);
double flowRateFormula(float pipeDiameter, float velocity)
{
double p = pow(pipeDiameter, 2);
double result = 0.25 * PI * p * veloc... |
9,011,738 | I'm making a REST call and receiving this XML back:
```
<replacement><![CDATA[this is & ampersand]]></replacement>
```
I've substringed out the bit that I really care about:
```
this is & ampersand
```
How do I now decode this snippet into (I'm not using yaws):
```
this is & ampersand
``` | 2012/01/25 | [
"https://Stackoverflow.com/questions/9011738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/742195/"
] | You're going to get a lot of error due to the fact that you're using `int` everywhere. `float` or `double` would be a better choice. This alone could explain why you're getting the same results despite entering different values. For example, `int flow=0.25*x` would give the same value for `flow` for all x where x > -4 ... | You are doing floating point arithmetic and returning the result to int. I would change variables to floats or doubles were needed. |
9,011,738 | I'm making a REST call and receiving this XML back:
```
<replacement><![CDATA[this is & ampersand]]></replacement>
```
I've substringed out the bit that I really care about:
```
this is & ampersand
```
How do I now decode this snippet into (I'm not using yaws):
```
this is & ampersand
``` | 2012/01/25 | [
"https://Stackoverflow.com/questions/9011738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/742195/"
] | To get accurate result, you need `float` or `double` type.
Please try this:
```
#include <stdio.h>
#include <math.h>
double PI = 3.14;
double flowRateFormula(float, float);
double flowRateFormula(float pipeDiameter, float velocity)
{
double p = pow(pipeDiameter, 2);
double result = 0.25 * PI * p * veloc... | You are doing floating point arithmetic and returning the result to int. I would change variables to floats or doubles were needed. |
24,035,234 | I am currently building an application in three.js alongside some jQuery. I am currently raycasting and placing a helper at the location of where the raycast hits. More or less I am trying to achieve **[this](http://threejs.org/examples/#webgl_geometry_terrain_raycast).**
I have managed to achieve this, however upon m... | 2014/06/04 | [
"https://Stackoverflow.com/questions/24035234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1363484/"
] | As everything else is correct, your `mouseVector` `x` and `y` values (i.e. `clientX` and `clientY`) are most likely off as compared with your WebGL canvas (for instance, you may be getting these from some element other than the canvas.
Easiest way to check for this is to place the mouse in the top left corner of your ... | Oddly enough the issue seemed to resolve itself upon changing the perspective camera near parameter from 0.1 to 1
```
camera = new THREE.PerspectiveCamera(45, canvaswidth / canvasheight , 0.1, 10000 );
```
To:
```
camera = new THREE.PerspectiveCamera(45, canvaswidth / canvasheight , 1, 10000 );
```
I am still no... |
24,035,234 | I am currently building an application in three.js alongside some jQuery. I am currently raycasting and placing a helper at the location of where the raycast hits. More or less I am trying to achieve **[this](http://threejs.org/examples/#webgl_geometry_terrain_raycast).**
I have managed to achieve this, however upon m... | 2014/06/04 | [
"https://Stackoverflow.com/questions/24035234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1363484/"
] | Oddly enough the issue seemed to resolve itself upon changing the perspective camera near parameter from 0.1 to 1
```
camera = new THREE.PerspectiveCamera(45, canvaswidth / canvasheight , 0.1, 10000 );
```
To:
```
camera = new THREE.PerspectiveCamera(45, canvaswidth / canvasheight , 1, 10000 );
```
I am still no... | Because I am not using the full screen resolution as the size of my WebGL canvas, I needed to do an alternate calculation to subtract the distance between the window and the canvas, to define where my mouse actually was hovering..
```
function onDocumentMouseMove( event ) {
mouseVector.x = (event.offsetX / (window... |
24,035,234 | I am currently building an application in three.js alongside some jQuery. I am currently raycasting and placing a helper at the location of where the raycast hits. More or less I am trying to achieve **[this](http://threejs.org/examples/#webgl_geometry_terrain_raycast).**
I have managed to achieve this, however upon m... | 2014/06/04 | [
"https://Stackoverflow.com/questions/24035234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1363484/"
] | As everything else is correct, your `mouseVector` `x` and `y` values (i.e. `clientX` and `clientY`) are most likely off as compared with your WebGL canvas (for instance, you may be getting these from some element other than the canvas.
Easiest way to check for this is to place the mouse in the top left corner of your ... | Use event.OffsetX and event.OffsetY if you are using ClientX and ClientY. |
24,035,234 | I am currently building an application in three.js alongside some jQuery. I am currently raycasting and placing a helper at the location of where the raycast hits. More or less I am trying to achieve **[this](http://threejs.org/examples/#webgl_geometry_terrain_raycast).**
I have managed to achieve this, however upon m... | 2014/06/04 | [
"https://Stackoverflow.com/questions/24035234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1363484/"
] | As everything else is correct, your `mouseVector` `x` and `y` values (i.e. `clientX` and `clientY`) are most likely off as compared with your WebGL canvas (for instance, you may be getting these from some element other than the canvas.
Easiest way to check for this is to place the mouse in the top left corner of your ... | Had many difficulties with this, and still not sure I understand why this works, but this calculation of x and y works for me.
```
let canvas = document.querySelector('canvas');
let x = (event.offsetX / canvas.clientWidth) * 2 - 1;
let y = -(event.offsetY / canvas.clientHeight) * 2 + 1;
``` |
24,035,234 | I am currently building an application in three.js alongside some jQuery. I am currently raycasting and placing a helper at the location of where the raycast hits. More or less I am trying to achieve **[this](http://threejs.org/examples/#webgl_geometry_terrain_raycast).**
I have managed to achieve this, however upon m... | 2014/06/04 | [
"https://Stackoverflow.com/questions/24035234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1363484/"
] | As everything else is correct, your `mouseVector` `x` and `y` values (i.e. `clientX` and `clientY`) are most likely off as compared with your WebGL canvas (for instance, you may be getting these from some element other than the canvas.
Easiest way to check for this is to place the mouse in the top left corner of your ... | Because I am not using the full screen resolution as the size of my WebGL canvas, I needed to do an alternate calculation to subtract the distance between the window and the canvas, to define where my mouse actually was hovering..
```
function onDocumentMouseMove( event ) {
mouseVector.x = (event.offsetX / (window... |
24,035,234 | I am currently building an application in three.js alongside some jQuery. I am currently raycasting and placing a helper at the location of where the raycast hits. More or less I am trying to achieve **[this](http://threejs.org/examples/#webgl_geometry_terrain_raycast).**
I have managed to achieve this, however upon m... | 2014/06/04 | [
"https://Stackoverflow.com/questions/24035234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1363484/"
] | Use event.OffsetX and event.OffsetY if you are using ClientX and ClientY. | Because I am not using the full screen resolution as the size of my WebGL canvas, I needed to do an alternate calculation to subtract the distance between the window and the canvas, to define where my mouse actually was hovering..
```
function onDocumentMouseMove( event ) {
mouseVector.x = (event.offsetX / (window... |
24,035,234 | I am currently building an application in three.js alongside some jQuery. I am currently raycasting and placing a helper at the location of where the raycast hits. More or less I am trying to achieve **[this](http://threejs.org/examples/#webgl_geometry_terrain_raycast).**
I have managed to achieve this, however upon m... | 2014/06/04 | [
"https://Stackoverflow.com/questions/24035234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1363484/"
] | Had many difficulties with this, and still not sure I understand why this works, but this calculation of x and y works for me.
```
let canvas = document.querySelector('canvas');
let x = (event.offsetX / canvas.clientWidth) * 2 - 1;
let y = -(event.offsetY / canvas.clientHeight) * 2 + 1;
``` | Because I am not using the full screen resolution as the size of my WebGL canvas, I needed to do an alternate calculation to subtract the distance between the window and the canvas, to define where my mouse actually was hovering..
```
function onDocumentMouseMove( event ) {
mouseVector.x = (event.offsetX / (window... |
5,614,446 | Is there a way to bind a Silverlight control to an object (or database table's row) which contains the values of several control's properties, doing so without by define the binding for each property?
For instance:
Let's say I have the class (or entity based on database table's row) with the following values:
```
cla... | 2011/04/10 | [
"https://Stackoverflow.com/questions/5614446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/701219/"
] | I have the same issue with relative URLs in a rendered control in the same fashion I think that you are experiencing.
My problem is that I noticed the request.path is relative to the service call, apparently AJAX or IIS creates a subdirectory under your current page and that's why ResolveClientUrl or "tilde" resolves... | Everything that Marty described is correct, and I'm not sure how to fix this issue either, but here's a workaround that I use, which detects when the extra "../" is prepended and corrects the situation by readding the subdirectory into the URL:
```
// this is the link that will be appended to the fullpath+subd... |
432,353 | ### Problem
My Dropbox context menu is missing in OS X Snow Leopard (10.6.8). While the Dropbox service runs normally, Finder doesn't show the icons and also doesn't give me the ability to browse files on the website or copy the public link.

### What I've tried
* Removed `~/... | 2012/06/04 | [
"https://superuser.com/questions/432353",
"https://superuser.com",
"https://superuser.com/users/48078/"
] | In [this thread](http://forums.dropbox.com/topic.php?id=17420), the person reported that Context menu is shown upon restarting the computer. can you please try that?
of course after install/reinstall :-). | **Common fix to missing contextual menus in macOS: Confirm that the "Folder Actions Setup..." service is enabled in System Preferences.**
System Preferences -> Keyboard -> Shortcuts -> Services -> Files and Folders. Make sure "Folder Actions Setup..." is enabled. (This has worked since Mac OS X 10.6.8, tested again in... |
432,353 | ### Problem
My Dropbox context menu is missing in OS X Snow Leopard (10.6.8). While the Dropbox service runs normally, Finder doesn't show the icons and also doesn't give me the ability to browse files on the website or copy the public link.

### What I've tried
* Removed `~/... | 2012/06/04 | [
"https://superuser.com/questions/432353",
"https://superuser.com",
"https://superuser.com/users/48078/"
] | In [this thread](http://forums.dropbox.com/topic.php?id=17420), the person reported that Context menu is shown upon restarting the computer. can you please try that?
of course after install/reinstall :-). | I had the same problem and found that if I quit and restarted the Dropbox application it would work again.
I found that sometimes I would reboot/log out and in and it would work, other times a reboot/log out wouldn't help. |
432,353 | ### Problem
My Dropbox context menu is missing in OS X Snow Leopard (10.6.8). While the Dropbox service runs normally, Finder doesn't show the icons and also doesn't give me the ability to browse files on the website or copy the public link.

### What I've tried
* Removed `~/... | 2012/06/04 | [
"https://superuser.com/questions/432353",
"https://superuser.com",
"https://superuser.com/users/48078/"
] | In [this thread](http://forums.dropbox.com/topic.php?id=17420), the person reported that Context menu is shown upon restarting the computer. can you please try that?
of course after install/reinstall :-). | Definitively, Dropbox was the problem. This work for my on Mac OSX Snow Leopard and Lion.
1. Go to Preferences > Keyboard > Keyboard shortcuts
2. Look for Services then Files and Folders
3. Probably "Folder actions setup..." will be enable. Uncheck it, then close Preferences and force quit Finder
4. To force quit Find... |
432,353 | ### Problem
My Dropbox context menu is missing in OS X Snow Leopard (10.6.8). While the Dropbox service runs normally, Finder doesn't show the icons and also doesn't give me the ability to browse files on the website or copy the public link.

### What I've tried
* Removed `~/... | 2012/06/04 | [
"https://superuser.com/questions/432353",
"https://superuser.com",
"https://superuser.com/users/48078/"
] | In [this thread](http://forums.dropbox.com/topic.php?id=17420), the person reported that Context menu is shown upon restarting the computer. can you please try that?
of course after install/reinstall :-). | Simply relaunching Finder brought back the contextual menu items for Dropbox. My method: Option+click on the Finder icon in Mac Dock and select Relaunch.
It's too bad that Desktop Dropbox has been "dying" this way for me for the past couple weeks. A recent upgrade to Dropbox? A glitch introduced by my upgrade from Sie... |
432,353 | ### Problem
My Dropbox context menu is missing in OS X Snow Leopard (10.6.8). While the Dropbox service runs normally, Finder doesn't show the icons and also doesn't give me the ability to browse files on the website or copy the public link.

### What I've tried
* Removed `~/... | 2012/06/04 | [
"https://superuser.com/questions/432353",
"https://superuser.com",
"https://superuser.com/users/48078/"
] | **Common fix to missing contextual menus in macOS: Confirm that the "Folder Actions Setup..." service is enabled in System Preferences.**
System Preferences -> Keyboard -> Shortcuts -> Services -> Files and Folders. Make sure "Folder Actions Setup..." is enabled. (This has worked since Mac OS X 10.6.8, tested again in... | I had the same problem and found that if I quit and restarted the Dropbox application it would work again.
I found that sometimes I would reboot/log out and in and it would work, other times a reboot/log out wouldn't help. |
432,353 | ### Problem
My Dropbox context menu is missing in OS X Snow Leopard (10.6.8). While the Dropbox service runs normally, Finder doesn't show the icons and also doesn't give me the ability to browse files on the website or copy the public link.

### What I've tried
* Removed `~/... | 2012/06/04 | [
"https://superuser.com/questions/432353",
"https://superuser.com",
"https://superuser.com/users/48078/"
] | **Common fix to missing contextual menus in macOS: Confirm that the "Folder Actions Setup..." service is enabled in System Preferences.**
System Preferences -> Keyboard -> Shortcuts -> Services -> Files and Folders. Make sure "Folder Actions Setup..." is enabled. (This has worked since Mac OS X 10.6.8, tested again in... | Definitively, Dropbox was the problem. This work for my on Mac OSX Snow Leopard and Lion.
1. Go to Preferences > Keyboard > Keyboard shortcuts
2. Look for Services then Files and Folders
3. Probably "Folder actions setup..." will be enable. Uncheck it, then close Preferences and force quit Finder
4. To force quit Find... |
432,353 | ### Problem
My Dropbox context menu is missing in OS X Snow Leopard (10.6.8). While the Dropbox service runs normally, Finder doesn't show the icons and also doesn't give me the ability to browse files on the website or copy the public link.

### What I've tried
* Removed `~/... | 2012/06/04 | [
"https://superuser.com/questions/432353",
"https://superuser.com",
"https://superuser.com/users/48078/"
] | **Common fix to missing contextual menus in macOS: Confirm that the "Folder Actions Setup..." service is enabled in System Preferences.**
System Preferences -> Keyboard -> Shortcuts -> Services -> Files and Folders. Make sure "Folder Actions Setup..." is enabled. (This has worked since Mac OS X 10.6.8, tested again in... | Simply relaunching Finder brought back the contextual menu items for Dropbox. My method: Option+click on the Finder icon in Mac Dock and select Relaunch.
It's too bad that Desktop Dropbox has been "dying" this way for me for the past couple weeks. A recent upgrade to Dropbox? A glitch introduced by my upgrade from Sie... |
432,353 | ### Problem
My Dropbox context menu is missing in OS X Snow Leopard (10.6.8). While the Dropbox service runs normally, Finder doesn't show the icons and also doesn't give me the ability to browse files on the website or copy the public link.

### What I've tried
* Removed `~/... | 2012/06/04 | [
"https://superuser.com/questions/432353",
"https://superuser.com",
"https://superuser.com/users/48078/"
] | I had the same problem and found that if I quit and restarted the Dropbox application it would work again.
I found that sometimes I would reboot/log out and in and it would work, other times a reboot/log out wouldn't help. | Simply relaunching Finder brought back the contextual menu items for Dropbox. My method: Option+click on the Finder icon in Mac Dock and select Relaunch.
It's too bad that Desktop Dropbox has been "dying" this way for me for the past couple weeks. A recent upgrade to Dropbox? A glitch introduced by my upgrade from Sie... |
432,353 | ### Problem
My Dropbox context menu is missing in OS X Snow Leopard (10.6.8). While the Dropbox service runs normally, Finder doesn't show the icons and also doesn't give me the ability to browse files on the website or copy the public link.

### What I've tried
* Removed `~/... | 2012/06/04 | [
"https://superuser.com/questions/432353",
"https://superuser.com",
"https://superuser.com/users/48078/"
] | Definitively, Dropbox was the problem. This work for my on Mac OSX Snow Leopard and Lion.
1. Go to Preferences > Keyboard > Keyboard shortcuts
2. Look for Services then Files and Folders
3. Probably "Folder actions setup..." will be enable. Uncheck it, then close Preferences and force quit Finder
4. To force quit Find... | Simply relaunching Finder brought back the contextual menu items for Dropbox. My method: Option+click on the Finder icon in Mac Dock and select Relaunch.
It's too bad that Desktop Dropbox has been "dying" this way for me for the past couple weeks. A recent upgrade to Dropbox? A glitch introduced by my upgrade from Sie... |
1,031,710 | Am currently working on an application that requires users to submit posts and comments which is displayed on the site. As we all know that user input can't be trusted so i used htmlspecialchars($string,ENT\_QUOTES) to process user's posts and comments.
Now, i want some certain html tags ignored. such as `<b><br />` ... | 2009/06/23 | [
"https://Stackoverflow.com/questions/1031710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53804/"
] | It is **very, very difficult** to allow only some HTML tags without allowing any possibility of script injection or the like.
I would actually recommend avoiding this and using something that generates HTML such as [this UBB code parser](http://www.phpclasses.org/browse/package/818.html) (or similar). Or even [Markdo... | You can replace the quoted string to re-insert the allowed tags. For `<b>` tags for example:
```
$string = str_replace(array('<b>', </>), array('<b>', '</b>'), $string);
```
I would only allow very distinct, complete tags to be as secure as possible. I.e. Don't use regular expressions if you don't have t... |
1,031,710 | Am currently working on an application that requires users to submit posts and comments which is displayed on the site. As we all know that user input can't be trusted so i used htmlspecialchars($string,ENT\_QUOTES) to process user's posts and comments.
Now, i want some certain html tags ignored. such as `<b><br />` ... | 2009/06/23 | [
"https://Stackoverflow.com/questions/1031710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53804/"
] | **solution a)**
use strip\_tags insted of htmlspecialchars, and whitelist the needed tags.
**better solution b)**
Use bbcodes, and give aliases to the wanted tags, e.g: [b]bold[/b] | You can replace the quoted string to re-insert the allowed tags. For `<b>` tags for example:
```
$string = str_replace(array('<b>', </>), array('<b>', '</b>'), $string);
```
I would only allow very distinct, complete tags to be as secure as possible. I.e. Don't use regular expressions if you don't have t... |
1,031,710 | Am currently working on an application that requires users to submit posts and comments which is displayed on the site. As we all know that user input can't be trusted so i used htmlspecialchars($string,ENT\_QUOTES) to process user's posts and comments.
Now, i want some certain html tags ignored. such as `<b><br />` ... | 2009/06/23 | [
"https://Stackoverflow.com/questions/1031710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53804/"
] | **solution a)**
use strip\_tags insted of htmlspecialchars, and whitelist the needed tags.
**better solution b)**
Use bbcodes, and give aliases to the wanted tags, e.g: [b]bold[/b] | I would heavily recommend you use Zend\_Filter for filtering through user input. Specifically, see:
<http://framework.zend.com/manual/en/zend.filter.html#zend.filter.introduction.using> |
1,031,710 | Am currently working on an application that requires users to submit posts and comments which is displayed on the site. As we all know that user input can't be trusted so i used htmlspecialchars($string,ENT\_QUOTES) to process user's posts and comments.
Now, i want some certain html tags ignored. such as `<b><br />` ... | 2009/06/23 | [
"https://Stackoverflow.com/questions/1031710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53804/"
] | It is **very, very difficult** to allow only some HTML tags without allowing any possibility of script injection or the like.
I would actually recommend avoiding this and using something that generates HTML such as [this UBB code parser](http://www.phpclasses.org/browse/package/818.html) (or similar). Or even [Markdo... | This isn't as simple as you might thing because neither [`htmlspecialchars()`](http://de.php.net/manual/en/function.htmlspecialchars.php) nor [`htmlentities()`](http://de.php.net/manual/en/function.htmlentities.php) provides any options to ignore certain tags (both functions don't even know the meaning of the notion of... |
1,031,710 | Am currently working on an application that requires users to submit posts and comments which is displayed on the site. As we all know that user input can't be trusted so i used htmlspecialchars($string,ENT\_QUOTES) to process user's posts and comments.
Now, i want some certain html tags ignored. such as `<b><br />` ... | 2009/06/23 | [
"https://Stackoverflow.com/questions/1031710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53804/"
] | > Tired of using BBCode due to the current landscape of deficient or insecure HTML filters?
--> [HTML Purifier](http://htmlpurifier.org/)
> HTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, ... | I would heavily recommend you use Zend\_Filter for filtering through user input. Specifically, see:
<http://framework.zend.com/manual/en/zend.filter.html#zend.filter.introduction.using> |
1,031,710 | Am currently working on an application that requires users to submit posts and comments which is displayed on the site. As we all know that user input can't be trusted so i used htmlspecialchars($string,ENT\_QUOTES) to process user's posts and comments.
Now, i want some certain html tags ignored. such as `<b><br />` ... | 2009/06/23 | [
"https://Stackoverflow.com/questions/1031710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53804/"
] | You can replace the quoted string to re-insert the allowed tags. For `<b>` tags for example:
```
$string = str_replace(array('<b>', </>), array('<b>', '</b>'), $string);
```
I would only allow very distinct, complete tags to be as secure as possible. I.e. Don't use regular expressions if you don't have t... | I would heavily recommend you use Zend\_Filter for filtering through user input. Specifically, see:
<http://framework.zend.com/manual/en/zend.filter.html#zend.filter.introduction.using> |
1,031,710 | Am currently working on an application that requires users to submit posts and comments which is displayed on the site. As we all know that user input can't be trusted so i used htmlspecialchars($string,ENT\_QUOTES) to process user's posts and comments.
Now, i want some certain html tags ignored. such as `<b><br />` ... | 2009/06/23 | [
"https://Stackoverflow.com/questions/1031710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53804/"
] | > Tired of using BBCode due to the current landscape of deficient or insecure HTML filters?
--> [HTML Purifier](http://htmlpurifier.org/)
> HTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, ... | This isn't as simple as you might thing because neither [`htmlspecialchars()`](http://de.php.net/manual/en/function.htmlspecialchars.php) nor [`htmlentities()`](http://de.php.net/manual/en/function.htmlentities.php) provides any options to ignore certain tags (both functions don't even know the meaning of the notion of... |
1,031,710 | Am currently working on an application that requires users to submit posts and comments which is displayed on the site. As we all know that user input can't be trusted so i used htmlspecialchars($string,ENT\_QUOTES) to process user's posts and comments.
Now, i want some certain html tags ignored. such as `<b><br />` ... | 2009/06/23 | [
"https://Stackoverflow.com/questions/1031710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53804/"
] | **solution a)**
use strip\_tags insted of htmlspecialchars, and whitelist the needed tags.
**better solution b)**
Use bbcodes, and give aliases to the wanted tags, e.g: [b]bold[/b] | > Tired of using BBCode due to the current landscape of deficient or insecure HTML filters?
--> [HTML Purifier](http://htmlpurifier.org/)
> HTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, ... |
1,031,710 | Am currently working on an application that requires users to submit posts and comments which is displayed on the site. As we all know that user input can't be trusted so i used htmlspecialchars($string,ENT\_QUOTES) to process user's posts and comments.
Now, i want some certain html tags ignored. such as `<b><br />` ... | 2009/06/23 | [
"https://Stackoverflow.com/questions/1031710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53804/"
] | **solution a)**
use strip\_tags insted of htmlspecialchars, and whitelist the needed tags.
**better solution b)**
Use bbcodes, and give aliases to the wanted tags, e.g: [b]bold[/b] | It is **very, very difficult** to allow only some HTML tags without allowing any possibility of script injection or the like.
I would actually recommend avoiding this and using something that generates HTML such as [this UBB code parser](http://www.phpclasses.org/browse/package/818.html) (or similar). Or even [Markdo... |
1,031,710 | Am currently working on an application that requires users to submit posts and comments which is displayed on the site. As we all know that user input can't be trusted so i used htmlspecialchars($string,ENT\_QUOTES) to process user's posts and comments.
Now, i want some certain html tags ignored. such as `<b><br />` ... | 2009/06/23 | [
"https://Stackoverflow.com/questions/1031710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53804/"
] | It is **very, very difficult** to allow only some HTML tags without allowing any possibility of script injection or the like.
I would actually recommend avoiding this and using something that generates HTML such as [this UBB code parser](http://www.phpclasses.org/browse/package/818.html) (or similar). Or even [Markdo... | I would heavily recommend you use Zend\_Filter for filtering through user input. Specifically, see:
<http://framework.zend.com/manual/en/zend.filter.html#zend.filter.introduction.using> |
8,259,625 | I have UIImage outlet in TableViewCell which I will use it later in UITableView. When I check this in instruments I get some memory leak on UIImageView. I'm not releasing the UIImageView in the UITableViewCell, because I get exc\_bad\_access if I release it in the tavleViewCell.
My question is where do I release this ... | 2011/11/24 | [
"https://Stackoverflow.com/questions/8259625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/965383/"
] | UITableView caches cells for later reuse. That shows up as a memory leak but you can eventually reuse the cell so it is not really leaked.
What you can do is release the imageview that is retained by your custom UITableViewCell when the cell scrolls off screen, but that could lead to performance problems if the image ... | try setting it to `nil` i.e in dealloc:
```
self.imageViewName = nil;
``` |
8,259,625 | I have UIImage outlet in TableViewCell which I will use it later in UITableView. When I check this in instruments I get some memory leak on UIImageView. I'm not releasing the UIImageView in the UITableViewCell, because I get exc\_bad\_access if I release it in the tavleViewCell.
My question is where do I release this ... | 2011/11/24 | [
"https://Stackoverflow.com/questions/8259625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/965383/"
] | First, let's define what you mean. When we're talking about a true memory leak, that's when heap has been allocated but there are no longer any pointers to it anywhere in your code. It is truly leaked, lost, and cannot be reused. If the Leaks tool identifies it as a leak that means that it is this kind of leak, which i... | try setting it to `nil` i.e in dealloc:
```
self.imageViewName = nil;
``` |
8,259,625 | I have UIImage outlet in TableViewCell which I will use it later in UITableView. When I check this in instruments I get some memory leak on UIImageView. I'm not releasing the UIImageView in the UITableViewCell, because I get exc\_bad\_access if I release it in the tavleViewCell.
My question is where do I release this ... | 2011/11/24 | [
"https://Stackoverflow.com/questions/8259625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/965383/"
] | UITableView caches cells for later reuse. That shows up as a memory leak but you can eventually reuse the cell so it is not really leaked.
What you can do is release the imageview that is retained by your custom UITableViewCell when the cell scrolls off screen, but that could lead to performance problems if the image ... | First, let's define what you mean. When we're talking about a true memory leak, that's when heap has been allocated but there are no longer any pointers to it anywhere in your code. It is truly leaked, lost, and cannot be reused. If the Leaks tool identifies it as a leak that means that it is this kind of leak, which i... |
18,134,889 | I want make a specific element of each dictionary the first element in a list of dictionaries. How would I do this, or is it even possible given that dictionaries are unordered?
I don't want to use .sort() by itself or OrderedDict because both will not bring the desired element to the top of the keys as the keys are a... | 2013/08/08 | [
"https://Stackoverflow.com/questions/18134889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1849997/"
] | Dicts don't have any top or bottom. You can try something like this:
```
>>> from itertools import chain
>>> dic = {'a': 1, 'b': 2, 'c': 3}
>>> key = 'b'
for k in chain(key, (dic.viewkeys()-key)):
print k, dic[k]
...
b 2
a 1
c 3
```
Better use an `OrderedDict`.
```
>>> from collections import OrderedDict
>... | >
> is it even possible given that dictionaries are unordered?
>
>
>
No, it's not possible. Any solution you find that seems to do the trick will not be guaranteed to work between python versions, builds, code contexts, etc. If you want an ordered data type, you'll need something other than a dictionary. |
18,134,889 | I want make a specific element of each dictionary the first element in a list of dictionaries. How would I do this, or is it even possible given that dictionaries are unordered?
I don't want to use .sort() by itself or OrderedDict because both will not bring the desired element to the top of the keys as the keys are a... | 2013/08/08 | [
"https://Stackoverflow.com/questions/18134889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1849997/"
] | Wrap your dict in a list and move your code out. Instead of
```
data = {'code':'this is the code', 'some':'other', 'stuff':'here'}
```
do
```
data = ['this is the code', {'some':'other', 'stuff':'here'}]
``` | >
> is it even possible given that dictionaries are unordered?
>
>
>
No, it's not possible. Any solution you find that seems to do the trick will not be guaranteed to work between python versions, builds, code contexts, etc. If you want an ordered data type, you'll need something other than a dictionary. |
18,134,889 | I want make a specific element of each dictionary the first element in a list of dictionaries. How would I do this, or is it even possible given that dictionaries are unordered?
I don't want to use .sort() by itself or OrderedDict because both will not bring the desired element to the top of the keys as the keys are a... | 2013/08/08 | [
"https://Stackoverflow.com/questions/18134889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1849997/"
] | Python dicts have a well-defined order since python 3.6 so this is entirely possible now, although it was not possible when the question was asked.
One way to do this is first create one dict containing only 'b' and one dict containing the rest, then merging them in the right order.
```
x = {'a': 1, 'b': 2, 'c': 3}
fi... | >
> is it even possible given that dictionaries are unordered?
>
>
>
No, it's not possible. Any solution you find that seems to do the trick will not be guaranteed to work between python versions, builds, code contexts, etc. If you want an ordered data type, you'll need something other than a dictionary. |
18,134,889 | I want make a specific element of each dictionary the first element in a list of dictionaries. How would I do this, or is it even possible given that dictionaries are unordered?
I don't want to use .sort() by itself or OrderedDict because both will not bring the desired element to the top of the keys as the keys are a... | 2013/08/08 | [
"https://Stackoverflow.com/questions/18134889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1849997/"
] | As others have pointed out, Python's dictionaries are now ordered (by insertion order) since Python 3.6. The cleanest way I know to move a single item to the front of a dictionary is to use `pop()`:
```py
d = {'a': 1, 'b': 2, 'c': 3} # original dict
d = {'b': d.pop('b'), **d} # new order
print(d)
# {'b': 2, 'a': 1, ... | >
> is it even possible given that dictionaries are unordered?
>
>
>
No, it's not possible. Any solution you find that seems to do the trick will not be guaranteed to work between python versions, builds, code contexts, etc. If you want an ordered data type, you'll need something other than a dictionary. |
18,134,889 | I want make a specific element of each dictionary the first element in a list of dictionaries. How would I do this, or is it even possible given that dictionaries are unordered?
I don't want to use .sort() by itself or OrderedDict because both will not bring the desired element to the top of the keys as the keys are a... | 2013/08/08 | [
"https://Stackoverflow.com/questions/18134889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1849997/"
] | Wrap your dict in a list and move your code out. Instead of
```
data = {'code':'this is the code', 'some':'other', 'stuff':'here'}
```
do
```
data = ['this is the code', {'some':'other', 'stuff':'here'}]
``` | Dicts don't have any top or bottom. You can try something like this:
```
>>> from itertools import chain
>>> dic = {'a': 1, 'b': 2, 'c': 3}
>>> key = 'b'
for k in chain(key, (dic.viewkeys()-key)):
print k, dic[k]
...
b 2
a 1
c 3
```
Better use an `OrderedDict`.
```
>>> from collections import OrderedDict
>... |
18,134,889 | I want make a specific element of each dictionary the first element in a list of dictionaries. How would I do this, or is it even possible given that dictionaries are unordered?
I don't want to use .sort() by itself or OrderedDict because both will not bring the desired element to the top of the keys as the keys are a... | 2013/08/08 | [
"https://Stackoverflow.com/questions/18134889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1849997/"
] | Dicts don't have any top or bottom. You can try something like this:
```
>>> from itertools import chain
>>> dic = {'a': 1, 'b': 2, 'c': 3}
>>> key = 'b'
for k in chain(key, (dic.viewkeys()-key)):
print k, dic[k]
...
b 2
a 1
c 3
```
Better use an `OrderedDict`.
```
>>> from collections import OrderedDict
>... | Python dicts have a well-defined order since python 3.6 so this is entirely possible now, although it was not possible when the question was asked.
One way to do this is first create one dict containing only 'b' and one dict containing the rest, then merging them in the right order.
```
x = {'a': 1, 'b': 2, 'c': 3}
fi... |
18,134,889 | I want make a specific element of each dictionary the first element in a list of dictionaries. How would I do this, or is it even possible given that dictionaries are unordered?
I don't want to use .sort() by itself or OrderedDict because both will not bring the desired element to the top of the keys as the keys are a... | 2013/08/08 | [
"https://Stackoverflow.com/questions/18134889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1849997/"
] | Dicts don't have any top or bottom. You can try something like this:
```
>>> from itertools import chain
>>> dic = {'a': 1, 'b': 2, 'c': 3}
>>> key = 'b'
for k in chain(key, (dic.viewkeys()-key)):
print k, dic[k]
...
b 2
a 1
c 3
```
Better use an `OrderedDict`.
```
>>> from collections import OrderedDict
>... | As others have pointed out, Python's dictionaries are now ordered (by insertion order) since Python 3.6. The cleanest way I know to move a single item to the front of a dictionary is to use `pop()`:
```py
d = {'a': 1, 'b': 2, 'c': 3} # original dict
d = {'b': d.pop('b'), **d} # new order
print(d)
# {'b': 2, 'a': 1, ... |
18,134,889 | I want make a specific element of each dictionary the first element in a list of dictionaries. How would I do this, or is it even possible given that dictionaries are unordered?
I don't want to use .sort() by itself or OrderedDict because both will not bring the desired element to the top of the keys as the keys are a... | 2013/08/08 | [
"https://Stackoverflow.com/questions/18134889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1849997/"
] | Wrap your dict in a list and move your code out. Instead of
```
data = {'code':'this is the code', 'some':'other', 'stuff':'here'}
```
do
```
data = ['this is the code', {'some':'other', 'stuff':'here'}]
``` | Python dicts have a well-defined order since python 3.6 so this is entirely possible now, although it was not possible when the question was asked.
One way to do this is first create one dict containing only 'b' and one dict containing the rest, then merging them in the right order.
```
x = {'a': 1, 'b': 2, 'c': 3}
fi... |
18,134,889 | I want make a specific element of each dictionary the first element in a list of dictionaries. How would I do this, or is it even possible given that dictionaries are unordered?
I don't want to use .sort() by itself or OrderedDict because both will not bring the desired element to the top of the keys as the keys are a... | 2013/08/08 | [
"https://Stackoverflow.com/questions/18134889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1849997/"
] | Wrap your dict in a list and move your code out. Instead of
```
data = {'code':'this is the code', 'some':'other', 'stuff':'here'}
```
do
```
data = ['this is the code', {'some':'other', 'stuff':'here'}]
``` | As others have pointed out, Python's dictionaries are now ordered (by insertion order) since Python 3.6. The cleanest way I know to move a single item to the front of a dictionary is to use `pop()`:
```py
d = {'a': 1, 'b': 2, 'c': 3} # original dict
d = {'b': d.pop('b'), **d} # new order
print(d)
# {'b': 2, 'a': 1, ... |
1,599,368 | This was a question in a maths contest, where no calculator was allowed. Also, note that only a (>,< or =) relationship is being searched for and not the value of the numbers itself.
>
> Which is larger, $\sqrt[2015]{2015!}$ or $\sqrt[2016]{2016!}$ ?
>
>
>
---
**What I've done:**
My approach is to divide one n... | 2016/01/04 | [
"https://math.stackexchange.com/questions/1599368",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/59553/"
] | Starting with:
$$\sqrt[2015]{2015!}\mid\sqrt[2016]{2016!}$$
---
Raise each side to the power of $2015\cdot2016$:
$$2015!^{2016}\mid2016!^{2015}$$
---
Divide each side by $2015!^{2015}$:
$$2015!^{1}\mid2016^{2015}$$
---
Write it explicitly as:
$$\underbrace{1\cdot2\cdot\ldots\cdot2015}\_{2015\text{ terms}}\mid... | Look at the function:
$$y(x)=\sqrt[x]{x!}=\left(\Gamma(x+1)\right)^{1/x}$$
It's a monotonically strictly increasing function, as:
$$y'(x) = \frac{1}{x}\left(\Gamma(x+1)\right)^{1/x-1}\Gamma'(x+1)>0,\forall x>1$$
$\blacksquare$
As a side note:
$$\lim\_{x\to\infty}y(x)=\frac{1}{e}x$$
So you can expect the RHS to be lage... |
1,599,368 | This was a question in a maths contest, where no calculator was allowed. Also, note that only a (>,< or =) relationship is being searched for and not the value of the numbers itself.
>
> Which is larger, $\sqrt[2015]{2015!}$ or $\sqrt[2016]{2016!}$ ?
>
>
>
---
**What I've done:**
My approach is to divide one n... | 2016/01/04 | [
"https://math.stackexchange.com/questions/1599368",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/59553/"
] | Starting with:
$$\sqrt[2015]{2015!}\mid\sqrt[2016]{2016!}$$
---
Raise each side to the power of $2015\cdot2016$:
$$2015!^{2016}\mid2016!^{2015}$$
---
Divide each side by $2015!^{2015}$:
$$2015!^{1}\mid2016^{2015}$$
---
Write it explicitly as:
$$\underbrace{1\cdot2\cdot\ldots\cdot2015}\_{2015\text{ terms}}\mid... | $$\log \left(2016!^{1/2016}\right) -\log \left(2015!^{1/2015}\right)=$$ $$=\frac {1}{2016}\log (2016)-\left(\frac {1}{2015}-\frac {1}{2016}\right)\sum\_{n=1}^{2015}\log n=$$ $$=\frac {1}{2016}\log (2016)- \frac {1}{(2016)(2015)}\sum\_{n=1}^{2015}\log n>$$ $$>\frac {1}{2016}\log (2016)-\frac {1}{(2016)(2015)}\sum\_{n=1}... |
1,599,368 | This was a question in a maths contest, where no calculator was allowed. Also, note that only a (>,< or =) relationship is being searched for and not the value of the numbers itself.
>
> Which is larger, $\sqrt[2015]{2015!}$ or $\sqrt[2016]{2016!}$ ?
>
>
>
---
**What I've done:**
My approach is to divide one n... | 2016/01/04 | [
"https://math.stackexchange.com/questions/1599368",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/59553/"
] | Look at the function:
$$y(x)=\sqrt[x]{x!}=\left(\Gamma(x+1)\right)^{1/x}$$
It's a monotonically strictly increasing function, as:
$$y'(x) = \frac{1}{x}\left(\Gamma(x+1)\right)^{1/x-1}\Gamma'(x+1)>0,\forall x>1$$
$\blacksquare$
As a side note:
$$\lim\_{x\to\infty}y(x)=\frac{1}{e}x$$
So you can expect the RHS to be lage... | $$\log \left(2016!^{1/2016}\right) -\log \left(2015!^{1/2015}\right)=$$ $$=\frac {1}{2016}\log (2016)-\left(\frac {1}{2015}-\frac {1}{2016}\right)\sum\_{n=1}^{2015}\log n=$$ $$=\frac {1}{2016}\log (2016)- \frac {1}{(2016)(2015)}\sum\_{n=1}^{2015}\log n>$$ $$>\frac {1}{2016}\log (2016)-\frac {1}{(2016)(2015)}\sum\_{n=1}... |
16,475,415 | I'm using Struts 2. Using an interceptor, I create a database connection at the start of each page execution.
So for example, if a user goes to "myAction.do", it will create the database connection and then call `myAction.do` method.
What I'm looking for now is an interceptor or any other way to automatically call a ... | 2013/05/10 | [
"https://Stackoverflow.com/questions/16475415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49153/"
] | In interceptor you can write pre processing and post processing logics.
Pre processing logic will execute before the action executes and
post processing logic executes after the action executes.
>
> Struts2 provides very powerful mechanism of controlling a request
> using Interceptors. Interceptors are responsible ... | Fully described in <http://blog.agilelogicsolutions.com/2011/05/struts-2-interceptors-before-between.html>
You can have interceptor:
1. Before Action
2. Between Action and Result
3. After View Rendered
As mentioned in the site here are code samples
Before Interceptor
```
public class BeforeInterceptor extends Ab... |
627,898 | I am designing a two layer PCB with high speed signals with rise and fall times as low as 3ns.
I was doing some studying and learned that for better signal intergrity and EMI a good grounding strategy is critial. To lower the effects of displacment current lowering crosstalk, routing a ground element along with each h... | 2022/07/18 | [
"https://electronics.stackexchange.com/questions/627898",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/317868/"
] | If a 2 layer PCB is your only option: make the second layer ground and route your signals and power on the first. A proper ground/return plane is key for every signal and avoid sharing of the return path as much as possible. (A GND plane is preferable compared to a return trace)
High speed signals tend to follow under... | A 2-layer PCB will be insufficient for fast signals when the design is dense using recent tiny surface-mount chips.
On a 2-layer PCB, you won't have the luxury of having a power plane and a ground plane unless the design is rather simple.
The separation between the ground plane and signal traces on a 2-layer PCB is s... |
669,466 | I have two equations in the `\gathered` environment.
```
\documentclass{book}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{gathered}
\Delta U_{ab}+\Delta U_{ba}=0\\
\int_{\vec r_a}^{\vec r_b}\vec F\cdot d\vec r +\int_{\vec r_b}^{\vec r_a}\vec F\cdot d\vec r=0
\label{ce23}
... | 2022/12/23 | [
"https://tex.stackexchange.com/questions/669466",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/284954/"
] | Just use `gather` instead of `gathered`.
[](https://i.stack.imgur.com/qYQO0.png)
```
\documentclass{book}
\usepackage{amsmath}
\begin{document}
\begin{gather}
\Delta U_{ab}+\Delta U_{ba}=0 \nonumber\\
\int_{\vec r_a}^{\vec r_b}\vec F\cdot d\vec r +\int_{\vec r_b}^{... | It's better to use `gathered`, if possible, so TeX is able to use short vertical skips in case the line preceding the display is short. Compare the two otherwise identical displays: the space surrounding the second one is too wide.
The key is `\begin{gathered}[b]`.
```
\documentclass{book}
\usepackage{amsmath}
\usep... |
21,261,266 | I have made a public "Utils" class, where I put some general **static** methods that are frequently used.
Inside that Utils class, I have created a private static inner class, of some "tool" that Utils supplies. (That tools is some kind of a parser for my needs).
One of the methods in Utils, returns a new instance of t... | 2014/01/21 | [
"https://Stackoverflow.com/questions/21261266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2494840/"
] | It's not correct. You won't be able to use your class - You cannot use the return value in your static factory method (right now it won't compile, but I guess the return value is supposed to be `Parser`). The visibility of the return value makes it inaccessible for anyone using your factory method.
A workaround would ... | While the methods are public, the class itself is private, so those methods are *effectively* private as they're only accessible from within the containing class. Your IDE appears to be treating them the same as `private` methods, warning you if you define one that is never called.
P.S. as an aside, there's no such th... |
550,467 | I guess there are two major approaches to date representations in XML:
```
<date>1984-10-27</date>
```
and
```
<date>
<year>1984</year>
<month>10</month>
<day>27</day>
</date>
```
Personally I would go for the former. It's more compact and at the same time more readable. The split-up of the second form see... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66056/"
] | Practical experience has taught me that the easiest date values to work with is seconds-since-epoch. This value is portable across all languages and is timezone insensitive (your local date libraries will handle it).
For better or worse, XML tends to prefer more verbose and human readable values. If you want to use a ... | I vote for broken up. Whats wrong with the first you ask?
* is that day/month or month/day ...errors are likely both human and machine
* needs to be tokenized to get out the date information
* you are storing formatting(separator) characters |
550,467 | I guess there are two major approaches to date representations in XML:
```
<date>1984-10-27</date>
```
and
```
<date>
<year>1984</year>
<month>10</month>
<day>27</day>
</date>
```
Personally I would go for the former. It's more compact and at the same time more readable. The split-up of the second form see... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66056/"
] | Practical experience has taught me that the easiest date values to work with is seconds-since-epoch. This value is portable across all languages and is timezone insensitive (your local date libraries will handle it).
For better or worse, XML tends to prefer more verbose and human readable values. If you want to use a ... | While I agree with lucas-insasho that seconds-since-epoch is generally the easiest date/time representation to work with, it's not generally the easiest one to work with in XML. It can't be usefully processed by XSLT 1.0, nor can it be validated using XML Schema.
You can of course represent data in XML however you wa... |
550,467 | I guess there are two major approaches to date representations in XML:
```
<date>1984-10-27</date>
```
and
```
<date>
<year>1984</year>
<month>10</month>
<day>27</day>
</date>
```
Personally I would go for the former. It's more compact and at the same time more readable. The split-up of the second form see... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66056/"
] | The standard for dates/times in xml is much more formal than that; most xml parsers will respect (for example):
* 2009-02-15
* 2009-02-15T10:20:34.0000000
* 2009-02-15T10:20:34.0000000+00:00
This is always yyyy-MM-dd; the time portion is optional, as is the UTC offset.
(edit: [lucas-insasho](https://stackoverflow.co... | I vote for broken up. Whats wrong with the first you ask?
* is that day/month or month/day ...errors are likely both human and machine
* needs to be tokenized to get out the date information
* you are storing formatting(separator) characters |
550,467 | I guess there are two major approaches to date representations in XML:
```
<date>1984-10-27</date>
```
and
```
<date>
<year>1984</year>
<month>10</month>
<day>27</day>
</date>
```
Personally I would go for the former. It's more compact and at the same time more readable. The split-up of the second form see... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66056/"
] | While I agree with lucas-insasho that seconds-since-epoch is generally the easiest date/time representation to work with, it's not generally the easiest one to work with in XML. It can't be usefully processed by XSLT 1.0, nor can it be validated using XML Schema.
You can of course represent data in XML however you wa... | I vote for broken up. Whats wrong with the first you ask?
* is that day/month or month/day ...errors are likely both human and machine
* needs to be tokenized to get out the date information
* you are storing formatting(separator) characters |
550,467 | I guess there are two major approaches to date representations in XML:
```
<date>1984-10-27</date>
```
and
```
<date>
<year>1984</year>
<month>10</month>
<day>27</day>
</date>
```
Personally I would go for the former. It's more compact and at the same time more readable. The split-up of the second form see... | 2009/02/15 | [
"https://Stackoverflow.com/questions/550467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66056/"
] | The standard for dates/times in xml is much more formal than that; most xml parsers will respect (for example):
* 2009-02-15
* 2009-02-15T10:20:34.0000000
* 2009-02-15T10:20:34.0000000+00:00
This is always yyyy-MM-dd; the time portion is optional, as is the UTC offset.
(edit: [lucas-insasho](https://stackoverflow.co... | While I agree with lucas-insasho that seconds-since-epoch is generally the easiest date/time representation to work with, it's not generally the easiest one to work with in XML. It can't be usefully processed by XSLT 1.0, nor can it be validated using XML Schema.
You can of course represent data in XML however you wa... |
4,857,323 | I'm trying to ajaxify my will\_pagniate pagination in rails. I want to have the old page fade out and the new one fade in.
Here's the relevant part of my controller:
```
respond_to do |format|
format.html # new.html.erb
format.js {
render :update do |page|
page.replace 'page', :partial => 'cur_page'
... | 2011/01/31 | [
"https://Stackoverflow.com/questions/4857323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/173635/"
] | I tried putting more of the work into the javascript helpers:
```
respond_to do |format|
format.html # new.html.erb
format.js {
render :update do |page|
page.visual_effect :fade, 'posts', :afterFinsh => "function(){" +
page.replace 'page', :partial => 'cur_page' +
page.visual_effect(:appear, ... | Not very familiar with RoR, does it generate its own client-side JS that may possibly be battling your code?
If not, I would say the problem is somewhere in your own client-side code. For testing, get rid of the HREF attribute from the anchor tag and place the URL as a string literal in the Ajax request. If nothing ha... |
4,857,323 | I'm trying to ajaxify my will\_pagniate pagination in rails. I want to have the old page fade out and the new one fade in.
Here's the relevant part of my controller:
```
respond_to do |format|
format.html # new.html.erb
format.js {
render :update do |page|
page.replace 'page', :partial => 'cur_page'
... | 2011/01/31 | [
"https://Stackoverflow.com/questions/4857323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/173635/"
] | Here is what I did using `jQuery` and working well too :)
Put your `will_paginate` helper view call in a div
```
#tickets_pagination
= will_paginate @tickets
```
In application.js
```
$("#tickets_pagination .pagination a").live("click", function() {
$.get("/users/?"+this.href.split("?")[1], null, null, "script... | Not very familiar with RoR, does it generate its own client-side JS that may possibly be battling your code?
If not, I would say the problem is somewhere in your own client-side code. For testing, get rid of the HREF attribute from the anchor tag and place the URL as a string literal in the Ajax request. If nothing ha... |
4,857,323 | I'm trying to ajaxify my will\_pagniate pagination in rails. I want to have the old page fade out and the new one fade in.
Here's the relevant part of my controller:
```
respond_to do |format|
format.html # new.html.erb
format.js {
render :update do |page|
page.replace 'page', :partial => 'cur_page'
... | 2011/01/31 | [
"https://Stackoverflow.com/questions/4857323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/173635/"
] | I tried putting more of the work into the javascript helpers:
```
respond_to do |format|
format.html # new.html.erb
format.js {
render :update do |page|
page.visual_effect :fade, 'posts', :afterFinsh => "function(){" +
page.replace 'page', :partial => 'cur_page' +
page.visual_effect(:appear, ... | You seem to mix up things a bit.
Either you write `$('posts').fade` or `new Effect.fade('posts')`.
Secondly, i can't seem to find the `afterFinish` option in the [documentation](http://madrobby.github.com/scriptaculous/effect-fade/).
So i would suggest something along the following lines:
```
container.observe('clic... |
4,857,323 | I'm trying to ajaxify my will\_pagniate pagination in rails. I want to have the old page fade out and the new one fade in.
Here's the relevant part of my controller:
```
respond_to do |format|
format.html # new.html.erb
format.js {
render :update do |page|
page.replace 'page', :partial => 'cur_page'
... | 2011/01/31 | [
"https://Stackoverflow.com/questions/4857323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/173635/"
] | Here is what I did using `jQuery` and working well too :)
Put your `will_paginate` helper view call in a div
```
#tickets_pagination
= will_paginate @tickets
```
In application.js
```
$("#tickets_pagination .pagination a").live("click", function() {
$.get("/users/?"+this.href.split("?")[1], null, null, "script... | I tried putting more of the work into the javascript helpers:
```
respond_to do |format|
format.html # new.html.erb
format.js {
render :update do |page|
page.visual_effect :fade, 'posts', :afterFinsh => "function(){" +
page.replace 'page', :partial => 'cur_page' +
page.visual_effect(:appear, ... |
4,857,323 | I'm trying to ajaxify my will\_pagniate pagination in rails. I want to have the old page fade out and the new one fade in.
Here's the relevant part of my controller:
```
respond_to do |format|
format.html # new.html.erb
format.js {
render :update do |page|
page.replace 'page', :partial => 'cur_page'
... | 2011/01/31 | [
"https://Stackoverflow.com/questions/4857323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/173635/"
] | Here is what I did using `jQuery` and working well too :)
Put your `will_paginate` helper view call in a div
```
#tickets_pagination
= will_paginate @tickets
```
In application.js
```
$("#tickets_pagination .pagination a").live("click", function() {
$.get("/users/?"+this.href.split("?")[1], null, null, "script... | You seem to mix up things a bit.
Either you write `$('posts').fade` or `new Effect.fade('posts')`.
Secondly, i can't seem to find the `afterFinish` option in the [documentation](http://madrobby.github.com/scriptaculous/effect-fade/).
So i would suggest something along the following lines:
```
container.observe('clic... |
11,752,576 | I have 3 tables in my sql database like these :
```
Documents : (DocID, FileName) //list of all docs that were attached to items
Items : (ItemID, ...) //list of all items
DocumentRelation : (DocID, ItemID) //the relation between docs and items
```
In my winform application I have showed all records of **Items** tabl... | 2012/08/01 | [
"https://Stackoverflow.com/questions/11752576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/713099/"
] | Try something like:
```
string query;
foreach (Item in SelectedItems)
{
query += "select DocID from DocumentRelation where ItemID =" + Item.Id;
query += "INTERSECT";
}
query -= "INTERSECT";
```
And exec the Query; | Linq
```
var td =
from s in Items
join r in DocumentRelation on s.ItemID equals r.ItemID
join k in Documents on k.DocID equals r.DocID
where Coll.Contains (s.ItemID) //Here Coll is the collection of ItemID which you can store when the users click on the grid view row
select new
{
FileName=k.FileName,
Docu... |
11,752,576 | I have 3 tables in my sql database like these :
```
Documents : (DocID, FileName) //list of all docs that were attached to items
Items : (ItemID, ...) //list of all items
DocumentRelation : (DocID, ItemID) //the relation between docs and items
```
In my winform application I have showed all records of **Items** tabl... | 2012/08/01 | [
"https://Stackoverflow.com/questions/11752576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/713099/"
] | Take one string and keep on adding itemid comma separated in that,like 1,2,3 and then write query like
```
declare ItemID varchar(50);
set ItemID='1,2,3';
select FileName
from documents
Left Join DocumentRelation on Documents.DocId = DocumentRelation.DocId
where
DocumentRelation.ItemID in (select * from > dbo... | Linq
```
var td =
from s in Items
join r in DocumentRelation on s.ItemID equals r.ItemID
join k in Documents on k.DocID equals r.DocID
where Coll.Contains (s.ItemID) //Here Coll is the collection of ItemID which you can store when the users click on the grid view row
select new
{
FileName=k.FileName,
Docu... |
11,752,576 | I have 3 tables in my sql database like these :
```
Documents : (DocID, FileName) //list of all docs that were attached to items
Items : (ItemID, ...) //list of all items
DocumentRelation : (DocID, ItemID) //the relation between docs and items
```
In my winform application I have showed all records of **Items** tabl... | 2012/08/01 | [
"https://Stackoverflow.com/questions/11752576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/713099/"
] | Try something like:
```
string query;
foreach (Item in SelectedItems)
{
query += "select DocID from DocumentRelation where ItemID =" + Item.Id;
query += "INTERSECT";
}
query -= "INTERSECT";
```
And exec the Query; | Here's one approach. I'll let you figure out how you want to supply the list of items as arguments. And I also assume that (DocID, ItemID) is a primary key in the relations table. The `having` condition is what enforces your requirement that all select items are related to the list of documents you're seeking.
```
;wi... |
11,752,576 | I have 3 tables in my sql database like these :
```
Documents : (DocID, FileName) //list of all docs that were attached to items
Items : (ItemID, ...) //list of all items
DocumentRelation : (DocID, ItemID) //the relation between docs and items
```
In my winform application I have showed all records of **Items** tabl... | 2012/08/01 | [
"https://Stackoverflow.com/questions/11752576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/713099/"
] | Try something like:
```
string query;
foreach (Item in SelectedItems)
{
query += "select DocID from DocumentRelation where ItemID =" + Item.Id;
query += "INTERSECT";
}
query -= "INTERSECT";
```
And exec the Query; | Take one string and keep on adding itemid comma separated in that,like 1,2,3 and then write query like
```
declare ItemID varchar(50);
set ItemID='1,2,3';
select FileName
from documents
Left Join DocumentRelation on Documents.DocId = DocumentRelation.DocId
where
DocumentRelation.ItemID in (select * from > dbo... |
11,752,576 | I have 3 tables in my sql database like these :
```
Documents : (DocID, FileName) //list of all docs that were attached to items
Items : (ItemID, ...) //list of all items
DocumentRelation : (DocID, ItemID) //the relation between docs and items
```
In my winform application I have showed all records of **Items** tabl... | 2012/08/01 | [
"https://Stackoverflow.com/questions/11752576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/713099/"
] | Take one string and keep on adding itemid comma separated in that,like 1,2,3 and then write query like
```
declare ItemID varchar(50);
set ItemID='1,2,3';
select FileName
from documents
Left Join DocumentRelation on Documents.DocId = DocumentRelation.DocId
where
DocumentRelation.ItemID in (select * from > dbo... | Here's one approach. I'll let you figure out how you want to supply the list of items as arguments. And I also assume that (DocID, ItemID) is a primary key in the relations table. The `having` condition is what enforces your requirement that all select items are related to the list of documents you're seeking.
```
;wi... |
39,130,227 | How can I set the active class name of a Link for a path that contains an optional parameter?
Below are some details of what I am trying to achieve:
* A route in my application has a path that contains an optional URL parameter - eventId:
`<Route path="/sendInvite(/:eventId)" component={SendInviteContainer} />`
* In... | 2016/08/24 | [
"https://Stackoverflow.com/questions/39130227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1139206/"
] | You need to put you `/sendInvite(/:eventId)` under `/sendInvite` route
It should be something like this:-
```
<Route path="/sendInvite" component={container} >
<Route path="/sendInvite(/:eventId)" component={SendInviteContainer} />
</Route>
```
This should keep you parent route active.
You can check out [here... | ```
import {NavLink, Route} from 'react-router-dom';
<NavLink
ctiveClassName="activeLink" className="month"
to="/tab1/"
onClick={() => /*to scroll to top*/
window.scrollTo({top:0,behavior:"smooth"})
}
>
Tab 1
</NavLink>
```
**in css**
```
.activeLink{
background-color:#f00; /*for red background*/
}
``` |
39,130,227 | How can I set the active class name of a Link for a path that contains an optional parameter?
Below are some details of what I am trying to achieve:
* A route in my application has a path that contains an optional URL parameter - eventId:
`<Route path="/sendInvite(/:eventId)" component={SendInviteContainer} />`
* In... | 2016/08/24 | [
"https://Stackoverflow.com/questions/39130227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1139206/"
] | You need to put you `/sendInvite(/:eventId)` under `/sendInvite` route
It should be something like this:-
```
<Route path="/sendInvite" component={container} >
<Route path="/sendInvite(/:eventId)" component={SendInviteContainer} />
</Route>
```
This should keep you parent route active.
You can check out [here... | Another *and better option in my opinion* would be `isActive`, example:
```
<NavLink
to='path'
className='whatever'
isActive={() => window.location.hash.indexOf('sendInvite') > -1}>
Title
</NavLink>
``` |
39,130,227 | How can I set the active class name of a Link for a path that contains an optional parameter?
Below are some details of what I am trying to achieve:
* A route in my application has a path that contains an optional URL parameter - eventId:
`<Route path="/sendInvite(/:eventId)" component={SendInviteContainer} />`
* In... | 2016/08/24 | [
"https://Stackoverflow.com/questions/39130227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1139206/"
] | Another *and better option in my opinion* would be `isActive`, example:
```
<NavLink
to='path'
className='whatever'
isActive={() => window.location.hash.indexOf('sendInvite') > -1}>
Title
</NavLink>
``` | ```
import {NavLink, Route} from 'react-router-dom';
<NavLink
ctiveClassName="activeLink" className="month"
to="/tab1/"
onClick={() => /*to scroll to top*/
window.scrollTo({top:0,behavior:"smooth"})
}
>
Tab 1
</NavLink>
```
**in css**
```
.activeLink{
background-color:#f00; /*for red background*/
}
``` |
5,607,906 | I have a full working php script for user activation that I wrote. Fully working in a sense that it displays no errors while on my actual web hosting, although when I am working in WAMP2 I get errors such as these.
```
Notice: Undefined index: type in C:\wamp\www\activate.php on line 4
Notice: Undefined index: usernam... | 2011/04/09 | [
"https://Stackoverflow.com/questions/5607906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/690929/"
] | >
> is it bad practice to have undefined
> variables?
>
>
>
Yes
>
> how do I overcome the problem?
>
>
>
By not using variables that don't exist.
Or by using variables that have been initialized with a default value, if the expected value has not been provided.
For example :
```
if (isset($_POST['login']... | <http://php.net/manual/en/errorfunc.configuration.php> - display\_errors and display\_startup\_errors
Also what I want to say - its good practice to check if array key exists:
```
$login = isset($_POST['login']) ? $_POST['login'] : NULL;
``` |
5,607,906 | I have a full working php script for user activation that I wrote. Fully working in a sense that it displays no errors while on my actual web hosting, although when I am working in WAMP2 I get errors such as these.
```
Notice: Undefined index: type in C:\wamp\www\activate.php on line 4
Notice: Undefined index: usernam... | 2011/04/09 | [
"https://Stackoverflow.com/questions/5607906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/690929/"
] | Your PHP is configured to show Notices, Warnings etc. on your WAMP2 configuration.
In the hosting environment this is disabled, and will probably only show critical errors.
You can find out more about error reporting : <http://forums.devshed.com/php-development-5/changing-error-reporting-in-php-ini-549798.html>
If y... | <http://php.net/manual/en/errorfunc.configuration.php> - display\_errors and display\_startup\_errors
Also what I want to say - its good practice to check if array key exists:
```
$login = isset($_POST['login']) ? $_POST['login'] : NULL;
``` |
5,607,906 | I have a full working php script for user activation that I wrote. Fully working in a sense that it displays no errors while on my actual web hosting, although when I am working in WAMP2 I get errors such as these.
```
Notice: Undefined index: type in C:\wamp\www\activate.php on line 4
Notice: Undefined index: usernam... | 2011/04/09 | [
"https://Stackoverflow.com/questions/5607906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/690929/"
] | >
> is it bad practice to have undefined
> variables?
>
>
>
Yes
>
> how do I overcome the problem?
>
>
>
By not using variables that don't exist.
Or by using variables that have been initialized with a default value, if the expected value has not been provided.
For example :
```
if (isset($_POST['login']... | Your host has most likely error\_reporting set to a value in which E\_NOTICE's are not shown (E\_ALL ^ E\_NOTICE). I always check the existence of my variables, so no notices on undefined variables / indices are thrown. That aids me in debugging, in which I always enable E\_NOTICE (error\_reporting = E\_ALL).
You may ... |
5,607,906 | I have a full working php script for user activation that I wrote. Fully working in a sense that it displays no errors while on my actual web hosting, although when I am working in WAMP2 I get errors such as these.
```
Notice: Undefined index: type in C:\wamp\www\activate.php on line 4
Notice: Undefined index: usernam... | 2011/04/09 | [
"https://Stackoverflow.com/questions/5607906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/690929/"
] | >
> is it bad practice to have undefined
> variables?
>
>
>
Yes
>
> how do I overcome the problem?
>
>
>
By not using variables that don't exist.
Or by using variables that have been initialized with a default value, if the expected value has not been provided.
For example :
```
if (isset($_POST['login']... | Your PHP is configured to show Notices, Warnings etc. on your WAMP2 configuration.
In the hosting environment this is disabled, and will probably only show critical errors.
You can find out more about error reporting : <http://forums.devshed.com/php-development-5/changing-error-reporting-in-php-ini-549798.html>
If y... |
5,607,906 | I have a full working php script for user activation that I wrote. Fully working in a sense that it displays no errors while on my actual web hosting, although when I am working in WAMP2 I get errors such as these.
```
Notice: Undefined index: type in C:\wamp\www\activate.php on line 4
Notice: Undefined index: usernam... | 2011/04/09 | [
"https://Stackoverflow.com/questions/5607906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/690929/"
] | Your PHP is configured to show Notices, Warnings etc. on your WAMP2 configuration.
In the hosting environment this is disabled, and will probably only show critical errors.
You can find out more about error reporting : <http://forums.devshed.com/php-development-5/changing-error-reporting-in-php-ini-549798.html>
If y... | Your host has most likely error\_reporting set to a value in which E\_NOTICE's are not shown (E\_ALL ^ E\_NOTICE). I always check the existence of my variables, so no notices on undefined variables / indices are thrown. That aids me in debugging, in which I always enable E\_NOTICE (error\_reporting = E\_ALL).
You may ... |
86,979 | I've used Ubuntu using WUBI for a couple of months and decided that this was not what I wanted and that Ubuntu should have its own partition. I have it set up like that now. My dilemma deals with what bootloader to use as the primary one.
As it is now, after my laptop's splash screen, Grub 2 shows up and one of the o... | 2011/12/11 | [
"https://askubuntu.com/questions/86979",
"https://askubuntu.com",
"https://askubuntu.com/users/37536/"
] | Depends, both work well, use the one you feel most comfortable with.
If you want support from the Linux / Ubuntu community , use grub.
If you use the windows boot loader, your support will be either Microsoft or the Windows community. | I've been dual booting using grub on 7 systems (actually 5 different people / families) for a couple of years, have been through several upgrades. Some of them keep a version for 3 releases then have to do multiple upgrades at the same time. I have personally never had a problem and since all these systems just have th... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.