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 |
|---|---|---|---|---|---|
31,520,022 | In one project I'm using I can't set breakpoints in Swift code, Xcode always crashes when reaching one of them, doesn't matter if it's a "manual" or an exception breakpoint.
In other projects everything works as expected, only for one project Xcode 6.4 (6E35b) always crashes.
I tried cleaning, deleting derived data, ... | 2015/07/20 | [
"https://Stackoverflow.com/questions/31520022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27404/"
] | I would try uninstalling and reinstalling Xcode to see if it helps... I've heard of successes with this technique for similar issues.
Just delete the entire Xcode.app from /Applications, and reinstall from the .dmg. If you're not certain of the binaries and have time / bandwidth, consider re-downloading the .dmg.
If ... | It's a longshot, but let me know if it's working:
uncheck the "Always show Dissasembly" check
```
Debug > Debug Workflow > Always Show Disassembly
```
In older versions of Xcode (<6.1):
```
Product > Debug Workflow > Show Disassembly When Debugging
``` |
31,520,022 | In one project I'm using I can't set breakpoints in Swift code, Xcode always crashes when reaching one of them, doesn't matter if it's a "manual" or an exception breakpoint.
In other projects everything works as expected, only for one project Xcode 6.4 (6E35b) always crashes.
I tried cleaning, deleting derived data, ... | 2015/07/20 | [
"https://Stackoverflow.com/questions/31520022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27404/"
] | I would try uninstalling and reinstalling Xcode to see if it helps... I've heard of successes with this technique for similar issues.
Just delete the entire Xcode.app from /Applications, and reinstall from the .dmg. If you're not certain of the binaries and have time / bandwidth, consider re-downloading the .dmg.
If ... | I've just spent the past few hours trying to solve exactly the same issue.
I thought at first, it had started due to installing Xcode 7 on the same machine as Xcode 6.4. The problem certainly coincided.
However, due to having version control, I could look and see what files had changed since opening the project with ... |
31,520,022 | In one project I'm using I can't set breakpoints in Swift code, Xcode always crashes when reaching one of them, doesn't matter if it's a "manual" or an exception breakpoint.
In other projects everything works as expected, only for one project Xcode 6.4 (6E35b) always crashes.
I tried cleaning, deleting derived data, ... | 2015/07/20 | [
"https://Stackoverflow.com/questions/31520022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27404/"
] | It's a longshot, but let me know if it's working:
uncheck the "Always show Dissasembly" check
```
Debug > Debug Workflow > Always Show Disassembly
```
In older versions of Xcode (<6.1):
```
Product > Debug Workflow > Show Disassembly When Debugging
``` | I've just spent the past few hours trying to solve exactly the same issue.
I thought at first, it had started due to installing Xcode 7 on the same machine as Xcode 6.4. The problem certainly coincided.
However, due to having version control, I could look and see what files had changed since opening the project with ... |
19,786,717 | All browsers apart from IE are working nicely with Uploadify in my project.
So just going to the demo page in IE10 :
<http://www.uploadify.com/demos/>
I see that for IE the upload button is not properly changed to its Uploadify upload button.
On F12 debug, under console I can see the following error:
SEC7111: HTTP... | 2013/11/05 | [
"https://Stackoverflow.com/questions/19786717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1444886/"
] | I personally always use != for clarity, unless I'm looking for a number that is either greater than or less than another number. Since <> implies greater than or less than as opposed to not equals, it doesn't read well with strings - unless alpha-sorting/ranking is what's desired.
For example:
```
String myVar = 'ap... | You can find it in formula operators reference [here](http://help.salesforce.com/HTViewHelpDoc?id=customize_functions_a_h.htm&language=en_US#NotEqual) |
54,959,174 | I have page Job and element with logo and button `apply`. I added to this element `position: fixed` and when I scroll page I have this element STICKY and when I scroll to footer the logo and button overlaps with the footer. Can I change it somehow to make this element (logo and button) turn off `position: fixed` at the... | 2019/03/02 | [
"https://Stackoverflow.com/questions/54959174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11140304/"
] | You can use position:sticky..
And browser support is great.
Check this link [`link`](https://caniuse.com/#search=position%3A%20sticky)
Example: [This Link](https://jsfiddle.net/8Lg9om1p/2/) | like [thislink](https://stackoverflow.com/questions/5902822/stopping-fixed-position-scrolling-at-a-certain-point) you can do it with this jquery code
```
var windw = this;
$.fn.followTo = function ( pos ) {
var $this = this,
$window = $(windw);
$window.scroll(function(e){
if ($window.scrollTop() > pos) {
... |
46,532,415 | So I have an array.
```
$numbers1 = [31, 60, 54, 7, 13, 2, 9, 68, 5, 2, 9, 68, 5, 2];
```
What I have to do is use a foreach-loop to sum each item with 20 and then place them in a new Array, `$newArray`. This is what I've come up with so far.
```
$numbers1 = [31, 60, 54, 7, 13, 2, 9, 68, 5, 2, 9, 68, 5, 2];
foreac... | 2017/10/02 | [
"https://Stackoverflow.com/questions/46532415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8701895/"
] | Your question basically works. Replace `$newArray` with `$value` as so:
```
$numbers1 = [31, 60, 54, 7, 13, 2, 9, 68, 5, 2, 9, 68, 5, 2];
foreach ($numbers1 as &$value) {
$value += 20;
}
```
Then if you need it in a new array use add the following line afterwards:
```
$newArray = $numbers1;
```
Since you are... | ### General solution, not suitable for this exact question
Use `array_map` instead(for better codestyle):
```
$newArray = array_map(function ($x) {
return $x + 20;
}, [31, 60, 54, 7, 13, 2, 9, 68, 5, 2, 9, 68, 5, 2]);
```
This will assign the function to each entry and thus will increase each value by 20. |
30,502 | Are both *Als* and *Während* possible terms in this sentence? Do they both express that the actions happen at the same time? Although the waiting is longer..
>
> Als/Während er auf den Bus wartete, bemerkte er, dass er kein Geld dabei
> hatte
>
>
> | 2016/06/23 | [
"https://german.stackexchange.com/questions/30502",
"https://german.stackexchange.com",
"https://german.stackexchange.com/users/8784/"
] | In your sentence both are fine. However, in your very example I would tend to use *als*.
You normally use *während* to indicate that two events or activities are happening at the same time (and for a while).
>
> Während er auf den Bus wartete, hörte er Musik.
>
>
>
An example that is in stark contrast to the one... | "Als" can be translated as "when." Während can be translated as "for" or "during."
"Als" refers to a "point in time." Während refers to a "span" of time, or time **period.**
It is when referring to "short" periods of time that the two overlap. |
6,193,607 | For some reason when I try to compile my code, I get this error:
fatal error: direct.h: No such file or directory
compilation terminated.
I'm on linux using g++ (GCC) 4.6.0 20110509 (Red Hat 4.6.0-7) | 2011/05/31 | [
"https://Stackoverflow.com/questions/6193607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | `direct.h` is part of the Digital Mars compiler, not gcc.
Most of its functions have similar names on linux that's posix standarized. Read the manpage for e.g. [getcwd](http://pubs.opengroup.org/onlinepubs/009695399/functions/getcwd.html) , [rmdir](http://pubs.opengroup.org/onlinepubs/009695399/functions/rmdir.html), ... | Commonly, is a C/C++ header file provided by Microsoft Windows, so it cannot works in linux.
[reference at wikipedia](https://en.wikipedia.org/wiki/Direct.h)
You can use unistd.h to replace the actions in direct.h like mkdir, rmdir, etc. |
6,193,607 | For some reason when I try to compile my code, I get this error:
fatal error: direct.h: No such file or directory
compilation terminated.
I'm on linux using g++ (GCC) 4.6.0 20110509 (Red Hat 4.6.0-7) | 2011/05/31 | [
"https://Stackoverflow.com/questions/6193607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | `direct.h` is part of the Digital Mars compiler, not gcc.
Most of its functions have similar names on linux that's posix standarized. Read the manpage for e.g. [getcwd](http://pubs.opengroup.org/onlinepubs/009695399/functions/getcwd.html) , [rmdir](http://pubs.opengroup.org/onlinepubs/009695399/functions/rmdir.html), ... | I took SWMM5 source code and modify the files following the readme and some small fixes. It seems in linux you do not need direct.h at all for the CLE version. I have tested several of the examples provided by EPA
<https://www.epa.gov/sites/production/files/2014-05/epaswmm5_apps_manual.zip>
You can get the files [from... |
6,193,607 | For some reason when I try to compile my code, I get this error:
fatal error: direct.h: No such file or directory
compilation terminated.
I'm on linux using g++ (GCC) 4.6.0 20110509 (Red Hat 4.6.0-7) | 2011/05/31 | [
"https://Stackoverflow.com/questions/6193607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Commonly, is a C/C++ header file provided by Microsoft Windows, so it cannot works in linux.
[reference at wikipedia](https://en.wikipedia.org/wiki/Direct.h)
You can use unistd.h to replace the actions in direct.h like mkdir, rmdir, etc. | I took SWMM5 source code and modify the files following the readme and some small fixes. It seems in linux you do not need direct.h at all for the CLE version. I have tested several of the examples provided by EPA
<https://www.epa.gov/sites/production/files/2014-05/epaswmm5_apps_manual.zip>
You can get the files [from... |
15,064,498 | setOnItemClickListener doesn't work with android Spinner. Here is my code:
```
supplier.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Au... | 2013/02/25 | [
"https://Stackoverflow.com/questions/15064498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2106800/"
] | setOnItemClickListener will not work with android spinner.Alternatively, try using this method:
>
> setOnItemSelectedListener
>
>
>
Change your code like this:
```
supplier.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, ... | **1.** I think you should check your xml file which contains the spinner. Make sure haven't set `android:clickable = "false"`.
**2.** please check your spinner adapter and make sure in your `getView(int position, View convertView, ViewGroup parent)` method, you haven't set any widget click callback event such as `Butt... |
15,064,498 | setOnItemClickListener doesn't work with android Spinner. Here is my code:
```
supplier.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Au... | 2013/02/25 | [
"https://Stackoverflow.com/questions/15064498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2106800/"
] | **1.** I think you should check your xml file which contains the spinner. Make sure haven't set `android:clickable = "false"`.
**2.** please check your spinner adapter and make sure in your `getView(int position, View convertView, ViewGroup parent)` method, you haven't set any widget click callback event such as `Butt... | I may be going off course, but thought to suggest you to use `OnItemSelectedListener` which is broader than `OnItemClickListener` for Spinners:
```
supplier.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
long arg3)... |
15,064,498 | setOnItemClickListener doesn't work with android Spinner. Here is my code:
```
supplier.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Au... | 2013/02/25 | [
"https://Stackoverflow.com/questions/15064498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2106800/"
] | setOnItemClickListener will not work with android spinner.Alternatively, try using this method:
>
> setOnItemSelectedListener
>
>
>
Change your code like this:
```
supplier.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, ... | Use this
```
supplier.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
}
@Override
public void onNothingSelected... |
15,064,498 | setOnItemClickListener doesn't work with android Spinner. Here is my code:
```
supplier.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Au... | 2013/02/25 | [
"https://Stackoverflow.com/questions/15064498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2106800/"
] | Use this
```
supplier.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
}
@Override
public void onNothingSelected... | I think `supplier` in your code means `spinner`, do Replace this line
```
String msupplier=supplier.getSelectedItem().toString();
```
with the below line:
```
String msupplier= supplier.getItemAtPosition(position).toString();
``` |
15,064,498 | setOnItemClickListener doesn't work with android Spinner. Here is my code:
```
supplier.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Au... | 2013/02/25 | [
"https://Stackoverflow.com/questions/15064498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2106800/"
] | setOnItemClickListener will not work with android spinner.Alternatively, try using this method:
>
> setOnItemSelectedListener
>
>
>
Change your code like this:
```
supplier.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, ... | `OnItemSelectedListener()` serves a different purpose than a click listener. Most importantly, it doesn't fire if you click on the currently selected item again. In some cases this might not be a problem but in other cases, it might well be. So the real answer is not to tell people to use a different and probably unsui... |
15,064,498 | setOnItemClickListener doesn't work with android Spinner. Here is my code:
```
supplier.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Au... | 2013/02/25 | [
"https://Stackoverflow.com/questions/15064498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2106800/"
] | **1.** I think you should check your xml file which contains the spinner. Make sure haven't set `android:clickable = "false"`.
**2.** please check your spinner adapter and make sure in your `getView(int position, View convertView, ViewGroup parent)` method, you haven't set any widget click callback event such as `Butt... | Use this
```
supplier.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
}
@Override
public void onNothingSelected... |
15,064,498 | setOnItemClickListener doesn't work with android Spinner. Here is my code:
```
supplier.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Au... | 2013/02/25 | [
"https://Stackoverflow.com/questions/15064498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2106800/"
] | **1.** I think you should check your xml file which contains the spinner. Make sure haven't set `android:clickable = "false"`.
**2.** please check your spinner adapter and make sure in your `getView(int position, View convertView, ViewGroup parent)` method, you haven't set any widget click callback event such as `Butt... | I think `supplier` in your code means `spinner`, do Replace this line
```
String msupplier=supplier.getSelectedItem().toString();
```
with the below line:
```
String msupplier= supplier.getItemAtPosition(position).toString();
``` |
15,064,498 | setOnItemClickListener doesn't work with android Spinner. Here is my code:
```
supplier.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Au... | 2013/02/25 | [
"https://Stackoverflow.com/questions/15064498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2106800/"
] | `OnItemSelectedListener()` serves a different purpose than a click listener. Most importantly, it doesn't fire if you click on the currently selected item again. In some cases this might not be a problem but in other cases, it might well be. So the real answer is not to tell people to use a different and probably unsui... | I think `supplier` in your code means `spinner`, do Replace this line
```
String msupplier=supplier.getSelectedItem().toString();
```
with the below line:
```
String msupplier= supplier.getItemAtPosition(position).toString();
``` |
15,064,498 | setOnItemClickListener doesn't work with android Spinner. Here is my code:
```
supplier.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Au... | 2013/02/25 | [
"https://Stackoverflow.com/questions/15064498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2106800/"
] | `OnItemSelectedListener()` serves a different purpose than a click listener. Most importantly, it doesn't fire if you click on the currently selected item again. In some cases this might not be a problem but in other cases, it might well be. So the real answer is not to tell people to use a different and probably unsui... | i have faced this issues. setOnItemClickListener will not works with spinner. My solution is as following:
```
mSpinnerYears.setAdapter(adapter);
mSpinnerYears.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view... |
15,064,498 | setOnItemClickListener doesn't work with android Spinner. Here is my code:
```
supplier.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Au... | 2013/02/25 | [
"https://Stackoverflow.com/questions/15064498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2106800/"
] | `OnItemSelectedListener()` serves a different purpose than a click listener. Most importantly, it doesn't fire if you click on the currently selected item again. In some cases this might not be a problem but in other cases, it might well be. So the real answer is not to tell people to use a different and probably unsui... | I may be going off course, but thought to suggest you to use `OnItemSelectedListener` which is broader than `OnItemClickListener` for Spinners:
```
supplier.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
long arg3)... |
48,055,971 | I want to avoid using for loop in the following code to achieve performance. Is vectorization suitable for this kind of problem?
```
a = np.array([[0,1,2,3,4],
[5,6,7,8,9],
[0,1,2,3,4],
[5,6,7,8,9],
[0,1,2,3,4]],dtype= np.float32)
temp_a = np.copy(a)
for i in r... | 2018/01/02 | [
"https://Stackoverflow.com/questions/48055971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7912237/"
] | You are basically doing convolution, with some special treatment for borders.
Try the following:
```
from scipy.signal import convolve2d
# define your filter
f = np.array([[0.0, 0.2, 0.0],
[0.2,-0.8, 0.2],
[0.0, 0.2, 0.0]])
# select parts of 'a' to be used for convolution
b = (a * (a > 3... | My trail uses 3 filters, `rot90`, `np.where`, `np.sum`, and `np.multiply`. I am not sure which way to benchmark is more reasonable. If you **do not** take into account the time to create filters, it is roughly 4 times faster.
```
# Each filter basically does what `op` tries to achieve in a loop
filter1 = np.array([[... |
48,055,971 | I want to avoid using for loop in the following code to achieve performance. Is vectorization suitable for this kind of problem?
```
a = np.array([[0,1,2,3,4],
[5,6,7,8,9],
[0,1,2,3,4],
[5,6,7,8,9],
[0,1,2,3,4]],dtype= np.float32)
temp_a = np.copy(a)
for i in r... | 2018/01/02 | [
"https://Stackoverflow.com/questions/48055971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7912237/"
] | You are basically doing convolution, with some special treatment for borders.
Try the following:
```
from scipy.signal import convolve2d
# define your filter
f = np.array([[0.0, 0.2, 0.0],
[0.2,-0.8, 0.2],
[0.0, 0.2, 0.0]])
# select parts of 'a' to be used for convolution
b = (a * (a > 3... | I came up with this solution:
```
a = np.array([[0,0,0,0,0],
[0,6,2,8,0],
[0,1,5,3,0],
[0,6,7,8,0],
[0,0,0,0,0]],dtype= np.float32)
up= np.zeros_like(a)
down= np.zeros_like(a)
right= np.zeros_like(a)
left = np.zeros_like(a)
def new_a(a,u,r,d,l):
c = np.cop... |
408,062 | Notation: let us have a particle of spin(more generally angular momentum, but for simplicity just consider spin) $j\_1$ with projection to the third axis $m\_1$ and a particle with spin $j\_2$ with projection of $m\_2$. We want to combine them into a doublet with total spin $J$ and its projection $M$. We write clebsch-... | 2018/05/24 | [
"https://physics.stackexchange.com/questions/408062",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/31844/"
] | Quoting Wikipedia on Clebsch-Gordan coefficients we have the orthogonality relation:
$$\sum^{j\_1+j\_2}\_{J=|j\_1-j\_2|}\sum^{J}\_{M=-J}<j\_1,m\_1,j\_2,m\_2|J,M><J,M|j\_1,m'\_1,j\_2,m'\_2>=\\=<j\_1,m\_1,j\_2,m\_2|j\_1,m'\_1,j\_2,m'\_2>=\delta\_{m\_1,m'\_1}\delta\_{m\_2,m'\_2}$$
This is the closest I could find resemb... | The simplest way to look at such sums is to start with
$$
\langle j\_1m\_1; j\_2m\_2\vert j\_1’m\_1’; j\_2’m\_2’\rangle =
\delta\_{j\_1j\_1’}\delta\_{j\_2j\_2’}\delta\_{m\_1m\_1’}\delta\_{m\_2m\_2’}\, ,
$$
insert the unit operator in the form of
$$
1= \sum\_{JM}\vert JM\rangle\langle JM\vert
$$
where $J$ runs over all ... |
10,726,785 | I'm pretty new to PHP, I'm working in WordPress but I don't think that this question is WordPress specific. Basically, I've run a MySQL query that returns some numbers. In WordPress, you can use a function called wp\_list\_pages() to say exactly which pages you want to include in something, like this:
```
wp_list_pag... | 2012/05/23 | [
"https://Stackoverflow.com/questions/10726785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/774359/"
] | **Option 1**
If you want variables to be evaluated, you need to use double quotes.
```
wp_list_pages("include=$pagelist")
```
or
```
wp_list_pages("include={$pagelist}")
```
**Option 2**
Use string concatenation
```
wp_list_pages('include=' . $pagelist);
```
**Option 3**
Use [`sprintf`](http://php.net/manua... | In PHP variables are only looked for in double quotes, other than that you are spot on. So use " instead of '
```
wp_list_pages("include=$pagelist");
```
Another thing you could do is concatenate the variable with the string with a . like this:
```
wp_list_pages('include='.$pagelist);
``` |
10,726,785 | I'm pretty new to PHP, I'm working in WordPress but I don't think that this question is WordPress specific. Basically, I've run a MySQL query that returns some numbers. In WordPress, you can use a function called wp\_list\_pages() to say exactly which pages you want to include in something, like this:
```
wp_list_pag... | 2012/05/23 | [
"https://Stackoverflow.com/questions/10726785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/774359/"
] | **Option 1**
If you want variables to be evaluated, you need to use double quotes.
```
wp_list_pages("include=$pagelist")
```
or
```
wp_list_pages("include={$pagelist}")
```
**Option 2**
Use string concatenation
```
wp_list_pages('include=' . $pagelist);
```
**Option 3**
Use [`sprintf`](http://php.net/manua... | Did you try:
```
wp_list_pages('include=' . $pagelist);
```
OR
```
wp_list_pages("include={$pagelist}");
``` |
10,726,785 | I'm pretty new to PHP, I'm working in WordPress but I don't think that this question is WordPress specific. Basically, I've run a MySQL query that returns some numbers. In WordPress, you can use a function called wp\_list\_pages() to say exactly which pages you want to include in something, like this:
```
wp_list_pag... | 2012/05/23 | [
"https://Stackoverflow.com/questions/10726785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/774359/"
] | **Option 1**
If you want variables to be evaluated, you need to use double quotes.
```
wp_list_pages("include=$pagelist")
```
or
```
wp_list_pages("include={$pagelist}")
```
**Option 2**
Use string concatenation
```
wp_list_pages('include=' . $pagelist);
```
**Option 3**
Use [`sprintf`](http://php.net/manua... | To reference variables inside of strings, you'll need to use double quotes. |
26,003,445 | I am struggling with something and have tracked it down to the difference between two lists inside my code: from the Python Debugger:
```
(Pdb) Values
['Thing1', 'Thing2', 'Thing3']
(Pdb) values2
[['Thing1', 'Thing2', 'Thing3']]
```
I *do NOT* want the double brackets, what does this mean and how do I get rid of the... | 2014/09/23 | [
"https://Stackoverflow.com/questions/26003445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4071620/"
] | Don't think of it as "double brackets". Think of it as two sets of single brackets, one inside the other. A set of brackets means you have a list. Two sets of single brackets means you have two lists. One set of single brackets inside another means you have a list inside another list.
This is because the value you app... | `values2` is a list with a single element that is a list.
You are appending a list to a list. What you want to do is ***extend*** the `values2` list:
```
for report in Report.objects.filter(id=id):
values2.extend([str(report.name), str(report.subject), str(report.description)])
``` |
26,003,445 | I am struggling with something and have tracked it down to the difference between two lists inside my code: from the Python Debugger:
```
(Pdb) Values
['Thing1', 'Thing2', 'Thing3']
(Pdb) values2
[['Thing1', 'Thing2', 'Thing3']]
```
I *do NOT* want the double brackets, what does this mean and how do I get rid of the... | 2014/09/23 | [
"https://Stackoverflow.com/questions/26003445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4071620/"
] | Don't think of it as "double brackets". Think of it as two sets of single brackets, one inside the other. A set of brackets means you have a list. Two sets of single brackets means you have two lists. One set of single brackets inside another means you have a list inside another list.
This is because the value you app... | If you look at your loop
```
for report in Report.objects.filter(id=id):
values2.append( [ str(report.name), str(report.subject), str(report.description) ] )
```
you can see that what you are *appending* to `values2` is the the list
```
[ str(report.name), str(report.subject), str(report.description) ]
```
so... |
26,003,445 | I am struggling with something and have tracked it down to the difference between two lists inside my code: from the Python Debugger:
```
(Pdb) Values
['Thing1', 'Thing2', 'Thing3']
(Pdb) values2
[['Thing1', 'Thing2', 'Thing3']]
```
I *do NOT* want the double brackets, what does this mean and how do I get rid of the... | 2014/09/23 | [
"https://Stackoverflow.com/questions/26003445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4071620/"
] | `values2` is a list with a single element that is a list.
You are appending a list to a list. What you want to do is ***extend*** the `values2` list:
```
for report in Report.objects.filter(id=id):
values2.extend([str(report.name), str(report.subject), str(report.description)])
``` | If you look at your loop
```
for report in Report.objects.filter(id=id):
values2.append( [ str(report.name), str(report.subject), str(report.description) ] )
```
you can see that what you are *appending* to `values2` is the the list
```
[ str(report.name), str(report.subject), str(report.description) ]
```
so... |
8,165,509 | I was often wondering about the right way to do this:
For example, in my program I have around 100 constants (or enums) that are used in some calculation. They should preferrably be stored in one place. They can be grouped hierarchically, for example:
```
System3 / Rules / Rule7 / ParameterXY / MaxAverageValue
```
... | 2011/11/17 | [
"https://Stackoverflow.com/questions/8165509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/300929/"
] | How often is each constant re-used in multiple methods? You could consider reorganizing your constants. If you still find yourself with huge numbers of constants, try putting them in a static class with read-only properties.
If you just need a good place to look at them all in one place, you could also look at storing... | Well the way I do this is to have a sealed file called Constants.
so
```
public sealed class Constants
{
//for e.g.
//Sessions
public const string APPSESSIONKEY = "AppType";
}
```
Than I use this in the rest of my project and the importance here is what you will name it as it will help you remember it and ... |
8,165,509 | I was often wondering about the right way to do this:
For example, in my program I have around 100 constants (or enums) that are used in some calculation. They should preferrably be stored in one place. They can be grouped hierarchically, for example:
```
System3 / Rules / Rule7 / ParameterXY / MaxAverageValue
```
... | 2011/11/17 | [
"https://Stackoverflow.com/questions/8165509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/300929/"
] | >
> very long constant names
>
>
>
This is sort of gross, but at least it is discoverable. All your code would reside in the same place so you wouldn't have a problem finding it.
>
> I find nesting classes a nice way to do it, but some stylecop/fxcop rules forbid that, so this must be "bad" in some way
>
>
>
... | Well the way I do this is to have a sealed file called Constants.
so
```
public sealed class Constants
{
//for e.g.
//Sessions
public const string APPSESSIONKEY = "AppType";
}
```
Than I use this in the rest of my project and the importance here is what you will name it as it will help you remember it and ... |
8,165,509 | I was often wondering about the right way to do this:
For example, in my program I have around 100 constants (or enums) that are used in some calculation. They should preferrably be stored in one place. They can be grouped hierarchically, for example:
```
System3 / Rules / Rule7 / ParameterXY / MaxAverageValue
```
... | 2011/11/17 | [
"https://Stackoverflow.com/questions/8165509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/300929/"
] | How often is each constant re-used in multiple methods? You could consider reorganizing your constants. If you still find yourself with huge numbers of constants, try putting them in a static class with read-only properties.
If you just need a good place to look at them all in one place, you could also look at storing... | We use Resources files with a custom T4 template that generates a static class hierarchy with readonly string fields for the values.
The keys in our Resource file are separated with '.' to build the hierarchy.
We can have separate resource files that are compiled into one class hierarchy.
I know that nested classes ... |
8,165,509 | I was often wondering about the right way to do this:
For example, in my program I have around 100 constants (or enums) that are used in some calculation. They should preferrably be stored in one place. They can be grouped hierarchically, for example:
```
System3 / Rules / Rule7 / ParameterXY / MaxAverageValue
```
... | 2011/11/17 | [
"https://Stackoverflow.com/questions/8165509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/300929/"
] | >
> very long constant names
>
>
>
This is sort of gross, but at least it is discoverable. All your code would reside in the same place so you wouldn't have a problem finding it.
>
> I find nesting classes a nice way to do it, but some stylecop/fxcop rules forbid that, so this must be "bad" in some way
>
>
>
... | How often is each constant re-used in multiple methods? You could consider reorganizing your constants. If you still find yourself with huge numbers of constants, try putting them in a static class with read-only properties.
If you just need a good place to look at them all in one place, you could also look at storing... |
8,165,509 | I was often wondering about the right way to do this:
For example, in my program I have around 100 constants (or enums) that are used in some calculation. They should preferrably be stored in one place. They can be grouped hierarchically, for example:
```
System3 / Rules / Rule7 / ParameterXY / MaxAverageValue
```
... | 2011/11/17 | [
"https://Stackoverflow.com/questions/8165509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/300929/"
] | >
> very long constant names
>
>
>
This is sort of gross, but at least it is discoverable. All your code would reside in the same place so you wouldn't have a problem finding it.
>
> I find nesting classes a nice way to do it, but some stylecop/fxcop rules forbid that, so this must be "bad" in some way
>
>
>
... | We use Resources files with a custom T4 template that generates a static class hierarchy with readonly string fields for the values.
The keys in our Resource file are separated with '.' to build the hierarchy.
We can have separate resource files that are compiled into one class hierarchy.
I know that nested classes ... |
72,097,139 | I am learning React and I have a problem with my childCallback, for return data from child to parent.
I make a navbar and when I click on the navButton, the parent receive the name of the precedent button, I have to click two times for display the good data.
Here is my code :
```
//PARENT COMPONENT
export const Prof... | 2022/05/03 | [
"https://Stackoverflow.com/questions/72097139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16937328/"
] | If you're using an alias name for writes, that alias can only point to a single index which you're going to receive back in the bulk response
For instance, if `test_alias` is an alias to the `test` index, then when sending this bulk command:
```
POST test_alias/_doc/_bulk
{"index":{}}
{"foo": "bar"}
```
You will re... | You can provide the multiple index names while searching the data, if you are using `alias` and it has multiple indices by default it would search on all the indices, but if you want to filter it based on a few indices in your `alias`, that is also possible based on the fields in the underlying indices.
You can read t... |
9,776,347 | why would a static constructor throw exception when it references to
a const string in another class.
```
class MyClass
{
static MyClass()
{
ExamineLog();
}
static ExamineLog()
{
FilePath = HttpContext.Current.Server.MapPath(Helper.LogConfiguration); ... | 2012/03/19 | [
"https://Stackoverflow.com/questions/9776347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1279341/"
] | Thoughts:
* `HttpContext` might be null
* `HttpContext.Current` might be null
* `HttpContext.Current.Server` might be null
Further thoughts:
`Current` is a static property of the `HttpContext` class, so `HttpContext` is not an object reference, and it cannot be null. If you want to simplify your debugging, you can c... | my first bet is a bad string...
```
"\rootpath\counters.txt" // => "\r" is carriage return
```
So MapPath fails. |
9,776,347 | why would a static constructor throw exception when it references to
a const string in another class.
```
class MyClass
{
static MyClass()
{
ExamineLog();
}
static ExamineLog()
{
FilePath = HttpContext.Current.Server.MapPath(Helper.LogConfiguration); ... | 2012/03/19 | [
"https://Stackoverflow.com/questions/9776347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1279341/"
] | Thoughts:
* `HttpContext` might be null
* `HttpContext.Current` might be null
* `HttpContext.Current.Server` might be null
Further thoughts:
`Current` is a static property of the `HttpContext` class, so `HttpContext` is not an object reference, and it cannot be null. If you want to simplify your debugging, you can c... | My guess is that the HttpContext.Current is null in the context of a static constructor. It's been a while since I was knee-deep in ASP.NET, but IIRC, the HttpContext.Current won't be setup unless you're in the request-response life cycle of a page. I don't know when static constructors are necessarily executed in an A... |
63,689,798 | So I have a dataframe like so:
```
Occupation
ELECTRICIAN
ROAD ELECTRICIAN
ELECTRICIAN
FARMER
GRASS ELECTRICIAN
POLE ELECTRICIANS
ELECTRICIAN
INSPECTOR
```
So I would like any time ELECTRICIAN appears to be just ELECTRICIAN, no matter anything else in the cell.
So final product should be:
```
Occupation
ELECTRICIA... | 2020/09/01 | [
"https://Stackoverflow.com/questions/63689798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9393218/"
] | I would suggest this approach. It is better using `grepl()` as it produces logic values that can be easily detected in `ifelse()`:
```
#Data
df <- structure(list(Occupation = c("ELECTRICIAN", "ROAD ELECTRICIAN",
"ELECTRICIAN", "FARMER", "GRASS ELECTRICIAN", "POLE ELECTRICIANS",
"ELECTRICIAN", "INSPECTOR")), row.name... | Using `grep` you can get the index in `Occupation` where `"ELECTRICIAN"` is present and replace those values.
```
df$Occupation[grep('ELECTRICIAN', df$Occupation)] <- 'ELECTRICIAN'
df
# Occupation
#1 ELECTRICIAN
#2 ELECTRICIAN
#3 ELECTRICIAN
#4 FARMER
#5 ELECTRICIAN
#6 ELECTRICIAN
#7 ELECTRICIAN
#8 INSPECTOR... |
63,689,798 | So I have a dataframe like so:
```
Occupation
ELECTRICIAN
ROAD ELECTRICIAN
ELECTRICIAN
FARMER
GRASS ELECTRICIAN
POLE ELECTRICIANS
ELECTRICIAN
INSPECTOR
```
So I would like any time ELECTRICIAN appears to be just ELECTRICIAN, no matter anything else in the cell.
So final product should be:
```
Occupation
ELECTRICIA... | 2020/09/01 | [
"https://Stackoverflow.com/questions/63689798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9393218/"
] | Here's the tidyverse solution using the `stringr` package.
```
library(stringr)
df$Occupation<- str_replace_all(df$Occupation,".*ELECTRICIAN.*","ELECTRICIAN")
```
There's some debate over whether tidyverse solutions are "preferred," but I personally prefer them. I think the function names are much more... | Using `grep` you can get the index in `Occupation` where `"ELECTRICIAN"` is present and replace those values.
```
df$Occupation[grep('ELECTRICIAN', df$Occupation)] <- 'ELECTRICIAN'
df
# Occupation
#1 ELECTRICIAN
#2 ELECTRICIAN
#3 ELECTRICIAN
#4 FARMER
#5 ELECTRICIAN
#6 ELECTRICIAN
#7 ELECTRICIAN
#8 INSPECTOR... |
27,660,027 | I have a function that prints out:
```
echo $post->EE_Event->primary_datetime()->start_date_and_time();
```
result:
```
21-02-15 08:00
```
But i want to display it as:
```
08:00 21st February, 2015
```
I need help with a function to grab the existing printed out date and reformat it.
I have tried a few snippe... | 2014/12/26 | [
"https://Stackoverflow.com/questions/27660027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/712441/"
] | Try this code:
```
$yourDate = '21-02-15 08:00'; // $post->EE_Event->primary_datetime()->start_date_and_time()
$date = DateTime::createFromFormat('j-m-y G:i', $yourDate);
echo $date->format('G:i dS F, Y');
```
Try it online:
<http://ideone.com/a7EEK4>
In PHP >= 5.3 we have excellent date API.
See more here:
<http:/... | PHP's [`DateTime`](http://php.net/DateTime) class has exactly what you need. You want to use the [`createFromFormat`](http://php.net/manual/en/datetime.createfromformat.php) to parse it in, then use [`format`](http://php.net/manual/en/datetime.format.php) to print it back out.
```
$myDate = $post->EE_Event->primary_da... |
27,660,027 | I have a function that prints out:
```
echo $post->EE_Event->primary_datetime()->start_date_and_time();
```
result:
```
21-02-15 08:00
```
But i want to display it as:
```
08:00 21st February, 2015
```
I need help with a function to grab the existing printed out date and reformat it.
I have tried a few snippe... | 2014/12/26 | [
"https://Stackoverflow.com/questions/27660027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/712441/"
] | Try this code:
```
$yourDate = '21-02-15 08:00'; // $post->EE_Event->primary_datetime()->start_date_and_time()
$date = DateTime::createFromFormat('j-m-y G:i', $yourDate);
echo $date->format('G:i dS F, Y');
```
Try it online:
<http://ideone.com/a7EEK4>
In PHP >= 5.3 we have excellent date API.
See more here:
<http:/... | ```
echo date("G:i dS F, Y", strtotime($post->EE_Event->primary_datetime()->start_date_and_time()));
``` |
27,660,027 | I have a function that prints out:
```
echo $post->EE_Event->primary_datetime()->start_date_and_time();
```
result:
```
21-02-15 08:00
```
But i want to display it as:
```
08:00 21st February, 2015
```
I need help with a function to grab the existing printed out date and reformat it.
I have tried a few snippe... | 2014/12/26 | [
"https://Stackoverflow.com/questions/27660027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/712441/"
] | PHP's [`DateTime`](http://php.net/DateTime) class has exactly what you need. You want to use the [`createFromFormat`](http://php.net/manual/en/datetime.createfromformat.php) to parse it in, then use [`format`](http://php.net/manual/en/datetime.format.php) to print it back out.
```
$myDate = $post->EE_Event->primary_da... | ```
echo date("G:i dS F, Y", strtotime($post->EE_Event->primary_datetime()->start_date_and_time()));
``` |
64,235,111 | Hey I've been trying to find a way to delete the rows I need via formula without having to do change to much before it works.
When I download CSV, it stores time/date like this:
```
08:56 29-Sep
07:56 29-Sep
07:15 29-Sep
03:29 29-Sep
09:15 29-Sep
05:15 29-Sep
09:30 29-Sep
06:15 29-Sep
```
Each one being on ... | 2020/10/06 | [
"https://Stackoverflow.com/questions/64235111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14404006/"
] | Teylyn gave a TLDR while I was typing.
The longer answer, like Teylyn suggested is to flag the data.
You can use the HOUR() and ROUND() functions to extract the date/time from the string, then simply perform a simple next And/Or logic IF statement to flag yes/no for the removal.
```
=IF(OR(D2<0,AND(D2=0,C2<9),AND(D2... | There are several ways to achieve this.
* load all the CSV data into Excel, then sort the data and delete the rows you don't need
* load all the CSV data into Excel, then create a formula that flags rows you don't need, then filter the data based on that flag. This will not remove any data, only hide it from view.
* l... |
2,234,738 | I'm working with HiTech PICC32 on the PIC32MX series of microprocessors, but I think this question is general enough for anyone knowledgable in C. (This is almost equivalent to C90, with sizeof(int) = sizeof(long) = sizeof(float) = 4.)
Let's say I read a 4-byte word of data that represents a `float`. I can quickly con... | 2010/02/10 | [
"https://Stackoverflow.com/questions/2234738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188535/"
] | You can run the trick the other way for return values
```
float fl;
*(int*)&fl = eeprom_read_word(addr);
```
or
```
#define WORD_TO_FLOAT(f) (*(int*)&(f))
WORD_TO_FLOAT(fl) = eeprom_read_word(addr);
```
or as R Samuel Klatchko suggests
```
#define ASTYPE(type, val) (*(type*)&(val))
ASTYPE(WORD,fl) = eeprom_re... | Not really an answer, more a suggestion. Your FLOAT\_FROM\_WORD macro will be more natural to use and more flexible if it doesn't have a ; at the end
```
#define FLOAT_FROM_WORD(w) (*(float*)&(w))
fl = FLOAT_FROM_WORD(wd);
``` |
2,234,738 | I'm working with HiTech PICC32 on the PIC32MX series of microprocessors, but I think this question is general enough for anyone knowledgable in C. (This is almost equivalent to C90, with sizeof(int) = sizeof(long) = sizeof(float) = 4.)
Let's say I read a 4-byte word of data that represents a `float`. I can quickly con... | 2010/02/10 | [
"https://Stackoverflow.com/questions/2234738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188535/"
] | You can run the trick the other way for return values
```
float fl;
*(int*)&fl = eeprom_read_word(addr);
```
or
```
#define WORD_TO_FLOAT(f) (*(int*)&(f))
WORD_TO_FLOAT(fl) = eeprom_read_word(addr);
```
or as R Samuel Klatchko suggests
```
#define ASTYPE(type, val) (*(type*)&(val))
ASTYPE(WORD,fl) = eeprom_re... | It may not be possible in your exact situation, but upgrading to a C99 compiler would solve your problem too.
C99 has inline functions which, while acting like normal functions in parameters and return values, get improved efficiency in exactly this case with none of the drawbacks of macros. |
2,234,738 | I'm working with HiTech PICC32 on the PIC32MX series of microprocessors, but I think this question is general enough for anyone knowledgable in C. (This is almost equivalent to C90, with sizeof(int) = sizeof(long) = sizeof(float) = 4.)
Let's say I read a 4-byte word of data that represents a `float`. I can quickly con... | 2010/02/10 | [
"https://Stackoverflow.com/questions/2234738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188535/"
] | You can run the trick the other way for return values
```
float fl;
*(int*)&fl = eeprom_read_word(addr);
```
or
```
#define WORD_TO_FLOAT(f) (*(int*)&(f))
WORD_TO_FLOAT(fl) = eeprom_read_word(addr);
```
or as R Samuel Klatchko suggests
```
#define ASTYPE(type, val) (*(type*)&(val))
ASTYPE(WORD,fl) = eeprom_re... | you can take the address of a temporary value if you use a const reference:
```
FLOAT_FROM_WORD(w) (*(float*)&(const WORD &)(w))
```
but that won't work in c :(
(c doesn't have references right? works in visual c++)
as others have said, be it an inlined function or a temp in a define, the compiler will optimize it... |
2,234,738 | I'm working with HiTech PICC32 on the PIC32MX series of microprocessors, but I think this question is general enough for anyone knowledgable in C. (This is almost equivalent to C90, with sizeof(int) = sizeof(long) = sizeof(float) = 4.)
Let's say I read a 4-byte word of data that represents a `float`. I can quickly con... | 2010/02/10 | [
"https://Stackoverflow.com/questions/2234738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188535/"
] | You can run the trick the other way for return values
```
float fl;
*(int*)&fl = eeprom_read_word(addr);
```
or
```
#define WORD_TO_FLOAT(f) (*(int*)&(f))
WORD_TO_FLOAT(fl) = eeprom_read_word(addr);
```
or as R Samuel Klatchko suggests
```
#define ASTYPE(type, val) (*(type*)&(val))
ASTYPE(WORD,fl) = eeprom_re... | If this were GCC, you could do this:
```
#define atob(original, newtype) \
(((union { typeof(original) i; newtype j })(original)).k)
```
Wow. Hideous. But the usage is nice:
```
int i = 0xdeadbeef;
float f = atob(i, float);
```
I bet your compiler doesn't support either the `typeof` operator nor the `union` cas... |
2,234,738 | I'm working with HiTech PICC32 on the PIC32MX series of microprocessors, but I think this question is general enough for anyone knowledgable in C. (This is almost equivalent to C90, with sizeof(int) = sizeof(long) = sizeof(float) = 4.)
Let's say I read a 4-byte word of data that represents a `float`. I can quickly con... | 2010/02/10 | [
"https://Stackoverflow.com/questions/2234738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188535/"
] | you can take the address of a temporary value if you use a const reference:
```
FLOAT_FROM_WORD(w) (*(float*)&(const WORD &)(w))
```
but that won't work in c :(
(c doesn't have references right? works in visual c++)
as others have said, be it an inlined function or a temp in a define, the compiler will optimize it... | Not really an answer, more a suggestion. Your FLOAT\_FROM\_WORD macro will be more natural to use and more flexible if it doesn't have a ; at the end
```
#define FLOAT_FROM_WORD(w) (*(float*)&(w))
fl = FLOAT_FROM_WORD(wd);
``` |
2,234,738 | I'm working with HiTech PICC32 on the PIC32MX series of microprocessors, but I think this question is general enough for anyone knowledgable in C. (This is almost equivalent to C90, with sizeof(int) = sizeof(long) = sizeof(float) = 4.)
Let's say I read a 4-byte word of data that represents a `float`. I can quickly con... | 2010/02/10 | [
"https://Stackoverflow.com/questions/2234738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188535/"
] | If this were GCC, you could do this:
```
#define atob(original, newtype) \
(((union { typeof(original) i; newtype j })(original)).k)
```
Wow. Hideous. But the usage is nice:
```
int i = 0xdeadbeef;
float f = atob(i, float);
```
I bet your compiler doesn't support either the `typeof` operator nor the `union` cas... | Not really an answer, more a suggestion. Your FLOAT\_FROM\_WORD macro will be more natural to use and more flexible if it doesn't have a ; at the end
```
#define FLOAT_FROM_WORD(w) (*(float*)&(w))
fl = FLOAT_FROM_WORD(wd);
``` |
2,234,738 | I'm working with HiTech PICC32 on the PIC32MX series of microprocessors, but I think this question is general enough for anyone knowledgable in C. (This is almost equivalent to C90, with sizeof(int) = sizeof(long) = sizeof(float) = 4.)
Let's say I read a 4-byte word of data that represents a `float`. I can quickly con... | 2010/02/10 | [
"https://Stackoverflow.com/questions/2234738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188535/"
] | you can take the address of a temporary value if you use a const reference:
```
FLOAT_FROM_WORD(w) (*(float*)&(const WORD &)(w))
```
but that won't work in c :(
(c doesn't have references right? works in visual c++)
as others have said, be it an inlined function or a temp in a define, the compiler will optimize it... | It may not be possible in your exact situation, but upgrading to a C99 compiler would solve your problem too.
C99 has inline functions which, while acting like normal functions in parameters and return values, get improved efficiency in exactly this case with none of the drawbacks of macros. |
2,234,738 | I'm working with HiTech PICC32 on the PIC32MX series of microprocessors, but I think this question is general enough for anyone knowledgable in C. (This is almost equivalent to C90, with sizeof(int) = sizeof(long) = sizeof(float) = 4.)
Let's say I read a 4-byte word of data that represents a `float`. I can quickly con... | 2010/02/10 | [
"https://Stackoverflow.com/questions/2234738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188535/"
] | If this were GCC, you could do this:
```
#define atob(original, newtype) \
(((union { typeof(original) i; newtype j })(original)).k)
```
Wow. Hideous. But the usage is nice:
```
int i = 0xdeadbeef;
float f = atob(i, float);
```
I bet your compiler doesn't support either the `typeof` operator nor the `union` cas... | It may not be possible in your exact situation, but upgrading to a C99 compiler would solve your problem too.
C99 has inline functions which, while acting like normal functions in parameters and return values, get improved efficiency in exactly this case with none of the drawbacks of macros. |
2,234,738 | I'm working with HiTech PICC32 on the PIC32MX series of microprocessors, but I think this question is general enough for anyone knowledgable in C. (This is almost equivalent to C90, with sizeof(int) = sizeof(long) = sizeof(float) = 4.)
Let's say I read a 4-byte word of data that represents a `float`. I can quickly con... | 2010/02/10 | [
"https://Stackoverflow.com/questions/2234738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188535/"
] | If this were GCC, you could do this:
```
#define atob(original, newtype) \
(((union { typeof(original) i; newtype j })(original)).k)
```
Wow. Hideous. But the usage is nice:
```
int i = 0xdeadbeef;
float f = atob(i, float);
```
I bet your compiler doesn't support either the `typeof` operator nor the `union` cas... | you can take the address of a temporary value if you use a const reference:
```
FLOAT_FROM_WORD(w) (*(float*)&(const WORD &)(w))
```
but that won't work in c :(
(c doesn't have references right? works in visual c++)
as others have said, be it an inlined function or a temp in a define, the compiler will optimize it... |
39,655,817 | In order to solve a question I have to generate a list of prime numbers from 1 to 3000000, so I tried several ways to do this and unfortunately all failed...
First try: because all prime numbers bigger than 2 are odd numbers, so I first generate a list of odd numbers started with 3 called `allOddNums`. And then I gene... | 2016/09/23 | [
"https://Stackoverflow.com/questions/39655817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6707025/"
] | Fixed implementation of Sieve of Eratosthenes (your third try). I believe it should satisfy your needs.
```
public static void main (String[] args) throws java.lang.Exception {
int n = 3000000;
boolean[] isPrime = new boolean[n+1];
for (int i = 2; i <= n; i++) {
isPrime[i] = true;
}
for (... | An alternative approach would be to begin with a list of primes consisting of 2 and 3. Have a method `isPrime(int)` to determine whether a number is prime by dividing the candidate number by each prime in that list. Define another method, `findNextPrime()`, which `isPrime()` can call to expand the list as needed. This ... |
39,655,817 | In order to solve a question I have to generate a list of prime numbers from 1 to 3000000, so I tried several ways to do this and unfortunately all failed...
First try: because all prime numbers bigger than 2 are odd numbers, so I first generate a list of odd numbers started with 3 called `allOddNums`. And then I gene... | 2016/09/23 | [
"https://Stackoverflow.com/questions/39655817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6707025/"
] | Fixed implementation of Sieve of Eratosthenes (your third try). I believe it should satisfy your needs.
```
public static void main (String[] args) throws java.lang.Exception {
int n = 3000000;
boolean[] isPrime = new boolean[n+1];
for (int i = 2; i <= n; i++) {
isPrime[i] = true;
}
for (... | Memory is not an issue in your case. Array of size `n = 3000000` can be defined inside the stack frame of a function. Actually array of size 10^8 can be defined safely inside a function. If you need more than that define it as a gloabal variable(Instance variable). Coming to your code there is an `IndexOutOfBoundsExcep... |
39,655,817 | In order to solve a question I have to generate a list of prime numbers from 1 to 3000000, so I tried several ways to do this and unfortunately all failed...
First try: because all prime numbers bigger than 2 are odd numbers, so I first generate a list of odd numbers started with 3 called `allOddNums`. And then I gene... | 2016/09/23 | [
"https://Stackoverflow.com/questions/39655817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6707025/"
] | Fixed implementation of Sieve of Eratosthenes (your third try). I believe it should satisfy your needs.
```
public static void main (String[] args) throws java.lang.Exception {
int n = 3000000;
boolean[] isPrime = new boolean[n+1];
for (int i = 2; i <= n; i++) {
isPrime[i] = true;
}
for (... | This can generate prime numbers up to `Integer.MAX_VALUE` in few milliseconds. It also doesn't take as much memory as in Sieve of Eratosthenes approach.
```
public class Prime {
public static IntStream generate(int limit) {
return IntStream.range(2, Integer.MAX_VALUE).filter(Prime::isPrime).limit(limit);
}
... |
39,655,817 | In order to solve a question I have to generate a list of prime numbers from 1 to 3000000, so I tried several ways to do this and unfortunately all failed...
First try: because all prime numbers bigger than 2 are odd numbers, so I first generate a list of odd numbers started with 3 called `allOddNums`. And then I gene... | 2016/09/23 | [
"https://Stackoverflow.com/questions/39655817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6707025/"
] | An alternative approach would be to begin with a list of primes consisting of 2 and 3. Have a method `isPrime(int)` to determine whether a number is prime by dividing the candidate number by each prime in that list. Define another method, `findNextPrime()`, which `isPrime()` can call to expand the list as needed. This ... | Memory is not an issue in your case. Array of size `n = 3000000` can be defined inside the stack frame of a function. Actually array of size 10^8 can be defined safely inside a function. If you need more than that define it as a gloabal variable(Instance variable). Coming to your code there is an `IndexOutOfBoundsExcep... |
39,655,817 | In order to solve a question I have to generate a list of prime numbers from 1 to 3000000, so I tried several ways to do this and unfortunately all failed...
First try: because all prime numbers bigger than 2 are odd numbers, so I first generate a list of odd numbers started with 3 called `allOddNums`. And then I gene... | 2016/09/23 | [
"https://Stackoverflow.com/questions/39655817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6707025/"
] | An alternative approach would be to begin with a list of primes consisting of 2 and 3. Have a method `isPrime(int)` to determine whether a number is prime by dividing the candidate number by each prime in that list. Define another method, `findNextPrime()`, which `isPrime()` can call to expand the list as needed. This ... | This can generate prime numbers up to `Integer.MAX_VALUE` in few milliseconds. It also doesn't take as much memory as in Sieve of Eratosthenes approach.
```
public class Prime {
public static IntStream generate(int limit) {
return IntStream.range(2, Integer.MAX_VALUE).filter(Prime::isPrime).limit(limit);
}
... |
39,655,817 | In order to solve a question I have to generate a list of prime numbers from 1 to 3000000, so I tried several ways to do this and unfortunately all failed...
First try: because all prime numbers bigger than 2 are odd numbers, so I first generate a list of odd numbers started with 3 called `allOddNums`. And then I gene... | 2016/09/23 | [
"https://Stackoverflow.com/questions/39655817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6707025/"
] | Memory is not an issue in your case. Array of size `n = 3000000` can be defined inside the stack frame of a function. Actually array of size 10^8 can be defined safely inside a function. If you need more than that define it as a gloabal variable(Instance variable). Coming to your code there is an `IndexOutOfBoundsExcep... | This can generate prime numbers up to `Integer.MAX_VALUE` in few milliseconds. It also doesn't take as much memory as in Sieve of Eratosthenes approach.
```
public class Prime {
public static IntStream generate(int limit) {
return IntStream.range(2, Integer.MAX_VALUE).filter(Prime::isPrime).limit(limit);
}
... |
32,821,569 | I am trying to setup a dev environment using ansible and vagrant. Now i am stuck at cloning a git repo from bitbucket.
Below are Vagrantfile and ansible settings and things i have tried.
In my Vagrantfile i have `config.ssh.forward_agent = true`
In my deploy.yml i have
```
- name: ensure bitbucket is a known host... | 2015/09/28 | [
"https://Stackoverflow.com/questions/32821569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/216514/"
] | Able to run `git clone ...` successfully on vagrant box isn't sufficient.
The way I see it, what's happening is:
* ansible tries to opens an ssh connection to vagrant box as user 'vagrant' (`User=vagrant`) and supplies the identity file: `-o IdentityFile="/Users/ammar/.vagrant.d/insecure_private_key"`
* executes `/bi... | I had the same problem. Are you using "sudo: yes" in your script? If you are, then the root user needs access to the repo, not the vagrant user.
Add the public key file of the root user to the Bitbucket account and you should be fine.
Alternatively you could do the checkout via your normal user.
In any case, the pub... |
21,685,941 | My code looks similarly to this:
I create variable:
```
var person1;
```
Than I add this to array:
```
var people = [];
people.push(person1);
```
And finally I define what "person1" is:
```
person1 = new Person("Mike", 25, "London");
```
The problem is, people that are defined after pushing to array are undef... | 2014/02/10 | [
"https://Stackoverflow.com/questions/21685941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1804027/"
] | You have to create an instance of an object and push the object pointer onto the array. Right now the problem is that you are pushing `undefined` since you do not instantiate a `Person` object first.
explicitly your code current looks like this:
```
var person1 = undefined;
var people = [];
people.push(person1);//push... | first of all, you need to define `people` as an array `var people = []`
then push to array a default person`new person()`for example, and then refer to person by index `people[1]` (for example), and then change that... to what you want |
21,685,941 | My code looks similarly to this:
I create variable:
```
var person1;
```
Than I add this to array:
```
var people = [];
people.push(person1);
```
And finally I define what "person1" is:
```
person1 = new Person("Mike", 25, "London");
```
The problem is, people that are defined after pushing to array are undef... | 2014/02/10 | [
"https://Stackoverflow.com/questions/21685941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1804027/"
] | There are no pointers in javascript. `person1` is not going to be a pointer.
This variable is going to reference a value. When the variable is used, the **current** value is referenced. So, when this is used:
```
var person1;
people = [];
people.push(person1);
```
`undefined` shows up because that is what the curre... | first of all, you need to define `people` as an array `var people = []`
then push to array a default person`new person()`for example, and then refer to person by index `people[1]` (for example), and then change that... to what you want |
21,685,941 | My code looks similarly to this:
I create variable:
```
var person1;
```
Than I add this to array:
```
var people = [];
people.push(person1);
```
And finally I define what "person1" is:
```
person1 = new Person("Mike", 25, "London");
```
The problem is, people that are defined after pushing to array are undef... | 2014/02/10 | [
"https://Stackoverflow.com/questions/21685941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1804027/"
] | You have to create an instance of an object and push the object pointer onto the array. Right now the problem is that you are pushing `undefined` since you do not instantiate a `Person` object first.
explicitly your code current looks like this:
```
var person1 = undefined;
var people = [];
people.push(person1);//push... | The only thing you can do is:
```
var person1 = new Person();
var people = [];
people.push(person1);
people[0].name = "Mike";
people[0].age = 25;
people[0].city = "London";
``` |
21,685,941 | My code looks similarly to this:
I create variable:
```
var person1;
```
Than I add this to array:
```
var people = [];
people.push(person1);
```
And finally I define what "person1" is:
```
person1 = new Person("Mike", 25, "London");
```
The problem is, people that are defined after pushing to array are undef... | 2014/02/10 | [
"https://Stackoverflow.com/questions/21685941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1804027/"
] | There are no pointers in javascript. `person1` is not going to be a pointer.
This variable is going to reference a value. When the variable is used, the **current** value is referenced. So, when this is used:
```
var person1;
people = [];
people.push(person1);
```
`undefined` shows up because that is what the curre... | The only thing you can do is:
```
var person1 = new Person();
var people = [];
people.push(person1);
people[0].name = "Mike";
people[0].age = 25;
people[0].city = "London";
``` |
547,009 | >
> He is a pedant, a sesquipedalianist, an ambivert.
>
>
>
Is this grammatically correct? I am not sure about the use of "a sesquipedalianist". | 2020/09/19 | [
"https://english.stackexchange.com/questions/547009",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/399135/"
] | "He is a pedant, sesquipedalianist, and an ambivert" can be rewritten more compactly as "He is a pedant, sesquipedalianist, and ambivert". You should group together items in a list that require the same indefinite article, and only use it once at the start.
Whether you use 'a' or 'an' at the beginning of a list to sui... | Yes.
These are the rules for a/an articles:
1. ***A*** before words starting with consonant sounds.
e.g. A man, a university, a yacht...
2. ***An*** before words starting with vowel sounds.
e.g. An animal, an error...
So the sentence is grammatically correct. |
3,892,088 | I have an application which consists of a service and an executable. Essentially it's a forms application that is responsible for starting and stopping a service under specific circumstances.
On Windows XP the application manages this fine using the following code:
```
ServiceController controller = new ServiceContro... | 2010/10/08 | [
"https://Stackoverflow.com/questions/3892088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/460785/"
] | When you say that you started the application as Administrator, do you mean under an account in the Administrators group, or via a UAC prompt that requests administrator credentials? Without the UAC credentials prompt (or actually running as the Administrator account, not an account within the Administrators group), yo... | You can also try setting the UAC for your application to ["Run as Administrator"](https://stackoverflow.com/questions/1545355/stop-start-service-in-code-in-windows-7/4264605#4264605) in code. |
3,892,088 | I have an application which consists of a service and an executable. Essentially it's a forms application that is responsible for starting and stopping a service under specific circumstances.
On Windows XP the application manages this fine using the following code:
```
ServiceController controller = new ServiceContro... | 2010/10/08 | [
"https://Stackoverflow.com/questions/3892088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/460785/"
] | When you say that you started the application as Administrator, do you mean under an account in the Administrators group, or via a UAC prompt that requests administrator credentials? Without the UAC credentials prompt (or actually running as the Administrator account, not an account within the Administrators group), yo... | FYI, if you don't understand why it's not working in Vista or 7 even if the current user is in the administrator group, here is what MSDN has to say
>
> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-... |
3,892,088 | I have an application which consists of a service and an executable. Essentially it's a forms application that is responsible for starting and stopping a service under specific circumstances.
On Windows XP the application manages this fine using the following code:
```
ServiceController controller = new ServiceContro... | 2010/10/08 | [
"https://Stackoverflow.com/questions/3892088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/460785/"
] | FYI, if you don't understand why it's not working in Vista or 7 even if the current user is in the administrator group, here is what MSDN has to say
>
> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-... | You can also try setting the UAC for your application to ["Run as Administrator"](https://stackoverflow.com/questions/1545355/stop-start-service-in-code-in-windows-7/4264605#4264605) in code. |
63,795,182 | I've tried several answers on stackoverflow and non are working for me. I basically need all traffic on my site to end up at <https://www.domainname.com>. I can get everything working with the rules below except if someone types in <https://domainname.com>. In this case I need to add www to it.
```
<match url="(.*)" ... | 2020/09/08 | [
"https://Stackoverflow.com/questions/63795182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10653208/"
] | Thanks to Eric I realized that regular expressions can be used in snakemake rules' wildcards. The only problem is then that snakemake does not accept "empty" wildcards, but this can be overridden as explained in the post here: <https://groups.google.com/g/snakemake/c/S7fTL4jAYIM?pli=1>
Thus the solution to my problem i... | Can't you do it the very simple way:
```
rule with_something:
input:
vals_pca = 'stats/input_{something}.npz',
output:
for_cnv = 'stats/output_{something}.npz'
run:
# DO STUFF
```
Wildcards are defined by the output files. If you ask for file `output_typeWhatever_dWhatever.... |
14,341,157 | I'm creating a small tool and this tool will include a treeview of XML. There's no problem dealing with XML files with a small file size, but when I try to load a large XML file (21MB in size), my application becomes unresponsive and takes too much time to load the XML, and most of the time it doesn't load the XML at a... | 2013/01/15 | [
"https://Stackoverflow.com/questions/14341157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396335/"
] | You will have to separate the loading part from building the TreeView.
The loading can then happen on a background thread (BackgroundWorker).
Everything related to the TreeView has to happen on the Main thread but you can speed it up by using SuspendLayout et al. | You could try and use the Parallel.ForEach for child nodes to split things across cores. This will be tricky to implement though.
<http://msdn.microsoft.com/en-us/library/dd991486.aspx> |
14,341,157 | I'm creating a small tool and this tool will include a treeview of XML. There's no problem dealing with XML files with a small file size, but when I try to load a large XML file (21MB in size), my application becomes unresponsive and takes too much time to load the XML, and most of the time it doesn't load the XML at a... | 2013/01/15 | [
"https://Stackoverflow.com/questions/14341157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396335/"
] | You will have to separate the loading part from building the TreeView.
The loading can then happen on a background thread (BackgroundWorker).
Everything related to the TreeView has to happen on the Main thread but you can speed it up by using SuspendLayout et al. | First off you should really switch to a SAX-like approach when dealing with large files. Refer to [What is the best way to parse (big) XML in C# Code?](https://stackoverflow.com/questions/676274/what-is-the-best-way-to-parse-big-xml-in-c-sharp-code) for one possible solution.
Now you have a solid way to read files tha... |
14,341,157 | I'm creating a small tool and this tool will include a treeview of XML. There's no problem dealing with XML files with a small file size, but when I try to load a large XML file (21MB in size), my application becomes unresponsive and takes too much time to load the XML, and most of the time it doesn't load the XML at a... | 2013/01/15 | [
"https://Stackoverflow.com/questions/14341157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396335/"
] | You could try and use the Parallel.ForEach for child nodes to split things across cores. This will be tricky to implement though.
<http://msdn.microsoft.com/en-us/library/dd991486.aspx> | Instead of using `XmlDataDocument`, change the code to use `XmlReader` as this class offers the highest performance when working with XML files.
XmlReader is an abstract class that can read from a file or from any other stream of data. When reading from a file, you don't load the entire document at once.
more informat... |
14,341,157 | I'm creating a small tool and this tool will include a treeview of XML. There's no problem dealing with XML files with a small file size, but when I try to load a large XML file (21MB in size), my application becomes unresponsive and takes too much time to load the XML, and most of the time it doesn't load the XML at a... | 2013/01/15 | [
"https://Stackoverflow.com/questions/14341157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396335/"
] | You could try and use the Parallel.ForEach for child nodes to split things across cores. This will be tricky to implement though.
<http://msdn.microsoft.com/en-us/library/dd991486.aspx> | First off you should really switch to a SAX-like approach when dealing with large files. Refer to [What is the best way to parse (big) XML in C# Code?](https://stackoverflow.com/questions/676274/what-is-the-best-way-to-parse-big-xml-in-c-sharp-code) for one possible solution.
Now you have a solid way to read files tha... |
14,341,157 | I'm creating a small tool and this tool will include a treeview of XML. There's no problem dealing with XML files with a small file size, but when I try to load a large XML file (21MB in size), my application becomes unresponsive and takes too much time to load the XML, and most of the time it doesn't load the XML at a... | 2013/01/15 | [
"https://Stackoverflow.com/questions/14341157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396335/"
] | For the unresponsive part, you can load the xml in a BackgroundWorker asynchronously, and perhaps the whole process of building the treeview structure can be done that way and loaded in the control itself when done.
This might not improve speed a lot, but it will keep the UI responsive. Keep in mind that you cannot ac... | Instead of using `XmlDataDocument`, change the code to use `XmlReader` as this class offers the highest performance when working with XML files.
XmlReader is an abstract class that can read from a file or from any other stream of data. When reading from a file, you don't load the entire document at once.
more informat... |
14,341,157 | I'm creating a small tool and this tool will include a treeview of XML. There's no problem dealing with XML files with a small file size, but when I try to load a large XML file (21MB in size), my application becomes unresponsive and takes too much time to load the XML, and most of the time it doesn't load the XML at a... | 2013/01/15 | [
"https://Stackoverflow.com/questions/14341157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396335/"
] | You will have to separate the loading part from building the TreeView.
The loading can then happen on a background thread (BackgroundWorker).
Everything related to the TreeView has to happen on the Main thread but you can speed it up by using SuspendLayout et al. | Two minor suggestions: Instead of adding a node then looking it up, create it in a temp variable then work with it from there. And you can use a `foreach` loop instead of a `for` loop.
Replace
```
nodeList = inXmlNode.ChildNodes;
for (i = 0; i <= nodeList.Count - 1; i++)
{
xNode = inXmlNode.ChildNodes[i];
in... |
14,341,157 | I'm creating a small tool and this tool will include a treeview of XML. There's no problem dealing with XML files with a small file size, but when I try to load a large XML file (21MB in size), my application becomes unresponsive and takes too much time to load the XML, and most of the time it doesn't load the XML at a... | 2013/01/15 | [
"https://Stackoverflow.com/questions/14341157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396335/"
] | You will have to separate the loading part from building the TreeView.
The loading can then happen on a background thread (BackgroundWorker).
Everything related to the TreeView has to happen on the Main thread but you can speed it up by using SuspendLayout et al. | Instead of using `XmlDataDocument`, change the code to use `XmlReader` as this class offers the highest performance when working with XML files.
XmlReader is an abstract class that can read from a file or from any other stream of data. When reading from a file, you don't load the entire document at once.
more informat... |
14,341,157 | I'm creating a small tool and this tool will include a treeview of XML. There's no problem dealing with XML files with a small file size, but when I try to load a large XML file (21MB in size), my application becomes unresponsive and takes too much time to load the XML, and most of the time it doesn't load the XML at a... | 2013/01/15 | [
"https://Stackoverflow.com/questions/14341157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396335/"
] | You could try and use the Parallel.ForEach for child nodes to split things across cores. This will be tricky to implement though.
<http://msdn.microsoft.com/en-us/library/dd991486.aspx> | Two minor suggestions: Instead of adding a node then looking it up, create it in a temp variable then work with it from there. And you can use a `foreach` loop instead of a `for` loop.
Replace
```
nodeList = inXmlNode.ChildNodes;
for (i = 0; i <= nodeList.Count - 1; i++)
{
xNode = inXmlNode.ChildNodes[i];
in... |
14,341,157 | I'm creating a small tool and this tool will include a treeview of XML. There's no problem dealing with XML files with a small file size, but when I try to load a large XML file (21MB in size), my application becomes unresponsive and takes too much time to load the XML, and most of the time it doesn't load the XML at a... | 2013/01/15 | [
"https://Stackoverflow.com/questions/14341157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396335/"
] | For the unresponsive part, you can load the xml in a BackgroundWorker asynchronously, and perhaps the whole process of building the treeview structure can be done that way and loaded in the control itself when done.
This might not improve speed a lot, but it will keep the UI responsive. Keep in mind that you cannot ac... | First off you should really switch to a SAX-like approach when dealing with large files. Refer to [What is the best way to parse (big) XML in C# Code?](https://stackoverflow.com/questions/676274/what-is-the-best-way-to-parse-big-xml-in-c-sharp-code) for one possible solution.
Now you have a solid way to read files tha... |
14,341,157 | I'm creating a small tool and this tool will include a treeview of XML. There's no problem dealing with XML files with a small file size, but when I try to load a large XML file (21MB in size), my application becomes unresponsive and takes too much time to load the XML, and most of the time it doesn't load the XML at a... | 2013/01/15 | [
"https://Stackoverflow.com/questions/14341157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396335/"
] | You will have to separate the loading part from building the TreeView.
The loading can then happen on a background thread (BackgroundWorker).
Everything related to the TreeView has to happen on the Main thread but you can speed it up by using SuspendLayout et al. | For the unresponsive part, you can load the xml in a BackgroundWorker asynchronously, and perhaps the whole process of building the treeview structure can be done that way and loaded in the control itself when done.
This might not improve speed a lot, but it will keep the UI responsive. Keep in mind that you cannot ac... |
21,954,036 | I'm getting the error `[.WebGLRenderingContext]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering or is not 'texture complete'` when I run my web app in dartium. I've been trying to troubleshoot this issue for two days, including a full rew... | 2014/02/22 | [
"https://Stackoverflow.com/questions/21954036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2884502/"
] | Immediately after the code in my question I had bound the texture and send the sampler uniform. This was wrong because it was executed before the image loaded. To fix this, I put the calls to bind the texture and draw elements in the onload function:
```
image.onLoad.listen((e) {
gl.bindTexture(webGL.TEXTURE_2D,... | I had the same error. But in my case, I forgot to set
```
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER,... |
348,267 | I've tracked down a game named [superhot](http://superhotgame.com/) and downloaded zipped Linux version. I unzipped it and there was a directory named SUPERHOT-LINUX\_Data and file with extension .x86. I went to properties and ticked "can execute". But the file still doesn't start. All i can see is bunch of processes s... | 2013/09/21 | [
"https://askubuntu.com/questions/348267",
"https://askubuntu.com",
"https://askubuntu.com/users/194825/"
] | I solved by installing these libraries:
```
$ sudo apt-get install libglu1-mesa:i386 libxcursor1:i386
```
You can print shared library dependencies with:
```
$ ldd SUPERHOT-LINUX.x86
``` | Yes, your system lacks that library (`libGLU`). In this case it is available in the repositories so you just need to run
```
$ sudo apt-get install libglu1-mesa
```
If you find similar errors you can try to find the needed package using `apt-file`. In this case, to search packages that have the file `libGLU.so.1`:
... |
141,004 | I want to help a friend upgrading her macbook pro macbook 2012 MD101 from 4GB RAM and HDD to 8GB RAM and SSD.
Since I am not a mac guy myself, I need to ask you guys what is the compatible RAM modules for this particular mac model. Further more. As far as I know RAM modules should be 204pin SODIMM 1.5 volt?
Also doe... | 2014/08/05 | [
"https://apple.stackexchange.com/questions/141004",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/86863/"
] | As long as you can confirm the laptop is indeed from mid-2012 (later models have the memory soldered in), then these specs should work for you with either a 13" or 15" laptop (Apple started soldering memory in 17" laptops after 2011):
* 204-pin
* PC3-12800 DDr3 1600 MHz type RAM
(Found at <http://support.apple.com/kb... | I just put a Crucial MX-100 512GB in a 2011 model and was impressed by the performance. Measured faster than the Samsung 840 in my 2012 model. It came with the spacer needed to fit the 7mm drive snugly into the 9mm space on the MBP.
If you are going to the trouble to add memory, you might as well spend the extra $75 a... |
27,976,760 | I have a link on a website when it's clicked it will load a form in a div. The form is processed by a PHP script. I need the output from the PHP script to appear in that div. Any idea how to do this? Thanks
File header.php
```
<html>
<head>
<script>
$(document).ready(function(){
$(... | 2015/01/16 | [
"https://Stackoverflow.com/questions/27976760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574730/"
] | There are a couple of ways you can achieve this.
Lets say you have an anchor tag `<a href="..">My Href</a>` and you want to add CSS to it based on certain instances.
You can easily echo that css into the anchor element like so:
`<a <?php echo 'style="float: left;"'; ?> href="..">My Href</a>`
The output would be:... | Yes. It is possible.
There's actually two different ways.
**Method 1:** Inject PHP into your actual CSS. This is done by making your file .php, using regular HTML and CSS, and then doing as such:
```
.someclass {
/* Some code */
<?php // Whatever you wanna inject
?>
```
I have performed this many times, and no... |
27,976,760 | I have a link on a website when it's clicked it will load a form in a div. The form is processed by a PHP script. I need the output from the PHP script to appear in that div. Any idea how to do this? Thanks
File header.php
```
<html>
<head>
<script>
$(document).ready(function(){
$(... | 2015/01/16 | [
"https://Stackoverflow.com/questions/27976760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574730/"
] | There are a couple of ways you can achieve this.
Lets say you have an anchor tag `<a href="..">My Href</a>` and you want to add CSS to it based on certain instances.
You can easily echo that css into the anchor element like so:
`<a <?php echo 'style="float: left;"'; ?> href="..">My Href</a>`
The output would be:... | Yes, you can easily do that. You can either do it in the CSS file like 'ilarsona' said, or you can do it in the HTML file itself.
For example:
```
<!DOCTYPE html>
<html>
<head>
<title>The Title</title>
<style>
p {<?php *Insert dynamic styles here* ?>};
</style>
</head>
... |
792 | In recent times i found that one user is basically copy pasting posts from arbitrary/unknown blogs as answers.Many of his answers are like that with [this](https://hinduism.stackexchange.com/a/17295/4732) being a typical example.
How to deal with them(such answers)?
I don't think we should allow this to continue.What... | 2017/02/26 | [
"https://hinduism.meta.stackexchange.com/questions/792",
"https://hinduism.meta.stackexchange.com",
"https://hinduism.meta.stackexchange.com/users/4732/"
] | Blogs which give Blog owner's interpretations shouldn't be allowed and answers which cite them as sources should be deleted.
For example, if a blog has exact Vedic Verses or Puranic verses, we can cite them in answers (without citing blog in answer) as these verses are not influenced by Blog author's intepretation. Si... | Simple Solution: **Use your voting power**!
---
If you don't use it enough, you've only yourself to blame in the long run! And when you downvote somebody's answer, don't forget to explain your reasons in comments. Always give feedback why you didn't like it.
Also, before voting, you can leave a comment and wait for ... |
23,513,879 | Lets say, i want to import/upload excel file to mysql from PHP
My HTML is like below
```
<form enctype="multipart/form-data" method="post" role="form" action="do.php">
<div class="form-group">
<label for="exampleInputFile">File Upload</label>
<input type="file" name="file" id="file" size="150">
... | 2014/05/07 | [
"https://Stackoverflow.com/questions/23513879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3576352/"
] | Stack is Last-In/First-Out construct where 'top' is tracked by ESP. On x86 stack 'grows' top down, meaning that it is initialized to certain value and pointer to 'top' of the stack goes down (lower value) when things are added to stack.
As an example, in the beginning your Stack could be the following:
```
+---... | `esp` is just a register (which points usually to the stack). It is **not** the stack. So sub does here the same as elsewhere. In your example `esp` becomes 0FFE0h. |
33,351,096 | I've been putting my first powershell scripts together for the last couple of hours and I keep seeing an error that I can't seem to get to the bottom of.
I'm using the Powershell ISE tool to write and run the scripts.
To see if its something in my script I've created a super simple test script and I'm seeing the same... | 2015/10/26 | [
"https://Stackoverflow.com/questions/33351096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/155926/"
] | You are calling the function before it is defined. The reason it works the second time, is a result of the first run. When it is ran the first time it's defining the function, so when you run the script the second time it knows what the function is. | You need to declare your function *before* you invoke it. It works the second time because then it's been declared. Think of how this would work if you were just at a powershell command line and you typed: "Test;" What would you expect to happen? |
32,514,441 | I am working on an application whereby I need to listen to changes in native contacts database like if a contact is edited/deleted or a new contact is added.
I know I can achieve this with the help of contentobservers. However I found it pretty strange that android SDK does not provide a way to know which contact is a... | 2015/09/11 | [
"https://Stackoverflow.com/questions/32514441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1051423/"
] | [This interesting thread from the early days of Android](https://groups.google.com/d/msg/android-developers/oayhLnhmQGQ/OYqkBEIm644J) indicates that the `ContentObserver` did use to tell you what had changed, but it was too difficult to provide that information. It goes on to state why (at least at that time) re-queryi... | This service class provide the wake up call from the changes of contacts add, update, delete operations from the background. I don't know whether this piece of code is useful for you.
```
public class ContactOberverService extends Service {
private static final String TAG = "ContactOberverService";
@Nullable
... |
10,214,340 | I'm using DB2 v9
I have a stored procedure with paramaters that can potentially be passed in as empty strings. Here somer pseudocode for what I'm trying to do:
```
WHERE myColumn.name =
IF param1 = '' THEN
**disregard this param, all column values are eligible**
ELSE
myColumn.name = param1;
... | 2012/04/18 | [
"https://Stackoverflow.com/questions/10214340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/817934/"
] | ```
SELECT ...
FROM ...
WHERE param1 = ''
OR myColumn.name = param1
;
``` | The [answer](https://stackoverflow.com/questions/10214340/db2-conditional-where-clause/10214393#10214393) provided by [wildplasser](https://stackoverflow.com/users/905902/wildplasser) is correct, but there are some additional considerations that may helpful to include.
First, it might be possible that the stored proce... |
10,214,340 | I'm using DB2 v9
I have a stored procedure with paramaters that can potentially be passed in as empty strings. Here somer pseudocode for what I'm trying to do:
```
WHERE myColumn.name =
IF param1 = '' THEN
**disregard this param, all column values are eligible**
ELSE
myColumn.name = param1;
... | 2012/04/18 | [
"https://Stackoverflow.com/questions/10214340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/817934/"
] | ```
SELECT ...
FROM ...
WHERE param1 = ''
OR myColumn.name = param1
;
``` | Another Keyword here would be "[Dynamic SQL](https://www.ibm.com/developerworks/mydeveloperworks/blogs/SQLTips4DB2LUW/entry/prepare_execute?lang=en)". Build your queries as a string and either `EXECUTE IMMEDIATE` them (for UPDATE, INSERT or DDL's) or use `PREPARE`/`OPEN`/`FETCH` (for SELECT's). |
10,214,340 | I'm using DB2 v9
I have a stored procedure with paramaters that can potentially be passed in as empty strings. Here somer pseudocode for what I'm trying to do:
```
WHERE myColumn.name =
IF param1 = '' THEN
**disregard this param, all column values are eligible**
ELSE
myColumn.name = param1;
... | 2012/04/18 | [
"https://Stackoverflow.com/questions/10214340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/817934/"
] | The [answer](https://stackoverflow.com/questions/10214340/db2-conditional-where-clause/10214393#10214393) provided by [wildplasser](https://stackoverflow.com/users/905902/wildplasser) is correct, but there are some additional considerations that may helpful to include.
First, it might be possible that the stored proce... | Another Keyword here would be "[Dynamic SQL](https://www.ibm.com/developerworks/mydeveloperworks/blogs/SQLTips4DB2LUW/entry/prepare_execute?lang=en)". Build your queries as a string and either `EXECUTE IMMEDIATE` them (for UPDATE, INSERT or DDL's) or use `PREPARE`/`OPEN`/`FETCH` (for SELECT's). |
23,194,437 | Modern dialects of HTML and rules of good practice disallow to omit the semicolon in HTML entities(`&likethat;`). But I have a task to parse arbitrary pages and have to deal with the bad html entities without semicolons. And this is perfectly rendered by browsers. How can I decode HTML entities without semicolons into ... | 2014/04/21 | [
"https://Stackoverflow.com/questions/23194437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2992008/"
] | You can get a list of all html entities and use this to replace all without semicolon by their UTF-8 representations:
```
// get all HTML entities
$mapping = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES | ENT_HTML5, 'UTF-8');
// change array values representing the entities to regex pattern with negativ looka... | My guess would be that you could try loading the document using [DOMDocument::loadHTML](http://www.php.net/manual/en/domdocument.loadhtml.php), and try saving it then using [DOMDocument::saveHTML](http://www.php.net/manual/en/domdocument.savehtml.php).
You may specify additional options using [libxml constants](http:/... |
30,689,604 | I am in the process of creating a 2D tile-based platform game for Mac OSX in swift. I have come across problems with the controls when more than one key is pushed at a time. For example; if 'D' makes the character move to the right, and 'W' makes him jump; if I hold 'D' to make the character run, then tap 'W' to make h... | 2015/06/07 | [
"https://Stackoverflow.com/questions/30689604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3427188/"
] | The repeated keydown events that occur when a key is held down are generated by the keyboard hardware. On the PC, the protocol definition says:
>
> If you press a key, its make code is sent to the computer. When you press and hold down a key, that key becomes typematic, which means the keyboard will keep sending that... | Jim Garrison's answer seems correct. A workaround in this case, could be to have the character move right when you press the D key down, and continue to move right using a loop until the D key is released, which you can check using the func keyUp(theEvent: NSEvent)
If using SpritKit, you can do the character movement ... |
17,485,886 | what is the difference between `Html.BeginForm`() and `Ajax.Beginform`() in MVC3. I just want to know the scenarios where I can use `Html.BeginForm`() and where I can use `Ajax.Beginform`(). | 2013/07/05 | [
"https://Stackoverflow.com/questions/17485886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1961208/"
] | **Ajax**
1. Won't redirect the form even you do a `RedirectAction()`.
2. Will perform save , update and any modification operations asynchronously.
3. Validate the Form using `FormMethods - OnSubmit`. So you are abort the `Post`
4. This creates a form that submits its values using an asynchronous ajax request. This al... | `Html.BeginForm()` will use simple posting on page, it means your page will be refreshed when you post your form.
when `Ajax.BeginForm()` will use ajax posting on page, it means your page will not be refreshed when you post your form. |
17,485,886 | what is the difference between `Html.BeginForm`() and `Ajax.Beginform`() in MVC3. I just want to know the scenarios where I can use `Html.BeginForm`() and where I can use `Ajax.Beginform`(). | 2013/07/05 | [
"https://Stackoverflow.com/questions/17485886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1961208/"
] | **Html.BeginForm()** will create a form on the page that submits its values to the server as a synchronous HTTP request, refreshing the entire page in the process.
**Ajax.BeginForm()** creates a form that submits its values using an asynchronous ajax request. This allows a portion of the page to be update without requ... | `Html.BeginForm()` will use simple posting on page, it means your page will be refreshed when you post your form.
when `Ajax.BeginForm()` will use ajax posting on page, it means your page will not be refreshed when you post your form. |
17,485,886 | what is the difference between `Html.BeginForm`() and `Ajax.Beginform`() in MVC3. I just want to know the scenarios where I can use `Html.BeginForm`() and where I can use `Ajax.Beginform`(). | 2013/07/05 | [
"https://Stackoverflow.com/questions/17485886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1961208/"
] | `Html.BeginForm()` will use simple posting on page, it means your page will be refreshed when you post your form.
when `Ajax.BeginForm()` will use ajax posting on page, it means your page will not be refreshed when you post your form. | @Html.BeginForm is used to post the data by full page refresh whereas @Ajax.BeginForm performs Post back function and allows some portion of Html to be reloaded rather than overall page refresh. |
17,485,886 | what is the difference between `Html.BeginForm`() and `Ajax.Beginform`() in MVC3. I just want to know the scenarios where I can use `Html.BeginForm`() and where I can use `Ajax.Beginform`(). | 2013/07/05 | [
"https://Stackoverflow.com/questions/17485886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1961208/"
] | **Ajax**
1. Won't redirect the form even you do a `RedirectAction()`.
2. Will perform save , update and any modification operations asynchronously.
3. Validate the Form using `FormMethods - OnSubmit`. So you are abort the `Post`
4. This creates a form that submits its values using an asynchronous ajax request. This al... | @Html.BeginForm is used to post the data by full page refresh whereas @Ajax.BeginForm performs Post back function and allows some portion of Html to be reloaded rather than overall page refresh. |
17,485,886 | what is the difference between `Html.BeginForm`() and `Ajax.Beginform`() in MVC3. I just want to know the scenarios where I can use `Html.BeginForm`() and where I can use `Ajax.Beginform`(). | 2013/07/05 | [
"https://Stackoverflow.com/questions/17485886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1961208/"
] | **Html.BeginForm()** will create a form on the page that submits its values to the server as a synchronous HTTP request, refreshing the entire page in the process.
**Ajax.BeginForm()** creates a form that submits its values using an asynchronous ajax request. This allows a portion of the page to be update without requ... | @Html.BeginForm is used to post the data by full page refresh whereas @Ajax.BeginForm performs Post back function and allows some portion of Html to be reloaded rather than overall page refresh. |
69,551,899 | I have been reading this [article](https://css-tricks.com/how-nth-child-works/) and it is pretty clear to me so far that something along the lines of: `ul li:nth-child(3n+3)` will select every 3rd `li` due to the fact that the "n" within the expression starts at zero and then represents a set of all positive integers; ... | 2021/10/13 | [
"https://Stackoverflow.com/questions/69551899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4625899/"
] | `Xn` essentially means every Xth child, where `Xn+Y` is every Xth child with an offset of Y.
`1n` is quite nonsensical, as it will just select every child (every 1th child, which essentially is just every child).
```css
div:nth-child(1n)
{
color: red;
}
```
```html
<div>Hi</div>
<div>Hi</div>
<div>Hi</div>
<div>Hi... | Your feeling is correct, `:nth-child(1n)` does not equal `:nth-child(0)`. A selector with an expression like `:nth-child(1n)`, or actually `:nth-child(n)` which is the same would select all children. So apparently it wouldn't make much sense...
To understand which elements are going to be selected you have to give `n`... |
69,551,899 | I have been reading this [article](https://css-tricks.com/how-nth-child-works/) and it is pretty clear to me so far that something along the lines of: `ul li:nth-child(3n+3)` will select every 3rd `li` due to the fact that the "n" within the expression starts at zero and then represents a set of all positive integers; ... | 2021/10/13 | [
"https://Stackoverflow.com/questions/69551899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4625899/"
] | `Xn` essentially means every Xth child, where `Xn+Y` is every Xth child with an offset of Y.
`1n` is quite nonsensical, as it will just select every child (every 1th child, which essentially is just every child).
```css
div:nth-child(1n)
{
color: red;
}
```
```html
<div>Hi</div>
<div>Hi</div>
<div>Hi</div>
<div>Hi... | `.block:nth-child(1n)` will target every element with the class `block` that is a multiple of 1
So it will result the exact same thing as `.block{...}`
```css
.block {
height: 50px;
width: 50px;
background: dodgerblue;
margin: 3px;
}
.block:nth-child(1n) {
background: red;
}
```
```html
<div class="block"... |
69,551,899 | I have been reading this [article](https://css-tricks.com/how-nth-child-works/) and it is pretty clear to me so far that something along the lines of: `ul li:nth-child(3n+3)` will select every 3rd `li` due to the fact that the "n" within the expression starts at zero and then represents a set of all positive integers; ... | 2021/10/13 | [
"https://Stackoverflow.com/questions/69551899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4625899/"
] | Your feeling is correct, `:nth-child(1n)` does not equal `:nth-child(0)`. A selector with an expression like `:nth-child(1n)`, or actually `:nth-child(n)` which is the same would select all children. So apparently it wouldn't make much sense...
To understand which elements are going to be selected you have to give `n`... | `.block:nth-child(1n)` will target every element with the class `block` that is a multiple of 1
So it will result the exact same thing as `.block{...}`
```css
.block {
height: 50px;
width: 50px;
background: dodgerblue;
margin: 3px;
}
.block:nth-child(1n) {
background: red;
}
```
```html
<div class="block"... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.