qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
2,700,421 | HI All,
I have a PDF file with a xml attached, i need to parse the xml file. Does anyone knows how i do that?
I´m using C#.
Thanks in advance. | 2010/04/23 | [
"https://Stackoverflow.com/questions/2700421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/162752/"
] | Why are you trying to use generics if you only want an int?
```
// No need to compare b to true...
public static int val(this bool b, int v) { return b ? v : 0; }
```
Otherwise, use `default(T)` as others have mentioned.
```
public static T val<T>(this bool b, T v) { return b ? v : default(T); }
```
`default(T)` ... | If there's only valid type for T then it shouldn't be generic:
```
public static int val(this bool b, int v)
{
return b ? v : 0;
}
```
If you want this to work for any value type you could do this:
```
public static int val<T>(this bool b, T v) where T : struct
{
return b ? v : default(T);
}
``` |
2,700,421 | HI All,
I have a PDF file with a xml attached, i need to parse the xml file. Does anyone knows how i do that?
I´m using C#.
Thanks in advance. | 2010/04/23 | [
"https://Stackoverflow.com/questions/2700421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/162752/"
] | If you want T to be an int, accept an int and not a T. Otherwise, consider returning default(T) if b == false.
`return b ? v : default(T);`
If T is an int, it will return 0. If it is a reference type, it will be null. And on and on.. | There is no way to do this in C#. You can do
`where T: struct`, and force T to be a value type, but that still isn't enough.
Or you can do
`default(T)`, which is 0 when T is an int. |
2,700,421 | HI All,
I have a PDF file with a xml attached, i need to parse the xml file. Does anyone knows how i do that?
I´m using C#.
Thanks in advance. | 2010/04/23 | [
"https://Stackoverflow.com/questions/2700421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/162752/"
] | There is no way to do this in C#. You can do
`where T: struct`, and force T to be a value type, but that still isn't enough.
Or you can do
`default(T)`, which is 0 when T is an int. | If there's only valid type for T then it shouldn't be generic:
```
public static int val(this bool b, int v)
{
return b ? v : 0;
}
```
If you want this to work for any value type you could do this:
```
public static int val<T>(this bool b, T v) where T : struct
{
return b ? v : default(T);
}
``` |
2,700,421 | HI All,
I have a PDF file with a xml attached, i need to parse the xml file. Does anyone knows how i do that?
I´m using C#.
Thanks in advance. | 2010/04/23 | [
"https://Stackoverflow.com/questions/2700421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/162752/"
] | There is no way to do this in C#. You can do
`where T: struct`, and force T to be a value type, but that still isn't enough.
Or you can do
`default(T)`, which is 0 when T is an int. | Srsly!
To "restrict T to int" you take advantage of a special compiler feature known as `strong-typing`:
```
static public class Blah
{
public static int val(this bool b, int v) { return b == true? v:0; }
}
```
Tada! :)
Seriously, why are you using generics? |
2,700,421 | HI All,
I have a PDF file with a xml attached, i need to parse the xml file. Does anyone knows how i do that?
I´m using C#.
Thanks in advance. | 2010/04/23 | [
"https://Stackoverflow.com/questions/2700421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/162752/"
] | If you want T to be an int, accept an int and not a T. Otherwise, consider returning default(T) if b == false.
`return b ? v : default(T);`
If T is an int, it will return 0. If it is a reference type, it will be null. And on and on.. | Why are you trying to use generics if you only want an int?
```
// No need to compare b to true...
public static int val(this bool b, int v) { return b ? v : 0; }
```
Otherwise, use `default(T)` as others have mentioned.
```
public static T val<T>(this bool b, T v) { return b ? v : default(T); }
```
`default(T)` ... |
2,700,421 | HI All,
I have a PDF file with a xml attached, i need to parse the xml file. Does anyone knows how i do that?
I´m using C#.
Thanks in advance. | 2010/04/23 | [
"https://Stackoverflow.com/questions/2700421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/162752/"
] | If you want T to be an int, accept an int and not a T. Otherwise, consider returning default(T) if b == false.
`return b ? v : default(T);`
If T is an int, it will return 0. If it is a reference type, it will be null. And on and on.. | If there's only valid type for T then it shouldn't be generic:
```
public static int val(this bool b, int v)
{
return b ? v : 0;
}
```
If you want this to work for any value type you could do this:
```
public static int val<T>(this bool b, T v) where T : struct
{
return b ? v : default(T);
}
``` |
2,700,421 | HI All,
I have a PDF file with a xml attached, i need to parse the xml file. Does anyone knows how i do that?
I´m using C#.
Thanks in advance. | 2010/04/23 | [
"https://Stackoverflow.com/questions/2700421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/162752/"
] | If you want T to be an int, accept an int and not a T. Otherwise, consider returning default(T) if b == false.
`return b ? v : default(T);`
If T is an int, it will return 0. If it is a reference type, it will be null. And on and on.. | Srsly!
To "restrict T to int" you take advantage of a special compiler feature known as `strong-typing`:
```
static public class Blah
{
public static int val(this bool b, int v) { return b == true? v:0; }
}
```
Tada! :)
Seriously, why are you using generics? |
2,700,421 | HI All,
I have a PDF file with a xml attached, i need to parse the xml file. Does anyone knows how i do that?
I´m using C#.
Thanks in advance. | 2010/04/23 | [
"https://Stackoverflow.com/questions/2700421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/162752/"
] | Why are you trying to use generics if you only want an int?
```
// No need to compare b to true...
public static int val(this bool b, int v) { return b ? v : 0; }
```
Otherwise, use `default(T)` as others have mentioned.
```
public static T val<T>(this bool b, T v) { return b ? v : default(T); }
```
`default(T)` ... | Srsly!
To "restrict T to int" you take advantage of a special compiler feature known as `strong-typing`:
```
static public class Blah
{
public static int val(this bool b, int v) { return b == true? v:0; }
}
```
Tada! :)
Seriously, why are you using generics? |
15,689,950 | How can I bind multiple events on tinymce such that those events e.g. click, keyup and change have the same handler function?
I am trying like this but the events are not firing.
```
tinymce.dom.Event.add(ed, 'click keyup change', function (ed, e) {
// Handler here...
});
```
I also tried th... | 2013/03/28 | [
"https://Stackoverflow.com/questions/15689950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1839698/"
] | ```
function myFunction(ed, e) {
// do what you want
}
tinymce.dom.Event.add(ed, 'click', myFunction);
tinymce.dom.Event.add(ed, 'keyup', myFunction);
tinymce.dom.Event.add(ed, 'change', myFunction);
``` | Make one callback function and pass it to each of them
I do **not** believe that `tinymce` gives you the ability to add multiple events at once.
For example:
```
callbackFn = function (ed, e) {
// Handler here...
};
tinymce.dom.Event.add(ed, 'click', callbackFn );
tinymce.dom.Event.add(ed, 'k... |
5,496,870 | I have a table with a lot of data and I need to join it with some other large tables.
Only a small portion of my table is actually relevant for me each time.
When is it best to filter my data?
1. In the where clause of the SQL.
2. Create a temp table with the specific data and only then join it.
3. Add the predicate... | 2011/03/31 | [
"https://Stackoverflow.com/questions/5496870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392335/"
] | Because you are using INNER JOINs the WHERE or JOIN debate only depends on your taste and style. Personally, I like to keep the links between the two tables (e.g. foreign key constraint) in the ON clause, and actual filters against data in the WHERE clause.
SQL Server will parse the query into the same token tree, and... | You should put your query in the management studio, tick "include actual execution plan", and run it. That way you will get the exact answer what SQL server did with your query. From then, you can move forward with optimization.
In general:
* The columns used for join should be indexed
* Use the most discriminating f... |
5,496,870 | I have a table with a lot of data and I need to join it with some other large tables.
Only a small portion of my table is actually relevant for me each time.
When is it best to filter my data?
1. In the where clause of the SQL.
2. Create a temp table with the specific data and only then join it.
3. Add the predicate... | 2011/03/31 | [
"https://Stackoverflow.com/questions/5496870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392335/"
] | Because you are using INNER JOINs the WHERE or JOIN debate only depends on your taste and style. Personally, I like to keep the links between the two tables (e.g. foreign key constraint) in the ON clause, and actual filters against data in the WHERE clause.
SQL Server will parse the query into the same token tree, and... | In a decent cost based query planner what happens is (your case)
1. join conditions and where conditions are parsed at same level
2. the type of join and statistics determines the path (what happens first) - in such a way that the smallest intermediate results are retrieved (least I/O > fastest query) |
5,496,870 | I have a table with a lot of data and I need to join it with some other large tables.
Only a small portion of my table is actually relevant for me each time.
When is it best to filter my data?
1. In the where clause of the SQL.
2. Create a temp table with the specific data and only then join it.
3. Add the predicate... | 2011/03/31 | [
"https://Stackoverflow.com/questions/5496870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392335/"
] | You should put your query in the management studio, tick "include actual execution plan", and run it. That way you will get the exact answer what SQL server did with your query. From then, you can move forward with optimization.
In general:
* The columns used for join should be indexed
* Use the most discriminating f... | In a decent cost based query planner what happens is (your case)
1. join conditions and where conditions are parsed at same level
2. the type of join and statistics determines the path (what happens first) - in such a way that the smallest intermediate results are retrieved (least I/O > fastest query) |
1,211,100 | I want to install and use the scribus application. I am using Xubuntu 18.04 as primary OS on a Dell 3162 notebook computer. | 2020/02/17 | [
"https://askubuntu.com/questions/1211100",
"https://askubuntu.com",
"https://askubuntu.com/users/1045090/"
] | To install Scribus, open the Ubuntu Software center. Search for "Scribus" and click the entry that appears. You then can start the install with the "Install" button. | You could do it by:
1. Update packages information: `sudo apt-get update`
2. Install it using `sudo apt-get install scribus` |
10,927,615 | I have an application where i have implemented call,sms,email functionality as shown below, i wanted to know how do i make the phone number:99999999 and mailto:example@gmail.com dynamic , so that i will replace the phone number and email field from some variable.
SMS functionality
{
```
xtype:... | 2012/06/07 | [
"https://Stackoverflow.com/questions/10927615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/429349/"
] | Store your values of sms number, email address and call number in some address like shown below ..
```
var contactNo = "**9999999**";
var emailId = "example@gmail.com";
var smsNo = "**99999999**";
```
and then make call as shown below,
```
window.location.href = "sms:"+smsNo;
window.location.href = "mailto:"+... | You can do this by just using the `<a>` tag
For phone number
```
<a href="tel:999999999">999999999</a>
```
For E-Mail
```
<a href="mailto:webmaster@example.com">webmaster@example.com</a>
```
For SMS
```
<a href="sms:999999999">Send SMS</a>
```
Tapping on the link will automatically summon the corresponding ap... |
284,675 | I come over from [PPCG](https://codegolf.stackexchange.com), and a few of the people in chat are [talking about organizing a conference of sorts](https://chat.stackexchange.com/transcript/message/32384074#32384074). This conference would have direct links to the PPCG site (what with coming from the site and all).
Say ... | 2016/09/17 | [
"https://meta.stackexchange.com/questions/284675",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/308256/"
] | Not only is this perfectly OK, but it's exactly what community ads are for, and is explicitly allowed on the [community ads meta post](http://meta.codegolf.stackexchange.com/q/9463/31716). To quote [Grace Note](https://meta.stackexchange.com/users/146126/grace-note):
>
> This is a method for the community to control ... | Yes
===
A site-specific "community promotion ad" is created with the primary intention of promoting a community and serving content which the users of that community would be interested in. If an ad about a conference receives enough votes to be displayed, then I see no reason to exclude it from the scope.
I have see... |
317,103 | I'm trying to use `ab` to test my webserver, but it only supports HTTP/1.1 (reject requests that have HTTP/1.0 in the first line). The `-k` switch only adds a header with `connection: keep-alive`.
Is it possible to make `ab` send HTTP/1.1 request? | 2011/09/30 | [
"https://serverfault.com/questions/317103",
"https://serverfault.com",
"https://serverfault.com/users/88870/"
] | how about using Siege, it is as easy to use as ab, but it supports HTTP/1.1:
<http://www.joedog.org/index/siege-home> | A way found in [CMU's 15-441](https://github.com/computer-networks/liso-starter-code/blob/b92be13efb5a5aefbab129cf0325eb5256fa9734/DockerFile#L7):
```
perl -pi -e 's/HTTP\/1.0/HTTP\/1.1/g' /usr/bin/ab
```
Hacky, but it works! :D |
53,198,424 | In the following code I am trying for each band to get the number of band members. I've tried a number of things but nothing works. The following looks like it should but doesn't.
If any one could point out what I'm doing wrong it would be greatly appreciated.
```
numMembers = sizeof(bands[0]) / sizeof(bands[0].membe... | 2018/11/07 | [
"https://Stackoverflow.com/questions/53198424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9791286/"
] | >
> what I'm doing wrong
>
>
>
**Wrong `numMembers` calculation**
`numMembers` should be the number of elements in the array. (20)
Each `bands[i].member` has 20 elements given `char *members[20]`. Several elements are populated with pointers to *string literals*. Most elements remain 0 (`NULL`).
```
// numMembe... | For numMembers = sizeof(bands[0]) / sizeof(bands[0].members);
sizeofband(bands[0]) will give the size of one band struct - that is the 10 bytes for name, and then 20 \* the size of a pointer.
sizeof(bands[0].members); will give 20\*thesizeof a pointer
Not what you want, as sizeof doesn't take into consideration the ... |
53,198,424 | In the following code I am trying for each band to get the number of band members. I've tried a number of things but nothing works. The following looks like it should but doesn't.
If any one could point out what I'm doing wrong it would be greatly appreciated.
```
numMembers = sizeof(bands[0]) / sizeof(bands[0].membe... | 2018/11/07 | [
"https://Stackoverflow.com/questions/53198424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9791286/"
] | You don't have a "two dimensional array". What you have is a simple *array of* `struct band` which contains two simple character arrays as its members.
There is actually no need to compute the number of `"members"` in each bands. All you need to compute is the number of `bands`, e.g.
```
int nbands = sizeof bands... | For numMembers = sizeof(bands[0]) / sizeof(bands[0].members);
sizeofband(bands[0]) will give the size of one band struct - that is the 10 bytes for name, and then 20 \* the size of a pointer.
sizeof(bands[0].members); will give 20\*thesizeof a pointer
Not what you want, as sizeof doesn't take into consideration the ... |
53,198,424 | In the following code I am trying for each band to get the number of band members. I've tried a number of things but nothing works. The following looks like it should but doesn't.
If any one could point out what I'm doing wrong it would be greatly appreciated.
```
numMembers = sizeof(bands[0]) / sizeof(bands[0].membe... | 2018/11/07 | [
"https://Stackoverflow.com/questions/53198424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9791286/"
] | You don't have a "two dimensional array". What you have is a simple *array of* `struct band` which contains two simple character arrays as its members.
There is actually no need to compute the number of `"members"` in each bands. All you need to compute is the number of `bands`, e.g.
```
int nbands = sizeof bands... | >
> what I'm doing wrong
>
>
>
**Wrong `numMembers` calculation**
`numMembers` should be the number of elements in the array. (20)
Each `bands[i].member` has 20 elements given `char *members[20]`. Several elements are populated with pointers to *string literals*. Most elements remain 0 (`NULL`).
```
// numMembe... |
72,447,828 | i have a dataset which requires me to **print out values larger than the average with the years**. I'm able to retrieve the datas but not together with the years.
is there any efficient way i can use to display both datas together?
below is a snippet of the dataset with years and datas respectively.
`[2010,2011,2012,2... | 2022/05/31 | [
"https://Stackoverflow.com/questions/72447828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18241625/"
] | Since the question is not really explained I am not sure that is exactly what you except :
```py
date = [2010,2011,2012,2013,2014,2015,2016,2017]
data = [29057,30979,31746,32964,31738,31010,31158,28736]
date_mean = np.mean(date)
for i,year in enumerate(date):
if year > date_mean:
print(year, data[i])
``... | ```
np.c_[y[x>x.mean()], x[x>x.mean()]]
#output:
array([[ 2011, 30979],
[ 2012, 31746],
[ 2013, 32964],
[ 2014, 31738],
[ 2015, 31010],
[ 2016, 31158]])
```
`x>x.mean()` returns a boolean mask (`True` is `x>x.mean()` and `False` otherwise); we can use this mask to select `x` values... |
72,447,828 | i have a dataset which requires me to **print out values larger than the average with the years**. I'm able to retrieve the datas but not together with the years.
is there any efficient way i can use to display both datas together?
below is a snippet of the dataset with years and datas respectively.
`[2010,2011,2012,2... | 2022/05/31 | [
"https://Stackoverflow.com/questions/72447828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18241625/"
] | Since the question is not really explained I am not sure that is exactly what you except :
```py
date = [2010,2011,2012,2013,2014,2015,2016,2017]
data = [29057,30979,31746,32964,31738,31010,31158,28736]
date_mean = np.mean(date)
for i,year in enumerate(date):
if year > date_mean:
print(year, data[i])
``... | To group your two lists together, you could use [zip](https://docs.python.org/3.10/library/functions.html#zip).
Example:
```py
years = [2010,2011,2012,2013,2014,2015,2016,2017]
values = [29057,30979,31746,32964,31738,31010,31158,28736]
pair = list(zip(years, values))
```
Output:
```
>>> pair
[(2010, 29057), (2011,... |
72,447,828 | i have a dataset which requires me to **print out values larger than the average with the years**. I'm able to retrieve the datas but not together with the years.
is there any efficient way i can use to display both datas together?
below is a snippet of the dataset with years and datas respectively.
`[2010,2011,2012,2... | 2022/05/31 | [
"https://Stackoverflow.com/questions/72447828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18241625/"
] | Since the question is not really explained I am not sure that is exactly what you except :
```py
date = [2010,2011,2012,2013,2014,2015,2016,2017]
data = [29057,30979,31746,32964,31738,31010,31158,28736]
date_mean = np.mean(date)
for i,year in enumerate(date):
if year > date_mean:
print(year, data[i])
``... | You can select the date with a condition in array and the get the corresponding x with.index()
```js
date = [2010,2011,2012,2013,2014,2015,2016,2017]
x = [29057,30979,31746,32964,31738,31010,31158,28736]
year = [d for d in date if d >= (np.mean(date))]
for d in year:
print(d, x[date.index(d)])
>>>2014 31738
2... |
72,447,828 | i have a dataset which requires me to **print out values larger than the average with the years**. I'm able to retrieve the datas but not together with the years.
is there any efficient way i can use to display both datas together?
below is a snippet of the dataset with years and datas respectively.
`[2010,2011,2012,2... | 2022/05/31 | [
"https://Stackoverflow.com/questions/72447828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18241625/"
] | Using numpy:
```
years = np.array([2010,2011,2012,2013,2014,2015,2016,2017])
data = np.array([29057,30979,31746,32964,31738,31010,31158,28736])
out = np.stack([years, data])[:, data>data.mean()]
```
output:
```
array([[ 2011, 2012, 2013, 2014, 2015, 2016],
[30979, 31746, 32964, 31738, 31010, 31158]])
... | ```
np.c_[y[x>x.mean()], x[x>x.mean()]]
#output:
array([[ 2011, 30979],
[ 2012, 31746],
[ 2013, 32964],
[ 2014, 31738],
[ 2015, 31010],
[ 2016, 31158]])
```
`x>x.mean()` returns a boolean mask (`True` is `x>x.mean()` and `False` otherwise); we can use this mask to select `x` values... |
72,447,828 | i have a dataset which requires me to **print out values larger than the average with the years**. I'm able to retrieve the datas but not together with the years.
is there any efficient way i can use to display both datas together?
below is a snippet of the dataset with years and datas respectively.
`[2010,2011,2012,2... | 2022/05/31 | [
"https://Stackoverflow.com/questions/72447828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18241625/"
] | To group your two lists together, you could use [zip](https://docs.python.org/3.10/library/functions.html#zip).
Example:
```py
years = [2010,2011,2012,2013,2014,2015,2016,2017]
values = [29057,30979,31746,32964,31738,31010,31158,28736]
pair = list(zip(years, values))
```
Output:
```
>>> pair
[(2010, 29057), (2011,... | ```
np.c_[y[x>x.mean()], x[x>x.mean()]]
#output:
array([[ 2011, 30979],
[ 2012, 31746],
[ 2013, 32964],
[ 2014, 31738],
[ 2015, 31010],
[ 2016, 31158]])
```
`x>x.mean()` returns a boolean mask (`True` is `x>x.mean()` and `False` otherwise); we can use this mask to select `x` values... |
72,447,828 | i have a dataset which requires me to **print out values larger than the average with the years**. I'm able to retrieve the datas but not together with the years.
is there any efficient way i can use to display both datas together?
below is a snippet of the dataset with years and datas respectively.
`[2010,2011,2012,2... | 2022/05/31 | [
"https://Stackoverflow.com/questions/72447828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18241625/"
] | You can select the date with a condition in array and the get the corresponding x with.index()
```js
date = [2010,2011,2012,2013,2014,2015,2016,2017]
x = [29057,30979,31746,32964,31738,31010,31158,28736]
year = [d for d in date if d >= (np.mean(date))]
for d in year:
print(d, x[date.index(d)])
>>>2014 31738
2... | ```
np.c_[y[x>x.mean()], x[x>x.mean()]]
#output:
array([[ 2011, 30979],
[ 2012, 31746],
[ 2013, 32964],
[ 2014, 31738],
[ 2015, 31010],
[ 2016, 31158]])
```
`x>x.mean()` returns a boolean mask (`True` is `x>x.mean()` and `False` otherwise); we can use this mask to select `x` values... |
72,447,828 | i have a dataset which requires me to **print out values larger than the average with the years**. I'm able to retrieve the datas but not together with the years.
is there any efficient way i can use to display both datas together?
below is a snippet of the dataset with years and datas respectively.
`[2010,2011,2012,2... | 2022/05/31 | [
"https://Stackoverflow.com/questions/72447828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18241625/"
] | Using numpy:
```
years = np.array([2010,2011,2012,2013,2014,2015,2016,2017])
data = np.array([29057,30979,31746,32964,31738,31010,31158,28736])
out = np.stack([years, data])[:, data>data.mean()]
```
output:
```
array([[ 2011, 2012, 2013, 2014, 2015, 2016],
[30979, 31746, 32964, 31738, 31010, 31158]])
... | To group your two lists together, you could use [zip](https://docs.python.org/3.10/library/functions.html#zip).
Example:
```py
years = [2010,2011,2012,2013,2014,2015,2016,2017]
values = [29057,30979,31746,32964,31738,31010,31158,28736]
pair = list(zip(years, values))
```
Output:
```
>>> pair
[(2010, 29057), (2011,... |
72,447,828 | i have a dataset which requires me to **print out values larger than the average with the years**. I'm able to retrieve the datas but not together with the years.
is there any efficient way i can use to display both datas together?
below is a snippet of the dataset with years and datas respectively.
`[2010,2011,2012,2... | 2022/05/31 | [
"https://Stackoverflow.com/questions/72447828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18241625/"
] | Using numpy:
```
years = np.array([2010,2011,2012,2013,2014,2015,2016,2017])
data = np.array([29057,30979,31746,32964,31738,31010,31158,28736])
out = np.stack([years, data])[:, data>data.mean()]
```
output:
```
array([[ 2011, 2012, 2013, 2014, 2015, 2016],
[30979, 31746, 32964, 31738, 31010, 31158]])
... | You can select the date with a condition in array and the get the corresponding x with.index()
```js
date = [2010,2011,2012,2013,2014,2015,2016,2017]
x = [29057,30979,31746,32964,31738,31010,31158,28736]
year = [d for d in date if d >= (np.mean(date))]
for d in year:
print(d, x[date.index(d)])
>>>2014 31738
2... |
124,297 | I was looking into the Dobles of years past after watching videos of Jay Leno's Doble E-20 and was trying to imagine how one could make the steam car a viable competitor to EVs and obviously one of the problems is the pollution from coal or wood being used for the fire.
Well what if the boiler contained electric heati... | 2018/09/05 | [
"https://worldbuilding.stackexchange.com/questions/124297",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/55055/"
] | This wouldn't work, sorry.
What you are describing is a [perpetual motion engine](https://en.wikipedia.org/wiki/Perpetual_motion) which violate the laws of thermodynamics and are impossible to build.
Basically you use electricity to heat the water, then use the water to generate electricity...but you lose energy at e... | Yes, but...
-----------
This is feasible, but it would be an immensely inefficient thing to do. Electric cars consist of a battery/inverter combo which works at around 90% combined efficiency, and an electromotor which, too, has an efficiency upwards of 90% for converting electricity to motion, and which can collect s... |
124,297 | I was looking into the Dobles of years past after watching videos of Jay Leno's Doble E-20 and was trying to imagine how one could make the steam car a viable competitor to EVs and obviously one of the problems is the pollution from coal or wood being used for the fire.
Well what if the boiler contained electric heati... | 2018/09/05 | [
"https://worldbuilding.stackexchange.com/questions/124297",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/55055/"
] | This wouldn't work, sorry.
What you are describing is a [perpetual motion engine](https://en.wikipedia.org/wiki/Perpetual_motion) which violate the laws of thermodynamics and are impossible to build.
Basically you use electricity to heat the water, then use the water to generate electricity...but you lose energy at e... | As noted, this is a violation of the laws of Thermodynamics. The other factor which would make this infeasable (and is also related to thermodynamics) is the issue of where the electrical energy comes from in the first place?
A common critique of EV's is they are "Coal Powered" cars. This is a reference to the fact t... |
124,297 | I was looking into the Dobles of years past after watching videos of Jay Leno's Doble E-20 and was trying to imagine how one could make the steam car a viable competitor to EVs and obviously one of the problems is the pollution from coal or wood being used for the fire.
Well what if the boiler contained electric heati... | 2018/09/05 | [
"https://worldbuilding.stackexchange.com/questions/124297",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/55055/"
] | What you propose would technically work, though it wouldn't really add much (if any noticeable) power to the system. In fact something similar is already done:
Closed cycle steam engines feed back the steam into the boiler, that is so they need less replenishing of their water supply. The decrease of water consumption... | The water would make the car quite heavy, especially compared to normal EVs. However, it gives you one option: you can heat the water while the car is parked via an external power source. The water will be in a pressure tank, so the boiling temperature will rise (and you can store more energy in the same amount of wate... |
124,297 | I was looking into the Dobles of years past after watching videos of Jay Leno's Doble E-20 and was trying to imagine how one could make the steam car a viable competitor to EVs and obviously one of the problems is the pollution from coal or wood being used for the fire.
Well what if the boiler contained electric heati... | 2018/09/05 | [
"https://worldbuilding.stackexchange.com/questions/124297",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/55055/"
] | What you propose would technically work, though it wouldn't really add much (if any noticeable) power to the system. In fact something similar is already done:
Closed cycle steam engines feed back the steam into the boiler, that is so they need less replenishing of their water supply. The decrease of water consumption... | Yes, but...
-----------
This is feasible, but it would be an immensely inefficient thing to do. Electric cars consist of a battery/inverter combo which works at around 90% combined efficiency, and an electromotor which, too, has an efficiency upwards of 90% for converting electricity to motion, and which can collect s... |
124,297 | I was looking into the Dobles of years past after watching videos of Jay Leno's Doble E-20 and was trying to imagine how one could make the steam car a viable competitor to EVs and obviously one of the problems is the pollution from coal or wood being used for the fire.
Well what if the boiler contained electric heati... | 2018/09/05 | [
"https://worldbuilding.stackexchange.com/questions/124297",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/55055/"
] | No. It wouldn't be feasible as a competitor to Electronic Vehicles (EV)s, ever.
Normal EVs generally boil down to a battery and an electromotor. Electromotors are, in general, fairly simple — and most importantly, cheap — to make. The only thing you need for electromotor is basically some wire that you coil around an ... | As noted, this is a violation of the laws of Thermodynamics. The other factor which would make this infeasable (and is also related to thermodynamics) is the issue of where the electrical energy comes from in the first place?
A common critique of EV's is they are "Coal Powered" cars. This is a reference to the fact t... |
124,297 | I was looking into the Dobles of years past after watching videos of Jay Leno's Doble E-20 and was trying to imagine how one could make the steam car a viable competitor to EVs and obviously one of the problems is the pollution from coal or wood being used for the fire.
Well what if the boiler contained electric heati... | 2018/09/05 | [
"https://worldbuilding.stackexchange.com/questions/124297",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/55055/"
] | No. It wouldn't be feasible as a competitor to Electronic Vehicles (EV)s, ever.
Normal EVs generally boil down to a battery and an electromotor. Electromotors are, in general, fairly simple — and most importantly, cheap — to make. The only thing you need for electromotor is basically some wire that you coil around an ... | Yes, but...
-----------
This is feasible, but it would be an immensely inefficient thing to do. Electric cars consist of a battery/inverter combo which works at around 90% combined efficiency, and an electromotor which, too, has an efficiency upwards of 90% for converting electricity to motion, and which can collect s... |
124,297 | I was looking into the Dobles of years past after watching videos of Jay Leno's Doble E-20 and was trying to imagine how one could make the steam car a viable competitor to EVs and obviously one of the problems is the pollution from coal or wood being used for the fire.
Well what if the boiler contained electric heati... | 2018/09/05 | [
"https://worldbuilding.stackexchange.com/questions/124297",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/55055/"
] | This wouldn't work, sorry.
What you are describing is a [perpetual motion engine](https://en.wikipedia.org/wiki/Perpetual_motion) which violate the laws of thermodynamics and are impossible to build.
Basically you use electricity to heat the water, then use the water to generate electricity...but you lose energy at e... | The water would make the car quite heavy, especially compared to normal EVs. However, it gives you one option: you can heat the water while the car is parked via an external power source. The water will be in a pressure tank, so the boiling temperature will rise (and you can store more energy in the same amount of wate... |
124,297 | I was looking into the Dobles of years past after watching videos of Jay Leno's Doble E-20 and was trying to imagine how one could make the steam car a viable competitor to EVs and obviously one of the problems is the pollution from coal or wood being used for the fire.
Well what if the boiler contained electric heati... | 2018/09/05 | [
"https://worldbuilding.stackexchange.com/questions/124297",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/55055/"
] | This wouldn't work, sorry.
What you are describing is a [perpetual motion engine](https://en.wikipedia.org/wiki/Perpetual_motion) which violate the laws of thermodynamics and are impossible to build.
Basically you use electricity to heat the water, then use the water to generate electricity...but you lose energy at e... | What you propose would technically work, though it wouldn't really add much (if any noticeable) power to the system. In fact something similar is already done:
Closed cycle steam engines feed back the steam into the boiler, that is so they need less replenishing of their water supply. The decrease of water consumption... |
124,297 | I was looking into the Dobles of years past after watching videos of Jay Leno's Doble E-20 and was trying to imagine how one could make the steam car a viable competitor to EVs and obviously one of the problems is the pollution from coal or wood being used for the fire.
Well what if the boiler contained electric heati... | 2018/09/05 | [
"https://worldbuilding.stackexchange.com/questions/124297",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/55055/"
] | This wouldn't work, sorry.
What you are describing is a [perpetual motion engine](https://en.wikipedia.org/wiki/Perpetual_motion) which violate the laws of thermodynamics and are impossible to build.
Basically you use electricity to heat the water, then use the water to generate electricity...but you lose energy at e... | No. It wouldn't be feasible as a competitor to Electronic Vehicles (EV)s, ever.
Normal EVs generally boil down to a battery and an electromotor. Electromotors are, in general, fairly simple — and most importantly, cheap — to make. The only thing you need for electromotor is basically some wire that you coil around an ... |
124,297 | I was looking into the Dobles of years past after watching videos of Jay Leno's Doble E-20 and was trying to imagine how one could make the steam car a viable competitor to EVs and obviously one of the problems is the pollution from coal or wood being used for the fire.
Well what if the boiler contained electric heati... | 2018/09/05 | [
"https://worldbuilding.stackexchange.com/questions/124297",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/55055/"
] | No. It wouldn't be feasible as a competitor to Electronic Vehicles (EV)s, ever.
Normal EVs generally boil down to a battery and an electromotor. Electromotors are, in general, fairly simple — and most importantly, cheap — to make. The only thing you need for electromotor is basically some wire that you coil around an ... | What you propose would technically work, though it wouldn't really add much (if any noticeable) power to the system. In fact something similar is already done:
Closed cycle steam engines feed back the steam into the boiler, that is so they need less replenishing of their water supply. The decrease of water consumption... |
130,285 | This seems like it should be easy but I am trying to concisely enhance some nested associations with Mathematica objects (e.g., convert things to matrices, etc) but I'm having a bit of difficulty with nested items. In my case I want to go through an arbitrarily nested association and anywhere there is a key == 'someval... | 2016/11/03 | [
"https://mathematica.stackexchange.com/questions/130285",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/42162/"
] | You can use `Replace[]` on `Association`s, but it's sort of weird because it tries to treat keys transparently. If your `Replace` patterns include association markers (`<| |>`), then `Replace` can be convinced to care about keys, but the tricky part there is matching against *every* rule within an association.
It turn... | You may use [`MapAt`](http://reference.wolfram.com/language/ref/MapAt.html) if you don't mind explicitly specifying the [`Key`](http://reference.wolfram.com/language/ref/Key.html)s.
```
MapAt[MatrixForm, test, {{"correlation"}, {"descendants", "correlation"}}]
```
If `"descendants"` contains a list of [`Association`... |
130,285 | This seems like it should be easy but I am trying to concisely enhance some nested associations with Mathematica objects (e.g., convert things to matrices, etc) but I'm having a bit of difficulty with nested items. In my case I want to go through an arbitrarily nested association and anywhere there is a key == 'someval... | 2016/11/03 | [
"https://mathematica.stackexchange.com/questions/130285",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/42162/"
] | You can use `Replace[]` on `Association`s, but it's sort of weird because it tries to treat keys transparently. If your `Replace` patterns include association markers (`<| |>`), then `Replace` can be convinced to care about keys, but the tricky part there is matching against *every* rule within an association.
It turn... | Any occurrence of the association key `"correlation"` at any depth of an expression will have a position index that matches the pattern `{___, Key["correlation"]}`. We can use either `MapIndexed` or `ReplacePart` to exploit this observation and apply a function of our choosing at such positions (e.g., `MatrixForm`):
`... |
130,285 | This seems like it should be easy but I am trying to concisely enhance some nested associations with Mathematica objects (e.g., convert things to matrices, etc) but I'm having a bit of difficulty with nested items. In my case I want to go through an arbitrarily nested association and anywhere there is a key == 'someval... | 2016/11/03 | [
"https://mathematica.stackexchange.com/questions/130285",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/42162/"
] | Any occurrence of the association key `"correlation"` at any depth of an expression will have a position index that matches the pattern `{___, Key["correlation"]}`. We can use either `MapIndexed` or `ReplacePart` to exploit this observation and apply a function of our choosing at such positions (e.g., `MatrixForm`):
`... | You may use [`MapAt`](http://reference.wolfram.com/language/ref/MapAt.html) if you don't mind explicitly specifying the [`Key`](http://reference.wolfram.com/language/ref/Key.html)s.
```
MapAt[MatrixForm, test, {{"correlation"}, {"descendants", "correlation"}}]
```
If `"descendants"` contains a list of [`Association`... |
31,250,715 | I want to make a powershell scrip which will return some information(Hostname, OS, SP) about each computer that is connected to the network.
At the moment I try to pick the IP addresses which are used and store them in an array for later use.
My problem is that I try to get the status of the connection (successful/ti... | 2015/07/06 | [
"https://Stackoverflow.com/questions/31250715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4113692/"
] | Here's the problem!
You're storing the results of a `$ping.Send()` within `$result`, selecting only the `.Status` property.
That means your `$result` object looks like this:
```
>$result
Status
------
Success
```
You're then asking PowerShell to compare this to "Status=Success". The character's don't exactly mat... | So as FoxDeploy said is a problem with how I took the Status field out of the Ping object.
The way I found is :
```
$ping.Send("10.0.0.$computer") | select status | %{$_.Status -eq "Success"}
```
Basically I pass the object via the second pipe ("|") and then I select just the Status field (very similar to Java) :)... |
237,279 | I am an assistant teacher of English in a higher secondary school in a remote village of Basirhat - ii block. In my school the first summative evaluation is going on where in the English grammar question of class - vi it is asked to form the antonym of the word, 'Hope', by using suffix to it.
The concerned grammar te... | 2015/04/03 | [
"https://english.stackexchange.com/questions/237279",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/115865/"
] | If the question implies one suffix, it is somewhat unfair. Perhaps it could be rephrased to say "by using a suffix or suffixes"? | The question setter invites the problem.
The moment it is asked to add suffix(es), it is taken for granted that parts of speech will be changed.
It is generally seen that suffixes change part of speech (meaning may or may not change), while prefixes change meaning (but part of speech remains the same); but this argume... |
237,279 | I am an assistant teacher of English in a higher secondary school in a remote village of Basirhat - ii block. In my school the first summative evaluation is going on where in the English grammar question of class - vi it is asked to form the antonym of the word, 'Hope', by using suffix to it.
The concerned grammar te... | 2015/04/03 | [
"https://english.stackexchange.com/questions/237279",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/115865/"
] | If a the answer requires an antonym using a single suffix, the Oxford English Dictionary doesn't have one. The "hope" headwords on my OED CD are: hope, hopeable, hoped, hopeful, hopefully, hopefulness, hopeite (a phosphate of zinc), hopeless, hopelessly, hopelessness, hopelost, hopely, hoper, and hoping.
Given that "... | If the question implies one suffix, it is somewhat unfair. Perhaps it could be rephrased to say "by using a suffix or suffixes"? |
237,279 | I am an assistant teacher of English in a higher secondary school in a remote village of Basirhat - ii block. In my school the first summative evaluation is going on where in the English grammar question of class - vi it is asked to form the antonym of the word, 'Hope', by using suffix to it.
The concerned grammar te... | 2015/04/03 | [
"https://english.stackexchange.com/questions/237279",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/115865/"
] | There is no antonym for the word "hope" with the use of a single suffix. There is however a pair of adjectives that are antonyms of each other, both created with a single suffix: hopeful and hopeless. | The question setter invites the problem.
The moment it is asked to add suffix(es), it is taken for granted that parts of speech will be changed.
It is generally seen that suffixes change part of speech (meaning may or may not change), while prefixes change meaning (but part of speech remains the same); but this argume... |
237,279 | I am an assistant teacher of English in a higher secondary school in a remote village of Basirhat - ii block. In my school the first summative evaluation is going on where in the English grammar question of class - vi it is asked to form the antonym of the word, 'Hope', by using suffix to it.
The concerned grammar te... | 2015/04/03 | [
"https://english.stackexchange.com/questions/237279",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/115865/"
] | If a the answer requires an antonym using a single suffix, the Oxford English Dictionary doesn't have one. The "hope" headwords on my OED CD are: hope, hopeable, hoped, hopeful, hopefully, hopefulness, hopeite (a phosphate of zinc), hopeless, hopelessly, hopelessness, hopelost, hopely, hoper, and hoping.
Given that "... | There is no antonym for the word "hope" with the use of a single suffix. There is however a pair of adjectives that are antonyms of each other, both created with a single suffix: hopeful and hopeless. |
237,279 | I am an assistant teacher of English in a higher secondary school in a remote village of Basirhat - ii block. In my school the first summative evaluation is going on where in the English grammar question of class - vi it is asked to form the antonym of the word, 'Hope', by using suffix to it.
The concerned grammar te... | 2015/04/03 | [
"https://english.stackexchange.com/questions/237279",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/115865/"
] | If a the answer requires an antonym using a single suffix, the Oxford English Dictionary doesn't have one. The "hope" headwords on my OED CD are: hope, hopeable, hoped, hopeful, hopefully, hopefulness, hopeite (a phosphate of zinc), hopeless, hopelessly, hopelessness, hopelost, hopely, hoper, and hoping.
Given that "... | The question setter invites the problem.
The moment it is asked to add suffix(es), it is taken for granted that parts of speech will be changed.
It is generally seen that suffixes change part of speech (meaning may or may not change), while prefixes change meaning (but part of speech remains the same); but this argume... |
237,279 | I am an assistant teacher of English in a higher secondary school in a remote village of Basirhat - ii block. In my school the first summative evaluation is going on where in the English grammar question of class - vi it is asked to form the antonym of the word, 'Hope', by using suffix to it.
The concerned grammar te... | 2015/04/03 | [
"https://english.stackexchange.com/questions/237279",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/115865/"
] | In Modern English you can't form an antonym to "hope" by adding a suffix.
The word "hope" is of [Germanic origin](https://en.wiktionary.org/wiki/hope). Its equivalent in Modern German is *Hoffnung*, and in principle you can form the antonym *Hoffnungslos*, which literally means a lack of hope. From this comes the word... | The question setter invites the problem.
The moment it is asked to add suffix(es), it is taken for granted that parts of speech will be changed.
It is generally seen that suffixes change part of speech (meaning may or may not change), while prefixes change meaning (but part of speech remains the same); but this argume... |
237,279 | I am an assistant teacher of English in a higher secondary school in a remote village of Basirhat - ii block. In my school the first summative evaluation is going on where in the English grammar question of class - vi it is asked to form the antonym of the word, 'Hope', by using suffix to it.
The concerned grammar te... | 2015/04/03 | [
"https://english.stackexchange.com/questions/237279",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/115865/"
] | If a the answer requires an antonym using a single suffix, the Oxford English Dictionary doesn't have one. The "hope" headwords on my OED CD are: hope, hopeable, hoped, hopeful, hopefully, hopefulness, hopeite (a phosphate of zinc), hopeless, hopelessly, hopelessness, hopelost, hopely, hoper, and hoping.
Given that "... | In Modern English you can't form an antonym to "hope" by adding a suffix.
The word "hope" is of [Germanic origin](https://en.wiktionary.org/wiki/hope). Its equivalent in Modern German is *Hoffnung*, and in principle you can form the antonym *Hoffnungslos*, which literally means a lack of hope. From this comes the word... |
16,460,163 | I run this code to execute PowerShell code from an ASP.NET application:
```
System.Management.Automation.Runspaces.Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace();
runspace.Open();
System.Management.Automation.Runspaces.Pipeline pipeline = runspace.CreatePipeline();
pipeline... | 2013/05/09 | [
"https://Stackoverflow.com/questions/16460163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2365955/"
] | There are certain scenarios in which you can follow the steps suggested in the other answers, verify that Execution Policy is set correctly, and still have your scripts fail. If this happens to you, you are probably on a 64-bit machine with both 32-bit and 64-bit versions of PowerShell, and the failure is happening on ... | Try This:
```
Set-ExecutionPolicy -scope CurrentUser Unrestricted
``` |
16,460,163 | I run this code to execute PowerShell code from an ASP.NET application:
```
System.Management.Automation.Runspaces.Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace();
runspace.Open();
System.Management.Automation.Runspaces.Pipeline pipeline = runspace.CreatePipeline();
pipeline... | 2013/05/09 | [
"https://Stackoverflow.com/questions/16460163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2365955/"
] | Your script is blocked from executing due to the [execution policy](http://technet.microsoft.com/en-us/library/ee176961.aspx).
You need to run PowerShell as administrator and set it on the client PC to Unrestricted. You can do that by calling Invoke with:
```
Set-ExecutionPolicy Unrestricted
``` | Try This:
```
Set-ExecutionPolicy -scope CurrentUser Unrestricted
``` |
16,460,163 | I run this code to execute PowerShell code from an ASP.NET application:
```
System.Management.Automation.Runspaces.Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace();
runspace.Open();
System.Management.Automation.Runspaces.Pipeline pipeline = runspace.CreatePipeline();
pipeline... | 2013/05/09 | [
"https://Stackoverflow.com/questions/16460163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2365955/"
] | There are certain scenarios in which you can follow the steps suggested in the other answers, verify that Execution Policy is set correctly, and still have your scripts fail. If this happens to you, you are probably on a 64-bit machine with both 32-bit and 64-bit versions of PowerShell, and the failure is happening on ... | You need to run `Set-ExecutionPolicy`:
```
Set-ExecutionPolicy Unrestricted <-- Will allow unsigned PowerShell scripts to run.
Set-ExecutionPolicy Restricted <-- Will not allow unsigned PowerShell scripts to run.
Set-ExecutionPolicy RemoteSigned <-- Will allow only remotely signed PowerShell scripts to run.
``` |
16,460,163 | I run this code to execute PowerShell code from an ASP.NET application:
```
System.Management.Automation.Runspaces.Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace();
runspace.Open();
System.Management.Automation.Runspaces.Pipeline pipeline = runspace.CreatePipeline();
pipeline... | 2013/05/09 | [
"https://Stackoverflow.com/questions/16460163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2365955/"
] | Your script is blocked from executing due to the [execution policy](http://technet.microsoft.com/en-us/library/ee176961.aspx).
You need to run PowerShell as administrator and set it on the client PC to Unrestricted. You can do that by calling Invoke with:
```
Set-ExecutionPolicy Unrestricted
``` | There are certain scenarios in which you can follow the steps suggested in the other answers, verify that Execution Policy is set correctly, and still have your scripts fail. If this happens to you, you are probably on a 64-bit machine with both 32-bit and 64-bit versions of PowerShell, and the failure is happening on ... |
16,460,163 | I run this code to execute PowerShell code from an ASP.NET application:
```
System.Management.Automation.Runspaces.Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace();
runspace.Open();
System.Management.Automation.Runspaces.Pipeline pipeline = runspace.CreatePipeline();
pipeline... | 2013/05/09 | [
"https://Stackoverflow.com/questions/16460163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2365955/"
] | You need to run `Set-ExecutionPolicy`:
```
Set-ExecutionPolicy Unrestricted <-- Will allow unsigned PowerShell scripts to run.
Set-ExecutionPolicy Restricted <-- Will not allow unsigned PowerShell scripts to run.
Set-ExecutionPolicy RemoteSigned <-- Will allow only remotely signed PowerShell scripts to run.
``` | I had a similar issue and noted that the default cmd on Windows Server 2012 was running the x64 one.
For Windows 7, Windows 8, Windows Server 2008 R2 or Windows Server 2012, run the following commands as Administrator:
### x86
Open `C:\Windows\SysWOW64\cmd.exe`
Run the command: `powershell Set-ExecutionPolicy Remote... |
16,460,163 | I run this code to execute PowerShell code from an ASP.NET application:
```
System.Management.Automation.Runspaces.Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace();
runspace.Open();
System.Management.Automation.Runspaces.Pipeline pipeline = runspace.CreatePipeline();
pipeline... | 2013/05/09 | [
"https://Stackoverflow.com/questions/16460163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2365955/"
] | The problem is that the execution policy is set on a per user basis. You'll need to run the following command in your application every time you run it to enable it to work:
```
Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned
```
There probably is a way to set this for the ASP.NET user as well, but ... | Try This:
```
Set-ExecutionPolicy -scope CurrentUser Unrestricted
``` |
16,460,163 | I run this code to execute PowerShell code from an ASP.NET application:
```
System.Management.Automation.Runspaces.Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace();
runspace.Open();
System.Management.Automation.Runspaces.Pipeline pipeline = runspace.CreatePipeline();
pipeline... | 2013/05/09 | [
"https://Stackoverflow.com/questions/16460163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2365955/"
] | There are certain scenarios in which you can follow the steps suggested in the other answers, verify that Execution Policy is set correctly, and still have your scripts fail. If this happens to you, you are probably on a 64-bit machine with both 32-bit and 64-bit versions of PowerShell, and the failure is happening on ... | The problem is that the execution policy is set on a per user basis. You'll need to run the following command in your application every time you run it to enable it to work:
```
Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned
```
There probably is a way to set this for the ASP.NET user as well, but ... |
16,460,163 | I run this code to execute PowerShell code from an ASP.NET application:
```
System.Management.Automation.Runspaces.Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace();
runspace.Open();
System.Management.Automation.Runspaces.Pipeline pipeline = runspace.CreatePipeline();
pipeline... | 2013/05/09 | [
"https://Stackoverflow.com/questions/16460163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2365955/"
] | You need to run `Set-ExecutionPolicy`:
```
Set-ExecutionPolicy Unrestricted <-- Will allow unsigned PowerShell scripts to run.
Set-ExecutionPolicy Restricted <-- Will not allow unsigned PowerShell scripts to run.
Set-ExecutionPolicy RemoteSigned <-- Will allow only remotely signed PowerShell scripts to run.
``` | Try This:
```
Set-ExecutionPolicy -scope CurrentUser Unrestricted
``` |
16,460,163 | I run this code to execute PowerShell code from an ASP.NET application:
```
System.Management.Automation.Runspaces.Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace();
runspace.Open();
System.Management.Automation.Runspaces.Pipeline pipeline = runspace.CreatePipeline();
pipeline... | 2013/05/09 | [
"https://Stackoverflow.com/questions/16460163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2365955/"
] | Your script is blocked from executing due to the [execution policy](http://technet.microsoft.com/en-us/library/ee176961.aspx).
You need to run PowerShell as administrator and set it on the client PC to Unrestricted. You can do that by calling Invoke with:
```
Set-ExecutionPolicy Unrestricted
``` | You need to run `Set-ExecutionPolicy`:
```
Set-ExecutionPolicy Unrestricted <-- Will allow unsigned PowerShell scripts to run.
Set-ExecutionPolicy Restricted <-- Will not allow unsigned PowerShell scripts to run.
Set-ExecutionPolicy RemoteSigned <-- Will allow only remotely signed PowerShell scripts to run.
``` |
16,460,163 | I run this code to execute PowerShell code from an ASP.NET application:
```
System.Management.Automation.Runspaces.Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace();
runspace.Open();
System.Management.Automation.Runspaces.Pipeline pipeline = runspace.CreatePipeline();
pipeline... | 2013/05/09 | [
"https://Stackoverflow.com/questions/16460163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2365955/"
] | Your script is blocked from executing due to the [execution policy](http://technet.microsoft.com/en-us/library/ee176961.aspx).
You need to run PowerShell as administrator and set it on the client PC to Unrestricted. You can do that by calling Invoke with:
```
Set-ExecutionPolicy Unrestricted
``` | The problem is that the execution policy is set on a per user basis. You'll need to run the following command in your application every time you run it to enable it to work:
```
Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned
```
There probably is a way to set this for the ASP.NET user as well, but ... |
53,135,903 | I ran the following command for my node app:
```
$ npm install browser-sync --save-dev
```
Installation was successful, `browser-sync` appears in my `package.json` file as well as my `node_modules` directory.
However, when I run `$ browser-sync --version` to check that it's working, I get the following error:
>
>... | 2018/11/03 | [
"https://Stackoverflow.com/questions/53135903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9084125/"
] | This is because you're trying to **use a module locally which is normally installed globally**. *Modules installed globally end up on your `PATH` environment variable*, which is why you can run them from the terminal as you're trying to do:
```
$ browser-sync --version
```
If you want to use the `browser-sync` modul... | If you installed browser-sync using `npm --save` or `npm --save-dev` you can run it by writing a script in your package.json. Here's an example of a script I added:
```
{
...
"scripts": {
"dev-server": "browser-sync start --server 'public' --files 'public'"
},
...
}
```
You can run the scripts from you project... |
53,135,903 | I ran the following command for my node app:
```
$ npm install browser-sync --save-dev
```
Installation was successful, `browser-sync` appears in my `package.json` file as well as my `node_modules` directory.
However, when I run `$ browser-sync --version` to check that it's working, I get the following error:
>
>... | 2018/11/03 | [
"https://Stackoverflow.com/questions/53135903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9084125/"
] | If you installed browser-sync using `npm --save` or `npm --save-dev` you can run it by writing a script in your package.json. Here's an example of a script I added:
```
{
...
"scripts": {
"dev-server": "browser-sync start --server 'public' --files 'public'"
},
...
}
```
You can run the scripts from you project... | The other answers still work, but a newer approach has emerged since `npm` added the `npx` command: `npx <package-name>`.
>
> This command allows you to run an arbitrary command from an npm
> package (either one installed locally, or fetched remotely), in a
> similar context as running it via npm run.
>
>
>
Sourc... |
53,135,903 | I ran the following command for my node app:
```
$ npm install browser-sync --save-dev
```
Installation was successful, `browser-sync` appears in my `package.json` file as well as my `node_modules` directory.
However, when I run `$ browser-sync --version` to check that it's working, I get the following error:
>
>... | 2018/11/03 | [
"https://Stackoverflow.com/questions/53135903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9084125/"
] | This is because you're trying to **use a module locally which is normally installed globally**. *Modules installed globally end up on your `PATH` environment variable*, which is why you can run them from the terminal as you're trying to do:
```
$ browser-sync --version
```
If you want to use the `browser-sync` modul... | The other answers still work, but a newer approach has emerged since `npm` added the `npx` command: `npx <package-name>`.
>
> This command allows you to run an arbitrary command from an npm
> package (either one installed locally, or fetched remotely), in a
> similar context as running it via npm run.
>
>
>
Sourc... |
222,716 | Why does [Mongodb production notes](https://docs.mongodb.com/manual/administration/production-notes/) have no recommendations about the disk block size? AFAIU, disk block size would have a considerable impact on a throughput intensive application. Does disk block size have any impact on mongodb performance in practice? | 2018/11/16 | [
"https://dba.stackexchange.com/questions/222716",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/128159/"
] | >
> Why does Mongodb production notes have no recommendations about the
> disk block size?
>
>
>
As per MongoDB documentation [Configure Block Size in a Blockstore](https://docs.opsmanager.mongodb.com/current/tutorial/configure-block-size/) When you back up your deployment to a [Blockstores](https://docs.opsmanag... | MongoDB doesn't but WiredTiger does. See: <https://source.wiredtiger.com/3.1.0/tune_page_size_and_comp.html> |
40,220,285 | I have such a python numpy array;
```
[[-0.17433028 -0.20116786 -0.17599097 -0.1907735 0.27599955 -0.16071874]
[-0.21809219 -0.20256139 -0.15900832 -0.18323743 -0.26910328 0.78731642]]
```
How can I reshape the array as the following?
```
[[-0.17433028, -0.21809219], [-0.20116786, -0.20256139], [-0.17599097, -0... | 2016/10/24 | [
"https://Stackoverflow.com/questions/40220285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4393898/"
] | You want to use the `transpose` method:
```
>>> arr = np.array([[-0.17433028, -0.20116786, -0.17599097, -0.1907735, 0.27599955, -0.16071874], [-0.21809219, -0.20256139, -0.15900832, -0.18323743, -0.26910328, 0.78731642]])
>>> arr.transpose()
array([[-0.17433028, -0.21809219],
[-0.20116786, -0.20256139],
... | This looks like you want the transpose of the matrix. You can do this with `numpy.transpose(array)`. |
3,521 | I just got a pair of Dansko clogs from a clothing swap and was dismayed to realize after closer inspection that they have a flower pattern embossed all over them.
[](https://www.dansko.com/Womens/Footwear/Styles/clogs/Pro%20XP/Black%20Floral%20Tooled)
Image from [dansko.c... | 2017/10/05 | [
"https://crafts.stackexchange.com/questions/3521",
"https://crafts.stackexchange.com",
"https://crafts.stackexchange.com/users/2378/"
] | Start with acetone (nail polish remover) and see if that does the trick. Agitating with a Q-tip can speed things along. It all depends on what the coating is, but acetone won't hurt the copper so it's a good place to start. If it works but isn't fast, you might try soaking it for an hour or so.
A more aggressive appro... | Another thing you could try is lemon essential oil. It's very strong in this pure form and tends to eat away at things. It won't have any effect on the copper. |
3,521 | I just got a pair of Dansko clogs from a clothing swap and was dismayed to realize after closer inspection that they have a flower pattern embossed all over them.
[](https://www.dansko.com/Womens/Footwear/Styles/clogs/Pro%20XP/Black%20Floral%20Tooled)
Image from [dansko.c... | 2017/10/05 | [
"https://crafts.stackexchange.com/questions/3521",
"https://crafts.stackexchange.com",
"https://crafts.stackexchange.com/users/2378/"
] | Start with acetone (nail polish remover) and see if that does the trick. Agitating with a Q-tip can speed things along. It all depends on what the coating is, but acetone won't hurt the copper so it's a good place to start. If it works but isn't fast, you might try soaking it for an hour or so.
A more aggressive appro... | If the acetone suggested earlier doesn't work, put the ring into paint thinner to soak (or mineral spirits, but paint thinner is somewhat less expensive and simply a less refined version of mineral spirits). Let it soak at least 15 minutes, then brush with an old stiff toothbrush. If the varnish comes off, put the ring... |
3,521 | I just got a pair of Dansko clogs from a clothing swap and was dismayed to realize after closer inspection that they have a flower pattern embossed all over them.
[](https://www.dansko.com/Womens/Footwear/Styles/clogs/Pro%20XP/Black%20Floral%20Tooled)
Image from [dansko.c... | 2017/10/05 | [
"https://crafts.stackexchange.com/questions/3521",
"https://crafts.stackexchange.com",
"https://crafts.stackexchange.com/users/2378/"
] | If the acetone suggested earlier doesn't work, put the ring into paint thinner to soak (or mineral spirits, but paint thinner is somewhat less expensive and simply a less refined version of mineral spirits). Let it soak at least 15 minutes, then brush with an old stiff toothbrush. If the varnish comes off, put the ring... | Another thing you could try is lemon essential oil. It's very strong in this pure form and tends to eat away at things. It won't have any effect on the copper. |
74,795 | I'm asking for the curve construction of the discount curve in the case where payment currency and collateral currency are different.
If I refer to BBG, in the case of a USD swap collateralized in EUR, they use the curve N°400 (MBB EUR Coll For USD). How do they construct this curve ? | 2023/03/01 | [
"https://quant.stackexchange.com/questions/74795",
"https://quant.stackexchange.com",
"https://quant.stackexchange.com/users/27240/"
] | TO answer the question in the comment. Suppose you have a USD cash flow receivable in 5yrs and you are trying to calculate the PV. You need to know the interest rate that you are paying on the EUR cash collateral. Suppose this is Eonia flat. Then you execute a 5yr currency basis swap where you lend the Euro collateral ... | If I recall Cooking with collateral by Piterbarg (<https://www.risk.net/derivatives/2194249/cooking-collateral>) has the details but you effectively need to use FX swaps to get the basis adjust discount rate you want. |
43,486,831 | I'm trying to understand how System.out can invoke println(). All the searches say System.out is an instance of PrintStream class therefore it can invoke a method in that class.
BUT...
When I try to duplicate this with the following a NullPointerException results.
```
public class Main {
public static void main(... | 2017/04/19 | [
"https://Stackoverflow.com/questions/43486831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839077/"
] | Why doesn't `System.out` require initialisation? Well ...
Deep inside the `System` class, there's a method called `initializeSystemClass` which the JVM calls. It sets `System.out` to the right value, so you don't have to.
Note that `System.out` is NOT an instance of `PrintStream` - it's a REFERENCE to an instance of ... | You haven't \_initialized `calc`. You *could* have written
```
static Calc calc = new Calc();
```
and it would have worked (depending on the definition of Calc). |
43,486,831 | I'm trying to understand how System.out can invoke println(). All the searches say System.out is an instance of PrintStream class therefore it can invoke a method in that class.
BUT...
When I try to duplicate this with the following a NullPointerException results.
```
public class Main {
public static void main(... | 2017/04/19 | [
"https://Stackoverflow.com/questions/43486831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839077/"
] | You haven't \_initialized `calc`. You *could* have written
```
static Calc calc = new Calc();
```
and it would have worked (depending on the definition of Calc). | As @LouisWasserman points out, the reason that your code gives an NPE is that you haven't initialized the `calc` variable. As a result, it gets *default initialized* to `null`. The solution: initialize it!
But the deeper question is why `System.out` doesn't need to be initialized. That is because the Java runtime init... |
43,486,831 | I'm trying to understand how System.out can invoke println(). All the searches say System.out is an instance of PrintStream class therefore it can invoke a method in that class.
BUT...
When I try to duplicate this with the following a NullPointerException results.
```
public class Main {
public static void main(... | 2017/04/19 | [
"https://Stackoverflow.com/questions/43486831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839077/"
] | Why doesn't `System.out` require initialisation? Well ...
Deep inside the `System` class, there's a method called `initializeSystemClass` which the JVM calls. It sets `System.out` to the right value, so you don't have to.
Note that `System.out` is NOT an instance of `PrintStream` - it's a REFERENCE to an instance of ... | As @LouisWasserman points out, the reason that your code gives an NPE is that you haven't initialized the `calc` variable. As a result, it gets *default initialized* to `null`. The solution: initialize it!
But the deeper question is why `System.out` doesn't need to be initialized. That is because the Java runtime init... |
19,288,849 | I am using Net::Twitter::Lite and I want to post text with parts in italics. I learned that this is possible with Unicode: <http://mothereff.in/twitalics> There is Java-Script code, but I do not understand it. Is there some Perl code that does the same? Or can somebody explain what the JavaScript does so that I can do ... | 2013/10/10 | [
"https://Stackoverflow.com/questions/19288849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2660362/"
] | This program will convert a string of characters into italics, using the Unicode characters for mathematical symbols.
```
#!/usr/bin/perl -CS
use strict;
use warnings;
use 5.010;
use charnames ':full';
my $out;
foreach (@ARGV) {
foreach my $char (split //) {
if ($char =~ /[A-Z]/) {
my $charname = "MATHE... | If you have an old version of Perl, you can use the following:
```
#!/usr/bin/perl
binmode(STDOUT, ":utf8");
$output="";
foreach (@ARGV)
{
foreach $char (split //)
{
if ($char =~ /[A-Z]/) {$d=119860-65+ord($char); $char = pack("U",$d)}
if ($char =~ /h/) {$char="\x{210e}"}
if ($char =~ /[a-z]/) {$d=119886-97+... |
337,310 | The following question seems intuitively true, but I'm unable to see the proof. While I could prove it when $U=\mathbb{R}^n$, but for other open sets, I do not have a proof. Although I could construct $\alpha:[0,1]\to\mathbb{R}^n$ satisfying 1, 2 and 3, I can't force it to remain in $\bar{U}$. Could you please let me k... | 2019/07/31 | [
"https://mathoverflow.net/questions/337310",
"https://mathoverflow.net",
"https://mathoverflow.net/users/27832/"
] | In my other answer, I show how the result for $\mathbb{R}^N$ can be extended to arbitrary $U$. Here I prove that the result is actually *false* for $U = \mathbb{R}^N$ (so in a sense my other answer is completely void).
Consider $p = 0$ and $p\_n$ such that the shortest path that includes all $p\_n$ contained in the sh... | If $p \in U$, then there is a neighbourhood $V$ of $p$ which is diffeomorphic with $\mathbb{R}^N$ and which contains all but finitely many $p\_n$. Let $\Phi : \mathbb{R}^N \to V$ be such a a diffeomorphism. One can use the result for $\mathbb{R}^N$ (and $\Phi^{-1}(p\_n)$, $\Phi^{-1}(p)$) to get a path $\beta : [\tfrac{... |
396,530 | I have two identical [Lenovo P24h-10](https://www.lenovo.com/us/en/accessories-and-monitors/monitors/professional/P24h-10F16238QP123-8inch-Monitor-HDMI/p/61AEGAR3US) monitors plugged into my Macbook. Each one has it's own USB-C cord. I thought about using a single Display Port cord and then daisy-chaining them together... | 2020/07/20 | [
"https://apple.stackexchange.com/questions/396530",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/136696/"
] | I've experienced this as well, and there are a few fixes that I've found.
**Solution One**
This fix involves involve running macros on startup. [Here's a link to the "Keyboard Maestro"](https://superuser.com/a/1468790/610064) method which includes using a [utility called displayplacer on github.](https://github.com/ja... | >
> In the Display Preferences, each monitor is listed as P24h-10 (1) and P24h-10 (2), and they can change.
>
>
>
The problem here has to do with the [EDID information](https://en.wikipedia.org/wiki/Extended_Display_Identification_Data#:%7E:text=Extended%20display%20identification%20data%20%28EDID%29%20is%20a%20da... |
72,907,260 | I have multiple arrays (~32). I want to remove all blank elements from them. How can it be done in a short way (may be via one foreach loop or 1-2 command lines)?
I tried the below, but it's not working:
```
my @refreshArrayList=("@list1", "@list2", "@list3","@list4", "@list5", "@list6" , "@list7");
foreach m... | 2022/07/08 | [
"https://Stackoverflow.com/questions/72907260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17843701/"
] | The key here is to check the type of the object. If is a string, use the string's length for the order, otherwise assume it is an `int` and use the value itself for the order.
This will throw an exception if there are something else in the object list, for example an instance of some random class.
```
var list = new ... | I hope i understood your sorting intension correctly. You could use a custom comparer to isolate the comparison logic which could check if it is a string or a number. For example,
```
public class Comparer : IComparer<object>
{
public int Compare(object a, object b)
{
var valA = GetValue(a);
va... |
72,907,260 | I have multiple arrays (~32). I want to remove all blank elements from them. How can it be done in a short way (may be via one foreach loop or 1-2 command lines)?
I tried the below, but it's not working:
```
my @refreshArrayList=("@list1", "@list2", "@list3","@list4", "@list5", "@list6" , "@list7");
foreach m... | 2022/07/08 | [
"https://Stackoverflow.com/questions/72907260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17843701/"
] | The key here is to check the type of the object. If is a string, use the string's length for the order, otherwise assume it is an `int` and use the value itself for the order.
This will throw an exception if there are something else in the object list, for example an instance of some random class.
```
var list = new ... | ```
List<dynamic> aLst = new List<dynamic>();
aLst.Add(7);
aLst.Add("aaa");
aLst.Add("aa");
aLst.Add("cccc");
aLst.Add("a");
aLst.Add(2);
aLst.Add(5);
aLst.Add("cccccc");
for (int i = 0; i < aLst.Count; i++)
{
if (aLst[i] is int val)
{
aLst.RemoveAt(i);
aLst.Insert(0, val);
}
}
//v... |
72,907,260 | I have multiple arrays (~32). I want to remove all blank elements from them. How can it be done in a short way (may be via one foreach loop or 1-2 command lines)?
I tried the below, but it's not working:
```
my @refreshArrayList=("@list1", "@list2", "@list3","@list4", "@list5", "@list6" , "@list7");
foreach m... | 2022/07/08 | [
"https://Stackoverflow.com/questions/72907260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17843701/"
] | I hope i understood your sorting intension correctly. You could use a custom comparer to isolate the comparison logic which could check if it is a string or a number. For example,
```
public class Comparer : IComparer<object>
{
public int Compare(object a, object b)
{
var valA = GetValue(a);
va... | ```
List<dynamic> aLst = new List<dynamic>();
aLst.Add(7);
aLst.Add("aaa");
aLst.Add("aa");
aLst.Add("cccc");
aLst.Add("a");
aLst.Add(2);
aLst.Add(5);
aLst.Add("cccccc");
for (int i = 0; i < aLst.Count; i++)
{
if (aLst[i] is int val)
{
aLst.RemoveAt(i);
aLst.Insert(0, val);
}
}
//v... |
257,665 | I have installed Windows and Ubuntu side by side on my system. I heard that it harmful to the hard disk if we access files ont the Windows partition from Ubuntu. Is this true? | 2013/02/18 | [
"https://askubuntu.com/questions/257665",
"https://askubuntu.com",
"https://askubuntu.com/users/133148/"
] | Yes, writing to files on a NTFS partition from Ubuntu can possibly harm your Windows installation. There are mainly two reasons for this:
1. When accessed from Ubuntu Windows file permissions are not respected. This means we have full read and write access to files we may had flagged read-only or hidden from Windows. ... | ubuntu(ext) and window(NTFS) have different kind of partitions , in ubuntu you can mount a windows or NTFS partitons and access your file as a safe way,
but if you want to do some modification and change in files so , keep be alert because both have different file saving, storing structure. so when you want to save fil... |
13,826 | I read [here](http://z80.info/decoding.htm) that if the Z80 encounters e.g. multiple 0xdd prefixes in sequence, for each 0xxdd except the last it acts almost like a NOP, but does not allow interrupts to occur immediately after "executing" the discarded byte.
My question is: If an instruction is prefixed by 0xdd, but n... | 2020/02/17 | [
"https://retrocomputing.stackexchange.com/questions/13826",
"https://retrocomputing.stackexchange.com",
"https://retrocomputing.stackexchange.com/users/16318/"
] | The `0xDD` does not allow an interrupt to happen after it's been fetched, no matter what comes next in the instruction stream.
As Wayne Conrad pointed out, otherwise the CPU would have to time travel into the future to find out what instruction is going to get fetched. | The Z80 increments the program counter while it is performing an opcode fetch. As a consequence, by the time an opcode byte is fetched, the Z80 will be committed to completing the instruction before any interrupt may occur. If a DD or FD happened to be followed by an opcode byte whose meaning would not be affected by i... |
24,539,145 | We're trying to run the command
```
brunch new MySkeleton MyProject
```
this results in the error
```
02 Jul 14:56:30 - error: Error: npm ERR! not found: git
npm ERR!
npm ERR! Failed using git.
npm ERR! This is most likely not a problem with npm itself.
npm ERR! Please check if you have git installed and in your PA... | 2014/07/02 | [
"https://Stackoverflow.com/questions/24539145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/282194/"
] | The skeleton we're using contains references to other brunch pieces which live in github. So it seems that while brunch itself doesn't intrinsically require git, the fact that the brunch ecosystem is hosted in github makes the *installation* of a git a de-facto requirement.
But, just because brunch uses git, that does... | `brunch new MyProject MySkeleton` |
41,528,015 | A year ago I programmed a chess AI using the Alphabeta prunning algorithm. This was relatively straight forward to do in c++. One of the main issues I considered while doing this was making my code efficient. I did this by using having a data type I called a "game" that I passed around through the search tree made by t... | 2017/01/08 | [
"https://Stackoverflow.com/questions/41528015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6343313/"
] | Would be great to see the router definition of your server.
>
> This works fine when navigating in the app but when I refresh it does not work
>
>
>
What do you mean? Does your server reply with a 404 status code?
If so, here's what's happening:
* Nagivate on localhost:3000 : Your browser do a GET request on / ... | You have to make all requests return View that contains root Angular2 app tag. Then no matter what is your URL it'll load the same view and it will let Angular2 handle routing.
[How to handle angular2 route path in Nodejs](https://stackoverflow.com/questions/34847972/how-to-handle-angular2-route-path-in-nodejs) |
41,528,015 | A year ago I programmed a chess AI using the Alphabeta prunning algorithm. This was relatively straight forward to do in c++. One of the main issues I considered while doing this was making my code efficient. I did this by using having a data type I called a "game" that I passed around through the search tree made by t... | 2017/01/08 | [
"https://Stackoverflow.com/questions/41528015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6343313/"
] | Would be great to see the router definition of your server.
>
> This works fine when navigating in the app but when I refresh it does not work
>
>
>
What do you mean? Does your server reply with a 404 status code?
If so, here's what's happening:
* Nagivate on localhost:3000 : Your browser do a GET request on / ... | Have you tried to put in your `index.html` in the `<header>` section something like:
```
<base href="/">
```
or sometimes it also need:
```
<base href="/index.html">
``` |
13,321,431 | As in topic - does anybody know any jQuery plugin or JS script to handle mouse wheel / scrollbar draggin' page scroll, that allows you to call any function after scrolling is done (callback)?
Nicescroll would seem to be really nice solution, except it does not provide any callbacks
Thanks. | 2012/11/10 | [
"https://Stackoverflow.com/questions/13321431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1514386/"
] | In MySql you can't update a table if you have a subquery that references the same table, but you could sostitute the subquery with JOINS. I would do this, it's a trick but it works:
```
UPDATE
inbox inner join (select max(id) as maxid from inbox) mx on inbox.id = mx.maxid
SET inbox.`read` = 0
```
**EDIT:** I see y... | You need to escape [reserved words in MySQL](http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html) like `read` with backticks. You can also use `limit` to update just the greatest record.
```
UPDATE inbox
SET `READ` = 0
order by id desc
limit 1
```
[SQLFiddle example](http://sqlfiddle.com/#!2/998b1/1) |
6,581,293 | This is my function:
```
string GaugeStr;
void someFunction() {
float pie = someFloat();
stringstream ss (stringstream::in | stringstream::out);
ss << pie;
GaugeStr = ss.str();
}
```
When I run the function, it works properly. When I call it however for a second time (`someFunction(); someFunction();... | 2011/07/05 | [
"https://Stackoverflow.com/questions/6581293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/717524/"
] | @Bo spotted a good line (after the question was edited...). I agree.
Here is a suggestion to fix it:
```
GaugeWid.clear();
std::copy(GaugeStr.begin(), GaugeStr.end(), std::back_inserter(GaugeWid));
```
---
@kongr45gpen:
I suspect a threading bug:
* you are doing updates of a variable names GaugeStr (sounds like ... | I just tried it:
```
#include <iostream>
#include <sstream>
using namespace std;
string GaugeStr;
float someFloat() {
return (float) 3.41;
}
void someFunction() {
float pie = someFloat();
stringstream ss (stringstream::in | stringstream::out);
ss << pie;
GaugeStr = ss.str();
}
int main() {... |
6,581,293 | This is my function:
```
string GaugeStr;
void someFunction() {
float pie = someFloat();
stringstream ss (stringstream::in | stringstream::out);
ss << pie;
GaugeStr = ss.str();
}
```
When I run the function, it works properly. When I call it however for a second time (`someFunction(); someFunction();... | 2011/07/05 | [
"https://Stackoverflow.com/questions/6581293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/717524/"
] | This doesn't work
```
std::wstring GaugeWid;
std::copy(GaugeStr.begin(), GaugeStr.end(), GaugeWid.begin());
```
when `GaugeWid` doesn't have a size. And it doesn't convert the characters either.
If you want a wide string, use a `wstringstream`. | I just tried it:
```
#include <iostream>
#include <sstream>
using namespace std;
string GaugeStr;
float someFloat() {
return (float) 3.41;
}
void someFunction() {
float pie = someFloat();
stringstream ss (stringstream::in | stringstream::out);
ss << pie;
GaugeStr = ss.str();
}
int main() {... |
593,831 | I know this has been asked before but I'm having trouble understanding the answers I've found. Basically I want to use
```
sed -i 's/*string*/*/some/directory*/g' file.txt
```
and I can't find a straight answer on how to make `*/some/directory*` not break up the `sed` syntax. | 2020/06/19 | [
"https://unix.stackexchange.com/questions/593831",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/416200/"
] | `sed` allows several syntax delimiters, `/` being only the one most commonly used.
You can just as well say
```
sed -i 's,<string>,<some/directory>,g' file.txt
```
where the `,` now has the function usually performed by the `/`, thereby freeing the latter from its special meaning.
Note, however (as pointed out by ... | Replacing the delimiter with one that is known not to appear in the search or replace strings is a good option when you can find a delimiter that does not appear in them. I tend to use the plus sign, rather than a comma, but that's a matter of habit more than anything.
However, if you can't find a delimiter that doesn... |
593,831 | I know this has been asked before but I'm having trouble understanding the answers I've found. Basically I want to use
```
sed -i 's/*string*/*/some/directory*/g' file.txt
```
and I can't find a straight answer on how to make `*/some/directory*` not break up the `sed` syntax. | 2020/06/19 | [
"https://unix.stackexchange.com/questions/593831",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/416200/"
] | `sed` allows several syntax delimiters, `/` being only the one most commonly used.
You can just as well say
```
sed -i 's,<string>,<some/directory>,g' file.txt
```
where the `,` now has the function usually performed by the `/`, thereby freeing the latter from its special meaning.
Note, however (as pointed out by ... | @AdminBee I have only seen the `#` used as delimiter so far, guess it appears less often in the patterns than a comma:
```
sed -i 's#<string>#<some/directory>#g' file.txt
``` |
593,831 | I know this has been asked before but I'm having trouble understanding the answers I've found. Basically I want to use
```
sed -i 's/*string*/*/some/directory*/g' file.txt
```
and I can't find a straight answer on how to make `*/some/directory*` not break up the `sed` syntax. | 2020/06/19 | [
"https://unix.stackexchange.com/questions/593831",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/416200/"
] | Replacing the delimiter with one that is known not to appear in the search or replace strings is a good option when you can find a delimiter that does not appear in them. I tend to use the plus sign, rather than a comma, but that's a matter of habit more than anything.
However, if you can't find a delimiter that doesn... | @AdminBee I have only seen the `#` used as delimiter so far, guess it appears less often in the patterns than a comma:
```
sed -i 's#<string>#<some/directory>#g' file.txt
``` |
38,572,888 | I need a window function that partitions by some keys (=column names), orders by another column name and returns the rows with top x ranks.
This works fine for ascending order:
```
def getTopX(df: DataFrame, top_x: String, top_key: String, top_value:String): DataFrame ={
val top_keys: List[String] = top_key.spli... | 2016/07/25 | [
"https://Stackoverflow.com/questions/38572888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1325071/"
] | There are two versions of `orderBy`, one that works with strings and one that works with `Column` objects ([API](https://spark.apache.org/docs/latest/api/scala/index.html#org.apache.spark.sql.expressions.WindowSpec)). Your code is using the first version, which does not allow for changing the sort order. You need to sw... | Say for example, if we need to order by a column called `Date` in descending order in the Window function, use the `$` symbol before the column name which will enable us to use the `asc` or `desc` syntax.
```
Window.orderBy($"Date".desc)
```
After specifying the column name in double quotes, give `.desc` which will ... |
38,572,888 | I need a window function that partitions by some keys (=column names), orders by another column name and returns the rows with top x ranks.
This works fine for ascending order:
```
def getTopX(df: DataFrame, top_x: String, top_key: String, top_value:String): DataFrame ={
val top_keys: List[String] = top_key.spli... | 2016/07/25 | [
"https://Stackoverflow.com/questions/38572888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1325071/"
] | There are two versions of `orderBy`, one that works with strings and one that works with `Column` objects ([API](https://spark.apache.org/docs/latest/api/scala/index.html#org.apache.spark.sql.expressions.WindowSpec)). Your code is using the first version, which does not allow for changing the sort order. You need to sw... | Column
```
col = new Column("ts")
col = col.desc()
WindowSpec w = Window.partitionBy("col1", "col2").orderBy(col)
``` |
38,572,888 | I need a window function that partitions by some keys (=column names), orders by another column name and returns the rows with top x ranks.
This works fine for ascending order:
```
def getTopX(df: DataFrame, top_x: String, top_key: String, top_value:String): DataFrame ={
val top_keys: List[String] = top_key.spli... | 2016/07/25 | [
"https://Stackoverflow.com/questions/38572888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1325071/"
] | Say for example, if we need to order by a column called `Date` in descending order in the Window function, use the `$` symbol before the column name which will enable us to use the `asc` or `desc` syntax.
```
Window.orderBy($"Date".desc)
```
After specifying the column name in double quotes, give `.desc` which will ... | Column
```
col = new Column("ts")
col = col.desc()
WindowSpec w = Window.partitionBy("col1", "col2").orderBy(col)
``` |
57,976,704 | The simplest code to demonstrate the issue is this:
Main interface in Kotlin:
```
interface Base <T : Any> {
fun go(field: T)
}
```
Abstract class implementing it and the method:
```
abstract class Impl : Base<Int> {
override fun go(field: Int) {}
}
```
Java class:
```
public class JavaImpl extends Impl {
}... | 2019/09/17 | [
"https://Stackoverflow.com/questions/57976704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2429489/"
] | Looking at the byte code we can see, that the `Impl`-class basically has produced the following function:
```
public go(I)V
```
where the parameter is a primitive integer. Also a synthetic bridge-function (`go(Object)`) is generated, which however would also be generated on the Java-side for such generic functions.
... | You can use `javap` to analyze the problem, showing members of compiled interface and classes.
*javap Base*
```
public interface Base<T> {
public abstract void go(T);
}
```
*javap Impl*
```
public abstract class Impl implements Base<java.lang.Integer> {
public void go(int);
public void go(java.lang.Object);
... |
555,795 | I was generating large XLS (Microsof Ofice Excel spreadsheet) file for a client with XML. The file has 72MB and when I try to open it in LibreOffice it crush on `"General input/output error"` yet when I check the XML with `xmllint myfile.xls` the XML has no input errors.
I'm wondering is there a similar console comman... | 2014/12/02 | [
"https://askubuntu.com/questions/555795",
"https://askubuntu.com",
"https://askubuntu.com/users/106182/"
] | Sorry this is a non-Linux/non-command line trick. Get the free MS Office 365/MS Office Online/OneDrive then check it from the web. | Huh, The whole issue seems to be the LibreOffice itself. I've installed `Gnumeric` which is not Java based (it's C based) and it works well :)
I'm just guessing that it's because LibreOffice is much more heavier (more features per single cell) so I guess Java didn't handle it with memory coverage.
So conclusion: my ... |
56,175,071 | Struggling. Please help.
```
a="/var/www/test/some/page3.html"
```
I need to transform it to
```
a="some/page3.html"
```
I'm trying
```
a=$(sed "s~/var/www/test/~~g" $a)
```
But getting baaaad results. | 2019/05/16 | [
"https://Stackoverflow.com/questions/56175071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11322142/"
] | [Bash parameter parsing](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html).
No need to run a subprocess.
```
$: a="/var/www/test/some/page3.html"
$: echo "${a%/*/*}" # the part you want to get rid of
/var/www/test
$: echo "${a#${a%/*/*}}" # strip that
/some/page3.html
```
If ... | ```
a="/var/www/test/some/page3.html"
a=$(basename $(dirname "$a"))/$(basename "$a")
echo "$a"
```
Output:
```
some/page3.html
``` |
56,175,071 | Struggling. Please help.
```
a="/var/www/test/some/page3.html"
```
I need to transform it to
```
a="some/page3.html"
```
I'm trying
```
a=$(sed "s~/var/www/test/~~g" $a)
```
But getting baaaad results. | 2019/05/16 | [
"https://Stackoverflow.com/questions/56175071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11322142/"
] | [Bash parameter parsing](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html).
No need to run a subprocess.
```
$: a="/var/www/test/some/page3.html"
$: echo "${a%/*/*}" # the part you want to get rid of
/var/www/test
$: echo "${a#${a%/*/*}}" # strip that
/some/page3.html
```
If ... | Use this if you want to print the last 2 path sections:
```
$ a='/var/www/test/some/page3.html'
$ [[ $a =~ [^/]+/[^/]+$ ]] && a="${BASH_REMATCH[0]}"
$ echo "$a"
some/page3.html
```
Use this if you want to remove the first 3 path sections:
```
$ a="/var/www/test/some/page3.html"
$ [[ $a =~ ^(/[^/]+){3}/(.*) ]] && a=... |
21,243 | Firstly a preface: all training's good and especially overhead training where the environment's so unforgiving. Plus lots of practice.
Where around the world are dive locations where you *must* have the cave diving certifications to dive? For example in Mexico or Florida.
What level are these requirements, if any, w... | 2018/12/12 | [
"https://outdoors.stackexchange.com/questions/21243",
"https://outdoors.stackexchange.com",
"https://outdoors.stackexchange.com/users/12122/"
] | Straight up the Answer is almost certainly NO, since unless there is some way of restricting access to a site, any person can put on dive gear and go dive without any experience/training. I am not aware of any countries with laws prohibiting scuba diving in any form except for reward (commercial gain).
The more accep... | Most caves and mines in Germany require a cave certification, and I assume they are all privately owned and locked.
Examples:
* [Nuttlar](https://tauchschule-sauerland.de/bergwerk_tauchvorraussetzungen_hoehlentaucher/): prerequisite Full Cave or other cave certificate plus check dive ([try dive possible](https://tauc... |
21,243 | Firstly a preface: all training's good and especially overhead training where the environment's so unforgiving. Plus lots of practice.
Where around the world are dive locations where you *must* have the cave diving certifications to dive? For example in Mexico or Florida.
What level are these requirements, if any, w... | 2018/12/12 | [
"https://outdoors.stackexchange.com/questions/21243",
"https://outdoors.stackexchange.com",
"https://outdoors.stackexchange.com/users/12122/"
] | Straight up the Answer is almost certainly NO, since unless there is some way of restricting access to a site, any person can put on dive gear and go dive without any experience/training. I am not aware of any countries with laws prohibiting scuba diving in any form except for reward (commercial gain).
The more accep... | Late to the party, but whatever.
There are sites in Australia that are on very well-known but enclosed private property. The only way you can physically access those sites, is by knowing the local protocols.
For example, at one site, you have to park outside a farmer’s house - keeping off his carefully manicured gras... |
6,353,361 | I am using SQLite database for my application.
The Table Structure Goes Like :
```
_id : integer primary key
name : text
day : date
```
I am able to store date in format : `dd-mmmmm-yyyy` eg. `15-June-2011`
But when i tried to retrieve all records filtered by date from the database it returns me null.
```
data... | 2011/06/15 | [
"https://Stackoverflow.com/questions/6353361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/610940/"
] | In java programming you can convert any date format into long (time in milliseconds) and viceversa. My opinion is while storing format the date into long format in java and then store long value of date in database. also while retrieving you can retrieve the long value and then format that as per your expected date for... | The function `strftime('%d-%m-%Y',date('now'))` returns a string with the month in numeric format (from 01 to 12). As far as I can tell from [the docs](http://www.sqlite.org/lang_datefunc.html), there is no format specifier to return the full name of the month.
I think you'll have to store your dates using numerical m... |
15,579,898 | I've below code in one of my php files to fetch data from DB:
```
$products = $this->db->get_rows('SELECT * from products WHERE shop_id='.$_SESSION['shop_id'].'AND tags,title,text LIKE \'%'.$_POST['search'].'%\'');
```
Is it problematic? I mean LIKE operator can be injected?
***Edited***
please provide examples of... | 2013/03/22 | [
"https://Stackoverflow.com/questions/15579898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1020526/"
] | Any operator can be injected without binding.
```
$_POST['search'] = "1%'; DROP TABLE myTable LIKE '%";
```
Would make
```
.... AND tags,title,text LIKE '%1%'; DROP TABLE myTable LIKE '%%'
```
Read on [how to bind parameters](http://php.net/manual/en/pdostatement.bindparam.php). | Of course this can be injected, you need to sanitize your input. Right now you are taking raw post data and inserting it into your SQL statement.
You should run your POST data through some sort of data sanitization, something like mysql\_real\_escape\_string or the like
Or at least prepared statements. let server sid... |
15,579,898 | I've below code in one of my php files to fetch data from DB:
```
$products = $this->db->get_rows('SELECT * from products WHERE shop_id='.$_SESSION['shop_id'].'AND tags,title,text LIKE \'%'.$_POST['search'].'%\'');
```
Is it problematic? I mean LIKE operator can be injected?
***Edited***
please provide examples of... | 2013/03/22 | [
"https://Stackoverflow.com/questions/15579898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1020526/"
] | Of course this can be injected, you need to sanitize your input. Right now you are taking raw post data and inserting it into your SQL statement.
You should run your POST data through some sort of data sanitization, something like mysql\_real\_escape\_string or the like
Or at least prepared statements. let server sid... | Never, ever, use database queries like that, don't construct a string with variables and use it for database activities.
Construct a string that will later on be prepared and executed, by inserting the variables into the string, making them not act like "commands" but as "values".
You can do it like this:
```
$query... |
15,579,898 | I've below code in one of my php files to fetch data from DB:
```
$products = $this->db->get_rows('SELECT * from products WHERE shop_id='.$_SESSION['shop_id'].'AND tags,title,text LIKE \'%'.$_POST['search'].'%\'');
```
Is it problematic? I mean LIKE operator can be injected?
***Edited***
please provide examples of... | 2013/03/22 | [
"https://Stackoverflow.com/questions/15579898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1020526/"
] | Of course this can be injected, you need to sanitize your input. Right now you are taking raw post data and inserting it into your SQL statement.
You should run your POST data through some sort of data sanitization, something like mysql\_real\_escape\_string or the like
Or at least prepared statements. let server sid... | This is really bad. Pulling vars into an SQL statement without cleaning or checking them is a good way to get pwnd. There are several things that people can inject into code. Another injection method to watch out for, 1=1 always returns true.
```
$products = $this->db->get_rows('SELECT * from products WHERE shop_id='.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.