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 |
|---|---|---|---|---|---|
10,784 | I plan on running PEX pipes both hot and cold across 16 feet of unheated attic space above a foyer. The foyer is 16' long and is off the kitchen, it isn't heated directly but is part of the house; it is usually colder than the rest of the house, mostly due to the cat door and slider the dogs go in and out of. There is ... | 2011/12/20 | [
"https://diy.stackexchange.com/questions/10784",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/4651/"
] | Additional information as this winter tests out badly routed plumbing. PEX that gets water frozen inside it stretches and expands over time.
The weak point is fittings. Depending on the fitting, it can crack, the crimp rings can be stretched leading to a leak from the fitting or the PEX slipping off under pressure. Th... | If you are using PEX, you can run it through your attic. PEX will NOT burst unless you live in a place that gets like 50 below. And it does not freeze as readily as metal pipe. We used PEX once and ended up replumbing our entire house with it. You can put foam insulation tubing on it to make you feel more secure, but y... |
10,784 | I plan on running PEX pipes both hot and cold across 16 feet of unheated attic space above a foyer. The foyer is 16' long and is off the kitchen, it isn't heated directly but is part of the house; it is usually colder than the rest of the house, mostly due to the cat door and slider the dogs go in and out of. There is ... | 2011/12/20 | [
"https://diy.stackexchange.com/questions/10784",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/4651/"
] | Pex in the attic simply needs to be run BELOW the insulation. Put it against the ceiling drywall, and it will never get particularly cold.
The problem is, lots of installers don't do this. My contractor actually went to some trouble to hang the pex up high. I had to go through and undo all the clamps and put it down b... | My research on topic:
1. Use PEX 'A' - it's better designed to flex; PEX is not guaranteed not to freeze or rupture; so use the better PEX grade; if possible avoid Grade 'B' and 'C'; use PEX 'A' if you have to go this method.
2. Will freeze and certainly can rupture, but less likely than copper pipes.
3. Make sure to... |
10,784 | I plan on running PEX pipes both hot and cold across 16 feet of unheated attic space above a foyer. The foyer is 16' long and is off the kitchen, it isn't heated directly but is part of the house; it is usually colder than the rest of the house, mostly due to the cat door and slider the dogs go in and out of. There is ... | 2011/12/20 | [
"https://diy.stackexchange.com/questions/10784",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/4651/"
] | Pex in the attic simply needs to be run BELOW the insulation. Put it against the ceiling drywall, and it will never get particularly cold.
The problem is, lots of installers don't do this. My contractor actually went to some trouble to hang the pex up high. I had to go through and undo all the clamps and put it down b... | Additional information as this winter tests out badly routed plumbing. PEX that gets water frozen inside it stretches and expands over time.
The weak point is fittings. Depending on the fitting, it can crack, the crimp rings can be stretched leading to a leak from the fitting or the PEX slipping off under pressure. Th... |
63,878,170 | The code:
```
if __name__ == '__main__':
n = int(input())
arr = list(map(int, input().rstrip().split()))
for i in range(n-1):
arr+=list(map(int, input().rstrip().split()))
arr=arr[::-1]
for i in arr:
print(i,'',end='')
```
The error which I get:
```
Compiler Message
Runtime Erro... | 2020/09/14 | [
"https://Stackoverflow.com/questions/63878170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14032073/"
] | You can try with this below script-
```
SELECT id,
MAX(CASE WHEN name = 'car1' THEN name END) car1,
MAX(CASE WHEN name = 'car2' THEN name END) car2,
MAX(CASE WHEN name = 'car3' THEN name END) car3
FROM your_table
GROUP BY id
``` | You can go for PIVOT feature.
```sql
;WITH src as
(
SELECT *
FROM
(
VALUES
(1, 'Car1', 'nissan'),
(1, 'Car2', 'audi'),
(1, 'Car3', 'toyota')
) as t (id, name, value)
)
SELECT *
FROM src
PIVOT
(
max(VALUE) FOR NAME IN ([Car1], [Car2], [Car3])
) as pvt
```
```
+----... |
51,940,312 | I found a function which performs the same as `strcmp` but I was unable to see where the comparison `s1 == s2` is happening. I need help. Thanks.
```
int MyStrcmp (const char *s1, const char *s2)
{
int i;
for (i = 0; s1[i] != 0 && s2[i] != 0; i++)
{
if (s1[i] > s2[i])
return +1;
... | 2018/08/21 | [
"https://Stackoverflow.com/questions/51940312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10146920/"
] | If `s1 == s2`, it also means that the length of the two strings are equal. Keeping this in mind, going through the for loop, none of the if statements in the loop are ever true. Therefore, we escape the for loop as `s1[i] = s2[i] = 0`, with `i` set to the length of the strings given. Now for the remaining two if statem... | We can not see '==' indeed, because the function use exclusion method, this function trys to filter all the inequality situations.
The first half of this function: compare each char between s1 and s2, if any of char is not equal, the function finish and return corresponding comparison result.
The second half of this... |
42,879,075 | **Question:**
>
> Write a function called `sumDigits`.
>
>
> Given a number, `sumDigits` returns the sum of all its digits.
>
>
> `var output = sumDigits(1148);`
>
> `console.log(output); // --> 14`
>
>
> If the number is negative, the first digit should count as negative.
>
>
> `var output = sumDigits(-3... | 2017/03/18 | [
"https://Stackoverflow.com/questions/42879075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7711351/"
] | This should do it:
```js
function sumDigits(num) {
var total = 0;
var newString = num.toString().split('');
for (var i = 0; i < newString.length; i ++) {
if(newString[i]==='-') { //check to see if the first char is -
i++; //if it is, lets move to the negative number
... | One way to do this, is to do a split that will keep the minus and the first digit together, not split.
You can do that with a regular expression, and use `match` instead of `split`:
```
var newString = num.toString().match(/-?\d/g);
```
```js
function sumDigits(num) {
var total = 0;
var newString = num.toStri... |
42,879,075 | **Question:**
>
> Write a function called `sumDigits`.
>
>
> Given a number, `sumDigits` returns the sum of all its digits.
>
>
> `var output = sumDigits(1148);`
>
> `console.log(output); // --> 14`
>
>
> If the number is negative, the first digit should count as negative.
>
>
> `var output = sumDigits(-3... | 2017/03/18 | [
"https://Stackoverflow.com/questions/42879075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7711351/"
] | This should do it:
```js
function sumDigits(num) {
var total = 0;
var newString = num.toString().split('');
for (var i = 0; i < newString.length; i ++) {
if(newString[i]==='-') { //check to see if the first char is -
i++; //if it is, lets move to the negative number
... | You could always use `String#replace` with a function as a parameter:
```js
function sumDigits (n) {
var total = 0
n.toFixed().replace(/-?\d/g, function (d) {
total += +d
})
return total
}
console.log(sumDigits(-1148)) //=> 14
``` |
42,879,075 | **Question:**
>
> Write a function called `sumDigits`.
>
>
> Given a number, `sumDigits` returns the sum of all its digits.
>
>
> `var output = sumDigits(1148);`
>
> `console.log(output); // --> 14`
>
>
> If the number is negative, the first digit should count as negative.
>
>
> `var output = sumDigits(-3... | 2017/03/18 | [
"https://Stackoverflow.com/questions/42879075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7711351/"
] | This should do it:
```js
function sumDigits(num) {
var total = 0;
var newString = num.toString().split('');
for (var i = 0; i < newString.length; i ++) {
if(newString[i]==='-') { //check to see if the first char is -
i++; //if it is, lets move to the negative number
... | >
> Is there a smarter way to even look at this?
>
>
>
You can avoid the conversion from number to string and back by using the modulo operator to extract the last digit. Repeat this step until you got all digits:
```js
function sumDigits(num) {
let total = 0, digit = 0;
while (num != 0) {
total += dig... |
42,879,075 | **Question:**
>
> Write a function called `sumDigits`.
>
>
> Given a number, `sumDigits` returns the sum of all its digits.
>
>
> `var output = sumDigits(1148);`
>
> `console.log(output); // --> 14`
>
>
> If the number is negative, the first digit should count as negative.
>
>
> `var output = sumDigits(-3... | 2017/03/18 | [
"https://Stackoverflow.com/questions/42879075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7711351/"
] | This should do it:
```js
function sumDigits(num) {
var total = 0;
var newString = num.toString().split('');
for (var i = 0; i < newString.length; i ++) {
if(newString[i]==='-') { //check to see if the first char is -
i++; //if it is, lets move to the negative number
... | ```
function sumDigits(num) {
let string = num.toString();
let zero = 0;
let total = 0;
for (var i = 0; i < string.length; i++) {
if (Math.sign(num) === 1) {
total = zero += Number(string[i]);
} else {
for (var i = 2; i < string.length; i++) {
total = (zero += Number(string... |
42,879,075 | **Question:**
>
> Write a function called `sumDigits`.
>
>
> Given a number, `sumDigits` returns the sum of all its digits.
>
>
> `var output = sumDigits(1148);`
>
> `console.log(output); // --> 14`
>
>
> If the number is negative, the first digit should count as negative.
>
>
> `var output = sumDigits(-3... | 2017/03/18 | [
"https://Stackoverflow.com/questions/42879075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7711351/"
] | One way to do this, is to do a split that will keep the minus and the first digit together, not split.
You can do that with a regular expression, and use `match` instead of `split`:
```
var newString = num.toString().match(/-?\d/g);
```
```js
function sumDigits(num) {
var total = 0;
var newString = num.toStri... | >
> Is there a smarter way to even look at this?
>
>
>
You can avoid the conversion from number to string and back by using the modulo operator to extract the last digit. Repeat this step until you got all digits:
```js
function sumDigits(num) {
let total = 0, digit = 0;
while (num != 0) {
total += dig... |
42,879,075 | **Question:**
>
> Write a function called `sumDigits`.
>
>
> Given a number, `sumDigits` returns the sum of all its digits.
>
>
> `var output = sumDigits(1148);`
>
> `console.log(output); // --> 14`
>
>
> If the number is negative, the first digit should count as negative.
>
>
> `var output = sumDigits(-3... | 2017/03/18 | [
"https://Stackoverflow.com/questions/42879075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7711351/"
] | One way to do this, is to do a split that will keep the minus and the first digit together, not split.
You can do that with a regular expression, and use `match` instead of `split`:
```
var newString = num.toString().match(/-?\d/g);
```
```js
function sumDigits(num) {
var total = 0;
var newString = num.toStri... | ```
function sumDigits(num) {
let string = num.toString();
let zero = 0;
let total = 0;
for (var i = 0; i < string.length; i++) {
if (Math.sign(num) === 1) {
total = zero += Number(string[i]);
} else {
for (var i = 2; i < string.length; i++) {
total = (zero += Number(string... |
42,879,075 | **Question:**
>
> Write a function called `sumDigits`.
>
>
> Given a number, `sumDigits` returns the sum of all its digits.
>
>
> `var output = sumDigits(1148);`
>
> `console.log(output); // --> 14`
>
>
> If the number is negative, the first digit should count as negative.
>
>
> `var output = sumDigits(-3... | 2017/03/18 | [
"https://Stackoverflow.com/questions/42879075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7711351/"
] | You could always use `String#replace` with a function as a parameter:
```js
function sumDigits (n) {
var total = 0
n.toFixed().replace(/-?\d/g, function (d) {
total += +d
})
return total
}
console.log(sumDigits(-1148)) //=> 14
``` | >
> Is there a smarter way to even look at this?
>
>
>
You can avoid the conversion from number to string and back by using the modulo operator to extract the last digit. Repeat this step until you got all digits:
```js
function sumDigits(num) {
let total = 0, digit = 0;
while (num != 0) {
total += dig... |
42,879,075 | **Question:**
>
> Write a function called `sumDigits`.
>
>
> Given a number, `sumDigits` returns the sum of all its digits.
>
>
> `var output = sumDigits(1148);`
>
> `console.log(output); // --> 14`
>
>
> If the number is negative, the first digit should count as negative.
>
>
> `var output = sumDigits(-3... | 2017/03/18 | [
"https://Stackoverflow.com/questions/42879075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7711351/"
] | You could always use `String#replace` with a function as a parameter:
```js
function sumDigits (n) {
var total = 0
n.toFixed().replace(/-?\d/g, function (d) {
total += +d
})
return total
}
console.log(sumDigits(-1148)) //=> 14
``` | ```
function sumDigits(num) {
let string = num.toString();
let zero = 0;
let total = 0;
for (var i = 0; i < string.length; i++) {
if (Math.sign(num) === 1) {
total = zero += Number(string[i]);
} else {
for (var i = 2; i < string.length; i++) {
total = (zero += Number(string... |
3,328,005 | Let $X$ be a compact metric space. Take a sequence $\{\mu\_n\}\_{n=1}^\infty$ of Borel probability measures on $X$. Assume that this sequence converges (weak-$\ast$) to a Borel probability measure $\mu$ on $X$.
Let $A$ be a Borel subset of $A$ such that $\mu\_n(A)=0$ for all $n\geq 1$. Is it necessarily true that $\mu... | 2019/08/19 | [
"https://math.stackexchange.com/questions/3328005",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/634463/"
] | No: take $X=[0,1]$, $\mu\_n=\delta\_{1/n}$, $\mu=\delta\_0$, and $A=\{0\}$. | If $\mu\_n\to\mu$ weak\* there's not much that can be said about convergence of $\mu\_n(A)$. If I recall correctly, assuming of course we're talking about regular Borel measures:
1. If $A$ is compact then $\mu(A)\ge\limsup\mu\_n(A)$.
2. If $A$ is open then $\mu(A)\le\liminf\mu\_n(A)$,
and I think that's about the who... |
10,700,957 | We are having some strange performance issues and I was hoping somebody may be able to point us in the right direction. Our scenario is an `ASP.NET MVC C#` website using `EF4 POCO` in `IIS 7` (highly specced servers, dedicated just for this application).
Obviously it's slow on application\_startup which is to be expe... | 2012/05/22 | [
"https://Stackoverflow.com/questions/10700957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/351711/"
] | Are you using LMHOSTS file? We had same issue. LMHOSTS file cache expires after 10 minutes by default. After system has been sitting idle for 10 minutes the host would use Broadcast message before reloading the LMHOSTS file causing the delay. | Since it is the first run (per app?) that is slow, you may be experiencing the compilation of the EDMX or the LINQ into SQL.
Possible solutions:
1. Use precompiled views and precompiled queries (may require a lot of refactoring).
<http://msdn.microsoft.com/en-us/library/bb896240.aspx>
<http://blogs.msdn.com/b/d... |
10,700,957 | We are having some strange performance issues and I was hoping somebody may be able to point us in the right direction. Our scenario is an `ASP.NET MVC C#` website using `EF4 POCO` in `IIS 7` (highly specced servers, dedicated just for this application).
Obviously it's slow on application\_startup which is to be expe... | 2012/05/22 | [
"https://Stackoverflow.com/questions/10700957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/351711/"
] | >
> It seems after looking at Sql Server Profiler after 5 minutes give or
> take 30 seconds with no activity in Sql Server Profiler and no site
> interaction a couple of "Audit Logout" entries appear for the
> application and as soon as that happens it then seems to take 10 - 15
> seconds to refresh the applicatio... | I would run "SQL Server Profiler" against SQL Server and capture a new trace while reproducing the problem by accessing the site after being idle 5-10 mins. After that look at the trace. Specifically, look for entries in which ApplicationName starts with "EntityFramework...". This will tell you what is EF doing at that... |
10,700,957 | We are having some strange performance issues and I was hoping somebody may be able to point us in the right direction. Our scenario is an `ASP.NET MVC C#` website using `EF4 POCO` in `IIS 7` (highly specced servers, dedicated just for this application).
Obviously it's slow on application\_startup which is to be expe... | 2012/05/22 | [
"https://Stackoverflow.com/questions/10700957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/351711/"
] | This should work if you use the below in your connection string:
```
server=MyServer;database=MyDatabase;Min Pool Size=1;Max Pool Size=100
```
It will force your connection pool to always maintain at least one connection. I must say I don't recommend this (persistant connection) but it will solve your problem. | Try to overwrite your timeout in the web.config like in this example:
```
Data Source=mydatabase;Initial Catalog=Match;Persist Security Info=True
;User ID=User;Password=password;Connection Timeout=120
```
If it works, this is not a solution..just a work around. |
10,700,957 | We are having some strange performance issues and I was hoping somebody may be able to point us in the right direction. Our scenario is an `ASP.NET MVC C#` website using `EF4 POCO` in `IIS 7` (highly specced servers, dedicated just for this application).
Obviously it's slow on application\_startup which is to be expe... | 2012/05/22 | [
"https://Stackoverflow.com/questions/10700957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/351711/"
] | >
> It seems after looking at Sql Server Profiler after 5 minutes give or
> take 30 seconds with no activity in Sql Server Profiler and no site
> interaction a couple of "Audit Logout" entries appear for the
> application and as soon as that happens it then seems to take 10 - 15
> seconds to refresh the applicatio... | Try to overwrite your timeout in the web.config like in this example:
```
Data Source=mydatabase;Initial Catalog=Match;Persist Security Info=True
;User ID=User;Password=password;Connection Timeout=120
```
If it works, this is not a solution..just a work around. |
10,700,957 | We are having some strange performance issues and I was hoping somebody may be able to point us in the right direction. Our scenario is an `ASP.NET MVC C#` website using `EF4 POCO` in `IIS 7` (highly specced servers, dedicated just for this application).
Obviously it's slow on application\_startup which is to be expe... | 2012/05/22 | [
"https://Stackoverflow.com/questions/10700957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/351711/"
] | Are you using LMHOSTS file? We had same issue. LMHOSTS file cache expires after 10 minutes by default. After system has been sitting idle for 10 minutes the host would use Broadcast message before reloading the LMHOSTS file causing the delay. | In our case the application was hosted in Azure App Service Plan and was having similar problem. Turned out to be a problem of not configuring virtual network. See the question/answer here - [EF Core 3.1.14 Recurring Cold Start](https://stackoverflow.com/questions/67409483/ef-core-3-1-14-recurring-cold-start/67445410#6... |
10,700,957 | We are having some strange performance issues and I was hoping somebody may be able to point us in the right direction. Our scenario is an `ASP.NET MVC C#` website using `EF4 POCO` in `IIS 7` (highly specced servers, dedicated just for this application).
Obviously it's slow on application\_startup which is to be expe... | 2012/05/22 | [
"https://Stackoverflow.com/questions/10700957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/351711/"
] | This should work if you use the below in your connection string:
```
server=MyServer;database=MyDatabase;Min Pool Size=1;Max Pool Size=100
```
It will force your connection pool to always maintain at least one connection. I must say I don't recommend this (persistant connection) but it will solve your problem. | Are you using LMHOSTS file? We had same issue. LMHOSTS file cache expires after 10 minutes by default. After system has been sitting idle for 10 minutes the host would use Broadcast message before reloading the LMHOSTS file causing the delay. |
10,700,957 | We are having some strange performance issues and I was hoping somebody may be able to point us in the right direction. Our scenario is an `ASP.NET MVC C#` website using `EF4 POCO` in `IIS 7` (highly specced servers, dedicated just for this application).
Obviously it's slow on application\_startup which is to be expe... | 2012/05/22 | [
"https://Stackoverflow.com/questions/10700957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/351711/"
] | >
> It seems after looking at Sql Server Profiler after 5 minutes give or
> take 30 seconds with no activity in Sql Server Profiler and no site
> interaction a couple of "Audit Logout" entries appear for the
> application and as soon as that happens it then seems to take 10 - 15
> seconds to refresh the applicatio... | Create a simple webpage that accesses the SQL Server with a trivial query like "Select getDate()" or some other cheap query. Then use an external service like Pingdom or other monitor to hit that page every 30 seconds or so. That should keep the connections warm. |
10,700,957 | We are having some strange performance issues and I was hoping somebody may be able to point us in the right direction. Our scenario is an `ASP.NET MVC C#` website using `EF4 POCO` in `IIS 7` (highly specced servers, dedicated just for this application).
Obviously it's slow on application\_startup which is to be expe... | 2012/05/22 | [
"https://Stackoverflow.com/questions/10700957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/351711/"
] | This should work if you use the below in your connection string:
```
server=MyServer;database=MyDatabase;Min Pool Size=1;Max Pool Size=100
```
It will force your connection pool to always maintain at least one connection. I must say I don't recommend this (persistant connection) but it will solve your problem. | Since it is the first run (per app?) that is slow, you may be experiencing the compilation of the EDMX or the LINQ into SQL.
Possible solutions:
1. Use precompiled views and precompiled queries (may require a lot of refactoring).
<http://msdn.microsoft.com/en-us/library/bb896240.aspx>
<http://blogs.msdn.com/b/d... |
10,700,957 | We are having some strange performance issues and I was hoping somebody may be able to point us in the right direction. Our scenario is an `ASP.NET MVC C#` website using `EF4 POCO` in `IIS 7` (highly specced servers, dedicated just for this application).
Obviously it's slow on application\_startup which is to be expe... | 2012/05/22 | [
"https://Stackoverflow.com/questions/10700957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/351711/"
] | >
> It seems after looking at Sql Server Profiler after 5 minutes give or
> take 30 seconds with no activity in Sql Server Profiler and no site
> interaction a couple of "Audit Logout" entries appear for the
> application and as soon as that happens it then seems to take 10 - 15
> seconds to refresh the applicatio... | Since it is the first run (per app?) that is slow, you may be experiencing the compilation of the EDMX or the LINQ into SQL.
Possible solutions:
1. Use precompiled views and precompiled queries (may require a lot of refactoring).
<http://msdn.microsoft.com/en-us/library/bb896240.aspx>
<http://blogs.msdn.com/b/d... |
10,700,957 | We are having some strange performance issues and I was hoping somebody may be able to point us in the right direction. Our scenario is an `ASP.NET MVC C#` website using `EF4 POCO` in `IIS 7` (highly specced servers, dedicated just for this application).
Obviously it's slow on application\_startup which is to be expe... | 2012/05/22 | [
"https://Stackoverflow.com/questions/10700957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/351711/"
] | >
> It seems after looking at Sql Server Profiler after 5 minutes give or
> take 30 seconds with no activity in Sql Server Profiler and no site
> interaction a couple of "Audit Logout" entries appear for the
> application and as soon as that happens it then seems to take 10 - 15
> seconds to refresh the applicatio... | In our case the application was hosted in Azure App Service Plan and was having similar problem. Turned out to be a problem of not configuring virtual network. See the question/answer here - [EF Core 3.1.14 Recurring Cold Start](https://stackoverflow.com/questions/67409483/ef-core-3-1-14-recurring-cold-start/67445410#6... |
62,223,854 | I have been struggling for the past hours trying to upload an image to firestore storage but I can't make it... The image seems to be corrupted once on Firestore
```
func (fs *FS) Upload(fileInput []byte, fileName string) error {
ctx, cancel := context.WithTimeout(context.Background(), fs.defaultTransferTimeout)
... | 2020/06/05 | [
"https://Stackoverflow.com/questions/62223854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6093604/"
] | You can iterate over the outer area two at a time. Then, iterate over the inner ones, and save the semester in the first array with the corresponding course in the second array in a `JSON` object as key-value pairs. You need to make sure that the length of the outer array is even, and that of the inner arrays are equal... | for loop processing 2 sets of arrays at once. Assumes that sets of arrays are same length.
```js
const content = [
['Spring 2017', 'Spring 2018', 'Spring 2019', 'Spring 2020'],
['Calc 1', 'Calc 2', 'Economics 1', 'Psychology 1'],
['Summer 2017', 'Summer 2018', 'Summer 2019', 'Summer 2020','x'],
['Swimming'... |
62,614,793 | I'd like to extend the CaseIterable protocol so that all CaseIterable enums have a `random` static var that returns a random case. This is the code I've tried
```
public extension CaseIterable {
static var random<T: CaseIterable>: T {
let allCases = self.allCases
return allCases[Int.random(n: allCa... | 2020/06/27 | [
"https://Stackoverflow.com/questions/62614793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3261886/"
] | So I figured it out. When adding a TensorFlow model to help with the object detection, apparently it has to contain metadata (so that that way, when you want to call "getLabels()" and its appropriate methods, it will actually return a label. Otherwise it will return nothing and cause errors apparently.
[![MLKit screen ... | To answer your #3 question:
>
> Once it detects an object, the app won't "change" (i.e when I move the phone, to try to detect another object, nothing in the display changes.
>
>
>
I'm guessing this is caused by the fact that your `imageProxy().close` needs to be a part of an OnCompletedListener else it will caus... |
34,079,561 | I am trying to do something like this:
```
string foo = "Hello, this is a string";
//and then search for it. Kind of like this
string foo2 = foo.Substring(0,2);
//then return the rest. Like for example foo2 returns "He".
//I want it to return the rest "llo, this is a string"
```
Thanks. | 2015/12/04 | [
"https://Stackoverflow.com/questions/34079561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5635030/"
] | **Xcode 8 • Swift 3**
```
extension Collection where Iterator.Element == UInt8 {
var bytes: [UInt8] { return Array(self) }
var data: Data { return Data(self) }
var string: String? { return String(data: data, encoding: .utf8) }
}
extension String {
var data: Data { return Data(utf8) }
}
```
usage:
`... | I actually ended up needing to do this for a stream of `UInt8` and was curious how hard utf8 decoding is. It's definitely not a one liner, but through the following direct implementation together:
```
import UIKit
let bytes:[UInt8] = [0xE2, 0x82, 0xEC, 0x00]
var g = bytes.generate()
extension String {
init(var ... |
34,079,561 | I am trying to do something like this:
```
string foo = "Hello, this is a string";
//and then search for it. Kind of like this
string foo2 = foo.Substring(0,2);
//then return the rest. Like for example foo2 returns "He".
//I want it to return the rest "llo, this is a string"
```
Thanks. | 2015/12/04 | [
"https://Stackoverflow.com/questions/34079561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5635030/"
] | ```
let buffUInt8: Array<UInt8> = [97, 98, 115, 100, 114, 102, 103, 104, 0]
// you need Int8 array
let buffInt8 = buffUInt8.map{ Int8(bitPattern: $0)}
let str = String.fromCString(buffInt8) // "absdrfgh"
```
alternatively you can use
```
String.fromCStringRepairingIllFormedUTF8(cs: UnsafePointer<CChar>) -> (String?... | I actually ended up needing to do this for a stream of `UInt8` and was curious how hard utf8 decoding is. It's definitely not a one liner, but through the following direct implementation together:
```
import UIKit
let bytes:[UInt8] = [0xE2, 0x82, 0xEC, 0x00]
var g = bytes.generate()
extension String {
init(var ... |
5,679,880 | What does this do?
```
const wchar_t *s = L"test";
```
If wchar\_t is two bytes on my machine, then why should we tell the compiler that the string should be treated in a way that each element is long i.e, *four* bytes in size? | 2011/04/15 | [
"https://Stackoverflow.com/questions/5679880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/570078/"
] | The `L` means that string is a string of `wchar_t` characters, rather than the normal string of `char` characters. I'm not sure where you got the bit about four bytes from.
From the spec section **6.4.5 String literals**, paragraph 2:
>
> A *character string literal* is a sequence of zero or more multibyte character... | It indicates a string of wide characters, of type `wchar_t`. |
5,679,880 | What does this do?
```
const wchar_t *s = L"test";
```
If wchar\_t is two bytes on my machine, then why should we tell the compiler that the string should be treated in a way that each element is long i.e, *four* bytes in size? | 2011/04/15 | [
"https://Stackoverflow.com/questions/5679880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/570078/"
] | The `L` means that string is a string of `wchar_t` characters, rather than the normal string of `char` characters. I'm not sure where you got the bit about four bytes from.
From the spec section **6.4.5 String literals**, paragraph 2:
>
> A *character string literal* is a sequence of zero or more multibyte character... | If you don't know what that `L` does, then why are you making an assertive statement about each array element being `long` ("four bytes in size")? Where did that idea with the `long` come from?
That `L` has as much relation to `long` as it has to "leprechaun" - no relation at all. The `L` prefix means that the followi... |
5,679,880 | What does this do?
```
const wchar_t *s = L"test";
```
If wchar\_t is two bytes on my machine, then why should we tell the compiler that the string should be treated in a way that each element is long i.e, *four* bytes in size? | 2011/04/15 | [
"https://Stackoverflow.com/questions/5679880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/570078/"
] | The `L` means that string is a string of `wchar_t` characters, rather than the normal string of `char` characters. I'm not sure where you got the bit about four bytes from.
From the spec section **6.4.5 String literals**, paragraph 2:
>
> A *character string literal* is a sequence of zero or more multibyte character... | `L` does not mean `long integer` when prefixing a string. It means each character in the string is a wide character.
Without this prefix, you are assigning a string of `char` to a `wchar_t` pointer, which would be a mismatch. |
5,679,880 | What does this do?
```
const wchar_t *s = L"test";
```
If wchar\_t is two bytes on my machine, then why should we tell the compiler that the string should be treated in a way that each element is long i.e, *four* bytes in size? | 2011/04/15 | [
"https://Stackoverflow.com/questions/5679880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/570078/"
] | If in doubt, consult the standard (§6.4.5, String Literals):
>
> A *character string literal* is a
> sequence of zero or more multibyte
> characters enclosed in double-quotes,
> as in `"xyz"`. A *wide string literal* is
> the same, except prefixed by the
> letter `L`.
>
>
>
Note that it **does not** indicate... | It indicates a string of wide characters, of type `wchar_t`. |
5,679,880 | What does this do?
```
const wchar_t *s = L"test";
```
If wchar\_t is two bytes on my machine, then why should we tell the compiler that the string should be treated in a way that each element is long i.e, *four* bytes in size? | 2011/04/15 | [
"https://Stackoverflow.com/questions/5679880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/570078/"
] | `L` does not mean `long integer` when prefixing a string. It means each character in the string is a wide character.
Without this prefix, you are assigning a string of `char` to a `wchar_t` pointer, which would be a mismatch. | It indicates a string of wide characters, of type `wchar_t`. |
5,679,880 | What does this do?
```
const wchar_t *s = L"test";
```
If wchar\_t is two bytes on my machine, then why should we tell the compiler that the string should be treated in a way that each element is long i.e, *four* bytes in size? | 2011/04/15 | [
"https://Stackoverflow.com/questions/5679880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/570078/"
] | If in doubt, consult the standard (§6.4.5, String Literals):
>
> A *character string literal* is a
> sequence of zero or more multibyte
> characters enclosed in double-quotes,
> as in `"xyz"`. A *wide string literal* is
> the same, except prefixed by the
> letter `L`.
>
>
>
Note that it **does not** indicate... | If you don't know what that `L` does, then why are you making an assertive statement about each array element being `long` ("four bytes in size")? Where did that idea with the `long` come from?
That `L` has as much relation to `long` as it has to "leprechaun" - no relation at all. The `L` prefix means that the followi... |
5,679,880 | What does this do?
```
const wchar_t *s = L"test";
```
If wchar\_t is two bytes on my machine, then why should we tell the compiler that the string should be treated in a way that each element is long i.e, *four* bytes in size? | 2011/04/15 | [
"https://Stackoverflow.com/questions/5679880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/570078/"
] | If in doubt, consult the standard (§6.4.5, String Literals):
>
> A *character string literal* is a
> sequence of zero or more multibyte
> characters enclosed in double-quotes,
> as in `"xyz"`. A *wide string literal* is
> the same, except prefixed by the
> letter `L`.
>
>
>
Note that it **does not** indicate... | `L` does not mean `long integer` when prefixing a string. It means each character in the string is a wide character.
Without this prefix, you are assigning a string of `char` to a `wchar_t` pointer, which would be a mismatch. |
5,679,880 | What does this do?
```
const wchar_t *s = L"test";
```
If wchar\_t is two bytes on my machine, then why should we tell the compiler that the string should be treated in a way that each element is long i.e, *four* bytes in size? | 2011/04/15 | [
"https://Stackoverflow.com/questions/5679880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/570078/"
] | `L` does not mean `long integer` when prefixing a string. It means each character in the string is a wide character.
Without this prefix, you are assigning a string of `char` to a `wchar_t` pointer, which would be a mismatch. | If you don't know what that `L` does, then why are you making an assertive statement about each array element being `long` ("four bytes in size")? Where did that idea with the `long` come from?
That `L` has as much relation to `long` as it has to "leprechaun" - no relation at all. The `L` prefix means that the followi... |
205,390 | Is there any way to tell postfix to send ALL bounces to ONE mailbox?
Right now bounces are sent to the Sender, but I would like to collect them all at one central place for further analyzing etc.
I read about bounces and address rewriting, but found nothing to clearly state if this is possible or not -- to be exact: ... | 2010/11/23 | [
"https://serverfault.com/questions/205390",
"https://serverfault.com",
"https://serverfault.com/users/61316/"
] | Usually your intrusion detection log for a rogue IP address would list the MAC, but since it does not, you can try the following.
Log onto your Cisco Device. Ping the rogue IP. Of course if you ACL is blocking access, this might be problematic.
```
ping 169.254.X.X
```
This will hopefully get the device's MAC addre... | ```
show mac-address-table dynamic
```
That will show you MAC-to-port mappings. |
601,678 | I was having a discussion with someone about why 3.5" hard drive adapters don't exist that run solely off USB. Please forgive me but my electrical engineering knowledge is minimal and been a long time since I've used it for anything practical.
I know typical USB 3 can provide 5V / 900mA (4.5W) DC.
12V conversion end ... | 2021/12/24 | [
"https://electronics.stackexchange.com/questions/601678",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/303794/"
] | If I'm not mistaken, a USB 3.1 port can even deliver 2A (nb : it might require power negotiation first).
But basicaly, it's just a question of power : each USB port gives you 4.5W (if 900mA) or 10W (if 2A).
Your hard drive, you need : 5\*0.43 + 12 \* 0.65 \* 1.3 = 12.3W (nb : I added a 1.3 multiplier for the 12V, to ... | you made the math wrong: from an USB3.0 you can get up to 5V at 900mA (4.5W), and with a converter, you can get an output of 12V at 375mA. At this point you have NO power available for the 5V rail needed by the HDD, and also is not enough for the 12V itself. You can't power an HDD which demands 12V at 0.65A.
Secondly,... |
601,678 | I was having a discussion with someone about why 3.5" hard drive adapters don't exist that run solely off USB. Please forgive me but my electrical engineering knowledge is minimal and been a long time since I've used it for anything practical.
I know typical USB 3 can provide 5V / 900mA (4.5W) DC.
12V conversion end ... | 2021/12/24 | [
"https://electronics.stackexchange.com/questions/601678",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/303794/"
] | you made the math wrong: from an USB3.0 you can get up to 5V at 900mA (4.5W), and with a converter, you can get an output of 12V at 375mA. At this point you have NO power available for the 5V rail needed by the HDD, and also is not enough for the 12V itself. You can't power an HDD which demands 12V at 0.65A.
Secondly,... | >
> I know typical USB 3 can provide 5V / 900mA (4.5W) DC.
>
>
>
That's not the power a USB 3.x port can provide "typically", that's the minimum power a USB 3.x port can provide and still meet the USB 3.x spec. I don't know if this is "typical" but I've seen many USB 3.x ports that will provide 7.5 watts, 5 volts ... |
601,678 | I was having a discussion with someone about why 3.5" hard drive adapters don't exist that run solely off USB. Please forgive me but my electrical engineering knowledge is minimal and been a long time since I've used it for anything practical.
I know typical USB 3 can provide 5V / 900mA (4.5W) DC.
12V conversion end ... | 2021/12/24 | [
"https://electronics.stackexchange.com/questions/601678",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/303794/"
] | If I'm not mistaken, a USB 3.1 port can even deliver 2A (nb : it might require power negotiation first).
But basicaly, it's just a question of power : each USB port gives you 4.5W (if 900mA) or 10W (if 2A).
Your hard drive, you need : 5\*0.43 + 12 \* 0.65 \* 1.3 = 12.3W (nb : I added a 1.3 multiplier for the 12V, to ... | They don't exist because they are not practical. If you need 10 watts and need to connect three USB cables just to run a single drive, and even require complex energy storage solution to get it started, it will be quite complex to draw power from three cables in a way that it fills USB specs. You can't just short the U... |
601,678 | I was having a discussion with someone about why 3.5" hard drive adapters don't exist that run solely off USB. Please forgive me but my electrical engineering knowledge is minimal and been a long time since I've used it for anything practical.
I know typical USB 3 can provide 5V / 900mA (4.5W) DC.
12V conversion end ... | 2021/12/24 | [
"https://electronics.stackexchange.com/questions/601678",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/303794/"
] | If I'm not mistaken, a USB 3.1 port can even deliver 2A (nb : it might require power negotiation first).
But basicaly, it's just a question of power : each USB port gives you 4.5W (if 900mA) or 10W (if 2A).
Your hard drive, you need : 5\*0.43 + 12 \* 0.65 \* 1.3 = 12.3W (nb : I added a 1.3 multiplier for the 12V, to ... | >
> I know typical USB 3 can provide 5V / 900mA (4.5W) DC.
>
>
>
That's not the power a USB 3.x port can provide "typically", that's the minimum power a USB 3.x port can provide and still meet the USB 3.x spec. I don't know if this is "typical" but I've seen many USB 3.x ports that will provide 7.5 watts, 5 volts ... |
601,678 | I was having a discussion with someone about why 3.5" hard drive adapters don't exist that run solely off USB. Please forgive me but my electrical engineering knowledge is minimal and been a long time since I've used it for anything practical.
I know typical USB 3 can provide 5V / 900mA (4.5W) DC.
12V conversion end ... | 2021/12/24 | [
"https://electronics.stackexchange.com/questions/601678",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/303794/"
] | They don't exist because they are not practical. If you need 10 watts and need to connect three USB cables just to run a single drive, and even require complex energy storage solution to get it started, it will be quite complex to draw power from three cables in a way that it fills USB specs. You can't just short the U... | >
> I know typical USB 3 can provide 5V / 900mA (4.5W) DC.
>
>
>
That's not the power a USB 3.x port can provide "typically", that's the minimum power a USB 3.x port can provide and still meet the USB 3.x spec. I don't know if this is "typical" but I've seen many USB 3.x ports that will provide 7.5 watts, 5 volts ... |
15,167,390 | I am currently using `getc()` in a loop to receive input from a user:
```
char x;
while (x != 'q')
{
printf("(c)ontinue or (q)uit?");
x = getc(stdin);
}
```
If the user enters `c` the loop executes, presumably taking an additional character (the terminator or possibly a newline, I am guessing?) as input the fi... | 2013/03/01 | [
"https://Stackoverflow.com/questions/15167390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2124880/"
] | >
> or should I be using it as a string and using the first character of the array?
>
>
>
Exactly.
```
char buf[32] = { 0 };
while (buf[0] != 'q') {
fgets(buf, sizeof(buf), stdin);
/* do stuff here */
}
``` | You could just ignore spaces:
```
int x = 0;
while (x != 'q' && x != EOF)
{
printf("(c)ontinue or (q)uit?");
while ((x = getc(stdin)) != EOF && isspace(x)) { /* ignore whitespace */ }
}
```
Also note that `getc()` returns an `int`, not `char`. This is important if you want to detect `EOF` which you should also... |
72,789,446 | I have two lists and I want to append one with another, like this:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
```
new list should be like this:
```
n = [['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
```
I try this but it didn't work:
```
for i, j in a,... | 2022/06/28 | [
"https://Stackoverflow.com/questions/72789446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14481446/"
] | Use list comprehension:
```py
[i+j for i,j in zip(a, b)]
```
Results in:
```py
[['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
``` | You can use `zip` and concatenation:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
c = [item[0] + item[1] for item in zip(a, b)]
```
Which yields:
```
['bmw', 12, 2]
['audi', 3, 4]
['benz', 7, 5]
['honda', 6, 23]
``` |
72,789,446 | I have two lists and I want to append one with another, like this:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
```
new list should be like this:
```
n = [['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
```
I try this but it didn't work:
```
for i, j in a,... | 2022/06/28 | [
"https://Stackoverflow.com/questions/72789446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14481446/"
] | You almost got it right, you should use `extend` instead of `append`:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
for i, j in zip(a, b):
i.extend(j)
print(a)
```
Output:
```
[['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
``` | You can use `zip` and concatenation:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
c = [item[0] + item[1] for item in zip(a, b)]
```
Which yields:
```
['bmw', 12, 2]
['audi', 3, 4]
['benz', 7, 5]
['honda', 6, 23]
``` |
72,789,446 | I have two lists and I want to append one with another, like this:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
```
new list should be like this:
```
n = [['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
```
I try this but it didn't work:
```
for i, j in a,... | 2022/06/28 | [
"https://Stackoverflow.com/questions/72789446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14481446/"
] | Use list comprehension:
```py
[i+j for i,j in zip(a, b)]
```
Results in:
```py
[['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
``` | You almost got it right, you should use `extend` instead of `append`:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
for i, j in zip(a, b):
i.extend(j)
print(a)
```
Output:
```
[['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
``` |
72,789,446 | I have two lists and I want to append one with another, like this:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
```
new list should be like this:
```
n = [['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
```
I try this but it didn't work:
```
for i, j in a,... | 2022/06/28 | [
"https://Stackoverflow.com/questions/72789446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14481446/"
] | ```
for el1, el2 in zip(a, b):
el1.extend(el2)
``` | You can use list comprehension:
```py
result = [a[i] + b[i] for i in range(len(a))]
```
Results in:
```py
[['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
``` |
72,789,446 | I have two lists and I want to append one with another, like this:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
```
new list should be like this:
```
n = [['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
```
I try this but it didn't work:
```
for i, j in a,... | 2022/06/28 | [
"https://Stackoverflow.com/questions/72789446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14481446/"
] | Use list comprehension:
```py
[i+j for i,j in zip(a, b)]
```
Results in:
```py
[['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
``` | Using `map()` & `lambda` function, `*` unpacking to a list and `+` list concatenation:
```
res = [*map(lambda x, y: x + y, a, b)]
print(res)
``` |
72,789,446 | I have two lists and I want to append one with another, like this:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
```
new list should be like this:
```
n = [['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
```
I try this but it didn't work:
```
for i, j in a,... | 2022/06/28 | [
"https://Stackoverflow.com/questions/72789446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14481446/"
] | You can use `zip` and concatenation:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
c = [item[0] + item[1] for item in zip(a, b)]
```
Which yields:
```
['bmw', 12, 2]
['audi', 3, 4]
['benz', 7, 5]
['honda', 6, 23]
``` | Using `map()` & `lambda` function, `*` unpacking to a list and `+` list concatenation:
```
res = [*map(lambda x, y: x + y, a, b)]
print(res)
``` |
72,789,446 | I have two lists and I want to append one with another, like this:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
```
new list should be like this:
```
n = [['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
```
I try this but it didn't work:
```
for i, j in a,... | 2022/06/28 | [
"https://Stackoverflow.com/questions/72789446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14481446/"
] | You almost got it right, you should use `extend` instead of `append`:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
for i, j in zip(a, b):
i.extend(j)
print(a)
```
Output:
```
[['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
``` | Using `map()` & `lambda` function, `*` unpacking to a list and `+` list concatenation:
```
res = [*map(lambda x, y: x + y, a, b)]
print(res)
``` |
72,789,446 | I have two lists and I want to append one with another, like this:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
```
new list should be like this:
```
n = [['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
```
I try this but it didn't work:
```
for i, j in a,... | 2022/06/28 | [
"https://Stackoverflow.com/questions/72789446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14481446/"
] | Use list comprehension:
```py
[i+j for i,j in zip(a, b)]
```
Results in:
```py
[['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
``` | ```
for el1, el2 in zip(a, b):
el1.extend(el2)
``` |
72,789,446 | I have two lists and I want to append one with another, like this:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
```
new list should be like this:
```
n = [['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
```
I try this but it didn't work:
```
for i, j in a,... | 2022/06/28 | [
"https://Stackoverflow.com/questions/72789446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14481446/"
] | ```
for el1, el2 in zip(a, b):
el1.extend(el2)
``` | Using `map()` & `lambda` function, `*` unpacking to a list and `+` list concatenation:
```
res = [*map(lambda x, y: x + y, a, b)]
print(res)
``` |
72,789,446 | I have two lists and I want to append one with another, like this:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
```
new list should be like this:
```
n = [['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
```
I try this but it didn't work:
```
for i, j in a,... | 2022/06/28 | [
"https://Stackoverflow.com/questions/72789446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14481446/"
] | You almost got it right, you should use `extend` instead of `append`:
```
a = [['bmw'], ['audi'], ['benz'], ['honda']]
b = [[12,2], [3,4], [7,5], [6,23]]
for i, j in zip(a, b):
i.extend(j)
print(a)
```
Output:
```
[['bmw', 12, 2], ['audi', 3, 4], ['benz', 7, 5], ['honda', 6, 23]]
``` | ```
for el1, el2 in zip(a, b):
el1.extend(el2)
``` |
47,622,664 | Hi Can any one suggest how to read data from datagrid in windowsforms application which has two columns(FileName and FilePath).
Below is the code I tried its returning all Filename and FilePath in single column(FileName).
Any suggestions would be helpful to me..
```
`
public System.Data.DataTable ExportToEx... | 2017/12/03 | [
"https://Stackoverflow.com/questions/47622664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8409752/"
] | You can use this regex `((\d+)\sMB)` if there are one or more spaces between the number and `MB` you can use `\s+` to match one or more space, you can do all this with Pattern
```
String text = "Your Day Traffic is 150 MB and your Night Traffic is 136 MB ";
String regex = "((\\d+)\\sMB)";
Pattern pattern = Pattern.com... | Please read the java docs on regex [here](https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html).
Essentially you have to ignore character between two "[number] MB" occurences. In that situation you can use a regex like so -
```
/.*\s+(\d+)\s+MB.*\s+(\d+)\s+MB/
```
Full code is given here -
```
i... |
11,709,441 | I'm looking to get live values for stock indexes, such as the Dow (DJIA) or Hang Seng Index (HSI).
These need to be generated from a (configurable) set of index symbols, and saved to VBA variables without any interaction with the sheets. Ideally this would be from Bloomberg, or Yahoo if need be (though any other sourc... | 2012/07/29 | [
"https://Stackoverflow.com/questions/11709441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1173672/"
] | If you want to retrieve live data using the Bloomberg API, you need to be a Bloomberg subscriber ($$$). As you also mention Yahoo, which is free, I suspect it is not what you want. | This isn't a simple task.
You'll need to initiate an HTTP GET request for <http://www.google.com/finance?q=GOOG>, and parse the return string you self.
The HTTP Request is sent with this code:
```
Set HttpReq = CreateObject("MSXML2.ServerXMLHTTP")
HttpReq.Open "GET", "http://www.google.com/finance?q=GOOG",... |
68,893 | I told my friend that I would create a dual boot system with his Windows Vista and not screw it up. It only boots to Ubuntu with no boot menu. At least it kept the compressed Windows partition. How do I get a dual boot system without being a rocket scientist before he comes home and breaks my neck? | 2011/10/18 | [
"https://askubuntu.com/questions/68893",
"https://askubuntu.com",
"https://askubuntu.com/users/28751/"
] | Install startupmanager, an application to help configure the boot up menu.
Open up the Software Center and Search for "Startup Manager" or "startupmanager" and click install.
Once it has installed run it by clicking on the ubuntu logo on the top left of the screen and searching for Startup Manager.
There should be a... | Boot ubuntu. From a terminal `ctrl alt t` type this `sudo update-grub`
Reboot and you should see a menu to choose windows. |
8,947,198 | Google's C++ style guide [says](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Header_File_Dependencies), "Don't use an #include when a forward declaration would suffice."
But [C++ Coding Standards](http://www.gotw.ca/publications/c++cs.htm) (Sutter and Alexandrescu), item #23 is, "Make header files se... | 2012/01/20 | [
"https://Stackoverflow.com/questions/8947198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/966071/"
] | I'd say both statements are correct. If you have a header file that contains only a pointer or a reference to some data type, then you only require a forward declaration.
If however your header contains an object of a particular type, then you should include the header where that type is defined. The advice from Sutte... | In addition to what's covered in the other answers, there are cases where you *must* use a forward declaration because of mutual dependences.
FWIW, if I only need a type name, I usually forward declare it. If it's a function declaration, I generally include it (though those cases are rare since non-member functions ar... |
8,947,198 | Google's C++ style guide [says](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Header_File_Dependencies), "Don't use an #include when a forward declaration would suffice."
But [C++ Coding Standards](http://www.gotw.ca/publications/c++cs.htm) (Sutter and Alexandrescu), item #23 is, "Make header files se... | 2012/01/20 | [
"https://Stackoverflow.com/questions/8947198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/966071/"
] | Dependency management is very important in C++: if you change a header file, all translation units depending on this header file need to be compiled. This can be very expensive. As a result you want your header files to be minimal in the sense that they don't include anything they don't need to include. This is what Go... | In addition to what's covered in the other answers, there are cases where you *must* use a forward declaration because of mutual dependences.
FWIW, if I only need a type name, I usually forward declare it. If it's a function declaration, I generally include it (though those cases are rare since non-member functions ar... |
8,947,198 | Google's C++ style guide [says](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Header_File_Dependencies), "Don't use an #include when a forward declaration would suffice."
But [C++ Coding Standards](http://www.gotw.ca/publications/c++cs.htm) (Sutter and Alexandrescu), item #23 is, "Make header files se... | 2012/01/20 | [
"https://Stackoverflow.com/questions/8947198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/966071/"
] | Sutter and Alexandrescu on item #22 say "Don't be over-dependent: Don't #include a definition when a forward declaration will do".
Personally, I agree with this statement. If in my class A, I don't use any functionality of a class B, nor I instantiate an object of class B, then my code doesn't need to know how class B... | I believe they're both saying exactly the same thing.
Suppose you have a method that takes a `Bar` by reference your your header file, but the method is defined in your source file. A forward declaration in the header is clearly sufficient for the header to compile standalone.
Now let's look at the user code. If the ... |
8,947,198 | Google's C++ style guide [says](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Header_File_Dependencies), "Don't use an #include when a forward declaration would suffice."
But [C++ Coding Standards](http://www.gotw.ca/publications/c++cs.htm) (Sutter and Alexandrescu), item #23 is, "Make header files se... | 2012/01/20 | [
"https://Stackoverflow.com/questions/8947198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/966071/"
] | Sutter and Alexandrescu on item #22 say "Don't be over-dependent: Don't #include a definition when a forward declaration will do".
Personally, I agree with this statement. If in my class A, I don't use any functionality of a class B, nor I instantiate an object of class B, then my code doesn't need to know how class B... | In addition to what's covered in the other answers, there are cases where you *must* use a forward declaration because of mutual dependences.
FWIW, if I only need a type name, I usually forward declare it. If it's a function declaration, I generally include it (though those cases are rare since non-member functions ar... |
8,947,198 | Google's C++ style guide [says](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Header_File_Dependencies), "Don't use an #include when a forward declaration would suffice."
But [C++ Coding Standards](http://www.gotw.ca/publications/c++cs.htm) (Sutter and Alexandrescu), item #23 is, "Make header files se... | 2012/01/20 | [
"https://Stackoverflow.com/questions/8947198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/966071/"
] | Sutter and Alexandrescu on item #22 say "Don't be over-dependent: Don't #include a definition when a forward declaration will do".
Personally, I agree with this statement. If in my class A, I don't use any functionality of a class B, nor I instantiate an object of class B, then my code doesn't need to know how class B... | I'd say both statements are correct. If you have a header file that contains only a pointer or a reference to some data type, then you only require a forward declaration.
If however your header contains an object of a particular type, then you should include the header where that type is defined. The advice from Sutte... |
8,947,198 | Google's C++ style guide [says](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Header_File_Dependencies), "Don't use an #include when a forward declaration would suffice."
But [C++ Coding Standards](http://www.gotw.ca/publications/c++cs.htm) (Sutter and Alexandrescu), item #23 is, "Make header files se... | 2012/01/20 | [
"https://Stackoverflow.com/questions/8947198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/966071/"
] | Sutter and Alexandrescu on item #22 say "Don't be over-dependent: Don't #include a definition when a forward declaration will do".
Personally, I agree with this statement. If in my class A, I don't use any functionality of a class B, nor I instantiate an object of class B, then my code doesn't need to know how class B... | Dependency management is very important in C++: if you change a header file, all translation units depending on this header file need to be compiled. This can be very expensive. As a result you want your header files to be minimal in the sense that they don't include anything they don't need to include. This is what Go... |
8,947,198 | Google's C++ style guide [says](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Header_File_Dependencies), "Don't use an #include when a forward declaration would suffice."
But [C++ Coding Standards](http://www.gotw.ca/publications/c++cs.htm) (Sutter and Alexandrescu), item #23 is, "Make header files se... | 2012/01/20 | [
"https://Stackoverflow.com/questions/8947198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/966071/"
] | Dependency management is very important in C++: if you change a header file, all translation units depending on this header file need to be compiled. This can be very expensive. As a result you want your header files to be minimal in the sense that they don't include anything they don't need to include. This is what Go... | These two recommendations are *completely* compatible with each other. You can follow both of them at the same time. They are in no way mutually exclusive -- it's not an "either or" situation.
A header may use a forward declaration, when that is all that is needed, and still be compilable stand-alone:
```
// Foo.hpp
... |
8,947,198 | Google's C++ style guide [says](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Header_File_Dependencies), "Don't use an #include when a forward declaration would suffice."
But [C++ Coding Standards](http://www.gotw.ca/publications/c++cs.htm) (Sutter and Alexandrescu), item #23 is, "Make header files se... | 2012/01/20 | [
"https://Stackoverflow.com/questions/8947198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/966071/"
] | Dependency management is very important in C++: if you change a header file, all translation units depending on this header file need to be compiled. This can be very expensive. As a result you want your header files to be minimal in the sense that they don't include anything they don't need to include. This is what Go... | Sutter and Alexandrescu are probably more correct here. If I forward declare `class Foo;` that for some reason resides in `bar.h` and do not include `bar.h`, good luck trying to find the declaration of `Foo` (especially if the code-base is large). |
8,947,198 | Google's C++ style guide [says](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Header_File_Dependencies), "Don't use an #include when a forward declaration would suffice."
But [C++ Coding Standards](http://www.gotw.ca/publications/c++cs.htm) (Sutter and Alexandrescu), item #23 is, "Make header files se... | 2012/01/20 | [
"https://Stackoverflow.com/questions/8947198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/966071/"
] | I believe they're both saying exactly the same thing.
Suppose you have a method that takes a `Bar` by reference your your header file, but the method is defined in your source file. A forward declaration in the header is clearly sufficient for the header to compile standalone.
Now let's look at the user code. If the ... | Sutter and Alexandrescu are probably more correct here. If I forward declare `class Foo;` that for some reason resides in `bar.h` and do not include `bar.h`, good luck trying to find the declaration of `Foo` (especially if the code-base is large). |
8,947,198 | Google's C++ style guide [says](http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Header_File_Dependencies), "Don't use an #include when a forward declaration would suffice."
But [C++ Coding Standards](http://www.gotw.ca/publications/c++cs.htm) (Sutter and Alexandrescu), item #23 is, "Make header files se... | 2012/01/20 | [
"https://Stackoverflow.com/questions/8947198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/966071/"
] | I believe they're both saying exactly the same thing.
Suppose you have a method that takes a `Bar` by reference your your header file, but the method is defined in your source file. A forward declaration in the header is clearly sufficient for the header to compile standalone.
Now let's look at the user code. If the ... | In addition to what's covered in the other answers, there are cases where you *must* use a forward declaration because of mutual dependences.
FWIW, if I only need a type name, I usually forward declare it. If it's a function declaration, I generally include it (though those cases are rare since non-member functions ar... |
29,956,131 | I am having this issue and have tried almost everything. I want one column with images and one with strings. I can get the strings, but not the images.
Here is what I have:
```
self.browserList=wx.ListCtrl(panel, pos=(20,150), size=(250,100),
style.wx.LC_REPORT|wx.BORDER_SUNKEN)
self.browserList.InsertColumn(0, ''... | 2015/04/29 | [
"https://Stackoverflow.com/questions/29956131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4696214/"
] | I get an error running your code.
But anyways, I can't explain why, but maybe I think you can resolve it by changing `wx.IMAGE_LIST_NORMAL` to `wx.IMAGE_LIST_SMALL`
Here is a simple code that I tried and worked for me.
```
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Fram... | First, an update of Deepas answer to the new wxPython Phoenix:
```
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title,size=(250, 250))
panel = wx.Panel(self, -1)
panel.SetBackgroundColour('white')
self.browserList=wx.... |
45,490,612 | I have two tables like this:
**Table1**
`emp_leave_summary(id,emp_id,leave_from_date,leave_to_date,leave_type)`
**Table2**
`emp_leave_daywise(id,emp_id,leave_date,leave_type)`
I would want to select `emp_id, leave_type` from **Table1** and insert into **Table2**.
**for example:**
In table1 I have this
```
id,... | 2017/08/03 | [
"https://Stackoverflow.com/questions/45490612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1795210/"
] | Try:
```
select * from
(select adddate('1970-01-01',t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) selected_date from
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0,
(select 0 i union select 1 union sele... | I have managed to get the preferred output using the below solution
**step1**
create a calendar table and insert the dates( all possible required dates) something like this
```
CREATE TABLE `db_calender` (
`c_date` date NOT NULL);
```
then insert dates into the calendar table, to insert easily i used this... |
45,490,612 | I have two tables like this:
**Table1**
`emp_leave_summary(id,emp_id,leave_from_date,leave_to_date,leave_type)`
**Table2**
`emp_leave_daywise(id,emp_id,leave_date,leave_type)`
I would want to select `emp_id, leave_type` from **Table1** and insert into **Table2**.
**for example:**
In table1 I have this
```
id,... | 2017/08/03 | [
"https://Stackoverflow.com/questions/45490612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1795210/"
] | Try:
```
select * from
(select adddate('1970-01-01',t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) selected_date from
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0,
(select 0 i union select 1 union sele... | Thanks for your schema. It makes it easy to work with your question.
I changed your schema a little to make use of auto\_increment
```
CREATE TABLE `emp_leave_summary` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`emp_id` int(11) NOT NULL,
`leave_from_date` date NOT NULL,
`leave_to_date` date NOT NULL,
`leave_ty... |
45,490,612 | I have two tables like this:
**Table1**
`emp_leave_summary(id,emp_id,leave_from_date,leave_to_date,leave_type)`
**Table2**
`emp_leave_daywise(id,emp_id,leave_date,leave_type)`
I would want to select `emp_id, leave_type` from **Table1** and insert into **Table2**.
**for example:**
In table1 I have this
```
id,... | 2017/08/03 | [
"https://Stackoverflow.com/questions/45490612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1795210/"
] | Thanks for your schema. It makes it easy to work with your question.
I changed your schema a little to make use of auto\_increment
```
CREATE TABLE `emp_leave_summary` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`emp_id` int(11) NOT NULL,
`leave_from_date` date NOT NULL,
`leave_to_date` date NOT NULL,
`leave_ty... | I have managed to get the preferred output using the below solution
**step1**
create a calendar table and insert the dates( all possible required dates) something like this
```
CREATE TABLE `db_calender` (
`c_date` date NOT NULL);
```
then insert dates into the calendar table, to insert easily i used this... |
47,469,063 | Forewarning: I'm very new to Django (and web development, in general).
I'm using Django to host a web-based UI that will take user input from a short survey, feed it through some analyses that I've developed in Python, and then present the visual output of these analyses in the UI.
My survey consists of 10 questions... | 2017/11/24 | [
"https://Stackoverflow.com/questions/47469063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4580366/"
] | Use getlist()
In your views.py
```
if method=="POST":
choices = request.POST.getlist('choice')
```
I feel you should change the input radio to checkbox. Radio won't allow multiple selection but Checkbox will.
Refer here: <https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.QueryDict.getlist> | You just need to organize your template a bit differently in order to have multiple questions within the same `form`. Litteraly in HTML it would translate into multiple text inputs and then one submit input below, all within one single form:
```
<form action="{% url 'polls:vote' question.id %}" method="post">
{% f... |
47,469,063 | Forewarning: I'm very new to Django (and web development, in general).
I'm using Django to host a web-based UI that will take user input from a short survey, feed it through some analyses that I've developed in Python, and then present the visual output of these analyses in the UI.
My survey consists of 10 questions... | 2017/11/24 | [
"https://Stackoverflow.com/questions/47469063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4580366/"
] | Ideally, this should have been done with Django Forms. Django forms have `widgets` and `RadioSelect` is one of them. You can use that to render your form and get the answer to each question at once.
But that will need a lot of change in the way you are currently doing things.
So, what you can do is, on click on a subm... | You just need to organize your template a bit differently in order to have multiple questions within the same `form`. Litteraly in HTML it would translate into multiple text inputs and then one submit input below, all within one single form:
```
<form action="{% url 'polls:vote' question.id %}" method="post">
{% f... |
54,054 | I am forming a universe of liquid futures/liquid FX forwards. I want a list of all liquid contracts, the key word being liquid. This is for an academic project, but you could imagine liquid being loosely defined as securities that could form the core trading portfolio of a mid-sized systematic trend-following CTA. This... | 2020/05/11 | [
"https://quant.stackexchange.com/questions/54054",
"https://quant.stackexchange.com",
"https://quant.stackexchange.com/users/34436/"
] | Systematically finding most liquid futures instruments
======================================================
---
Can we put together a better list than the academic articles?
-------------------------------------------------------------
Yes! The lists in existing publications [[1](https://www.sciencedirect.com/scie... | You could consider using the list of "liquid futures contracts" used in some previously published paper(s) on this subject, there are many. Alternatively, if you think previous studies missed some important contracts you could try to establish your own list independently.
I thought for example of the using the followi... |
3,074,713 | When dealing with big databases, which performs better: `IN` or `OR` in the SQL `WHERE` clause?
Is there any *difference* about the way they are executed? | 2010/06/19 | [
"https://Stackoverflow.com/questions/3074713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/88898/"
] | I think oracle is smart enough to convert the less efficient one (whichever that is) into the other. So I think the answer should rather depend on the readability of each (where I think that `IN` clearly wins) | `OR` makes sense (from readability point of view), when there are less values to be compared.
`IN` is useful esp. when you have a dynamic source, with which you want values to be compared.
Another alternative is to use a `JOIN` with a temporary table.
I don't think performance should be a problem, provided you have... |
3,074,713 | When dealing with big databases, which performs better: `IN` or `OR` in the SQL `WHERE` clause?
Is there any *difference* about the way they are executed? | 2010/06/19 | [
"https://Stackoverflow.com/questions/3074713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/88898/"
] | `OR` makes sense (from readability point of view), when there are less values to be compared.
`IN` is useful esp. when you have a dynamic source, with which you want values to be compared.
Another alternative is to use a `JOIN` with a temporary table.
I don't think performance should be a problem, provided you have... | I did a SQL query in a large number of OR (350). Postgres do it **437.80ms**.

Now use IN:

**23.18ms** |
3,074,713 | When dealing with big databases, which performs better: `IN` or `OR` in the SQL `WHERE` clause?
Is there any *difference* about the way they are executed? | 2010/06/19 | [
"https://Stackoverflow.com/questions/3074713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/88898/"
] | I assume you want to know the performance difference between the following:
```
WHERE foo IN ('a', 'b', 'c')
WHERE foo = 'a' OR foo = 'b' OR foo = 'c'
```
According to the [manual for MySQL](http://dev.mysql.com/doc/refman/5.5/en/comparison-operators.html#function_in) if the values are constant `IN` sorts the list a... | I did a SQL query in a large number of OR (350). Postgres do it **437.80ms**.

Now use IN:

**23.18ms** |
3,074,713 | When dealing with big databases, which performs better: `IN` or `OR` in the SQL `WHERE` clause?
Is there any *difference* about the way they are executed? | 2010/06/19 | [
"https://Stackoverflow.com/questions/3074713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/88898/"
] | The best way to find out is looking at the Execution Plan.
---
I tried it with **Oracle**, and it was exactly the same.
```
CREATE TABLE performance_test AS ( SELECT * FROM dba_objects );
SELECT * FROM performance_test
WHERE object_name IN ('DBMS_STANDARD', 'DBMS_REGISTRY', 'DBMS_LOB' );
```
Even though the query... | I did a SQL query in a large number of OR (350). Postgres do it **437.80ms**.

Now use IN:

**23.18ms** |
3,074,713 | When dealing with big databases, which performs better: `IN` or `OR` in the SQL `WHERE` clause?
Is there any *difference* about the way they are executed? | 2010/06/19 | [
"https://Stackoverflow.com/questions/3074713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/88898/"
] | I assume you want to know the performance difference between the following:
```
WHERE foo IN ('a', 'b', 'c')
WHERE foo = 'a' OR foo = 'b' OR foo = 'c'
```
According to the [manual for MySQL](http://dev.mysql.com/doc/refman/5.5/en/comparison-operators.html#function_in) if the values are constant `IN` sorts the list a... | The best way to find out is looking at the Execution Plan.
---
I tried it with **Oracle**, and it was exactly the same.
```
CREATE TABLE performance_test AS ( SELECT * FROM dba_objects );
SELECT * FROM performance_test
WHERE object_name IN ('DBMS_STANDARD', 'DBMS_REGISTRY', 'DBMS_LOB' );
```
Even though the query... |
3,074,713 | When dealing with big databases, which performs better: `IN` or `OR` in the SQL `WHERE` clause?
Is there any *difference* about the way they are executed? | 2010/06/19 | [
"https://Stackoverflow.com/questions/3074713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/88898/"
] | I assume you want to know the performance difference between the following:
```
WHERE foo IN ('a', 'b', 'c')
WHERE foo = 'a' OR foo = 'b' OR foo = 'c'
```
According to the [manual for MySQL](http://dev.mysql.com/doc/refman/5.5/en/comparison-operators.html#function_in) if the values are constant `IN` sorts the list a... | The OR operator needs a much more complex evaluation process than the IN construct because it allows many conditions, not only equals like IN.
Here is a like of what you can use with OR but that are not compatible with IN:
greater. greater or equal, less, less or equal, LIKE and some more like the oracle REGEXP\_LIKE... |
3,074,713 | When dealing with big databases, which performs better: `IN` or `OR` in the SQL `WHERE` clause?
Is there any *difference* about the way they are executed? | 2010/06/19 | [
"https://Stackoverflow.com/questions/3074713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/88898/"
] | The OR operator needs a much more complex evaluation process than the IN construct because it allows many conditions, not only equals like IN.
Here is a like of what you can use with OR but that are not compatible with IN:
greater. greater or equal, less, less or equal, LIKE and some more like the oracle REGEXP\_LIKE... | I think oracle is smart enough to convert the less efficient one (whichever that is) into the other. So I think the answer should rather depend on the readability of each (where I think that `IN` clearly wins) |
3,074,713 | When dealing with big databases, which performs better: `IN` or `OR` in the SQL `WHERE` clause?
Is there any *difference* about the way they are executed? | 2010/06/19 | [
"https://Stackoverflow.com/questions/3074713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/88898/"
] | I think oracle is smart enough to convert the less efficient one (whichever that is) into the other. So I think the answer should rather depend on the readability of each (where I think that `IN` clearly wins) | I did a SQL query in a large number of OR (350). Postgres do it **437.80ms**.

Now use IN:

**23.18ms** |
3,074,713 | When dealing with big databases, which performs better: `IN` or `OR` in the SQL `WHERE` clause?
Is there any *difference* about the way they are executed? | 2010/06/19 | [
"https://Stackoverflow.com/questions/3074713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/88898/"
] | I think oracle is smart enough to convert the less efficient one (whichever that is) into the other. So I think the answer should rather depend on the readability of each (where I think that `IN` clearly wins) | I'll add info for **PostgreSQL** version 11.8 (released 2020-05-14).
`IN` may be significantly faster. E.g. table with ~23M rows.
Query with `OR`:
```sql
explain analyse select sum(mnozstvi_rozdil)
from product_erecept
where okres_nazev = 'Brno-město' or okres_nazev = 'Pardubice';
-- execution plan
Finalize Aggrega... |
3,074,713 | When dealing with big databases, which performs better: `IN` or `OR` in the SQL `WHERE` clause?
Is there any *difference* about the way they are executed? | 2010/06/19 | [
"https://Stackoverflow.com/questions/3074713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/88898/"
] | I assume you want to know the performance difference between the following:
```
WHERE foo IN ('a', 'b', 'c')
WHERE foo = 'a' OR foo = 'b' OR foo = 'c'
```
According to the [manual for MySQL](http://dev.mysql.com/doc/refman/5.5/en/comparison-operators.html#function_in) if the values are constant `IN` sorts the list a... | `OR` makes sense (from readability point of view), when there are less values to be compared.
`IN` is useful esp. when you have a dynamic source, with which you want values to be compared.
Another alternative is to use a `JOIN` with a temporary table.
I don't think performance should be a problem, provided you have... |
55,737,964 | I have the following data and want to match certain strings as commented below.
```
FTUS80 KWBC 081454 AAA\r\r TAF AMD #should match 'AAA'
LTUS41 KCTP 082111 RR3\r\r TMLLNS\r #should match 'RR3' and 'TMLLNS'
SRUS55 KSLC 082010\r\r HM5SLC\r\r #should match 'HM5SLC'
SRUS55 KSLC 082010\r\r SIGC \r\r #should mat... | 2019/04/18 | [
"https://Stackoverflow.com/questions/55737964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3093032/"
] | There is probably a more elegant way, but you could do something like the following:
```
(?:\d{6}\s?)([A-Z\d]{3})?(?:[\r\n]{2}\s)([A-Z\d]{6}|[A-Z\d]{4}\s{2})?
```
* `(?:\d{6}\s?)` non capture group of 6 digits followed by an optional space
* `([A-Z\d]{3})?` optional capture group of 3 uppercase letters / digits
* `(... | It's not clear what's the end of line here but assuming it's Unix one `\n`, the following expression captures strings as requested (double quotes added to show white space)
```
sed -rne 's/^.{18} ?([A-Z0-9]{3,3})?\r{2}?([^\r]+)?\r.*$/"\1\2"/p' text.txt
```
Result
```
"AAA"
"RR3 TMLLNS"
" HM5SLC"
" SIGC "
```
* `... |
5,699,339 | I've used 'uniq -d -c file' in many shell scripts on linux machines, and it works.
On my MAC (OS X 10.6.7 with developer tools installed) it doesn't seems to work:
```
$ uniq -d -c testfile.txt
usage: uniq [-c | -d | -u] [-i] [-f fields] [-s chars] [input [output]]
```
It would be nice if anyone could checks this. | 2011/04/18 | [
"https://Stackoverflow.com/questions/5699339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/95914/"
] | Well, it's right there in the `Usage` message. `[ -c | -d | -u]` means you can use *one* of those possibilities, not two.
Since OSX is based on BSD, you can check that [here](http://www.manpages.info/freebsd/uniq.1.html) or, thanks to Ignacio, the more Apple-specific one [here](http://developer.apple.com/library/mac/#... | You can try this `awk` solution
```
awk '{a[$0]++}END{for(i in a)if(a[i]>1){ print i ,a[i] } }' file
``` |
8,063,599 | Let's see the following simplest code snippet in Java.
```
final public class Parsing
{
public static void main(String[] args)
{
int p=10;
int q=10;
System.out.println(p==q);
}
}
```
---
The above code in Java is fine and displays **true** as both p and q of the same type (int) ... | 2011/11/09 | [
"https://Stackoverflow.com/questions/8063599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1037210/"
] | You have to add parentheses () around p==q (the way you write it, it will be interpreted as ("\n"+p) == q, and String cannot be compared to a boolean). This operator precedence is desired for expressions like
```
if(a+b == c+d)
```
etc. So,
```
System.out.println("\n"+(p==q));
```
Should work just fine. | The order of precedence of operators means that your expression gets evaluated as
```
("\n" + p) == q
```
It is nonsensical to compare a string to an int so compilation fails, try:
```
"\n" + (p == q)
``` |
8,063,599 | Let's see the following simplest code snippet in Java.
```
final public class Parsing
{
public static void main(String[] args)
{
int p=10;
int q=10;
System.out.println(p==q);
}
}
```
---
The above code in Java is fine and displays **true** as both p and q of the same type (int) ... | 2011/11/09 | [
"https://Stackoverflow.com/questions/8063599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1037210/"
] | You have to add parentheses () around p==q (the way you write it, it will be interpreted as ("\n"+p) == q, and String cannot be compared to a boolean). This operator precedence is desired for expressions like
```
if(a+b == c+d)
```
etc. So,
```
System.out.println("\n"+(p==q));
```
Should work just fine. | Ah. The statement is wrong.
```
System.out.println("\n"+(p==q));
```
~Dheeraj |
8,063,599 | Let's see the following simplest code snippet in Java.
```
final public class Parsing
{
public static void main(String[] args)
{
int p=10;
int q=10;
System.out.println(p==q);
}
}
```
---
The above code in Java is fine and displays **true** as both p and q of the same type (int) ... | 2011/11/09 | [
"https://Stackoverflow.com/questions/8063599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1037210/"
] | You have to add parentheses () around p==q (the way you write it, it will be interpreted as ("\n"+p) == q, and String cannot be compared to a boolean). This operator precedence is desired for expressions like
```
if(a+b == c+d)
```
etc. So,
```
System.out.println("\n"+(p==q));
```
Should work just fine. | >
> System.out.println("\n"+p==q);
>
>
>
compiler treat it as
```
System.out.println(("\n"+p)==q);
```
Use
```
System.out.println("\n"+(p==q));
``` |
8,063,599 | Let's see the following simplest code snippet in Java.
```
final public class Parsing
{
public static void main(String[] args)
{
int p=10;
int q=10;
System.out.println(p==q);
}
}
```
---
The above code in Java is fine and displays **true** as both p and q of the same type (int) ... | 2011/11/09 | [
"https://Stackoverflow.com/questions/8063599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1037210/"
] | You have to add parentheses () around p==q (the way you write it, it will be interpreted as ("\n"+p) == q, and String cannot be compared to a boolean). This operator precedence is desired for expressions like
```
if(a+b == c+d)
```
etc. So,
```
System.out.println("\n"+(p==q));
```
Should work just fine. | >
> Which is not allowed at all because the expression p==q evaluates a boolean value and a boolean type in Java (not Boolean, a wrapper type) can never be converted to any other types available in Java.
>
>
>
This is completely wrong. Concatenating anything to a String is implemented by the compiler via `String.... |
8,063,599 | Let's see the following simplest code snippet in Java.
```
final public class Parsing
{
public static void main(String[] args)
{
int p=10;
int q=10;
System.out.println(p==q);
}
}
```
---
The above code in Java is fine and displays **true** as both p and q of the same type (int) ... | 2011/11/09 | [
"https://Stackoverflow.com/questions/8063599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1037210/"
] | The order of precedence of operators means that your expression gets evaluated as
```
("\n" + p) == q
```
It is nonsensical to compare a string to an int so compilation fails, try:
```
"\n" + (p == q)
``` | Ah. The statement is wrong.
```
System.out.println("\n"+(p==q));
```
~Dheeraj |
8,063,599 | Let's see the following simplest code snippet in Java.
```
final public class Parsing
{
public static void main(String[] args)
{
int p=10;
int q=10;
System.out.println(p==q);
}
}
```
---
The above code in Java is fine and displays **true** as both p and q of the same type (int) ... | 2011/11/09 | [
"https://Stackoverflow.com/questions/8063599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1037210/"
] | >
> System.out.println("\n"+p==q);
>
>
>
compiler treat it as
```
System.out.println(("\n"+p)==q);
```
Use
```
System.out.println("\n"+(p==q));
``` | Ah. The statement is wrong.
```
System.out.println("\n"+(p==q));
```
~Dheeraj |
8,063,599 | Let's see the following simplest code snippet in Java.
```
final public class Parsing
{
public static void main(String[] args)
{
int p=10;
int q=10;
System.out.println(p==q);
}
}
```
---
The above code in Java is fine and displays **true** as both p and q of the same type (int) ... | 2011/11/09 | [
"https://Stackoverflow.com/questions/8063599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1037210/"
] | >
> Which is not allowed at all because the expression p==q evaluates a boolean value and a boolean type in Java (not Boolean, a wrapper type) can never be converted to any other types available in Java.
>
>
>
This is completely wrong. Concatenating anything to a String is implemented by the compiler via `String.... | Ah. The statement is wrong.
```
System.out.println("\n"+(p==q));
```
~Dheeraj |
62,471 | What is the most basic valid module one can create in Drupal?
It would be useful to have a simple blueprint available, for anyone just getting started with Drupal. | 2013/02/16 | [
"https://drupal.stackexchange.com/questions/62471",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/1625/"
] | The below instructions allows one to create an empty module, and is helpful for anyone just getting started with module building. If you have troubles getting your first module working, or even showing up in Drupal, ensure you've read all the instructions below.
Drupal 8
========
A `project` must at least have
1. A ... | For Drupal 8, since the question mentioned a blueprint, I figure I'd mention the [Drupal Console](https://www.drupal.org/project/console) project.
Once that is installed, one can generate module code (and other things like scaffolding for custom entities, plugins, etc).
To generate a basic module from the command lin... |
5,450,076 | If unary `+`/`-` operators are used to perform conversions as the `Number()` casting function, then why do we need unary operators? What's the special need of these unary operators? | 2011/03/27 | [
"https://Stackoverflow.com/questions/5450076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/629305/"
] | The Unary `+` operator converts its operand to Number type.
The Unary `-` operator converts its operand to Number type, and then negates it.
(per the [ECMAScript spec](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf))
In practice, Unary `-` is used for simply putting negative numbers in norma... | The practical side of this is if you have a function that you need to return a number you can use
```
const result = +yourFunc()
```
instead of
```
const result = Number(yourFunc())
```
or
```
const result = -yourFunc()
```
instead of
```
const result = -Number(yourFunc())
```
It will return NaN the same wa... |
58,013,030 | I create navigation drawer activity using navigation Architecture. I put an icon on toolbar and I want to when click on the button, the new fragment should be open.
I got this **error:**
```
android.view.InflateException: Couldn't resolve menu item onClick handler addShareFragment in class com.example.myapplication.M... | 2019/09/19 | [
"https://Stackoverflow.com/questions/58013030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11758532/"
] | Instead of catching the brackets, you can replace the spaces that are preceded by `[` or followed by `]` with an empty string:
```
import re
my_string = "[ 0.53119281 1.53762345 ]"
my_regex_both = r"(?<=\[)\s+|\s+(?=\])"
replaced = re.sub(my_regex_both, '', my_string)
print(replaced)
```
Output:
```
[0.53119... | Another option you can use aside from MrGeek's answer would be to use a capture group to catch everything between your `my_regex_start` and `my_regex_end` like so:
```
import re
string1 = " [ 0.53119281 1.53762345 ]"
result = re.sub(r"(\[\s+)(.*?)(\s+\])", r"[\2]", string1)
print(result)
```
I have just sandwi... |
20,510,600 | I just upgraded from OSX Snow Leopard to Mavericks, and now fetchmail fails to invoke procmail. Mutt is also not working, but that is a different story.
The following poll (with names changed) has worked for several years:
`poll pop.1and1.com
protocol: pop3
username: abc@example.org
password: 123123123
nokeep
fe... | 2013/12/11 | [
"https://Stackoverflow.com/questions/20510600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/689003/"
] | Solution: I found a similar post in another forum from someone who solved the problem by getting procmail from the backup of his old system and installing under Mavericks.
I retrieved fetchmail, procmail, and mutt from the Time Machine, installed them. Also installed putmail.py, which had been deleted from /usr/bin. ... | Talked to Apple a few days ago. They are aware of the problem and plan on fixing it with their next update. In the meantime I was told to take the account offline and put it back online when you want to fetch mail. This is kind of a pain in the butt but it works and hopefully they will get it fixed soon. |
54,642,211 | Firstly, I'm totally new to Xcode 10 and Swift 4, and I've searched here but haven't found code that works.
What I'm after:
On launching app to play a video which is stored locally (called "launchvideo").
On completion of video to display/move to a UIviewcontroller with a storyboard ID of "menu"
So far I have my main... | 2019/02/12 | [
"https://Stackoverflow.com/questions/54642211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11048482/"
] | Firstly change your launch screen storyboard to Main storyboard from project settings in General tab.
Create one view controller with following name and write code to implement AVPlayer to play video.
```
import UIKit
import AVFoundation
class VideoLaunchVC: UIViewController {
func setupAVPlayer() {
le... | You have to load a video on **launchvideoVC**, like below way in **swift 4 and above**
```
import AVFoundation
import AVKit
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
initVideo()
}
func initVideo(){
do {
try AVAudioSession.sharedInstance().setCategory(... |
54,642,211 | Firstly, I'm totally new to Xcode 10 and Swift 4, and I've searched here but haven't found code that works.
What I'm after:
On launching app to play a video which is stored locally (called "launchvideo").
On completion of video to display/move to a UIviewcontroller with a storyboard ID of "menu"
So far I have my main... | 2019/02/12 | [
"https://Stackoverflow.com/questions/54642211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11048482/"
] | Firstly change your launch screen storyboard to Main storyboard from project settings in General tab.
Create one view controller with following name and write code to implement AVPlayer to play video.
```
import UIKit
import AVFoundation
class VideoLaunchVC: UIViewController {
func setupAVPlayer() {
le... | First you make a new view controller with view and change your launch screen storyboard to Main storyboard from project settings in General tab.
[](https://i.stack.imgur.com/oAse7.png)
And also add your video in folder.
[![enter image description h... |
1,419 | As a follow on question from the 2012 [Uh oh. We have a [beginner] tag!](https://robotics.meta.stackexchange.com/questions/88/uh-oh-we-have-a-beginner-tag), I’ve noticed a couple of the meta tags discussed for deletion are still being used. Was this intentional or have they crept back into use somehow? Examples (see be... | 2021/10/18 | [
"https://robotics.meta.stackexchange.com/questions/1419",
"https://robotics.meta.stackexchange.com",
"https://robotics.meta.stackexchange.com/users/27817/"
] | This is a complex question that doesn't have a great answer - while Ben's answer does give some good explanations for how the system has worked in the past and it's worth considering and following that guidance - we've changed how and when we take sites out of beta in recent years and that's impacted many of our older ... | There are some good links in the comments, but to answer your question:
>
> How can newcomers help?
>
>
>
The site stats on [Area51](https://area51.stackexchange.com/proposals/40020/robotics) give a good indication of what needs to happen to graduate to a non-Beta site. So the best thing to do to help the site is... |
1,419 | As a follow on question from the 2012 [Uh oh. We have a [beginner] tag!](https://robotics.meta.stackexchange.com/questions/88/uh-oh-we-have-a-beginner-tag), I’ve noticed a couple of the meta tags discussed for deletion are still being used. Was this intentional or have they crept back into use somehow? Examples (see be... | 2021/10/18 | [
"https://robotics.meta.stackexchange.com/questions/1419",
"https://robotics.meta.stackexchange.com",
"https://robotics.meta.stackexchange.com/users/27817/"
] | This is a complex question that doesn't have a great answer - while Ben's answer does give some good explanations for how the system has worked in the past and it's worth considering and following that guidance - we've changed how and when we take sites out of beta in recent years and that's impacted many of our older ... | I don't have much to add to [Ben](https://robotics.meta.stackexchange.com/a/1417/37) and [Catija](https://robotics.meta.stackexchange.com/a/1418/37)'s answers, and things haven't changed substantially since [my post](https://robotics.meta.stackexchange.com/a/1355/37) in 2017.
We still don't have enough users with a hi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.