qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
31,733,895 | ```
=IF(SUM(B12-B10)<0,0,SUM(B12-B10))
=IF(SUM(B12-B10)>3270,3270,SUM(B12-B10))
```
I am trying to write an excel formula that will not allow the cell's value to go below 0 or above 3270. I have the two formulas above but I am not sure how to get them both into once cell.
Does anyone know how to do this? | 2015/07/30 | [
"https://Stackoverflow.com/questions/31733895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1723258/"
] | You put the second IF statement in the False of the First IF statement.
```
=IF(SUM(B12-B10)<0,0,IF(SUM(B12-B10)>3270,3270,SUM(B12-B10)))
``` | This should work:
```
=IF(SUM(B12-B10)<0,0,IF(SUM(B12-B10)>3270,3270,SUM(B12-B10)))
```
Cheers |
31,733,895 | ```
=IF(SUM(B12-B10)<0,0,SUM(B12-B10))
=IF(SUM(B12-B10)>3270,3270,SUM(B12-B10))
```
I am trying to write an excel formula that will not allow the cell's value to go below 0 or above 3270. I have the two formulas above but I am not sure how to get them both into once cell.
Does anyone know how to do this? | 2015/07/30 | [
"https://Stackoverflow.com/questions/31733895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1723258/"
] | You put the second IF statement in the False of the First IF statement.
```
=IF(SUM(B12-B10)<0,0,IF(SUM(B12-B10)>3270,3270,SUM(B12-B10)))
``` | You don't need the *SUM()* function:
```
=IF(B12-B10<0,0,IF(B12-B10>3270,3270,B12-B10))
``` |
31,733,895 | ```
=IF(SUM(B12-B10)<0,0,SUM(B12-B10))
=IF(SUM(B12-B10)>3270,3270,SUM(B12-B10))
```
I am trying to write an excel formula that will not allow the cell's value to go below 0 or above 3270. I have the two formulas above but I am not sure how to get them both into once cell.
Does anyone know how to do this? | 2015/07/30 | [
"https://Stackoverflow.com/questions/31733895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1723258/"
] | You don't need the *SUM()* function:
```
=IF(B12-B10<0,0,IF(B12-B10>3270,3270,B12-B10))
``` | This should work:
```
=IF(SUM(B12-B10)<0,0,IF(SUM(B12-B10)>3270,3270,SUM(B12-B10)))
```
Cheers |
1,229,890 | **Update**
[The official Release Notes](https://wiki.ubuntu.com/FocalFossa/ReleaseNotes#Upgrading_from_Ubuntu_18.04_LTS_or_19.10) appear to have been updated recently (as of writing this the last update appears to have taken place on 3rd of June) to include the following statement:
>
> The **-d switch** is necessary... | 2020/04/23 | [
"https://askubuntu.com/questions/1229890",
"https://askubuntu.com",
"https://askubuntu.com/users/16023/"
] | The **development release** is the pre-release version of Ubuntu. It's the next future release.
* Using the *development release* means you want to be a *tester*. You want to discover problems and translate strings and file bugs. If that doesn't sound fun, then DON'T run the development release.
* Using `do-release-up... | The offical upgrade path from LTS to LTS will be opened after 20.04.1 is released.
To override this, option `-d` that means "development" is used.
It is a "forced" upgrade, that's why you get the "development release" message. |
1,229,890 | **Update**
[The official Release Notes](https://wiki.ubuntu.com/FocalFossa/ReleaseNotes#Upgrading_from_Ubuntu_18.04_LTS_or_19.10) appear to have been updated recently (as of writing this the last update appears to have taken place on 3rd of June) to include the following statement:
>
> The **-d switch** is necessary... | 2020/04/23 | [
"https://askubuntu.com/questions/1229890",
"https://askubuntu.com",
"https://askubuntu.com/users/16023/"
] | The offical upgrade path from LTS to LTS will be opened after 20.04.1 is released.
To override this, option `-d` that means "development" is used.
It is a "forced" upgrade, that's why you get the "development release" message. | No, the “Final Release” is ***not*** a “Development Release". Rather, the former refers to a **clean install** of Ubuntu, whereas the latter (here) refers to **upgrading** an existing Ubuntu installation:
* "**Final Release**" refers only to a [clean install](https://askubuntu.com/questions/5466/is-a-clean-install-bet... |
1,229,890 | **Update**
[The official Release Notes](https://wiki.ubuntu.com/FocalFossa/ReleaseNotes#Upgrading_from_Ubuntu_18.04_LTS_or_19.10) appear to have been updated recently (as of writing this the last update appears to have taken place on 3rd of June) to include the following statement:
>
> The **-d switch** is necessary... | 2020/04/23 | [
"https://askubuntu.com/questions/1229890",
"https://askubuntu.com",
"https://askubuntu.com/users/16023/"
] | The **development release** is the pre-release version of Ubuntu. It's the next future release.
* Using the *development release* means you want to be a *tester*. You want to discover problems and translate strings and file bugs. If that doesn't sound fun, then DON'T run the development release.
* Using `do-release-up... | No, the “Final Release” is ***not*** a “Development Release". Rather, the former refers to a **clean install** of Ubuntu, whereas the latter (here) refers to **upgrading** an existing Ubuntu installation:
* "**Final Release**" refers only to a [clean install](https://askubuntu.com/questions/5466/is-a-clean-install-bet... |
43,281 | I really don't know Chinese but I just started to study in China online. I am preparing a report and I need to mention my professor's name. In Chinese it's written as 刘雨欣(liuyuxin), this means 刘(liu) is her surname. Should I write Professor Liu Yuxin or Professor Yuxin Liu? | 2021/03/20 | [
"https://chinese.stackexchange.com/questions/43281",
"https://chinese.stackexchange.com",
"https://chinese.stackexchange.com/users/27739/"
] | Both 'Professor **Liu** Yuxin' and 'Professor Yuxin **Liu**' are acceptable (apply the first name first or the last name first format depend on the audience). To be safe, just highlight the family name with an underline or bold fond.
It is easier just use the last name 刘教授 (Professor Liu)
*You can call your professor... | 1. Just to supplement, you may ask if your professor has a specific preference / or is famously known for her name in the Western or Chinese order. Consider Lee Kwan Yew (李光耀), but Yo Yo Ma (馬友友).
2. There may also be a good justification to adopt the Western order, especially if your professor's work needs to be cited... |
57,974,146 | I was wondering what's the best approach for handling an autosubmit of a code that a user types in? I have this so far but idk if this works. I tried testing it but I wasn't performing as I expected.
```
This is the form control:
<div className="form-group">
<input
type="tel"
autoCompl... | 2019/09/17 | [
"https://Stackoverflow.com/questions/57974146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2039574/"
] | There is no need to use debouncing for such small task,just check lenght of code in setState's call back and submit.
```
changeCode = e => {
this.setState({ code: e.target.value },()=>{
if(this.state.code.length == 6) {
this.verifyCode();
}
});
};
``` | You can try with throttle and debounce:
```
if (this.verificationCode.length < 5) {
throttle(500, this.verifyCode)
} else {
debounce(500, this.verifyCode);
}
``` |
12,918 | The word "dormitory" means "sleeping place". Is there any similar word for "eating place"? | 2011/02/16 | [
"https://english.stackexchange.com/questions/12918",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/2019/"
] | There's also *refectory*:
>
> A refectory (also frater, frater house, fratery) is a dining room, especially in monasteries, boarding schools and academic institutions. One of the places it is most often used today is in graduate seminaries. It is derived from the Latin reficere: to remake or restore, via Late Latin ... | Some common "eating place" words are:
>
> bar, cafeteria, café, canteen, chophouse, coffee shop, diner, dining room, dive, doughtnut shop, drive-in, eatery, eating house, eating place, fast-food place, greasy spoon, grill, hamburger stand, hashery, hideaway, hotdog stand, inn, joint\*, luncheonette, lunchroom, night ... |
12,918 | The word "dormitory" means "sleeping place". Is there any similar word for "eating place"? | 2011/02/16 | [
"https://english.stackexchange.com/questions/12918",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/2019/"
] | There's also *refectory*:
>
> A refectory (also frater, frater house, fratery) is a dining room, especially in monasteries, boarding schools and academic institutions. One of the places it is most often used today is in graduate seminaries. It is derived from the Latin reficere: to remake or restore, via Late Latin ... | Maybe you're looking for the word "**eatery**".
>
> One of the best eateries in town.
>
>
>
Also the phrase "**eating place**" is very common.
There are some other words that I don't think you're looking for them. But you can also check them out.
Other words:
***cafe***, **self-service**, **diner**, **bistro**,... |
12,918 | The word "dormitory" means "sleeping place". Is there any similar word for "eating place"? | 2011/02/16 | [
"https://english.stackexchange.com/questions/12918",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/2019/"
] | Some common "eating place" words are:
>
> bar, cafeteria, café, canteen, chophouse, coffee shop, diner, dining room, dive, doughtnut shop, drive-in, eatery, eating house, eating place, fast-food place, greasy spoon, grill, hamburger stand, hashery, hideaway, hotdog stand, inn, joint\*, luncheonette, lunchroom, night ... | A restaurant, a diner, an eatery, and a café are all places where people go to eat meals. |
12,918 | The word "dormitory" means "sleeping place". Is there any similar word for "eating place"? | 2011/02/16 | [
"https://english.stackexchange.com/questions/12918",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/2019/"
] | There are lots of words for "eating place": dining room, cafeteria, restaurant, mess hall (military), galley (Navy), and so on.
Be aware that "dormitory" has a specific meaning, and is usually associated with schools, especially colleges. There are other words for sleeping place, including bedroom. If you're wondering... | Some common "eating place" words are:
>
> bar, cafeteria, café, canteen, chophouse, coffee shop, diner, dining room, dive, doughtnut shop, drive-in, eatery, eating house, eating place, fast-food place, greasy spoon, grill, hamburger stand, hashery, hideaway, hotdog stand, inn, joint\*, luncheonette, lunchroom, night ... |
12,918 | The word "dormitory" means "sleeping place". Is there any similar word for "eating place"? | 2011/02/16 | [
"https://english.stackexchange.com/questions/12918",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/2019/"
] | There's also *refectory*:
>
> A refectory (also frater, frater house, fratery) is a dining room, especially in monasteries, boarding schools and academic institutions. One of the places it is most often used today is in graduate seminaries. It is derived from the Latin reficere: to remake or restore, via Late Latin ... | There is no single word for eating place, there are many.
* Restaurant
* Diner
* Cafeteria
* Eatery
You have to make a choice. |
12,918 | The word "dormitory" means "sleeping place". Is there any similar word for "eating place"? | 2011/02/16 | [
"https://english.stackexchange.com/questions/12918",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/2019/"
] | There's also *refectory*:
>
> A refectory (also frater, frater house, fratery) is a dining room, especially in monasteries, boarding schools and academic institutions. One of the places it is most often used today is in graduate seminaries. It is derived from the Latin reficere: to remake or restore, via Late Latin ... | A restaurant, a diner, an eatery, and a café are all places where people go to eat meals. |
12,918 | The word "dormitory" means "sleeping place". Is there any similar word for "eating place"? | 2011/02/16 | [
"https://english.stackexchange.com/questions/12918",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/2019/"
] | There's also *refectory*:
>
> A refectory (also frater, frater house, fratery) is a dining room, especially in monasteries, boarding schools and academic institutions. One of the places it is most often used today is in graduate seminaries. It is derived from the Latin reficere: to remake or restore, via Late Latin ... | There are lots of words for "eating place": dining room, cafeteria, restaurant, mess hall (military), galley (Navy), and so on.
Be aware that "dormitory" has a specific meaning, and is usually associated with schools, especially colleges. There are other words for sleeping place, including bedroom. If you're wondering... |
12,918 | The word "dormitory" means "sleeping place". Is there any similar word for "eating place"? | 2011/02/16 | [
"https://english.stackexchange.com/questions/12918",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/2019/"
] | Maybe you're looking for the word "**eatery**".
>
> One of the best eateries in town.
>
>
>
Also the phrase "**eating place**" is very common.
There are some other words that I don't think you're looking for them. But you can also check them out.
Other words:
***cafe***, **self-service**, **diner**, **bistro**,... | There is no single word for eating place, there are many.
* Restaurant
* Diner
* Cafeteria
* Eatery
You have to make a choice. |
12,918 | The word "dormitory" means "sleeping place". Is there any similar word for "eating place"? | 2011/02/16 | [
"https://english.stackexchange.com/questions/12918",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/2019/"
] | Maybe you're looking for the word "**eatery**".
>
> One of the best eateries in town.
>
>
>
Also the phrase "**eating place**" is very common.
There are some other words that I don't think you're looking for them. But you can also check them out.
Other words:
***cafe***, **self-service**, **diner**, **bistro**,... | A restaurant, a diner, an eatery, and a café are all places where people go to eat meals. |
12,918 | The word "dormitory" means "sleeping place". Is there any similar word for "eating place"? | 2011/02/16 | [
"https://english.stackexchange.com/questions/12918",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/2019/"
] | There are lots of words for "eating place": dining room, cafeteria, restaurant, mess hall (military), galley (Navy), and so on.
Be aware that "dormitory" has a specific meaning, and is usually associated with schools, especially colleges. There are other words for sleeping place, including bedroom. If you're wondering... | There is no single word for eating place, there are many.
* Restaurant
* Diner
* Cafeteria
* Eatery
You have to make a choice. |
64,431,701 | I have a number of lists and I want to paste everything in the first row (which I do not need but also do not want to get rid of it) such that the data:
```
# A tibble: 4 x 7
financialVariable Currency `2019` `2020` `2021` `2022` `2023`
<chr> <chr> <chr> <chr> <chr> <chr> ... | 2020/10/19 | [
"https://Stackoverflow.com/questions/64431701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8959427/"
] | This seems like a bad idea... but here's a way to do it.
```
lapply(myList, function(x) {
new_val = do.call(paste, c(x[1, ], sep = "|"))
x[1, ] = NA
x$NewCol = NA
x$NewCol[1] = new_val
x
})
# $company1
# # A tibble: 4 x 7
# # Groups: financialVariable [4]
# financialVariable `2019` `2020` `2021` `... | Here is one possibility using an anonymous function:
```
myList %>%
map(function(x){
nc <- x %>% ungroup() %>% slice(1) %>% gather(date, val, -1) %>% pull(val) %>% paste0(collapse = "|")
x %>% ungroup %>%
mutate(newcol = if_else(1:n() == 1, nc, NA_character_))
})
``` |
64,431,701 | I have a number of lists and I want to paste everything in the first row (which I do not need but also do not want to get rid of it) such that the data:
```
# A tibble: 4 x 7
financialVariable Currency `2019` `2020` `2021` `2022` `2023`
<chr> <chr> <chr> <chr> <chr> <chr> ... | 2020/10/19 | [
"https://Stackoverflow.com/questions/64431701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8959427/"
] | This seems like a bad idea... but here's a way to do it.
```
lapply(myList, function(x) {
new_val = do.call(paste, c(x[1, ], sep = "|"))
x[1, ] = NA
x$NewCol = NA
x$NewCol[1] = new_val
x
})
# $company1
# # A tibble: 4 x 7
# # Groups: financialVariable [4]
# financialVariable `2019` `2020` `2021` `... | here is an option with `reduce` and `map`. We loop over the `list` with `map`, `ungroup` to remove the group attributes, then use `case_when` to create a logical index to paste (`str_c`) only the first row. By default, the other elements will be filled by `NA`
```
library(dplyr)
library(purrr)
library(stringr)
map(myL... |
53,124 | In the light of the [recently-added feature](https://meta.stackexchange.com/questions/3155/show-updates-to-favorite-questions-in-recent-activity/3808#3808) to automatically notify the user of any changes to "favorited" questions, this term "favorite" is becoming less and less accurate. [Some users don't even realize th... | 2010/06/09 | [
"https://meta.stackexchange.com/questions/53124",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/132636/"
] | I wouldn't suggest the word "followed" because the term has a [different connotation](http://area51.stackexchange.com/faq) in Area 51. If there is a need for different terminology, I would suggest "bookmark." The already-existing web term is consistent with its function. | If it's your "favorite", why wouldn't you be interested in things happening to it?
It just seems odd to me that one would say
>
> This question is one of my favorites!
>
>
>
And then
>
> ... but I am totally uninterested in any new answers or changes to it!
>
>
>
That said, there is this request, which I ... |
53,124 | In the light of the [recently-added feature](https://meta.stackexchange.com/questions/3155/show-updates-to-favorite-questions-in-recent-activity/3808#3808) to automatically notify the user of any changes to "favorited" questions, this term "favorite" is becoming less and less accurate. [Some users don't even realize th... | 2010/06/09 | [
"https://meta.stackexchange.com/questions/53124",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/132636/"
] | The name “favorite” is definitely misleading. E.g. see [Why not get reputation when your question is marked a favorite by somebody?](https://meta.stackexchange.com/questions/8457/why-not-get-reputation-when-your-question-is-marked-a-favorite-by-somebody/97314#97314)
If favorites will be renamed to BOOKMARKs, it will a... | If it's your "favorite", why wouldn't you be interested in things happening to it?
It just seems odd to me that one would say
>
> This question is one of my favorites!
>
>
>
And then
>
> ... but I am totally uninterested in any new answers or changes to it!
>
>
>
That said, there is this request, which I ... |
53,124 | In the light of the [recently-added feature](https://meta.stackexchange.com/questions/3155/show-updates-to-favorite-questions-in-recent-activity/3808#3808) to automatically notify the user of any changes to "favorited" questions, this term "favorite" is becoming less and less accurate. [Some users don't even realize th... | 2010/06/09 | [
"https://meta.stackexchange.com/questions/53124",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/132636/"
] | I wouldn't suggest the word "followed" because the term has a [different connotation](http://area51.stackexchange.com/faq) in Area 51. If there is a need for different terminology, I would suggest "bookmark." The already-existing web term is consistent with its function. | The name “favorite” is definitely misleading. E.g. see [Why not get reputation when your question is marked a favorite by somebody?](https://meta.stackexchange.com/questions/8457/why-not-get-reputation-when-your-question-is-marked-a-favorite-by-somebody/97314#97314)
If favorites will be renamed to BOOKMARKs, it will a... |
15,160,207 | [Apparently](http://wiki.postgresql.org/wiki/Working_with_Dates_and_Times_in_PostgreSQL), PostgreSQL doesn't have `DATEADD`, because you can just use the `+` or `-` operators.
I need to add a number of hours to a date, which is accomplished like this:
```
date_field + interval '8.25 hour'
```
Which is great, but I... | 2013/03/01 | [
"https://Stackoverflow.com/questions/15160207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] | Since you want to add *hours*, it should rather be:
```
SELECT date_field + interval '1 hour' * start_time
```
`start_time` can be any numerical value.
`'1 hour'` can be shortened to `'1h'`.
[`interval` can be multiplied by a scalar.](https://www.postgresql.org/docs/current/functions-datetime.html#OPERATORS-DA... | Found the answer, [in another SO question](https://stackoverflow.com/questions/10909902/how-to-add-number-of-days-in-postgresql-datetime):
```
date + interval '1' minute * FLOOR(start_time * 60)
```
Hope that helps anyone |
15,160,207 | [Apparently](http://wiki.postgresql.org/wiki/Working_with_Dates_and_Times_in_PostgreSQL), PostgreSQL doesn't have `DATEADD`, because you can just use the `+` or `-` operators.
I need to add a number of hours to a date, which is accomplished like this:
```
date_field + interval '8.25 hour'
```
Which is great, but I... | 2013/03/01 | [
"https://Stackoverflow.com/questions/15160207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] | Found the answer, [in another SO question](https://stackoverflow.com/questions/10909902/how-to-add-number-of-days-in-postgresql-datetime):
```
date + interval '1' minute * FLOOR(start_time * 60)
```
Hope that helps anyone | If anyone wants to add in time stamp then
```
select time '05:00' - interval '2 hours'
``` |
15,160,207 | [Apparently](http://wiki.postgresql.org/wiki/Working_with_Dates_and_Times_in_PostgreSQL), PostgreSQL doesn't have `DATEADD`, because you can just use the `+` or `-` operators.
I need to add a number of hours to a date, which is accomplished like this:
```
date_field + interval '8.25 hour'
```
Which is great, but I... | 2013/03/01 | [
"https://Stackoverflow.com/questions/15160207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] | Found the answer, [in another SO question](https://stackoverflow.com/questions/10909902/how-to-add-number-of-days-in-postgresql-datetime):
```
date + interval '1' minute * FLOOR(start_time * 60)
```
Hope that helps anyone | Another option is to use `make_interval()`
```
date_field + make_interval(hours => start_time)
``` |
15,160,207 | [Apparently](http://wiki.postgresql.org/wiki/Working_with_Dates_and_Times_in_PostgreSQL), PostgreSQL doesn't have `DATEADD`, because you can just use the `+` or `-` operators.
I need to add a number of hours to a date, which is accomplished like this:
```
date_field + interval '8.25 hour'
```
Which is great, but I... | 2013/03/01 | [
"https://Stackoverflow.com/questions/15160207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] | Since you want to add *hours*, it should rather be:
```
SELECT date_field + interval '1 hour' * start_time
```
`start_time` can be any numerical value.
`'1 hour'` can be shortened to `'1h'`.
[`interval` can be multiplied by a scalar.](https://www.postgresql.org/docs/current/functions-datetime.html#OPERATORS-DA... | The one worked for me is
```
SELECT date_field + interval '1' HOUR * start_time
```
**start\_time** can be any numerical value. |
15,160,207 | [Apparently](http://wiki.postgresql.org/wiki/Working_with_Dates_and_Times_in_PostgreSQL), PostgreSQL doesn't have `DATEADD`, because you can just use the `+` or `-` operators.
I need to add a number of hours to a date, which is accomplished like this:
```
date_field + interval '8.25 hour'
```
Which is great, but I... | 2013/03/01 | [
"https://Stackoverflow.com/questions/15160207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] | Since you want to add *hours*, it should rather be:
```
SELECT date_field + interval '1 hour' * start_time
```
`start_time` can be any numerical value.
`'1 hour'` can be shortened to `'1h'`.
[`interval` can be multiplied by a scalar.](https://www.postgresql.org/docs/current/functions-datetime.html#OPERATORS-DA... | If anyone wants to add in time stamp then
```
select time '05:00' - interval '2 hours'
``` |
15,160,207 | [Apparently](http://wiki.postgresql.org/wiki/Working_with_Dates_and_Times_in_PostgreSQL), PostgreSQL doesn't have `DATEADD`, because you can just use the `+` or `-` operators.
I need to add a number of hours to a date, which is accomplished like this:
```
date_field + interval '8.25 hour'
```
Which is great, but I... | 2013/03/01 | [
"https://Stackoverflow.com/questions/15160207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] | Since you want to add *hours*, it should rather be:
```
SELECT date_field + interval '1 hour' * start_time
```
`start_time` can be any numerical value.
`'1 hour'` can be shortened to `'1h'`.
[`interval` can be multiplied by a scalar.](https://www.postgresql.org/docs/current/functions-datetime.html#OPERATORS-DA... | Another option is to use `make_interval()`
```
date_field + make_interval(hours => start_time)
``` |
15,160,207 | [Apparently](http://wiki.postgresql.org/wiki/Working_with_Dates_and_Times_in_PostgreSQL), PostgreSQL doesn't have `DATEADD`, because you can just use the `+` or `-` operators.
I need to add a number of hours to a date, which is accomplished like this:
```
date_field + interval '8.25 hour'
```
Which is great, but I... | 2013/03/01 | [
"https://Stackoverflow.com/questions/15160207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] | The one worked for me is
```
SELECT date_field + interval '1' HOUR * start_time
```
**start\_time** can be any numerical value. | If anyone wants to add in time stamp then
```
select time '05:00' - interval '2 hours'
``` |
15,160,207 | [Apparently](http://wiki.postgresql.org/wiki/Working_with_Dates_and_Times_in_PostgreSQL), PostgreSQL doesn't have `DATEADD`, because you can just use the `+` or `-` operators.
I need to add a number of hours to a date, which is accomplished like this:
```
date_field + interval '8.25 hour'
```
Which is great, but I... | 2013/03/01 | [
"https://Stackoverflow.com/questions/15160207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] | The one worked for me is
```
SELECT date_field + interval '1' HOUR * start_time
```
**start\_time** can be any numerical value. | Another option is to use `make_interval()`
```
date_field + make_interval(hours => start_time)
``` |
15,160,207 | [Apparently](http://wiki.postgresql.org/wiki/Working_with_Dates_and_Times_in_PostgreSQL), PostgreSQL doesn't have `DATEADD`, because you can just use the `+` or `-` operators.
I need to add a number of hours to a date, which is accomplished like this:
```
date_field + interval '8.25 hour'
```
Which is great, but I... | 2013/03/01 | [
"https://Stackoverflow.com/questions/15160207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] | If anyone wants to add in time stamp then
```
select time '05:00' - interval '2 hours'
``` | Another option is to use `make_interval()`
```
date_field + make_interval(hours => start_time)
``` |
54,183,635 | [Picture of error](https://i.stack.imgur.com/ZXQbM.png)
First program I make after hello world. Firstname, lastname and age. When using String on age, everything works as expected. I was told to use Int on age instead of String, but when I changed to Int and try to compile, I get this error: "cannot find symbol". I gu... | 2019/01/14 | [
"https://Stackoverflow.com/questions/54183635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10912362/"
] | The type signatures of each give you a hint, but a rough summary is:
- Consumer `F -> ()`: Gets the effect object as an argument and calls something as an effect. Example: `Toast.makeText(context, effect.message(), duration).show();`
* Action `() -> ()`: Same as consumer but you don't need anything from the effect obj... | Here is how each of these work,
```
╔═════════════╤═══════════════════════════╤═════════════════════╗
║ Type │ Receives effect object? │ Can produce events? ║
╠═════════════╪═══════════════════════════╪═════════════════════╣
║ Action │ No │ No ║
║ Consumer │ ... |
178 | This question [Kiel traduki Esperante tiun ĉi ludkarton?](https://esperanto.stackexchange.com/questions/2486/kiel-traduki-esperante-tiun-%c4%89i-ludkarton) requests a translation of the text of a playing card, not any specific word or phrase. Is it outside the topic for this site? | 2016/12/22 | [
"https://esperanto.meta.stackexchange.com/questions/178",
"https://esperanto.meta.stackexchange.com",
"https://esperanto.meta.stackexchange.com/users/60/"
] | word-difference: you ask for the difference between **words**
word-choice: you ask which word you **should** use in a **specific context**
The emphasis can be very different. With "word-choice" you can ask opinion about if the word is uzinda or is useable in a specific context. "word-difference" is much more about th... | No, since they aren't synonyms. [word-difference](https://esperanto.stackexchange.com/questions/tagged/word-difference "show questions tagged 'word-difference'") is for questions asking about the difference between two words; [word-choice](https://esperanto.stackexchange.com/questions/tagged/word-choice "show questions... |
1,955,292 | We have "$f'(x)>0$ in interval $I\implies f(x)$ strictly increasing in interval $I$".
However, the converse is not true.
A frequently cited example is the function $f(x)=x^3$, which is strictly increasing but $f'(0)=0$.
Here comes my question:
>
> What is the necessary and sufficient condition of $f'(x)$ to... | 2016/10/05 | [
"https://math.stackexchange.com/questions/1955292",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/248555/"
] | Assume $f$ is differentiable on an interval $I$ and $f'(x)\ge 0$ on $I.$ Let $Z = \{x \in I: f'(x)=0\}.$ Then $f$ is strictly increasing on $I$ iff $Z$ contains no interval. (Here "interval" means "interval of positive length".)
Proof: Suppose $f$ is strictly increasing on $I.$ If $Z$ contained an interval $J,$ then $... | If $f(x)$ satisfies $f'(x)\ge 0$ for all $x\in \mathbb R$ and if for every $x\_0\in \mathbb R$ with $f'(x\_0)=0$, there is a neighborhood around $x\_0$ , such that $f'(x)\ne 0$ within this neighborhood (except $x\_0$) (in other words : isolated roots of the derivate ) , then $f(x)$ is strictly increasing on $\mathbb R$... |
3,538,904 | How do they code the logic of a user interface running on embedded hardware. Microwave ovens, flat screen televisions, portable DVD players and even a digital watches these days have complex user interfaces. Are there tools / frameworks available to remove all the dirty work or are the developers using IF ELSE kind of ... | 2010/08/21 | [
"https://Stackoverflow.com/questions/3538904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/427287/"
] | I've used the [**Quantum Platform**](http://www.state-machine.com/products/) family of frameworks from Quantum Leaps for several embedded products with user interfaces (and those without UIs as well).
The QP is a framework for event-driven programming (which essentially all embedded systems are). User interfaces in pa... | *Are there tools/frameworks to remove all the dirty work ..* ? Yes, there are. They are called embedded OS'es and RTOS'es. As a rule, they help in handling interrupts generated by timers, buttons, and other controls, they contain hardware abstraction levels, they include various communication protocol stacks and etc. S... |
3,538,904 | How do they code the logic of a user interface running on embedded hardware. Microwave ovens, flat screen televisions, portable DVD players and even a digital watches these days have complex user interfaces. Are there tools / frameworks available to remove all the dirty work or are the developers using IF ELSE kind of ... | 2010/08/21 | [
"https://Stackoverflow.com/questions/3538904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/427287/"
] | I've used the [**Quantum Platform**](http://www.state-machine.com/products/) family of frameworks from Quantum Leaps for several embedded products with user interfaces (and those without UIs as well).
The QP is a framework for event-driven programming (which essentially all embedded systems are). User interfaces in pa... | With embedded you have the freedom to do whatever you want, you are not confined by the limits of an operating system or worse an API. Embedded systems can be event driven, esp if power is a concern (battery powered) because you essentially want to go to low power and only wake up for events. But you can also use no in... |
17,641,774 | I've been trying to make a div stretch down to my footer, with limited success. I've tried using jQuery to do this but it has some issues:
```
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$(window).resize(function(){
var height = $(this).height() - $("#banner-wrapper").height() - $("#footer-... | 2013/07/14 | [
"https://Stackoverflow.com/questions/17641774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2581300/"
] | This solution is far from efficient:
```
private static void Main()
{
List<List<int>> list = new List<List<int>>
{
new List<int>() {1, 3, 6}, //Booking 1
new List<int>() {1, 2, 6}, //Booking 2
new List<int>() {1}, //Booking 3
n... | A simple way to look at this problem would be to choose from all combinations of the list of values, where every value in the combination is unique.
First figure out what all the combinations of values are.
```
public static IEnumerable<IList<T>> Combinations<T>(IEnumerable<IList<T>> collections)
{
if (collection... |
17,641,774 | I've been trying to make a div stretch down to my footer, with limited success. I've tried using jQuery to do this but it has some issues:
```
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$(window).resize(function(){
var height = $(this).height() - $("#banner-wrapper").height() - $("#footer-... | 2013/07/14 | [
"https://Stackoverflow.com/questions/17641774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2581300/"
] | Solve by recursion:
```
static IEnumerable<List<int>> GetCombinations(IEnumerable<List<int>> lists, IEnumerable<int> selected)
{
if (lists.Any())
{
var remainingLists = lists.Skip(1);
foreach (var item in lists.First().Where(x => !selected.Contains(x)))
foreach (var combo in GetComb... | A simple way to look at this problem would be to choose from all combinations of the list of values, where every value in the combination is unique.
First figure out what all the combinations of values are.
```
public static IEnumerable<IList<T>> Combinations<T>(IEnumerable<IList<T>> collections)
{
if (collection... |
98,164 | I'm looking for sort of an 'app-store' or Google Play store type functionality for apt-get packages. What I'd really like to do is select a category, like 'Music' or 'Internet' and see the list of available packages in that category with their summaries.
It'd be even better if the packages had ratings or reviews. Does... | 2013/10/30 | [
"https://unix.stackexchange.com/questions/98164",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/32762/"
] | Such a thing already exists for Ubuntu:
>
> <https://apps.ubuntu.com/>
>
>
>
You can browse by category and search for packages using the web interface. Each application also displays its rating and any reviews it has received - just like the Software Center in Ubuntu.
:
1. The classic: `synaptic`, you just need to click on the "Sections" button on the bottom left to browse by section. Should work on all Debian based distros and as far as I know is installed by default on all ... |
44,827,615 | I am trying to create a message box that will give the user the option to continue or stop if their search comes up with more than 1000 results. I have the message box made, but I don't know how to code the vbYes and the vbNo to either continue on with the code (vbYes) or to end the script (vbNO).
Here is my code.
... | 2017/06/29 | [
"https://Stackoverflow.com/questions/44827615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8167828/"
] | If I understood your problem, you have to compare the "Results" variable if is vbYes or vbNo.
Below a little and simple example.
```
If MsgBox("Continue?", vbYesNo,"Confirmation") = vbYes Then
'code if yes
Else
'End
End If
```
Hope that helps. ;) | `vbYes` is a constant, a member of an enum called `VbMsgBoxResult` that defines a bunch of related constants, including `vbYes` and `vbNo`.
```
If vbYes Then
```
That's like saying
```
If 42 Then
```
You have a constant expression that evaluates to a `Long` integer, and an `If` statement works with a *Boolean exp... |
58,284,520 | Imagine you have Angular service without provideIn, so it is available only in certain components and their children. Now one such component opens MatDialog -- is it possible to have that service injected there?
As I see by default Angular does not count MatDialog component as a child of caller component and also I d... | 2019/10/08 | [
"https://Stackoverflow.com/questions/58284520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4019404/"
] | All you have to do is provide the dialog.open method with ViewContainerRef where the desired service instance lives. 'VERY\_IMPORTANT\_SERVICE' will be available for injection in 'SomeComponent'. See the code below
```
@Component({
selector: 'cmp',
providers: [ VERY_IMPORTANT_SERVICE ]
})
export class Componen... | If you do not provide your service into the root, then you have to provide it either in
* An Angular feature (component, directive ...)
* An Angular module
Providing it into a feature implies that everytime that feature gets created, it gets an instance of that service.
If you provide it in the module, it implies ... |
27,955,697 | I am trying to create a python script that can receive multiple files as input through a command line.
Right now I am working with a method of using one file as input:
I would presently call the function using: `python function_name.py input_file.txt`
Using code that looks like this:
```
import sys
def function_nam... | 2015/01/15 | [
"https://Stackoverflow.com/questions/27955697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3875527/"
] | sys.argv is a list of arguments passed to the script. The first will be the name of the script (scriptname.py), and the rest will be whatever you type after it.
If you run `python function_name.py *.txt`, this will be expanded by the shell, to `python function_name.py 1.txt 2.txt blah.txt wibble.com.exe.extension.txt`... | You might want to check out the [glob](https://docs.python.org/2/library/glob.html) module. You could feed your command line into `glob.glob`, and it will give you a list of files matching the wildcards you sent in. Then you can work on them as you see fit |
14,565,063 | I setup Devise on `User` model with its default options.
I also have a `Company` model that needs to add data added whenever a user registers. A company owner setups a `User` to login with and a `Company` profile, both in the same form.
I setup `Company` model with `has_many :users` and `User` with `has_one :company`... | 2013/01/28 | [
"https://Stackoverflow.com/questions/14565063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/703670/"
] | Note that array indexes start with **zero**, try to decrement the value retrieved from the int array.
```
for (int i=0; i<intArray.length; i++) {
if(intArray[i] != 0) {
System.out.println( stringArray[ intArray[i]-1 ] );
}
}
``` | your loop is fine, but you must ensure that the int array has int values in the [0..stringArray) range. That is, if your stringArray has size 5, the valid random numbers are in the closed interval [0,1,2,3,4] |
48,045,884 | I'd like to define a function `f()` as follows (just an example) :
```
val f: (vararg strings: String) -> Unit = { for (str in it) println(str) }
```
so that I could invoke it with `f("a","b","c")`. For the above definition of `f()` I get the compilation error, pointing at the `vararg` modifier (Kotlin v. 1.3.60 ) :... | 2017/12/31 | [
"https://Stackoverflow.com/questions/48045884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/239101/"
] | I'm afraid this is not possible. The following demonstrates the type of a function with `vararg`. A `vararg` parameter is represented by an `Array`:
```
fun withVarargs(vararg x: String) = Unit
val f: KFunction1<Array<out String>, Unit> = ::withVarargs
```
This behavior is also suggested in the [docs](https://kotl... | If you need a function pointer (to be passed as an argument). It can be achieved with a workaround (hack):
```
fun f(vararg strings: String): Unit = strings.forEach(::println)
val fWrapper:(Array<String>)-> Unit = {arr:Array<String>->f(*arr)}
``` |
48,045,884 | I'd like to define a function `f()` as follows (just an example) :
```
val f: (vararg strings: String) -> Unit = { for (str in it) println(str) }
```
so that I could invoke it with `f("a","b","c")`. For the above definition of `f()` I get the compilation error, pointing at the `vararg` modifier (Kotlin v. 1.3.60 ) :... | 2017/12/31 | [
"https://Stackoverflow.com/questions/48045884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/239101/"
] | I'm afraid this is not possible. The following demonstrates the type of a function with `vararg`. A `vararg` parameter is represented by an `Array`:
```
fun withVarargs(vararg x: String) = Unit
val f: KFunction1<Array<out String>, Unit> = ::withVarargs
```
This behavior is also suggested in the [docs](https://kotl... | Since vararg is not possible to be defined in functions signatures I'll go for this:
```
val f: (ArrayList<String>) -> Unit = { for (str in it) println(str) }
``` |
48,045,884 | I'd like to define a function `f()` as follows (just an example) :
```
val f: (vararg strings: String) -> Unit = { for (str in it) println(str) }
```
so that I could invoke it with `f("a","b","c")`. For the above definition of `f()` I get the compilation error, pointing at the `vararg` modifier (Kotlin v. 1.3.60 ) :... | 2017/12/31 | [
"https://Stackoverflow.com/questions/48045884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/239101/"
] | I'm afraid this is not possible. The following demonstrates the type of a function with `vararg`. A `vararg` parameter is represented by an `Array`:
```
fun withVarargs(vararg x: String) = Unit
val f: KFunction1<Array<out String>, Unit> = ::withVarargs
```
This behavior is also suggested in the [docs](https://kotl... | ```
inline infix <reified T, R : Any> fun foo(funcs: (vararg arg: T) -> R) = this.bar(funcs)
``` |
48,045,884 | I'd like to define a function `f()` as follows (just an example) :
```
val f: (vararg strings: String) -> Unit = { for (str in it) println(str) }
```
so that I could invoke it with `f("a","b","c")`. For the above definition of `f()` I get the compilation error, pointing at the `vararg` modifier (Kotlin v. 1.3.60 ) :... | 2017/12/31 | [
"https://Stackoverflow.com/questions/48045884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/239101/"
] | If you need a function pointer (to be passed as an argument). It can be achieved with a workaround (hack):
```
fun f(vararg strings: String): Unit = strings.forEach(::println)
val fWrapper:(Array<String>)-> Unit = {arr:Array<String>->f(*arr)}
``` | Since vararg is not possible to be defined in functions signatures I'll go for this:
```
val f: (ArrayList<String>) -> Unit = { for (str in it) println(str) }
``` |
48,045,884 | I'd like to define a function `f()` as follows (just an example) :
```
val f: (vararg strings: String) -> Unit = { for (str in it) println(str) }
```
so that I could invoke it with `f("a","b","c")`. For the above definition of `f()` I get the compilation error, pointing at the `vararg` modifier (Kotlin v. 1.3.60 ) :... | 2017/12/31 | [
"https://Stackoverflow.com/questions/48045884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/239101/"
] | If you need a function pointer (to be passed as an argument). It can be achieved with a workaround (hack):
```
fun f(vararg strings: String): Unit = strings.forEach(::println)
val fWrapper:(Array<String>)-> Unit = {arr:Array<String>->f(*arr)}
``` | ```
inline infix <reified T, R : Any> fun foo(funcs: (vararg arg: T) -> R) = this.bar(funcs)
``` |
48,045,884 | I'd like to define a function `f()` as follows (just an example) :
```
val f: (vararg strings: String) -> Unit = { for (str in it) println(str) }
```
so that I could invoke it with `f("a","b","c")`. For the above definition of `f()` I get the compilation error, pointing at the `vararg` modifier (Kotlin v. 1.3.60 ) :... | 2017/12/31 | [
"https://Stackoverflow.com/questions/48045884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/239101/"
] | Since vararg is not possible to be defined in functions signatures I'll go for this:
```
val f: (ArrayList<String>) -> Unit = { for (str in it) println(str) }
``` | ```
inline infix <reified T, R : Any> fun foo(funcs: (vararg arg: T) -> R) = this.bar(funcs)
``` |
72,764,715 | Unable to find request IP address when port forwarding
Example :
My Laptop Call > Jump Server Call >> The Web Server
At the Web Server the request ip will be every time the jump server ip
How to know the real ip that is call the Web Server in my case is My laptop not the Jump Server | 2022/06/26 | [
"https://Stackoverflow.com/questions/72764715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17370829/"
] | Use this to get the IP address
```
let ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress
``` | If your jump server acts as a proxy you might want to check to X-FORWARDED-FOR header.
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For> |
51,759,185 | I have this animation:
```
override func viewDidLoad() {
super.viewDidLoad()
_ = Timer.scheduledTimer(timeInterval: 15, target: self, selector: #selector(self.callingFunction), userInfo: nil, repeats: true)
}
@objc func callingFunction(){
let image0:UIImage = UIImage(named: "next0.png")!
let i... | 2018/08/09 | [
"https://Stackoverflow.com/questions/51759185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10163860/"
] | You have to call function by using timer. Set timeInterval to 15 seconds.
```
callingFunction()
timer = Timer.scheduledTimer(timeInterval: 15, target: self, selector: #selector(self.callingFunction), userInfo: nil, repeats: true)
func callingFunction(){
//Execute your code
let image0:UIImage = UIImage(na... | You can use a timer:
```
let timer = Timer.scheduledTimer(withTimeInterval: 15, repeats: true) {
[weak self] (timer) in
self?.nextButton.imageView?.startAnimating()
}
```
To stop it:
```
timer.invalidate()
``` |
51,759,185 | I have this animation:
```
override func viewDidLoad() {
super.viewDidLoad()
_ = Timer.scheduledTimer(timeInterval: 15, target: self, selector: #selector(self.callingFunction), userInfo: nil, repeats: true)
}
@objc func callingFunction(){
let image0:UIImage = UIImage(named: "next0.png")!
let i... | 2018/08/09 | [
"https://Stackoverflow.com/questions/51759185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10163860/"
] | **Just Updating your code**
Just you need to set animationRepeatCount = 1 (this will help image change will stop in one), and when a timer reaches to 15sec then again call your callingFunction.
```
override func viewDidLoad() {
super.viewDidLoad()
/// You need to take class object here for timer, when viewWil... | You can use a timer:
```
let timer = Timer.scheduledTimer(withTimeInterval: 15, repeats: true) {
[weak self] (timer) in
self?.nextButton.imageView?.startAnimating()
}
```
To stop it:
```
timer.invalidate()
``` |
51,759,185 | I have this animation:
```
override func viewDidLoad() {
super.viewDidLoad()
_ = Timer.scheduledTimer(timeInterval: 15, target: self, selector: #selector(self.callingFunction), userInfo: nil, repeats: true)
}
@objc func callingFunction(){
let image0:UIImage = UIImage(named: "next0.png")!
let i... | 2018/08/09 | [
"https://Stackoverflow.com/questions/51759185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10163860/"
] | **Just Updating your code**
Just you need to set animationRepeatCount = 1 (this will help image change will stop in one), and when a timer reaches to 15sec then again call your callingFunction.
```
override func viewDidLoad() {
super.viewDidLoad()
/// You need to take class object here for timer, when viewWil... | You have to call function by using timer. Set timeInterval to 15 seconds.
```
callingFunction()
timer = Timer.scheduledTimer(timeInterval: 15, target: self, selector: #selector(self.callingFunction), userInfo: nil, repeats: true)
func callingFunction(){
//Execute your code
let image0:UIImage = UIImage(na... |
2,363,142 | I have Hash where values of keys are other Hashes.
Example: `{'key' => {'key2' => {'key3' => 'value'}}}`
How can I iterate through this structure? | 2010/03/02 | [
"https://Stackoverflow.com/questions/2363142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/282395/"
] | Is this what you want? (untested)
```
sub for_hash {
my ($hash, $fn) = @_;
while (my ($key, $value) = each %$hash) {
if ('HASH' eq ref $value) {
for_hash $value, $fn;
}
else {
$fn->($value);
}
}
}
my $example = {'key' => {'key2' => {'key3' => 'value'... | If you are using perl as a "CPAN interpreter" then in addition to [`Data::Visitor`](https://metacpan.org/pod/Data::Visitor) and [`Data::Deep`](https://metacpan.org/pod/Data::Deep) there is the super simple [`Data::Traverse`](https://metacpan.org/pod/Data::Traverse):
```
use Data::Traverse qw(traverse);
my %test_hash ... |
2,363,142 | I have Hash where values of keys are other Hashes.
Example: `{'key' => {'key2' => {'key3' => 'value'}}}`
How can I iterate through this structure? | 2010/03/02 | [
"https://Stackoverflow.com/questions/2363142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/282395/"
] | This answer builds on the idea behind Dave Hinton's -- namely, to write a general purpose subroutine to walk a hash structure. Such a hash walker takes a code reference and simply calls that code for each leaf node in the hash.
With such an approach, the same hash walker can be used to do many things, depending on whi... | [This post](https://stackoverflow.com/questions/1089530/perl-generating-arrays-inside-a-complex-hash) may be useful.
```
foreach my $key (keys %hash) {
foreach my $key2 (keys %{ $hash{$key} }) {
foreach my $key3 (keys %{ $hash{$key}{$key2} }) {
$value = $hash{$key}{$key2}->{$key3};
... |
2,363,142 | I have Hash where values of keys are other Hashes.
Example: `{'key' => {'key2' => {'key3' => 'value'}}}`
How can I iterate through this structure? | 2010/03/02 | [
"https://Stackoverflow.com/questions/2363142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/282395/"
] | This answer builds on the idea behind Dave Hinton's -- namely, to write a general purpose subroutine to walk a hash structure. Such a hash walker takes a code reference and simply calls that code for each leaf node in the hash.
With such an approach, the same hash walker can be used to do many things, depending on whi... | This is not really a new answer but I wanted to share how to do more than
just print all the hash values recursively but also to modify them if needed.
Here is my ever so slight modification of the dave4420's answer in which
the value is passed to the callback as a reference so my callback
routine could then modify ev... |
2,363,142 | I have Hash where values of keys are other Hashes.
Example: `{'key' => {'key2' => {'key3' => 'value'}}}`
How can I iterate through this structure? | 2010/03/02 | [
"https://Stackoverflow.com/questions/2363142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/282395/"
] | The earlier answers show how to roll your own solution, which is good to do at least once so you understand the guts of how perl references and data structures work. You should definitely take a read through [perldoc perldsc](http://MooseX-Types-Ro) and [perldoc perlref](http://perldoc.perl.org/perlref.html) if you hav... | This is not really a new answer but I wanted to share how to do more than
just print all the hash values recursively but also to modify them if needed.
Here is my ever so slight modification of the dave4420's answer in which
the value is passed to the callback as a reference so my callback
routine could then modify ev... |
2,363,142 | I have Hash where values of keys are other Hashes.
Example: `{'key' => {'key2' => {'key3' => 'value'}}}`
How can I iterate through this structure? | 2010/03/02 | [
"https://Stackoverflow.com/questions/2363142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/282395/"
] | This answer builds on the idea behind Dave Hinton's -- namely, to write a general purpose subroutine to walk a hash structure. Such a hash walker takes a code reference and simply calls that code for each leaf node in the hash.
With such an approach, the same hash walker can be used to do many things, depending on whi... | You will have to loop through it twice. i.e.
```
while ( ($family, $roles) = each %HoH ) {
print "$family: ";
while ( ($role, $person) = each %$roles ) {
print "$role=$person ";
}
print "\n";
}
``` |
2,363,142 | I have Hash where values of keys are other Hashes.
Example: `{'key' => {'key2' => {'key3' => 'value'}}}`
How can I iterate through this structure? | 2010/03/02 | [
"https://Stackoverflow.com/questions/2363142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/282395/"
] | Is this what you want? (untested)
```
sub for_hash {
my ($hash, $fn) = @_;
while (my ($key, $value) = each %$hash) {
if ('HASH' eq ref $value) {
for_hash $value, $fn;
}
else {
$fn->($value);
}
}
}
my $example = {'key' => {'key2' => {'key3' => 'value'... | This is not really a new answer but I wanted to share how to do more than
just print all the hash values recursively but also to modify them if needed.
Here is my ever so slight modification of the dave4420's answer in which
the value is passed to the callback as a reference so my callback
routine could then modify ev... |
2,363,142 | I have Hash where values of keys are other Hashes.
Example: `{'key' => {'key2' => {'key3' => 'value'}}}`
How can I iterate through this structure? | 2010/03/02 | [
"https://Stackoverflow.com/questions/2363142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/282395/"
] | Is this what you want? (untested)
```
sub for_hash {
my ($hash, $fn) = @_;
while (my ($key, $value) = each %$hash) {
if ('HASH' eq ref $value) {
for_hash $value, $fn;
}
else {
$fn->($value);
}
}
}
my $example = {'key' => {'key2' => {'key3' => 'value'... | ```
foreach my $keyname (keys(%foo) {
my $subhash = $foo{$keyname};
# stuff with $subhash as the value at $keyname
}
``` |
2,363,142 | I have Hash where values of keys are other Hashes.
Example: `{'key' => {'key2' => {'key3' => 'value'}}}`
How can I iterate through this structure? | 2010/03/02 | [
"https://Stackoverflow.com/questions/2363142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/282395/"
] | The earlier answers show how to roll your own solution, which is good to do at least once so you understand the guts of how perl references and data structures work. You should definitely take a read through [perldoc perldsc](http://MooseX-Types-Ro) and [perldoc perlref](http://perldoc.perl.org/perlref.html) if you hav... | You will have to loop through it twice. i.e.
```
while ( ($family, $roles) = each %HoH ) {
print "$family: ";
while ( ($role, $person) = each %$roles ) {
print "$role=$person ";
}
print "\n";
}
``` |
2,363,142 | I have Hash where values of keys are other Hashes.
Example: `{'key' => {'key2' => {'key3' => 'value'}}}`
How can I iterate through this structure? | 2010/03/02 | [
"https://Stackoverflow.com/questions/2363142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/282395/"
] | Is this what you want? (untested)
```
sub for_hash {
my ($hash, $fn) = @_;
while (my ($key, $value) = each %$hash) {
if ('HASH' eq ref $value) {
for_hash $value, $fn;
}
else {
$fn->($value);
}
}
}
my $example = {'key' => {'key2' => {'key3' => 'value'... | The earlier answers show how to roll your own solution, which is good to do at least once so you understand the guts of how perl references and data structures work. You should definitely take a read through [perldoc perldsc](http://MooseX-Types-Ro) and [perldoc perlref](http://perldoc.perl.org/perlref.html) if you hav... |
2,363,142 | I have Hash where values of keys are other Hashes.
Example: `{'key' => {'key2' => {'key3' => 'value'}}}`
How can I iterate through this structure? | 2010/03/02 | [
"https://Stackoverflow.com/questions/2363142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/282395/"
] | This is not really a new answer but I wanted to share how to do more than
just print all the hash values recursively but also to modify them if needed.
Here is my ever so slight modification of the dave4420's answer in which
the value is passed to the callback as a reference so my callback
routine could then modify ev... | ```
foreach my $keyname (keys(%foo) {
my $subhash = $foo{$keyname};
# stuff with $subhash as the value at $keyname
}
``` |
1,546,532 | The following doesn't compile
```
public static T Retrieve<T>(this NameValueCollection collection, String key) where T : Object
{
if (collection.AllKeys.Contains(key))
{
try
{
val = (T)Convert.ChangeType((object)collection[key], typeof(T));
}
catch { }
}
re... | 2009/10/09 | [
"https://Stackoverflow.com/questions/1546532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/111674/"
] | ```
where T : class
```
Your current constraint, `where T : Object` says "anything which is or inherits from System.Object", which is: everything. All types, including Int32 and String, inherit from System.Object. So constraining on Object would do nothing.
Edit: as usual, Eric shines a light on this [in a far more ... | I don't believe it is possible to constrain your generic argument purely to a nullable type. You can easily constrain it to a reference type (as in previous answer), but, while all reference types are nullable, not all nullables are reference types. |
48,576,401 | I want to know how to get the value of the button data-title (prbModalExt2.html) in jquery and insert it into a variable URL.
At this time the variable URL is created with the value `prbModalExt1.html`.
```
<div class="container ">
<div class="jumbotron"><a class="btn btn-primary" data-toggle="modal" href="#myMo... | 2018/02/02 | [
"https://Stackoverflow.com/questions/48576401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1907211/"
] | This works pretty fine for your use-case.
`nodemon src/app.js --exec "npm run lint && node"`
or you can write nodemon.json file in your root directory
```
{
"watch": ["src"],
"ignore": ["**/*.test.js", "**/*.spec.js", ".git", "node_modules"],
"exec": "npm run lint && node src/app.js"
}
``` | I've been using a custom script for a while now which I finally published to npm.
Check it out here: <https://github.com/theoephraim/lint-fix-nodemon>
This helps avoid double restarts when eslint fixes your files as well as not failing on the initial run if eslint has fatal errors.
Hope it helps! |
48,576,401 | I want to know how to get the value of the button data-title (prbModalExt2.html) in jquery and insert it into a variable URL.
At this time the variable URL is created with the value `prbModalExt1.html`.
```
<div class="container ">
<div class="jumbotron"><a class="btn btn-primary" data-toggle="modal" href="#myMo... | 2018/02/02 | [
"https://Stackoverflow.com/questions/48576401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1907211/"
] | This works pretty fine for your use-case.
`nodemon src/app.js --exec "npm run lint && node"`
or you can write nodemon.json file in your root directory
```
{
"watch": ["src"],
"ignore": ["**/*.test.js", "**/*.spec.js", ".git", "node_modules"],
"exec": "npm run lint && node src/app.js"
}
``` | Im using `nodemon` version 1.19.4. You just missed the "events" key. The right way would be to create a `nodemon.json` in your root folder like that, then a `lint` script in your `package.json` with your `lint` command:
```json
{
"watch": [ "src" ],
"ignore": ["**/*.test.js", "**/*.spec.js", ".git", "node_modules"... |
48,576,401 | I want to know how to get the value of the button data-title (prbModalExt2.html) in jquery and insert it into a variable URL.
At this time the variable URL is created with the value `prbModalExt1.html`.
```
<div class="container ">
<div class="jumbotron"><a class="btn btn-primary" data-toggle="modal" href="#myMo... | 2018/02/02 | [
"https://Stackoverflow.com/questions/48576401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1907211/"
] | The correct way is (in package.json and windows):
```
"scripts": {
"start": "node index",
"start-dev": "nodemon --exec \"npm run lint && node index\"",
},
``` | I've been using a custom script for a while now which I finally published to npm.
Check it out here: <https://github.com/theoephraim/lint-fix-nodemon>
This helps avoid double restarts when eslint fixes your files as well as not failing on the initial run if eslint has fatal errors.
Hope it helps! |
48,576,401 | I want to know how to get the value of the button data-title (prbModalExt2.html) in jquery and insert it into a variable URL.
At this time the variable URL is created with the value `prbModalExt1.html`.
```
<div class="container ">
<div class="jumbotron"><a class="btn btn-primary" data-toggle="modal" href="#myMo... | 2018/02/02 | [
"https://Stackoverflow.com/questions/48576401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1907211/"
] | The correct way is (in package.json and windows):
```
"scripts": {
"start": "node index",
"start-dev": "nodemon --exec \"npm run lint && node index\"",
},
``` | Im using `nodemon` version 1.19.4. You just missed the "events" key. The right way would be to create a `nodemon.json` in your root folder like that, then a `lint` script in your `package.json` with your `lint` command:
```json
{
"watch": [ "src" ],
"ignore": ["**/*.test.js", "**/*.spec.js", ".git", "node_modules"... |
48,576,401 | I want to know how to get the value of the button data-title (prbModalExt2.html) in jquery and insert it into a variable URL.
At this time the variable URL is created with the value `prbModalExt1.html`.
```
<div class="container ">
<div class="jumbotron"><a class="btn btn-primary" data-toggle="modal" href="#myMo... | 2018/02/02 | [
"https://Stackoverflow.com/questions/48576401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1907211/"
] | Im using `nodemon` version 1.19.4. You just missed the "events" key. The right way would be to create a `nodemon.json` in your root folder like that, then a `lint` script in your `package.json` with your `lint` command:
```json
{
"watch": [ "src" ],
"ignore": ["**/*.test.js", "**/*.spec.js", ".git", "node_modules"... | I've been using a custom script for a while now which I finally published to npm.
Check it out here: <https://github.com/theoephraim/lint-fix-nodemon>
This helps avoid double restarts when eslint fixes your files as well as not failing on the initial run if eslint has fatal errors.
Hope it helps! |
30,965,109 | I have resently begun to develop Android apps, and I do not know how to deploy simple HelloWorld app on my Android device. When I click the **Run** button, my device ***is not shown*** in the list of running devices.
P.S.: I am using Android Studio. | 2015/06/21 | [
"https://Stackoverflow.com/questions/30965109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4620951/"
] | I'd suggest a third option: **Put error logging and error display in the UI layer.**
Register a [central error handler](https://stackoverflow.com/q/4692392/87698) in your user interface. There, you can
* display the error (either a simple MessageBox or a fancy window with a "more details" and a "report to developers... | First of all : Always catch **only** exceptions you can handle ([See Eric Lippert Post](http://ericlippert.com/2008/09/10/vexing-exceptions/))
You can follow this strategy :
* If you cannot recover from the exception do it in the DAL layer only and log it.
* `try {} catch{}` in BAL layer if the user can handle it. |
58,568,321 | I have no idea how to make this more efficient, and am working through coding challenges. Any hints?
The objective is to return the unique value in an array.
[Test Conditions Which Code Fails](https://i.stack.imgur.com/1zZdq.png)
```
function solution($A) {
foreach ($A as $key => $value) {
$searchResu... | 2019/10/26 | [
"https://Stackoverflow.com/questions/58568321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12276946/"
] | I found the above code was interfering with the operation of the plugin WooCommerce Advanced Free Shipping. I de-activated that plugin and deleted the code above. I then installed Advanced Flat Rate Shipping for Woocommerce and that plugin allowed me to set parameters that prevented the two product categories from bein... | I made two important changes, changed the name of the function to avoid conflicts, and changed the method I'm removing for a specific test.
Note that the methods from what I saw come with lowercase letters, make sure your method is really the first capital letters this will make a difference;
Note that I left a comme... |
15,224,933 | I have a script that has two arrays, the initial data array (`$initial`), and the modified data array (`$modified`), but I have hit an issue in detecting the differences between the arrays. I need to determine which values (the keys will be different between them) have been added, and which values have been removed and... | 2013/03/05 | [
"https://Stackoverflow.com/questions/15224933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/803458/"
] | [array\_diff()](http://docs.php.net/function.array-diff) can do that.
```
<?php
$initial = array(1,2,3,4,5,6,7,8);
$modified = foo($initial);
$removed = array_diff($initial, $modified);
$added = array_diff($modified, $initial);
echo 'removed=', join(', ', $removed), "\n";
echo 'added=', join(', ', $added), "\n";
fu... | I was going to cancel the question, but I felt there might be useful to others having a similar problem, or if there is something foolish in here that I have missed, but anyway:
I used the following:
```
$dataAdded = array();
$dataRemoved = array();
foreach ($modified as $data) {
if (!in_array($data, $initial)) {... |
10,798 | Can I run multiple commands at once in geth's JavaScript console?
Can I do something like `> api1.command1() && api2.command2("arg2") && api1.command3()`? | 2016/12/20 | [
"https://ethereum.stackexchange.com/questions/10798",
"https://ethereum.stackexchange.com",
"https://ethereum.stackexchange.com/users/4938/"
] | Here's how I run my multiple command scripts in Linux and OS/X.
I've created a file `$HOME/bin/multipleCommands.sh` with the following contents:
```
#!/bin/sh
geth attach << EOF | grep "RESULT:" | sed "s/RESULT: //"
var balance1 = web3.fromWei(eth.getBalance("0x9535b2e7faaba5288511d89341d94a38063a349b"), "ether");
... | I propose you to put them in a JavaScript file and use
```
LoadScript ('/path/myjs.js').
```
<https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console#loadscript> |
10,798 | Can I run multiple commands at once in geth's JavaScript console?
Can I do something like `> api1.command1() && api2.command2("arg2") && api1.command3()`? | 2016/12/20 | [
"https://ethereum.stackexchange.com/questions/10798",
"https://ethereum.stackexchange.com",
"https://ethereum.stackexchange.com/users/4938/"
] | Can you separate them with `;` ? | I propose you to put them in a JavaScript file and use
```
LoadScript ('/path/myjs.js').
```
<https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console#loadscript> |
7,803,520 | I'm looking for a tool that will play nicely with Python.
Except for my Python requirement, my question is the same as this [one](https://stackoverflow.com/questions/74879/any-tools-to-generate-an-xsd-schema-from-an-xml-instance-document):
>
> "I am looking for a tool which will take an XML instance document and ou... | 2011/10/18 | [
"https://Stackoverflow.com/questions/7803520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/917272/"
] | According to the [PyCharm docs](https://www.jetbrains.com/help/pycharm/2016.1/generating-xml-schema-from-instance-document.html "PyCharm docs"), PyCharm has a facility for this. This is not exactly accessible by a program as an API. You are probably better off using [XML Schema Learner](https://github.com/kore/XML-Sche... | Are you looking for something like [pyxsd](http://pypi.python.org/pypi/pyxsd)? (primarily used for validation against a schema) Or maybe [PyXB](http://pyxb.sourceforge.net/)? (can generate classes based on xml) Otherwise, I don't think there's a tool [yet] that will generate the schema from within Python. Can you do it... |
7,803,520 | I'm looking for a tool that will play nicely with Python.
Except for my Python requirement, my question is the same as this [one](https://stackoverflow.com/questions/74879/any-tools-to-generate-an-xsd-schema-from-an-xml-instance-document):
>
> "I am looking for a tool which will take an XML instance document and ou... | 2011/10/18 | [
"https://Stackoverflow.com/questions/7803520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/917272/"
] | According to the [PyCharm docs](https://www.jetbrains.com/help/pycharm/2016.1/generating-xml-schema-from-instance-document.html "PyCharm docs"), PyCharm has a facility for this. This is not exactly accessible by a program as an API. You are probably better off using [XML Schema Learner](https://github.com/kore/XML-Sche... | Currently, there is no module that will run within your python program and do this conversion. But I see the problem of creating a XSD schema from XML as a tooling problem. It's the kind of functionality that I'll use once, to get a schema started but after that I'll be maintaining the schema myself. From reading a sin... |
45,795,308 | I am getting results from rest service into one string, it contain a number(id) or multiple number(multiple id) seprated by commas.
Now i want to pass above id or multiple id into function as a parameter so it returns me rolename, so how can i pass multiple id to functionin javascript....Kindly help as i am new to pro... | 2017/08/21 | [
"https://Stackoverflow.com/questions/45795308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8439599/"
] | the following code will help u to convert a comma separated string into an array,
```
var string = "1,2,3,4,5";
var array = string.split(","); // string to array conversion
function takesArray(a) { // taking an array as parameter
console.log(a);
}
takesArray(array); // passing array as argument
``` | use [Array.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
```
var a = ['a', 'b', 'c'];
a.forEach(function(element) {
console.log(element);
});
// a
// b
// c
```
or [Array.map](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objec... |
58,807,644 | I have a JS Object of the form stored in a variable `keyData`:
```
{type: "", label: "fname", title: "first name", …}
defaultvalue: ""
disabled: false
label: "fname"
readonly: false
required: "on"
title: "first name"
type: ""
__proto__: Object
```
I want to filter through these key-v... | 2019/11/11 | [
"https://Stackoverflow.com/questions/58807644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11349591/"
] | So in general you can use OpenCVs ColorMap to change colors in your image:
```
import cv2
img = cv2.imread(r"<IMAGE PATH>")
img = cv2.applyColorMap(img, cv2.COLORMAP_JET) # Change colors of image with predefined colormap
# Display the new image
cv2.imshow("img", img)
cv2.waitKey()
```
Now if you want to create your... | It looks like you have a typo in your loop:
```
for i in range(0, 10):
# if-elses
...
images.append(enhancer.enhance(10/10))
```
You're `enhancing` the image with a factor of `1.0` at each iteration, which according to the [docs](https://pillow.readthedocs.io/en/3.1.x/reference/ImageEnhance.html#PIL.Ima... |
79,136 | I have worked on rsync for the whole afternoon.
I have set a rsync server,but I don't know how to use it.
I have two machines:66 and 12.
66 is the server,I want to back 66's data to 12,so I use rsync.
I have done the following:
**In 66:**
```
sudo apt-get install xinetd
sudo vim /etc/xinetd.d/rsync
service rsync... | 2013/06/12 | [
"https://unix.stackexchange.com/questions/79136",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/40756/"
] | On the `12` box ( the one that is pulling the backup from the server) use this command instead:
```
rsync -av user@192.168.1.100::wwwroot /home/young001/backup --password-file=/home/rsync.pass
```
The `-a` option is the rsync archive mode : is designed to do recursion into directory and to preserve almost everyth... | **1.This will sync remote directory to local directory**
```
sudo rsync -r -a -v root@xx.xx.xx.xx:/path/to/remote/directory/ /path/to/local/directory/ 2>&1
```
**2.this will sync local directory to remote directory**
```
sudo rsync -r -a -v /path/to/local/directory/ root@xx.xx.xx.xx:/path/to/remote/directory/ 2>&1... |
3,018,674 | I am trying to calculate the derivative below:
$$ \frac{\partial }{\partial \theta} \left(-y\cdot \log\left(\frac{1}{1+e^{-\theta x}}\right)\right)=\frac{\partial }{\partial \theta} \left(y\cdot \log(1+e^{-\theta x})\right)= \frac{-y \cdot x \cdot e^{- \theta x}}{1+e^{- \theta x}} $$
where: $ \frac{y }{1+e^{-\theta x... | 2018/11/29 | [
"https://math.stackexchange.com/questions/3018674",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/374567/"
] | \begin{eqnarray}
\frac{\partial }{\partial \theta} \left[-y \ln\left(\frac{1}{1+e^{-\theta x}}\right)\right]&=&\frac{\partial }{\partial \theta} \left[y \ln\left(1+e^{-\theta x}\right)\right] \\
&=& -\frac{y x e^{- \theta x}}{1+e^{- \theta x}} \color{red}{\frac{e^{\theta x}}{e^{\theta x}}} \\
&=& -\frac{y x}{1 + e^{\co... | You are right and Mathematica is wrong ! |
61,325,924 | I have the following dataset (5200 entries) of water chemical compounds annual means organized by monitoring sites and sampling year:
```
data= data.frame(Site_ID=c(1, 1, 1, 2, 2, 2, 3, 3, 3), Year=c(2000, 2001, 2002, 2001, 2002, 2003, 2002, 2003, 2004), AnnualMean=c(1.1, 1.2, 1.1, 2.1, 2.6, 3.1, 2.7, 2.6, 1.9))
```
... | 2020/04/20 | [
"https://Stackoverflow.com/questions/61325924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12234712/"
] | One `dplyr` solution could be:
```
data %>%
group_by(Site_ID) %>%
mutate(Diff_ref = ifelse(Year == 2002, NA, AnnualMean - AnnualMean[Year == 2002]))
Site_ID Year AnnualMean Diff_ref
<dbl> <dbl> <dbl> <dbl>
1 1 2000 1.1 0
2 1 2001 1.2 0.1000
3 1 2002 ... | Using `data.table`
```
library(data.table)
setDT(data)[, Diff_ref := fifelse(Year == 2002, NA_real_,
AnnualMean - AnnualMean[Year == 2002]), Site_ID]
``` |
69,973,966 | Suppose I have a set of weeks
```
{string} weeks ={"Week 1","Week 2","Week 3","Week 4"}
```
Then I define a variable for each of the weeks
```
dvar boolean x[weeks];
```
If I want to, for all `w in Weeks`, sum over all weeks up to the week w, how can you do that? What I want to do is the following, which does not... | 2021/11/15 | [
"https://Stackoverflow.com/questions/69973966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1597775/"
] | By coincidence I stumbled across a page in the [OPL manual](https://www.ibm.com/docs/sv/icos/12.9.0?topic=functions-ord), describing the function `ord()` which seems to be a way forward. `ord(Set,element)` returns the position of the element in the set. Hence the code in the question should be
```
forall ( w in weeks ... | In fact you can compare strings in OPL so
```
{string} weeks ={"Week 1","Week 2","Week 3","Week 4"};
float rhs[weeks]=[1,2,3,4];
dvar boolean x[weeks];
subject to
{
forall ( w in weeks )
{
sum ( ww in weeks : ww<=w ) x[ww] >= rhs[w];
}
}
execute
{
for(var w1 in weeks) for(var w2 in weeks) if (w1<=w2... |
10,323,016 | I'm trying to do something that I thought would be easy but can't figure out how to write to a label inside my stating function.
```
public static void StartProcessing(object data)
{
lblError.Text = "Blah Blah"
}
```
I get the error "An object reference is required for the non-static field, method, or property..... | 2012/04/25 | [
"https://Stackoverflow.com/questions/10323016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1186144/"
] | Pass the label to your static function when you call it:
```
public static void StartProcessing(object data, Label lblError)
{
lblError.Text = "Blah Blah"
}
```
Static functions don't have access to controls because the controls belong to the *instance* of the page (class).
**Static** means that all instances o... | What you want to do is actually quite difficult.
You want to create a page, start an asynchronous task, send the page to the user, and then update content on the page after the asynchronous job finishes.
The problem is that by the time the asynchronous task finishes the page has already been sent, and based on the wa... |
61,507,704 | The `MASS::stepAIC` function takes an `lm` result as a parameter and does stepwise regression to find the "best" model. The following code is brain dead simple and works:
```r
library(MASS)
data("mtcars")
lm1 = lm(mpg ~ ., mtcars)
step1 = stepAIC(lm1, direction = "both", trace = FALSE)
```
I'm trying to put this in... | 2020/04/29 | [
"https://Stackoverflow.com/questions/61507704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3078502/"
] | Here is your culprit (within the `fit_model` function). Notice the environment where the formula was created.
```
Browse[1]> str(formula)
Class 'formula' language mpg ~ .
..- attr(*, ".Environment")=<environment: R_GlobalEnv>
```
What you could do is perhaps force in a new environment
```
fit_model = function(f... | As far as I can tell, this is a perfect case for using `enquote`:
```
fit_model <- function(formula, data) {
formula <- enquote(formula)
full_model <- lm(formula = formula, data = data)
stepAIC(full_model, direction = "both", trace = FALSE)
}
fit_model(mpg ~ ., mtcars)
#
#Call:
#lm(formula = mpg ~ wt + qsec + a... |
61,507,704 | The `MASS::stepAIC` function takes an `lm` result as a parameter and does stepwise regression to find the "best" model. The following code is brain dead simple and works:
```r
library(MASS)
data("mtcars")
lm1 = lm(mpg ~ ., mtcars)
step1 = stepAIC(lm1, direction = "both", trace = FALSE)
```
I'm trying to put this in... | 2020/04/29 | [
"https://Stackoverflow.com/questions/61507704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3078502/"
] | Here is your culprit (within the `fit_model` function). Notice the environment where the formula was created.
```
Browse[1]> str(formula)
Class 'formula' language mpg ~ .
..- attr(*, ".Environment")=<environment: R_GlobalEnv>
```
What you could do is perhaps force in a new environment
```
fit_model = function(f... | A solution based on `do.call` and described at this [link](https://stackoverflow.com/questions/10176524/function-works-boot-stepaic-but-throws-an-error-inside-another-function-env):
```
fit_model = function(formula, data) {
full_model <- do.call("lm", list(formula=formula, data=data))
step_model <- stepAIC(full_mo... |
4,952,228 | New to Linq to Entities. I am using entity framework and linq. In my db I have something akin to Cars, Users, UserCars where UserCars holds the ID from User and Cars. Standard stuff.
EF maps this to Car and User objects.
Now a user currently has many cars. Through my application I end up with a new List of Car IDs. ... | 2011/02/10 | [
"https://Stackoverflow.com/questions/4952228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428632/"
] | The `User` entity should have a `Cars` property. You can just clear that collection and then add the new Cars to reflect the new state, i.e. somewhat like this:
```
User myUser = context.Users.First();
var carCollection = context.Cars.Where( c => carIdCollection.Contains(c.Id));
myUser.Cars.Clear();
foreach(Car car i... | You could use a generic method which can handle what ever type you pass it:
```
Protected Sub UpdateManyToMany(Of T As Class)(database as SomeEntities, collection As ICollection(Of T), idList As List(Of Integer))
'update a many to many collection given a list of key IDs
collection.Clear()
Dim source = database.Set... |
22,526,118 | I got invitation to the Android Wear Developer program but when I try to install the Android Wear Preview app I see information that my device (Samsung Galaxy S2) is not compatible with the app. Is there some kind of list of devices compatible with Android Wear Preview app?
Thank you, | 2014/03/20 | [
"https://Stackoverflow.com/questions/22526118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2979749/"
] | I don't think there is a device spesific restriction, but according to [developer.android.com](http://developer.android.com/wear/preview/start.html#SetupApp)
```
Note: The Android Wear Preview app is compatible with Android 4.3 and higher and is not available for the Android emulator.
```
Edit: I think BLE is used f... | You need a 4.3+ Android smartphone. Because the Notification listener functionality has been added with API level 18.
Tablets were stated to be supported but right now they're filtered out from the store. You can still manually install the APK though.
Bluetooth LE isn't mandatory - for the preview at least. |
26,078,480 | i am new in java and android so i tried to do simple application with drawable layout and fragments. I now know how to load websites in app but i don't know how to show some pictures inside drawable layout fragment. I hope you guys have any ideas how can i show some pictures in one fragment. Any help is appreciated.
... | 2014/09/27 | [
"https://Stackoverflow.com/questions/26078480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3975092/"
] | Change `void foo( char ** bar )` to `void foo( char bar[][100] )`.
When you are passing a multidimensional array to a function, the first array dimension does not have to be specified. However the second(and subsequent) dimensions must be provided to the function.
For more information check this [C-Faq](http://c-faq.... | When you define a multi-dimensional array, the bytes are laid out contiguously in memory.
For instance:
```
char a[3][5];
```
will give you 15 contiguous bytes of memory, laid out as so:
```
----------------------------------------------
| a + 0 | a + 1 | a + 2 | a + 3 | a + 4 |
------------------------------... |
3,340,987 | Since there's a lot of code, I won't post it here. Rather, you can find it all [here](http://jsfiddle.net/ApCGU/). That way you can play around with it and run it:
```js
function P_Expand(item_id) {
$('#p_' + item_id).slideToggle();
}
```
```css
.data_table {
width: 650px;
margin-left: auto;
margin-right... | 2010/07/27 | [
"https://Stackoverflow.com/questions/3340987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/193619/"
] | [demo](http://fiddle.jshell.net/ApCGU/14/show/)
===============================================
[codes link](http://jsfiddle.net/ApCGU/14/)
```
.hidden_data {
overflow: hidden;
display:none; /* <--- remove this */
padding: 10px;
font-style: italic;
color: #777;
}
```
similar [problem answered](... | Give the hidden div a set height. [jsfiddle](http://jsfiddle.net/C3MPG/)
---
Edit. Found some answers [here](http://www.pewpewlaser.com/articles/jquery-smooth-animation). You can store the height of each element, and then reapply it. Not ideal for your situation, but maybe a starting point |
3,340,987 | Since there's a lot of code, I won't post it here. Rather, you can find it all [here](http://jsfiddle.net/ApCGU/). That way you can play around with it and run it:
```js
function P_Expand(item_id) {
$('#p_' + item_id).slideToggle();
}
```
```css
.data_table {
width: 650px;
margin-left: auto;
margin-right... | 2010/07/27 | [
"https://Stackoverflow.com/questions/3340987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/193619/"
] | Actually you don't need any of this.
Just give your hidden element a width:
```
.hidden_data {
display: none;
padding: 10px;
font-style: italic;
color: #777;
width: 300px;
}
```
It will just works!
PS: I spent all the weekend on this... | Give the hidden div a set height. [jsfiddle](http://jsfiddle.net/C3MPG/)
---
Edit. Found some answers [here](http://www.pewpewlaser.com/articles/jquery-smooth-animation). You can store the height of each element, and then reapply it. Not ideal for your situation, but maybe a starting point |
12,121,230 | I'm using the following codes (HTML and CSS) and by using the code you are unable to scroll up or down the page via mouse scroll or within the browser (Scroll bar on the right is not there)
HTML:
```
<div id="head">
<div id="logo">
<a href="#"></a>
</div>
<form style="display:inline;">
<input style="... | 2012/08/25 | [
"https://Stackoverflow.com/questions/12121230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/615777/"
] | Check your css:
```
overflow:hidden; /* get rid of scroll bars in IE */
```
for html, and for body
remove that line, or change to : `overflow:scroll;`
<http://www.w3schools.com/cssref/pr_pos_overflow.asp> | and also because you have no content div |
12,121,230 | I'm using the following codes (HTML and CSS) and by using the code you are unable to scroll up or down the page via mouse scroll or within the browser (Scroll bar on the right is not there)
HTML:
```
<div id="head">
<div id="logo">
<a href="#"></a>
</div>
<form style="display:inline;">
<input style="... | 2012/08/25 | [
"https://Stackoverflow.com/questions/12121230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/615777/"
] | Check your css:
```
overflow:hidden; /* get rid of scroll bars in IE */
```
for html, and for body
remove that line, or change to : `overflow:scroll;`
<http://www.w3schools.com/cssref/pr_pos_overflow.asp> | Overflow in the body should be auto or scroll. |
12,121,230 | I'm using the following codes (HTML and CSS) and by using the code you are unable to scroll up or down the page via mouse scroll or within the browser (Scroll bar on the right is not there)
HTML:
```
<div id="head">
<div id="logo">
<a href="#"></a>
</div>
<form style="display:inline;">
<input style="... | 2012/08/25 | [
"https://Stackoverflow.com/questions/12121230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/615777/"
] | Overflow in the body should be auto or scroll. | and also because you have no content div |
15,593,803 | I upgraded to Rails 3.2 and Ruby 1.9.3 and I get a very strange behavior
I have a Model called Entry. when a new Entry is created it get inserted into the DB with the current date and time.
But when I run `Entry.find_by_id(THE_ENTRY_ID).created_at` I get the "correct" created at datetime but In a different TimeZone f... | 2013/03/24 | [
"https://Stackoverflow.com/questions/15593803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/333466/"
] | OK after reading the DOCS and seeing this rails casts:
<http://railscasts.com/episodes/106-time-zones-revised>
everything is now clear.
```
config.time_zone = 'Eastern Time (US & Canada)'
```
this setting is the actual setting that's in charged of converting all time objects to this current time zone. that is way ... | Check the configuration in the `application.rb`. If no timezone is set, rails will take the default timezone of your operating system. To fix that, set UTC as the timezone. |
498,597 | ok so as stated in the subject line i have an HP DL380 G7 running esxi 5.0 free and an ILO3. Is there any way for me to get some decent monitoring of the hardware without paying any extra money for a vmware license which allows me to set the SNMP community string, or without needing to purchase HP SIM? I don't seem to ... | 2013/04/11 | [
"https://serverfault.com/questions/498597",
"https://serverfault.com",
"https://serverfault.com/users/103897/"
] | This limitation is created to "help" you decide to purchase the paid version.
However if you enable SNMP during the evaluation period the service will remain active.
It is also possible to monitor the ESXi server via CIM/WBEM. See: <http://blogs.vmware.com/vsphere/2010/04/hardware-health-monitoring-via-cim.html> | I'm a little curious about what you were expecting...
There's no HP System Management Page at port 2381 for ESXi installations. However, [HP Systems Insight Manager (HP SIM)](http://h18013.www1.hp.com/products/servers/management/hpsim/index.html?jumpid=go/hpsim) is free and available for download. It's overkill for on... |
498,597 | ok so as stated in the subject line i have an HP DL380 G7 running esxi 5.0 free and an ILO3. Is there any way for me to get some decent monitoring of the hardware without paying any extra money for a vmware license which allows me to set the SNMP community string, or without needing to purchase HP SIM? I don't seem to ... | 2013/04/11 | [
"https://serverfault.com/questions/498597",
"https://serverfault.com",
"https://serverfault.com/users/103897/"
] | This limitation is created to "help" you decide to purchase the paid version.
However if you enable SNMP during the evaluation period the service will remain active.
It is also possible to monitor the ESXi server via CIM/WBEM. See: <http://blogs.vmware.com/vsphere/2010/04/hardware-health-monitoring-via-cim.html> | Another option is not to use SNMP, but to use the iLO XML interface. You can query health status through it by crafting some XML and making an HTTP request. I use this all the time (though for keeping inventory, not for monitoring).
If you don't want to hand-craft XML (and who in his right mind would), maybe look at t... |
498,597 | ok so as stated in the subject line i have an HP DL380 G7 running esxi 5.0 free and an ILO3. Is there any way for me to get some decent monitoring of the hardware without paying any extra money for a vmware license which allows me to set the SNMP community string, or without needing to purchase HP SIM? I don't seem to ... | 2013/04/11 | [
"https://serverfault.com/questions/498597",
"https://serverfault.com",
"https://serverfault.com/users/103897/"
] | This limitation is created to "help" you decide to purchase the paid version.
However if you enable SNMP during the evaluation period the service will remain active.
It is also possible to monitor the ESXi server via CIM/WBEM. See: <http://blogs.vmware.com/vsphere/2010/04/hardware-health-monitoring-via-cim.html> | You do not need to **purchase** HP SIM. The basic functionality of HP SIM that you need to monitor your ESXi hosts' hardware via WBEM is available for free! |
22,893,714 | ```
template <typename T>
class Test
{
};
class A : public X;
class B;
Test<A> a; // OK
Test<B> b; // NOT OK
```
I would like to accomplish something like this.
Maybe this can be accomplished more easily. Basically, what I need it for is this: the template class T should be able to lock a std::mutex member m\_mut... | 2014/04/06 | [
"https://Stackoverflow.com/questions/22893714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1148251/"
] | With a static assertion and the appropriate [type trait class](http://en.cppreference.com/w/cpp/types/is_base_of):
```
#include <type_traits>
template <typename T>
class Test
{
static_assert( std::is_base_of<X,T>::value, "T doesn't derive from X!");
};
```
[**Live example**](http://coliru.stacked-crooked.com/a... | You can use [**`std::is_base_of<>`**](http://en.cppreference.com/w/cpp/types/is_base_of) with a SFINAE check:
```
template<
typename T,
typename = typename std::enable_if<std::is_base_of<X, T>::value>::type
>
class Test {
...
};
``` |
26,221,163 | I am running Atlassian stash and I can see the Pull request option on the Web based UI, but I want to know if my users can create Pull requests from their consoles for their working copies without using the stash web UI ? | 2014/10/06 | [
"https://Stackoverflow.com/questions/26221163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4114151/"
] | There are 2 Stash command line tools available:
<https://bitbucket.org/atlassian/stash-command-line-tools>
<https://marketplace.atlassian.com/plugins/org.swift.stash.cli>
Note that a pull request requires commits in a branch to be pushed rather than using the local working copy, and this works well in practice. | I have never done this, but it should be possible using the [Stash REST api](https://developer.atlassian.com/static/rest/stash/3.0.1/stash-rest.html) via some bash script or something to do the *POST*
>
> **/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests**
>
> This API can also be invoked... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.