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
3,318,270
I am new to java. I think this is the simplest problem but even i dont know how to solve this problem. I have one text file. In that file i have some words like below : **good bad efficiency** I want to add list of words into another by using java program. My output want to be like this **good bad good efficiency b...
2010/07/23
[ "https://Stackoverflow.com/questions/3318270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/341868/" ]
LINQ itself doesn't contain anything for this - I'd would use a normal `foreach` loop: ``` foreach (var value in objects.Select(x => x.someProperty) .Where(y => y != null)) { SomeFunction(value); } ``` Or if you want a query expression version: ``` var query = from obj in objects ...
``` objects.where(i => i.someProperty != null) .ToList() .ForEach(i=> SomeFunction(i.someProperty)) ```
3,318,270
I am new to java. I think this is the simplest problem but even i dont know how to solve this problem. I have one text file. In that file i have some words like below : **good bad efficiency** I want to add list of words into another by using java program. My output want to be like this **good bad good efficiency b...
2010/07/23
[ "https://Stackoverflow.com/questions/3318270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/341868/" ]
LINQ itself doesn't contain anything for this - I'd would use a normal `foreach` loop: ``` foreach (var value in objects.Select(x => x.someProperty) .Where(y => y != null)) { SomeFunction(value); } ``` Or if you want a query expression version: ``` var query = from obj in objects ...
You can move the if statement into a Where clause of Linq: ``` IEnumerable<MyClass> objects = ... foreach(MyClass obj in objects.Where(obj => obj.someProperty != null) { SomeFunction(obj.someProperty); } ``` Going further, you can use List's `ForEach` method: ``` IEnumerable<MyClass> objects = ... objects.Where...
3,318,270
I am new to java. I think this is the simplest problem but even i dont know how to solve this problem. I have one text file. In that file i have some words like below : **good bad efficiency** I want to add list of words into another by using java program. My output want to be like this **good bad good efficiency b...
2010/07/23
[ "https://Stackoverflow.com/questions/3318270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/341868/" ]
LINQ itself doesn't contain anything for this - I'd would use a normal `foreach` loop: ``` foreach (var value in objects.Select(x => x.someProperty) .Where(y => y != null)) { SomeFunction(value); } ``` Or if you want a query expression version: ``` var query = from obj in objects ...
Although it can be done with Linq, sometimes its not always necessary. Sometimes you lose readability of your code. For your particular example, I'd leave it alone.
3,318,270
I am new to java. I think this is the simplest problem but even i dont know how to solve this problem. I have one text file. In that file i have some words like below : **good bad efficiency** I want to add list of words into another by using java program. My output want to be like this **good bad good efficiency b...
2010/07/23
[ "https://Stackoverflow.com/questions/3318270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/341868/" ]
LINQ itself doesn't contain anything for this - I'd would use a normal `foreach` loop: ``` foreach (var value in objects.Select(x => x.someProperty) .Where(y => y != null)) { SomeFunction(value); } ``` Or if you want a query expression version: ``` var query = from obj in objects ...
LINQ is used to create a result, so if you use it to call `SomeFunction` for each found item, you would be using a side effect of the code to do the main work. Things like that makes the code harder to maintain. You can use it to filter out the non-null values, though: ``` foreach(MyClass obj in objects.Where(o => o....
3,318,270
I am new to java. I think this is the simplest problem but even i dont know how to solve this problem. I have one text file. In that file i have some words like below : **good bad efficiency** I want to add list of words into another by using java program. My output want to be like this **good bad good efficiency b...
2010/07/23
[ "https://Stackoverflow.com/questions/3318270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/341868/" ]
LINQ itself doesn't contain anything for this - I'd would use a normal `foreach` loop: ``` foreach (var value in objects.Select(x => x.someProperty) .Where(y => y != null)) { SomeFunction(value); } ``` Or if you want a query expression version: ``` var query = from obj in objects ...
One option is to use the pattern outlined in the book [Linq In Action](http://linqinaction.net/) which uses an extension method to add a ForEach operator to IEnumerable<> From the book: ``` public static void ForEach<T> (this IEnumerable<T> source, Action<T> func) { foreach (var item in source) func(item) } ...
3,897,587
I'm working on a pretty simple iPhone app at the moment. I have a UIWebView with a UIToolBar at the bottom of it with a button on it. I've built it all through code, although I did create an empty NIB as I am hoping to get Facebook Connect working with it eventually and have had problems when I don't set it up with thi...
2010/10/09
[ "https://Stackoverflow.com/questions/3897587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383125/" ]
`--lim` means "take one from the value of `lim` and use the result". The alternative `lim--` would be "use the value of `lim` and then take one away". So if `lim` starts at 1000 the first time the loop executes it will have the value `999` before it is checked to see if it's greater than 0. If it were `lim--` then th...
`--lim` or `lim--` is a short hand of `lim = lim - 1`, So maybe author want to use this syntax to better clarify!
3,897,587
I'm working on a pretty simple iPhone app at the moment. I have a UIWebView with a UIToolBar at the bottom of it with a button on it. I've built it all through code, although I did create an empty NIB as I am hoping to get Facebook Connect working with it eventually and have had problems when I don't set it up with thi...
2010/10/09
[ "https://Stackoverflow.com/questions/3897587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383125/" ]
`--lim` means "take one from the value of `lim` and use the result". The alternative `lim--` would be "use the value of `lim` and then take one away". So if `lim` starts at 1000 the first time the loop executes it will have the value `999` before it is checked to see if it's greater than 0. If it were `lim--` then th...
Excluding David's example (where the initial test of 'c' causes the loop body to never be executed, and thus lim is not decremented), and the possibility that lim is initially less than or equal to 1 (in which case the getchar() would not be executed), the code is equivalent to the following: ``` c=getchar(); while (...
3,897,587
I'm working on a pretty simple iPhone app at the moment. I have a UIWebView with a UIToolBar at the bottom of it with a button on it. I've built it all through code, although I did create an empty NIB as I am hoping to get Facebook Connect working with it eventually and have had problems when I don't set it up with thi...
2010/10/09
[ "https://Stackoverflow.com/questions/3897587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383125/" ]
Are you sure? ``` #include <stdio.h> int main() { int lim = 10; while (--lim > 0 && printf("%d\n",lim)); } ``` ouput: ``` 9 8 7 6 5 4 3 2 1 ```
`--lim` or `lim--` is a short hand of `lim = lim - 1`, So maybe author want to use this syntax to better clarify!
3,897,587
I'm working on a pretty simple iPhone app at the moment. I have a UIWebView with a UIToolBar at the bottom of it with a button on it. I've built it all through code, although I did create an empty NIB as I am hoping to get Facebook Connect working with it eventually and have had problems when I don't set it up with thi...
2010/10/09
[ "https://Stackoverflow.com/questions/3897587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383125/" ]
Try to compile and run this code. It should be somewhat enlightening. ``` #include <stdio.h> int main() { int lim = 10; while (--lim > 0 && 1 > 32) printf("I should never get here\n"); printf("%d\n",lim); // lim is now 9 } ``` Oh look, `lim` is now `9` even though I never actual...
`--lim` or `lim--` is a short hand of `lim = lim - 1`, So maybe author want to use this syntax to better clarify!
3,897,587
I'm working on a pretty simple iPhone app at the moment. I have a UIWebView with a UIToolBar at the bottom of it with a button on it. I've built it all through code, although I did create an empty NIB as I am hoping to get Facebook Connect working with it eventually and have had problems when I don't set it up with thi...
2010/10/09
[ "https://Stackoverflow.com/questions/3897587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383125/" ]
`--lim` means "take one from the value of `lim` and use the result". The alternative `lim--` would be "use the value of `lim` and then take one away". So if `lim` starts at 1000 the first time the loop executes it will have the value `999` before it is checked to see if it's greater than 0. If it were `lim--` then th...
Are you sure? ``` #include <stdio.h> int main() { int lim = 10; while (--lim > 0 && printf("%d\n",lim)); } ``` ouput: ``` 9 8 7 6 5 4 3 2 1 ```
3,897,587
I'm working on a pretty simple iPhone app at the moment. I have a UIWebView with a UIToolBar at the bottom of it with a button on it. I've built it all through code, although I did create an empty NIB as I am hoping to get Facebook Connect working with it eventually and have had problems when I don't set it up with thi...
2010/10/09
[ "https://Stackoverflow.com/questions/3897587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383125/" ]
Lim **is** decreasing, you probably made a mistake elsewhere. However, `--lim` is not quite equal to `lim = lim - 1`. There are two operators to perform increment/decrement of a variable: pre-increment(or decrement), and post-increment(or decrement). `++x` (pre-inc) and `x++` (post-inc) both modify the value of x by ...
`--lim` or `lim--` is a short hand of `lim = lim - 1`, So maybe author want to use this syntax to better clarify!
3,897,587
I'm working on a pretty simple iPhone app at the moment. I have a UIWebView with a UIToolBar at the bottom of it with a button on it. I've built it all through code, although I did create an empty NIB as I am hoping to get Facebook Connect working with it eventually and have had problems when I don't set it up with thi...
2010/10/09
[ "https://Stackoverflow.com/questions/3897587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383125/" ]
Lim **is** decreasing, you probably made a mistake elsewhere. However, `--lim` is not quite equal to `lim = lim - 1`. There are two operators to perform increment/decrement of a variable: pre-increment(or decrement), and post-increment(or decrement). `++x` (pre-inc) and `x++` (post-inc) both modify the value of x by ...
Excluding David's example (where the initial test of 'c' causes the loop body to never be executed, and thus lim is not decremented), and the possibility that lim is initially less than or equal to 1 (in which case the getchar() would not be executed), the code is equivalent to the following: ``` c=getchar(); while (...
3,897,587
I'm working on a pretty simple iPhone app at the moment. I have a UIWebView with a UIToolBar at the bottom of it with a button on it. I've built it all through code, although I did create an empty NIB as I am hoping to get Facebook Connect working with it eventually and have had problems when I don't set it up with thi...
2010/10/09
[ "https://Stackoverflow.com/questions/3897587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383125/" ]
`--lim` means "take one from the value of `lim` and use the result". The alternative `lim--` would be "use the value of `lim` and then take one away". So if `lim` starts at 1000 the first time the loop executes it will have the value `999` before it is checked to see if it's greater than 0. If it were `lim--` then th...
Lim **is** decreasing, you probably made a mistake elsewhere. However, `--lim` is not quite equal to `lim = lim - 1`. There are two operators to perform increment/decrement of a variable: pre-increment(or decrement), and post-increment(or decrement). `++x` (pre-inc) and `x++` (post-inc) both modify the value of x by ...
3,897,587
I'm working on a pretty simple iPhone app at the moment. I have a UIWebView with a UIToolBar at the bottom of it with a button on it. I've built it all through code, although I did create an empty NIB as I am hoping to get Facebook Connect working with it eventually and have had problems when I don't set it up with thi...
2010/10/09
[ "https://Stackoverflow.com/questions/3897587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383125/" ]
`--lim` means "take one from the value of `lim` and use the result". The alternative `lim--` would be "use the value of `lim` and then take one away". So if `lim` starts at 1000 the first time the loop executes it will have the value `999` before it is checked to see if it's greater than 0. If it were `lim--` then th...
Try to compile and run this code. It should be somewhat enlightening. ``` #include <stdio.h> int main() { int lim = 10; while (--lim > 0 && 1 > 32) printf("I should never get here\n"); printf("%d\n",lim); // lim is now 9 } ``` Oh look, `lim` is now `9` even though I never actual...
3,897,587
I'm working on a pretty simple iPhone app at the moment. I have a UIWebView with a UIToolBar at the bottom of it with a button on it. I've built it all through code, although I did create an empty NIB as I am hoping to get Facebook Connect working with it eventually and have had problems when I don't set it up with thi...
2010/10/09
[ "https://Stackoverflow.com/questions/3897587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383125/" ]
Try to compile and run this code. It should be somewhat enlightening. ``` #include <stdio.h> int main() { int lim = 10; while (--lim > 0 && 1 > 32) printf("I should never get here\n"); printf("%d\n",lim); // lim is now 9 } ``` Oh look, `lim` is now `9` even though I never actual...
Excluding David's example (where the initial test of 'c' causes the loop body to never be executed, and thus lim is not decremented), and the possibility that lim is initially less than or equal to 1 (in which case the getchar() would not be executed), the code is equivalent to the following: ``` c=getchar(); while (...
36,591,811
Hello i am working on this fix for 2-3 hours.. it was working at first, i moved some of my code to another file and required that file to make it cleaner then boom doesnt work anymore. ``` require('./mongooschema.js'); console.log(Mesaj); /// SECOND FILE mongooschema.js var mongoose = require('mongoose'); mongoose....
2016/04/13
[ "https://Stackoverflow.com/questions/36591811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4627680/" ]
> > Is CTI still valid as approach? > > > I think that if the number of the categories are in the order of tenth, and not of hundredth, then yes. > > How could I assign the correct attributes set to a product? > > > You could add to each category row the table name of corresponding table of attributes, and f...
In almost all situations it is "wrong" to have 55 tables with identical schema. Making it 1 table is better. But then it gets you into the nightmare called "Entity-Attribute-Value". Pick a few "attributes" that you usually need to search on. Put the rest into a JSON string in a single column. [More details](http://mys...
50,145,882
I'm trying to write a program that calculates the union and intersection of two sets of numbers. The sets can be represented using arrays So my code is working perfectly for the intersection, but for the union, it does something really weird. The code should do this: ``` Enter number of elements in set A: 5 Enter se...
2018/05/03
[ "https://Stackoverflow.com/questions/50145882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9476436/" ]
You never sort your arrays, but it looks like the `compute_union()` routine is assuming sorted arrays.
You are not looking if an element is already stored in the union set array or not. If you don't want to sort the arrays first, you could use a function like ``` int srch(int *a, int size, int x) { for(int i=0; i<size; ++i) { if(a[i]==x) { return 1; } } return 0; ...
50,145,882
I'm trying to write a program that calculates the union and intersection of two sets of numbers. The sets can be represented using arrays So my code is working perfectly for the intersection, but for the union, it does something really weird. The code should do this: ``` Enter number of elements in set A: 5 Enter se...
2018/05/03
[ "https://Stackoverflow.com/questions/50145882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9476436/" ]
> > My errors for the union are that they are not arranged in order and also it shouldnt print the repeated numbers and it does. > > > Sets typically are not ordered data structures, unless you specifically need an ordered set. But the second requirement about non repeated numbers is valid for a set; a set should ...
You are not looking if an element is already stored in the union set array or not. If you don't want to sort the arrays first, you could use a function like ``` int srch(int *a, int size, int x) { for(int i=0; i<size; ++i) { if(a[i]==x) { return 1; } } return 0; ...
27,672,337
I'm getting this error when submitting the form: > > org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.model.Account; nested exception is javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.mode...
2014/12/27
[ "https://Stackoverflow.com/questions/27672337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2287404/" ]
Since your id is auto generated value, don't send it from client side. I had a same issue. Make sure that you does't provide a value for auto generated attribute.
Be aware of Lombok .toBuilder() method - it is creating a new instance of the object, which can be pretty misleading, when you are trying to update the part of a child object. Example: ``` public class User { @OneToOne(...) Field x; } ``` ``` @Builder(toBuilder = true) public class Field { String a; String b; }...
27,672,337
I'm getting this error when submitting the form: > > org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.model.Account; nested exception is javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.mode...
2014/12/27
[ "https://Stackoverflow.com/questions/27672337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2287404/" ]
The error occurs because the **id** is set. Hibernate distinguishes between transient and detached objects and persist works only with transient objects. ``` isteamService.save(team); ``` in this operation can not be loaded id because is @GeneratedValue
Please, change `@OneToMany(cascade = CascadeType.ALL,..)` to `@OneToMany(cascade = CascadeType.REMOVE,...)` or another except `CascadeType.PERSIST` and the problem has been solved
27,672,337
I'm getting this error when submitting the form: > > org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.model.Account; nested exception is javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.mode...
2014/12/27
[ "https://Stackoverflow.com/questions/27672337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2287404/" ]
The error occurs because the **id** is set. Hibernate distinguishes between transient and detached objects and persist works only with transient objects. ``` isteamService.save(team); ``` in this operation can not be loaded id because is @GeneratedValue
Since your id is auto generated value, don't send it from client side. I had a same issue. Make sure that you does't provide a value for auto generated attribute.
27,672,337
I'm getting this error when submitting the form: > > org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.model.Account; nested exception is javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.mode...
2014/12/27
[ "https://Stackoverflow.com/questions/27672337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2287404/" ]
``` teamService.save(team); ``` Save method accepts only transient objects. What is the transient object you can find [here](http://docs.jboss.org/hibernate/core/3.3/reference/en/html/objectstate.html) `Transient - an object is transient if it has just been instantiated using the new operator, and it is not associat...
Please, change `@OneToMany(cascade = CascadeType.ALL,..)` to `@OneToMany(cascade = CascadeType.REMOVE,...)` or another except `CascadeType.PERSIST` and the problem has been solved
27,672,337
I'm getting this error when submitting the form: > > org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.model.Account; nested exception is javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.mode...
2014/12/27
[ "https://Stackoverflow.com/questions/27672337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2287404/" ]
``` teamService.save(team); ``` Save method accepts only transient objects. What is the transient object you can find [here](http://docs.jboss.org/hibernate/core/3.3/reference/en/html/objectstate.html) `Transient - an object is transient if it has just been instantiated using the new operator, and it is not associat...
The error occurs because the **id** is set. Hibernate distinguishes between transient and detached objects and persist works only with transient objects. ``` isteamService.save(team); ``` in this operation can not be loaded id because is @GeneratedValue
27,672,337
I'm getting this error when submitting the form: > > org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.model.Account; nested exception is javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.mode...
2014/12/27
[ "https://Stackoverflow.com/questions/27672337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2287404/" ]
Please, change `@OneToMany(cascade = CascadeType.ALL,..)` to `@OneToMany(cascade = CascadeType.REMOVE,...)` or another except `CascadeType.PERSIST` and the problem has been solved
This error happened for me when I tried to save a child entity and then pass the newly saved entity as parameter to a new parent object. For instance: `ChildA a = childAService.save(childAObject);` `Parent parent = new Parent()`; `parent.setChildA(a) // <=== Culprit` `parentService.save(parent);` Instead, do: `C...
27,672,337
I'm getting this error when submitting the form: > > org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.model.Account; nested exception is javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.mode...
2014/12/27
[ "https://Stackoverflow.com/questions/27672337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2287404/" ]
``` teamService.save(team); ``` Save method accepts only transient objects. What is the transient object you can find [here](http://docs.jboss.org/hibernate/core/3.3/reference/en/html/objectstate.html) `Transient - an object is transient if it has just been instantiated using the new operator, and it is not associat...
Since your id is auto generated value, don't send it from client side. I had a same issue. Make sure that you does't provide a value for auto generated attribute.
27,672,337
I'm getting this error when submitting the form: > > org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.model.Account; nested exception is javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.mode...
2014/12/27
[ "https://Stackoverflow.com/questions/27672337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2287404/" ]
``` teamService.save(team); ``` Save method accepts only transient objects. What is the transient object you can find [here](http://docs.jboss.org/hibernate/core/3.3/reference/en/html/objectstate.html) `Transient - an object is transient if it has just been instantiated using the new operator, and it is not associat...
This error happened for me when I tried to save a child entity and then pass the newly saved entity as parameter to a new parent object. For instance: `ChildA a = childAService.save(childAObject);` `Parent parent = new Parent()`; `parent.setChildA(a) // <=== Culprit` `parentService.save(parent);` Instead, do: `C...
27,672,337
I'm getting this error when submitting the form: > > org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.model.Account; nested exception is javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.mode...
2014/12/27
[ "https://Stackoverflow.com/questions/27672337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2287404/" ]
Please, change `@OneToMany(cascade = CascadeType.ALL,..)` to `@OneToMany(cascade = CascadeType.REMOVE,...)` or another except `CascadeType.PERSIST` and the problem has been solved
Since your id is auto generated value, don't send it from client side. I had a same issue. Make sure that you does't provide a value for auto generated attribute.
27,672,337
I'm getting this error when submitting the form: > > org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.model.Account; nested exception is javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.project.pmet.mode...
2014/12/27
[ "https://Stackoverflow.com/questions/27672337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2287404/" ]
The error occurs because the **id** is set. Hibernate distinguishes between transient and detached objects and persist works only with transient objects. ``` isteamService.save(team); ``` in this operation can not be loaded id because is @GeneratedValue
This error happened for me when I tried to save a child entity and then pass the newly saved entity as parameter to a new parent object. For instance: `ChildA a = childAService.save(childAObject);` `Parent parent = new Parent()`; `parent.setChildA(a) // <=== Culprit` `parentService.save(parent);` Instead, do: `C...
52,350,011
Basically my title is the question: Example: ``` >>> l=[1,2,3] >>> *l SyntaxError: can't use starred expression here >>> print(*l) 1 2 3 >>> ``` Why is that???
2018/09/16
[ "https://Stackoverflow.com/questions/52350011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8708364/" ]
because it's equivalent to positional arugments corspondent to the list, so when your not calling it somewhere that can take all the arguments, it makes no sense, since there are nowhere to put the arguments f.x. ``` print(*[1,2,3]) # is the same as print(1,2,3) ``` and ``` *[1,2,3] #is the same as - and do not th...
I think this is actually a question about understanding `*l` or generally `*ListLikeObject`. The critical point is `*ListLikeObject` is not a valid expression individually. It doesn't mean "Oh please unpack the list". An example can be `2 *[1, 2, 3]`(As we all know, it will output `[1, 2, 3, 1, 2, 3]`). If an individ...
41,858
Below is from a truffle test cases in javascript, where I was trying to add the gas cost to an account balance to confirm the sum of transaction, where the sum should be equal to the previous balance. But I couldn't get it to work! The rcpt.cumulativeGasUsed, web3.eth.gasPrice, getBalance(accounts[1]) are all correct...
2018/03/06
[ "https://ethereum.stackexchange.com/questions/41858", "https://ethereum.stackexchange.com", "https://ethereum.stackexchange.com/users/31355/" ]
Note: This answer is only valid for Truffle v4. --- I've tried this test with the MetaCoin example from truffle (ie run `truffle unbox metacoin` in an empty directory) ``` var MetaCoin = artifacts.require("./MetaCoin.sol"); contract('MetaCoin', function(accounts) { it("Test gas", async () => { const meta = aw...
The following code is the same code as [Ismael](https://ethereum.stackexchange.com/users/2124/ismael)'s code, with the changes to work with Truffle v5, as `getBalance`'s return type, beside `gasUsed` and `gasPrice` values are not BN by default: ``` var MetaCoin = artifacts.require("./MetaCoin.sol"); const { toBN } = ...
53,841,696
I have data in a table(list) as shown below, ``` id no1 no2 1000 0 511 1000 820 0 ``` I need data like shown below, ``` id no1 no2 1000 820 511 ``` Can anyone solve this. Thanks in advance.
2018/12/18
[ "https://Stackoverflow.com/questions/53841696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8029341/" ]
simple group by with summation will work for you ``` SELECT ID, SUM(NO1) NO1, SUM(NO2) NO2 FROM Table1 Group by ID ```
You can use sum or max: ``` select id,max(no1),max(no2) from tab_name group by id; ``` or ``` select id,sum(no1),sum(no2) from tab_name group by id; ```
3,835,043
I have a C server (a data feed handler) that has the potential to send millions of tiny messages per second across a few thousand long-lived Erlang processes. In a single day, some of these processes will receive a few *thousand* messages, while others will receive tens of *millions*. My interests are threefold: 1. t...
2010/09/30
[ "https://Stackoverflow.com/questions/3835043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/203104/" ]
Try the following DiffRange function. ``` public static DateTime DayStart(DateTime date) { return date.Date.AddHours(7); } public static DateTime DayEnd(DateTime date) { return date.Date.AddHours(19); } public static TimeSpan DiffSingleDay(DateTime start, DateTime end) { if ( start.Date != end.Date ) { ...
My implementation :) The idea is to quickly compute the total weeks, and walk the remaining week day by day... ``` public TimeSpan Compute(DateTime start, DateTime end) { // constant start / end times per day TimeSpan sevenAM = TimeSpan.FromHours(7); TimeSpan sevenPM = TimeSpan.FromHours(19); if( star...
3,835,043
I have a C server (a data feed handler) that has the potential to send millions of tiny messages per second across a few thousand long-lived Erlang processes. In a single day, some of these processes will receive a few *thousand* messages, while others will receive tens of *millions*. My interests are threefold: 1. t...
2010/09/30
[ "https://Stackoverflow.com/questions/3835043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/203104/" ]
You can, of course, use LINQ: ``` DateTime a = new DateTime(2010, 10, 30, 21, 58, 29); DateTime b = a + new TimeSpan(12, 5, 54, 24, 623); var minutes = from day in a.DaysInRangeUntil(b) where !day.IsWeekendDay() let start = Max(day.AddHours( 7), a) let end = Min(day.AddHour...
Use TimeSpan.TotalMinutes, subtract non-business days, subtract superfluous hours.
3,835,043
I have a C server (a data feed handler) that has the potential to send millions of tiny messages per second across a few thousand long-lived Erlang processes. In a single day, some of these processes will receive a few *thousand* messages, while others will receive tens of *millions*. My interests are threefold: 1. t...
2010/09/30
[ "https://Stackoverflow.com/questions/3835043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/203104/" ]
Take your start time, get the amount of minutes to the end of that day (Ie the 7pm). Then from the 7am the next day, count the amount of days to the final day (excluding any time into the end day). Calculate how many (If any) weekends have passed. (For every weekends reduce the count of days by 2). Do some simple ma...
It was a pretty hard question. For a basic, in a straightforward approach, I have written the below code: ``` DateTime start = new DateTime(2010, 01, 01, 21, 00, 00); DateTime end = new DateTime(2010, 10, 01, 14, 00, 00); // Shift start date's hour to 7 and same for end date // These will be added after doing calcula...
3,835,043
I have a C server (a data feed handler) that has the potential to send millions of tiny messages per second across a few thousand long-lived Erlang processes. In a single day, some of these processes will receive a few *thousand* messages, while others will receive tens of *millions*. My interests are threefold: 1. t...
2010/09/30
[ "https://Stackoverflow.com/questions/3835043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/203104/" ]
Take your start time, get the amount of minutes to the end of that day (Ie the 7pm). Then from the 7am the next day, count the amount of days to the final day (excluding any time into the end day). Calculate how many (If any) weekends have passed. (For every weekends reduce the count of days by 2). Do some simple ma...
My implementation :) The idea is to quickly compute the total weeks, and walk the remaining week day by day... ``` public TimeSpan Compute(DateTime start, DateTime end) { // constant start / end times per day TimeSpan sevenAM = TimeSpan.FromHours(7); TimeSpan sevenPM = TimeSpan.FromHours(19); if( star...
3,835,043
I have a C server (a data feed handler) that has the potential to send millions of tiny messages per second across a few thousand long-lived Erlang processes. In a single day, some of these processes will receive a few *thousand* messages, while others will receive tens of *millions*. My interests are threefold: 1. t...
2010/09/30
[ "https://Stackoverflow.com/questions/3835043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/203104/" ]
Take your start time, get the amount of minutes to the end of that day (Ie the 7pm). Then from the 7am the next day, count the amount of days to the final day (excluding any time into the end day). Calculate how many (If any) weekends have passed. (For every weekends reduce the count of days by 2). Do some simple ma...
I'm sure there's something I missed. ``` TimeSpan CalcBusinessTime(DateTime a, DateTime b) { if (a > b) { DateTime tmp = a; a = b; b = tmp; } if (a.TimeOfDay < new TimeSpan(7, 0, 0)) a = new DateTime(a.Year, a.Month, a.Day, 7, 0, 0); if (b.TimeOfDay > new T...
3,835,043
I have a C server (a data feed handler) that has the potential to send millions of tiny messages per second across a few thousand long-lived Erlang processes. In a single day, some of these processes will receive a few *thousand* messages, while others will receive tens of *millions*. My interests are threefold: 1. t...
2010/09/30
[ "https://Stackoverflow.com/questions/3835043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/203104/" ]
Try the following DiffRange function. ``` public static DateTime DayStart(DateTime date) { return date.Date.AddHours(7); } public static DateTime DayEnd(DateTime date) { return date.Date.AddHours(19); } public static TimeSpan DiffSingleDay(DateTime start, DateTime end) { if ( start.Date != end.Date ) { ...
Use TimeSpan.TotalMinutes, subtract non-business days, subtract superfluous hours.
3,835,043
I have a C server (a data feed handler) that has the potential to send millions of tiny messages per second across a few thousand long-lived Erlang processes. In a single day, some of these processes will receive a few *thousand* messages, while others will receive tens of *millions*. My interests are threefold: 1. t...
2010/09/30
[ "https://Stackoverflow.com/questions/3835043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/203104/" ]
You can, of course, use LINQ: ``` DateTime a = new DateTime(2010, 10, 30, 21, 58, 29); DateTime b = a + new TimeSpan(12, 5, 54, 24, 623); var minutes = from day in a.DaysInRangeUntil(b) where !day.IsWeekendDay() let start = Max(day.AddHours( 7), a) let end = Min(day.AddHour...
My implementation :) The idea is to quickly compute the total weeks, and walk the remaining week day by day... ``` public TimeSpan Compute(DateTime start, DateTime end) { // constant start / end times per day TimeSpan sevenAM = TimeSpan.FromHours(7); TimeSpan sevenPM = TimeSpan.FromHours(19); if( star...
3,835,043
I have a C server (a data feed handler) that has the potential to send millions of tiny messages per second across a few thousand long-lived Erlang processes. In a single day, some of these processes will receive a few *thousand* messages, while others will receive tens of *millions*. My interests are threefold: 1. t...
2010/09/30
[ "https://Stackoverflow.com/questions/3835043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/203104/" ]
Take your start time, get the amount of minutes to the end of that day (Ie the 7pm). Then from the 7am the next day, count the amount of days to the final day (excluding any time into the end day). Calculate how many (If any) weekends have passed. (For every weekends reduce the count of days by 2). Do some simple ma...
Try the following DiffRange function. ``` public static DateTime DayStart(DateTime date) { return date.Date.AddHours(7); } public static DateTime DayEnd(DateTime date) { return date.Date.AddHours(19); } public static TimeSpan DiffSingleDay(DateTime start, DateTime end) { if ( start.Date != end.Date ) { ...
3,835,043
I have a C server (a data feed handler) that has the potential to send millions of tiny messages per second across a few thousand long-lived Erlang processes. In a single day, some of these processes will receive a few *thousand* messages, while others will receive tens of *millions*. My interests are threefold: 1. t...
2010/09/30
[ "https://Stackoverflow.com/questions/3835043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/203104/" ]
You can, of course, use LINQ: ``` DateTime a = new DateTime(2010, 10, 30, 21, 58, 29); DateTime b = a + new TimeSpan(12, 5, 54, 24, 623); var minutes = from day in a.DaysInRangeUntil(b) where !day.IsWeekendDay() let start = Max(day.AddHours( 7), a) let end = Min(day.AddHour...
Try the following DiffRange function. ``` public static DateTime DayStart(DateTime date) { return date.Date.AddHours(7); } public static DateTime DayEnd(DateTime date) { return date.Date.AddHours(19); } public static TimeSpan DiffSingleDay(DateTime start, DateTime end) { if ( start.Date != end.Date ) { ...
3,835,043
I have a C server (a data feed handler) that has the potential to send millions of tiny messages per second across a few thousand long-lived Erlang processes. In a single day, some of these processes will receive a few *thousand* messages, while others will receive tens of *millions*. My interests are threefold: 1. t...
2010/09/30
[ "https://Stackoverflow.com/questions/3835043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/203104/" ]
You can, of course, use LINQ: ``` DateTime a = new DateTime(2010, 10, 30, 21, 58, 29); DateTime b = a + new TimeSpan(12, 5, 54, 24, 623); var minutes = from day in a.DaysInRangeUntil(b) where !day.IsWeekendDay() let start = Max(day.AddHours( 7), a) let end = Min(day.AddHour...
I won't write any code, but having a DateTime you can tell the Day of the week, thus you know how many weekends are in your range, so you can tell how many minutes are in a weekend. So it wouldn't be so hard... of course there must be an optimal one line solution... but i think you can get around with this one. I for...
23,215,697
I have a custom Wordpress table with the following contents: ``` account_info id | account_id | wp_title | wp_url 1 | 12345 | website | website.com ``` What is the best (or fastest) way to get the results? **Option 1:** ``` global $wpdb; $sql = "SELECT id, wp_title. wp_name FROM account_info"; $resu...
2014/04/22
[ "https://Stackoverflow.com/questions/23215697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/985664/" ]
When you are talking about "best" and "fastest" - these aren't the only things you need to take into consideration. *Readibility* is also key for future developers looking at your code. Option one clearly shows that, if the result set isn't empty, you loop around them and set some variables. Option two is *framework s...
This would depend on your objective, query language and the metta data design around indexing etc. In you example above collecting your results as an object above and iterating through would be the best option, if more than one option is available. If only ever expecting a singular result to be safe ad LIMIT 1 in you...
23,215,697
I have a custom Wordpress table with the following contents: ``` account_info id | account_id | wp_title | wp_url 1 | 12345 | website | website.com ``` What is the best (or fastest) way to get the results? **Option 1:** ``` global $wpdb; $sql = "SELECT id, wp_title. wp_name FROM account_info"; $resu...
2014/04/22
[ "https://Stackoverflow.com/questions/23215697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/985664/" ]
When you are talking about "best" and "fastest" - these aren't the only things you need to take into consideration. *Readibility* is also key for future developers looking at your code. Option one clearly shows that, if the result set isn't empty, you loop around them and set some variables. Option two is *framework s...
IMHO, I recommend the option 1, but even better I recommend using prepared statements, suggested by many authors. It avoids abuse of the protocol and mimimize data transfers. ``` $stmt = $dbh->prepare("SELECT id, wp_title. wp_name FROM account_info"); if ($stmt->execute(array())) { while ($row = $stmt->fetch()) { ...
59,192,023
I have some blog with some posts. Every page has a block "Read now" which contains post titles with count of readers at that moment (guests and auth users).The question is how to get these counters. I am usinng laravel Echo with beyondcode/laravel-websockets. Tryed to using presence channel, but it requires authorizati...
2019/12/05
[ "https://Stackoverflow.com/questions/59192023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4489464/" ]
You can try this method [by SaeedPrez](https://laracasts.com/discuss/channels/laravel/find-out-all-logged-in-users?page=0#reply=318054). Alternatively, you could try going through Laravels `Request` like this: ``` Request::session()->all() ``` Try dumping and dying (`dd()` function) and see how you could parse the ...
I think you can try init Echo.listen() on public channel once user hit the post page. From that, you can build logic to see how many people are in that post.id page by temporarily store the count data somewhere in Redis or just in database the belong to that specific post. And remove the count when user leave the page ...
26,239,083
I'm using `InnoDb` schema on `mysql 5.5`. `mysql 5.5` guide states: > > InnoDB uses the in-memory auto-increment counter as long as the server > runs. When the server is stopped and restarted, InnoDB reinitializes > the counter for each table for the first INSERT to the table, as > described earlier. > > > Th...
2014/10/07
[ "https://Stackoverflow.com/questions/26239083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1157935/" ]
you'll need to create a service that returns your user information ``` angular.module('app').factory('Authentication', function ($resource) { var resource = $resource('/user', {}, { query: { method: 'GET', cache: true } }); return resource.get().$promise; }); ``` ...
If you want to cheat a little, you can do this in `<head>` in your \_Layout: ``` <script type="text/javascript"> (function(myApp) { myApp.username = "@User.Identity.GetUserName()"; //optional myApp.otherStuff = "@moreMvcStuff"; })(window.myApp = window.myApp || {}); </script> ``` Then...
5,095,471
I have a small PHP mysql query looking at a table in my database. It's pulling all rows and then echoing out the record. Problem is I have a few empty rows in the table so what I get is a weird looking record. This is what I got: ``` <?php $con = mysql_connect("localhost","username","password"); if (!$con){ ...
2011/02/23
[ "https://Stackoverflow.com/questions/5095471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237153/" ]
You can put an `if(!empty($row['firstname']))` before you echo the row.
To print out only `rowname` and result from rows where result `IS NOT NULL`, try this: ``` if ($result = $mysqli->query($query)) { /* fetch associative array */ $i=1; while($a = $result->fetch_assoc()) { $i++; foreach ($a as $key => $value) { if($value != NULL) { ...
5,095,471
I have a small PHP mysql query looking at a table in my database. It's pulling all rows and then echoing out the record. Problem is I have a few empty rows in the table so what I get is a weird looking record. This is what I got: ``` <?php $con = mysql_connect("localhost","username","password"); if (!$con){ ...
2011/02/23
[ "https://Stackoverflow.com/questions/5095471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237153/" ]
Try SELECT column\_name FROM table\_name WHERE TRIM(column\_name) IS NOT NULL
You can put an `if(!empty($row['firstname']))` before you echo the row.
5,095,471
I have a small PHP mysql query looking at a table in my database. It's pulling all rows and then echoing out the record. Problem is I have a few empty rows in the table so what I get is a weird looking record. This is what I got: ``` <?php $con = mysql_connect("localhost","username","password"); if (!$con){ ...
2011/02/23
[ "https://Stackoverflow.com/questions/5095471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237153/" ]
why u not put > > Try SELECT column\_name FROM table\_name WHERE column\_name!='' > > >
To print out only `rowname` and result from rows where result `IS NOT NULL`, try this: ``` if ($result = $mysqli->query($query)) { /* fetch associative array */ $i=1; while($a = $result->fetch_assoc()) { $i++; foreach ($a as $key => $value) { if($value != NULL) { ...
5,095,471
I have a small PHP mysql query looking at a table in my database. It's pulling all rows and then echoing out the record. Problem is I have a few empty rows in the table so what I get is a weird looking record. This is what I got: ``` <?php $con = mysql_connect("localhost","username","password"); if (!$con){ ...
2011/02/23
[ "https://Stackoverflow.com/questions/5095471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237153/" ]
You can put an `if(!empty($row['firstname']))` before you echo the row.
I think in the "where" clause mention all field names like `first_name IS NOT NULL AND last_name IS NOT NULL`.
5,095,471
I have a small PHP mysql query looking at a table in my database. It's pulling all rows and then echoing out the record. Problem is I have a few empty rows in the table so what I get is a weird looking record. This is what I got: ``` <?php $con = mysql_connect("localhost","username","password"); if (!$con){ ...
2011/02/23
[ "https://Stackoverflow.com/questions/5095471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237153/" ]
why u not put > > Try SELECT column\_name FROM table\_name WHERE column\_name!='' > > >
Alex's empty check is good, and you can also check all three of them inline if you want to display incomplete records: ``` echo (! empty($row['firstname']) ? $row['firstname'] : "") .(! empty($row['city']) ? " - ".$row['city'] : "") .(! empty($row['state']) ? ", ".$row['state'] : "") . " &nbsp;|&nbsp; "...
5,095,471
I have a small PHP mysql query looking at a table in my database. It's pulling all rows and then echoing out the record. Problem is I have a few empty rows in the table so what I get is a weird looking record. This is what I got: ``` <?php $con = mysql_connect("localhost","username","password"); if (!$con){ ...
2011/02/23
[ "https://Stackoverflow.com/questions/5095471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237153/" ]
Alex's empty check is good, and you can also check all three of them inline if you want to display incomplete records: ``` echo (! empty($row['firstname']) ? $row['firstname'] : "") .(! empty($row['city']) ? " - ".$row['city'] : "") .(! empty($row['state']) ? ", ".$row['state'] : "") . " &nbsp;|&nbsp; "...
I think in the "where" clause mention all field names like `first_name IS NOT NULL AND last_name IS NOT NULL`.
5,095,471
I have a small PHP mysql query looking at a table in my database. It's pulling all rows and then echoing out the record. Problem is I have a few empty rows in the table so what I get is a weird looking record. This is what I got: ``` <?php $con = mysql_connect("localhost","username","password"); if (!$con){ ...
2011/02/23
[ "https://Stackoverflow.com/questions/5095471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237153/" ]
Alex's empty check is good, and you can also check all three of them inline if you want to display incomplete records: ``` echo (! empty($row['firstname']) ? $row['firstname'] : "") .(! empty($row['city']) ? " - ".$row['city'] : "") .(! empty($row['state']) ? ", ".$row['state'] : "") . " &nbsp;|&nbsp; "...
To print out only `rowname` and result from rows where result `IS NOT NULL`, try this: ``` if ($result = $mysqli->query($query)) { /* fetch associative array */ $i=1; while($a = $result->fetch_assoc()) { $i++; foreach ($a as $key => $value) { if($value != NULL) { ...
5,095,471
I have a small PHP mysql query looking at a table in my database. It's pulling all rows and then echoing out the record. Problem is I have a few empty rows in the table so what I get is a weird looking record. This is what I got: ``` <?php $con = mysql_connect("localhost","username","password"); if (!$con){ ...
2011/02/23
[ "https://Stackoverflow.com/questions/5095471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237153/" ]
why u not put > > Try SELECT column\_name FROM table\_name WHERE column\_name!='' > > >
I think in the "where" clause mention all field names like `first_name IS NOT NULL AND last_name IS NOT NULL`.
5,095,471
I have a small PHP mysql query looking at a table in my database. It's pulling all rows and then echoing out the record. Problem is I have a few empty rows in the table so what I get is a weird looking record. This is what I got: ``` <?php $con = mysql_connect("localhost","username","password"); if (!$con){ ...
2011/02/23
[ "https://Stackoverflow.com/questions/5095471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237153/" ]
Try SELECT column\_name FROM table\_name WHERE TRIM(column\_name) IS NOT NULL
I think in the "where" clause mention all field names like `first_name IS NOT NULL AND last_name IS NOT NULL`.
5,095,471
I have a small PHP mysql query looking at a table in my database. It's pulling all rows and then echoing out the record. Problem is I have a few empty rows in the table so what I get is a weird looking record. This is what I got: ``` <?php $con = mysql_connect("localhost","username","password"); if (!$con){ ...
2011/02/23
[ "https://Stackoverflow.com/questions/5095471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237153/" ]
Try SELECT column\_name FROM table\_name WHERE TRIM(column\_name) IS NOT NULL
Alex's empty check is good, and you can also check all three of them inline if you want to display incomplete records: ``` echo (! empty($row['firstname']) ? $row['firstname'] : "") .(! empty($row['city']) ? " - ".$row['city'] : "") .(! empty($row['state']) ? ", ".$row['state'] : "") . " &nbsp;|&nbsp; "...
2,495,932
Question: Take $\prec$ to be primitive and define $\preceq$ and $\sim$ in terms of $\prec$. Would I write: $x\preceq y$: $x \prec y$ (or would I not include this here?), not $(y \prec x)$; $x \sim y$: not $(x \prec y)$ and not $(y \prec x)$? I know how to take $\preceq$ and define $\prec$ and $\sim$ in terms of $\p...
2017/10/30
[ "https://math.stackexchange.com/questions/2495932", "https://math.stackexchange.com", "https://math.stackexchange.com/users/481752/" ]
Isn't it a matter of angle chasing? [![enter image description here](https://i.stack.imgur.com/UccpS.jpg)](https://i.stack.imgur.com/UccpS.jpg)
Find $\angle AMD$ from the isosceles triangle MAD instead. See if $\angle AMD + \angle AMB + \angle BMP = 180^0$ or not. Added: M is a point between P and D. There are only two cases that can happen:- (1) PM and MD form a straight line; or (2) PM and MD together form a crooked V; [but not both]. If $\angle AMD + \a...
46,287,242
I'm typing my first obiect program - BlackJack, and I have problem with print card image. My class Card extended JLabel and has ImageIcon property. ``` package Blackjack; import java.awt.Dimension; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; impo...
2017/09/18
[ "https://Stackoverflow.com/questions/46287242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8627376/" ]
The primary problem is, you never actually set the `icon` property of the `JLabel`, so it has nothing to show What I would recommend doing, is creating an instance of the face and back image and when the visible state changes, change the `icon` property ``` public class Card extends JLabel { private final String...
Instead of creating another `JFrame` (also pointed out by @user1803551) within the extended class, just set the frame up as this. This will still give you only one window. ``` public class Game extends JFrame{ private Table table; public Game(Table t){ setSize(800, 500); setLayout(new BorderLayout()); ...
52,503,263
I don't know why as I'm following the official documentation but the functions of onChipAdd and onChipDelete are not called when adding and deleting chips. ``` document.addEventListener('DOMContentLoaded', function() { var elems = document.querySelectorAll('.chips'); var instances = M.Chips.init(elems, { placeho...
2018/09/25
[ "https://Stackoverflow.com/questions/52503263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4334777/" ]
Ok, I got the answer on the chat with the team: ``` function chipAddCallback() { const lastTagAdded = this.chipsData[this.chipsData.length - 1].tag; const message = `"${lastTagAdded}" Chip added!`; console.log(message); } function chipDeleteCallback() { console.log("Chip Deleted!"); } function init() { $(".c...
You've to use `options` like this to call the callback functions of chips. ``` <div class="chips"></div> <script> document.addEventListener('DOMContentLoaded', function () { var options = { onChipAdd() { console.log("added"); }, onChipSelect() { ...
52,503,263
I don't know why as I'm following the official documentation but the functions of onChipAdd and onChipDelete are not called when adding and deleting chips. ``` document.addEventListener('DOMContentLoaded', function() { var elems = document.querySelectorAll('.chips'); var instances = M.Chips.init(elems, { placeho...
2018/09/25
[ "https://Stackoverflow.com/questions/52503263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4334777/" ]
Ok, I got the answer on the chat with the team: ``` function chipAddCallback() { const lastTagAdded = this.chipsData[this.chipsData.length - 1].tag; const message = `"${lastTagAdded}" Chip added!`; console.log(message); } function chipDeleteCallback() { console.log("Chip Deleted!"); } function init() { $(".c...
The below code works fine for me. I modified Germa's answer above a little bit. The only thing different is that onChipAdd, onChipSelect and onChipDelete are arrow functions. Check it out and give it a try for yourself. ``` document.addEventListener('DOMContentLoaded', function() { let elems = document.querySe...
43,501,782
I'm looking through an API, and all the examples are given using [cURL](https://curl.haxx.se/docs/manpage.html). I don't use cURL myself, and am looking for equivalent URL strings that I can send as GET arguments. For example, say the cURL command is this: ``` $ curl -X GET "https://thesite.com/api/orgs" \ -u ...
2017/04/19
[ "https://Stackoverflow.com/questions/43501782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3170465/" ]
This is related to the Authorization HTTP header and [HTTP Authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication), which will contain the username and the password. But this username is not a GET parameter, it goes into an HTTP Header, so it cannot be used it in the query string (?user=...). ...
You can use [file\_get\_contents](http://php.net/manual/en/function.file-get-contents.php) it does the same as curl Code example: ``` <?php $homepage = file_get_contents('http://www.example.com/'); echo $homepage; ?> ``` To send $\_POST and $\_GET requests you can use [Guzzle](http://docs.guzzlephp.org/en/latest/) ...
4,862,754
``` string filePath = ExportAndSaveInvoiceAsHtml(invoiceId); Response.AddHeader("Content-Disposition", "attachment;filename=" + Path.GetFileName(filePath)); Response.WriteFile(filePath); // Using Response.End() solves the problem // Response.End(); ``` I want to enable users to download HTML invoice (from gr...
2011/02/01
[ "https://Stackoverflow.com/questions/4862754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/520348/" ]
That's because the response is *buffered*. You have to call [Response.End()](http://msdn.microsoft.com/en-us/library/system.web.httpresponse.end.aspx) to flush the buffers and ensure the client gets the complete response before the handler thread completes. The [ThreadAbortException](http://msdn.microsoft.com/en-us/li...
Instead of Response.End() you can use ``` HttpContext.Current.ApplicationInstance.CompleteRequest() ``` This method tend to avoid throwing exceptions :)
2
Are discussion question okay? I'd like to start a discussion on why XSS should be renamed Script Injection, and if there is agreement on that (I've got a few arguments), if and how we could go about promoting it. If the question would get shot down anyway, I wouldn't want to waste time writing down the arguments...
2010/11/11
[ "https://security.meta.stackexchange.com/questions/2", "https://security.meta.stackexchange.com", "https://security.meta.stackexchange.com/users/18/" ]
Contrary to my previous answer (which I still prefer - but it looks like its not gonna happen) - if this is an all-inclusive, all-things-information-security, then we should also put more emphasis on other parts of infosec too, such as risk management, cryptography, etc. E.g. the following Area51 proposals should als...
As I said [here](https://security.meta.stackexchange.com/q/9/33), I think this site should be focused on Application Security only, thats a wide enough topic - but not just web security. While I might understand why @Robert would want to merge them, it's crystal clear that SO could not have included SF - completely di...
2
Are discussion question okay? I'd like to start a discussion on why XSS should be renamed Script Injection, and if there is agreement on that (I've got a few arguments), if and how we could go about promoting it. If the question would get shot down anyway, I wouldn't want to waste time writing down the arguments...
2010/11/11
[ "https://security.meta.stackexchange.com/questions/2", "https://security.meta.stackexchange.com", "https://security.meta.stackexchange.com/users/18/" ]
I agree with AviD on the professional vs end-user demarcation. I think the core assumption is that security professionals (or IT folks with a security responsibility) will be the ones coming here and posing questions or delivering answers. So from your question, how to implement a specific security task may well be ap...
As I said [here](https://security.meta.stackexchange.com/q/9/33), I think this site should be focused on Application Security only, thats a wide enough topic - but not just web security. While I might understand why @Robert would want to merge them, it's crystal clear that SO could not have included SF - completely di...
2
Are discussion question okay? I'd like to start a discussion on why XSS should be renamed Script Injection, and if there is agreement on that (I've got a few arguments), if and how we could go about promoting it. If the question would get shot down anyway, I wouldn't want to waste time writing down the arguments...
2010/11/11
[ "https://security.meta.stackexchange.com/questions/2", "https://security.meta.stackexchange.com", "https://security.meta.stackexchange.com/users/18/" ]
Contrary to my previous answer (which I still prefer - but it looks like its not gonna happen) - if this is an all-inclusive, all-things-information-security, then we should also put more emphasis on other parts of infosec too, such as risk management, cryptography, etc. E.g. the following Area51 proposals should als...
I agree with AviD on the professional vs end-user demarcation. I think the core assumption is that security professionals (or IT folks with a security responsibility) will be the ones coming here and posing questions or delivering answers. So from your question, how to implement a specific security task may well be ap...
281,787
Going forward, “rep-whore” (and its derivatives) will be treated like any other term that’s inconsistent with the community’s “be nice” policy: it will be removed. It’s totally okay if you’ve used it in the past. ================================================ Nobody’s judging the many users who’ve used it. And use...
2016/07/29
[ "https://meta.stackexchange.com/questions/281787", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/147336/" ]
Yeah... This seems like a good idea. The term has moved from its original jocular uses to something considerably more mean-spirited. I suspect most folks using the term now have some sort of nasty boogieman in mind rather than [good ol' Marc Gravell](https://meta.stackexchange.com/questions/15540/award-bounties-at-the-...
This feels a bit like [bowdlerisation](https://en.wikipedia.org/wiki/Thomas_Bowdler). I've *personally* avoided it and favour the term 'Power Gamer' or 'Bounty Hunter' (drawing from my mispent youth as a pen and paper gamer). To me the 'be nice' policy isn't about language use. It's about ensuring that as many of my...
281,787
Going forward, “rep-whore” (and its derivatives) will be treated like any other term that’s inconsistent with the community’s “be nice” policy: it will be removed. It’s totally okay if you’ve used it in the past. ================================================ Nobody’s judging the many users who’ve used it. And use...
2016/07/29
[ "https://meta.stackexchange.com/questions/281787", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/147336/" ]
Yeah... This seems like a good idea. The term has moved from its original jocular uses to something considerably more mean-spirited. I suspect most folks using the term now have some sort of nasty boogieman in mind rather than [good ol' Marc Gravell](https://meta.stackexchange.com/questions/15540/award-bounties-at-the-...
I've never used the term *rep-whore* and I agree that it sounds pejorative and belittling. Those who answer off-topic questions just to earn a few tens of reputation points should be called *SE user* because we did it one way or another in the past. However, what do you call a user who constantly answer off-topic quest...
281,787
Going forward, “rep-whore” (and its derivatives) will be treated like any other term that’s inconsistent with the community’s “be nice” policy: it will be removed. It’s totally okay if you’ve used it in the past. ================================================ Nobody’s judging the many users who’ve used it. And use...
2016/07/29
[ "https://meta.stackexchange.com/questions/281787", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/147336/" ]
> > It's time... > > > ...it's time to keep the [promise](https://meta.stackoverflow.com/a/320971/839601) made three months ago: > > we'll start looking at [increasing the number of close votes based on rep](https://meta.stackexchange.com/questions/266500/proposal-to-make-close-votes-scale-with-rep) > > > Yo...
I've never used the term *rep-whore* and I agree that it sounds pejorative and belittling. Those who answer off-topic questions just to earn a few tens of reputation points should be called *SE user* because we did it one way or another in the past. However, what do you call a user who constantly answer off-topic quest...
281,787
Going forward, “rep-whore” (and its derivatives) will be treated like any other term that’s inconsistent with the community’s “be nice” policy: it will be removed. It’s totally okay if you’ve used it in the past. ================================================ Nobody’s judging the many users who’ve used it. And use...
2016/07/29
[ "https://meta.stackexchange.com/questions/281787", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/147336/" ]
This feels a bit like [bowdlerisation](https://en.wikipedia.org/wiki/Thomas_Bowdler). I've *personally* avoided it and favour the term 'Power Gamer' or 'Bounty Hunter' (drawing from my mispent youth as a pen and paper gamer). To me the 'be nice' policy isn't about language use. It's about ensuring that as many of my...
I've never used the term *rep-whore* and I agree that it sounds pejorative and belittling. Those who answer off-topic questions just to earn a few tens of reputation points should be called *SE user* because we did it one way or another in the past. However, what do you call a user who constantly answer off-topic quest...
281,787
Going forward, “rep-whore” (and its derivatives) will be treated like any other term that’s inconsistent with the community’s “be nice” policy: it will be removed. It’s totally okay if you’ve used it in the past. ================================================ Nobody’s judging the many users who’ve used it. And use...
2016/07/29
[ "https://meta.stackexchange.com/questions/281787", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/147336/" ]
TL;DR: ------ Please don't just try to cure the symptoms when curing the cancer is this simple. Retract reputation gained from questions that are closed (or that were closed within a certain time frame, starting with the creation of the question), and you'll most likely fix this whole rep-system-abuse that's been go...
* **People are supposed to be seeking rep.** * **If people seeking rep are doing the "wrong things", you are giving rep for the "wrong things".** * **The main "wrong thing" is duplicates which are *answered* instead of *closed as duplicates*.** Flagging a duplicate gets no rep. Answering "how to make teh join" or "fi...
281,787
Going forward, “rep-whore” (and its derivatives) will be treated like any other term that’s inconsistent with the community’s “be nice” policy: it will be removed. It’s totally okay if you’ve used it in the past. ================================================ Nobody’s judging the many users who’ve used it. And use...
2016/07/29
[ "https://meta.stackexchange.com/questions/281787", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/147336/" ]
> > It's time... > > > ...it's time to keep the [promise](https://meta.stackoverflow.com/a/320971/839601) made three months ago: > > we'll start looking at [increasing the number of close votes based on rep](https://meta.stackexchange.com/questions/266500/proposal-to-make-close-votes-scale-with-rep) > > > Yo...
For what it's worth, if anyone wishes to call me a whore - either for rep or otherwise - I find this acceptable. I cannot guarantee a third party won't moderate our communication regardless, but i'm just going on-record as saying I do not feel people who say this to me are breaking any sort of social contract. I will n...
281,787
Going forward, “rep-whore” (and its derivatives) will be treated like any other term that’s inconsistent with the community’s “be nice” policy: it will be removed. It’s totally okay if you’ve used it in the past. ================================================ Nobody’s judging the many users who’ve used it. And use...
2016/07/29
[ "https://meta.stackexchange.com/questions/281787", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/147336/" ]
This feels a bit like [bowdlerisation](https://en.wikipedia.org/wiki/Thomas_Bowdler). I've *personally* avoided it and favour the term 'Power Gamer' or 'Bounty Hunter' (drawing from my mispent youth as a pen and paper gamer). To me the 'be nice' policy isn't about language use. It's about ensuring that as many of my...
For what it's worth, if anyone wishes to call me a whore - either for rep or otherwise - I find this acceptable. I cannot guarantee a third party won't moderate our communication regardless, but i'm just going on-record as saying I do not feel people who say this to me are breaking any sort of social contract. I will n...
281,787
Going forward, “rep-whore” (and its derivatives) will be treated like any other term that’s inconsistent with the community’s “be nice” policy: it will be removed. It’s totally okay if you’ve used it in the past. ================================================ Nobody’s judging the many users who’ve used it. And use...
2016/07/29
[ "https://meta.stackexchange.com/questions/281787", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/147336/" ]
TL;DR: ------ Please don't just try to cure the symptoms when curing the cancer is this simple. Retract reputation gained from questions that are closed (or that were closed within a certain time frame, starting with the creation of the question), and you'll most likely fix this whole rep-system-abuse that's been go...
I've never used the term *rep-whore* and I agree that it sounds pejorative and belittling. Those who answer off-topic questions just to earn a few tens of reputation points should be called *SE user* because we did it one way or another in the past. However, what do you call a user who constantly answer off-topic quest...
281,787
Going forward, “rep-whore” (and its derivatives) will be treated like any other term that’s inconsistent with the community’s “be nice” policy: it will be removed. It’s totally okay if you’ve used it in the past. ================================================ Nobody’s judging the many users who’ve used it. And use...
2016/07/29
[ "https://meta.stackexchange.com/questions/281787", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/147336/" ]
Yeah... This seems like a good idea. The term has moved from its original jocular uses to something considerably more mean-spirited. I suspect most folks using the term now have some sort of nasty boogieman in mind rather than [good ol' Marc Gravell](https://meta.stackexchange.com/questions/15540/award-bounties-at-the-...
For what it's worth, if anyone wishes to call me a whore - either for rep or otherwise - I find this acceptable. I cannot guarantee a third party won't moderate our communication regardless, but i'm just going on-record as saying I do not feel people who say this to me are breaking any sort of social contract. I will n...
281,787
Going forward, “rep-whore” (and its derivatives) will be treated like any other term that’s inconsistent with the community’s “be nice” policy: it will be removed. It’s totally okay if you’ve used it in the past. ================================================ Nobody’s judging the many users who’ve used it. And use...
2016/07/29
[ "https://meta.stackexchange.com/questions/281787", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/147336/" ]
> > It's time... > > > ...it's time to keep the [promise](https://meta.stackoverflow.com/a/320971/839601) made three months ago: > > we'll start looking at [increasing the number of close votes based on rep](https://meta.stackexchange.com/questions/266500/proposal-to-make-close-votes-scale-with-rep) > > > Yo...
This feels a bit like [bowdlerisation](https://en.wikipedia.org/wiki/Thomas_Bowdler). I've *personally* avoided it and favour the term 'Power Gamer' or 'Bounty Hunter' (drawing from my mispent youth as a pen and paper gamer). To me the 'be nice' policy isn't about language use. It's about ensuring that as many of my...
1,673,276
Suppose $\vec{w}=\frac{g}{||\vec{v}||} \vec{v}$, what is the derivative of $\vec{w}$ w.r.t. $\vec{v}$? Don't know how to deal with the norm of $\vec{v}$ here... Thanks in advance. :-) Edit: $L$ is a function of $\vec{w}$ and $g$. Based on $\vec{w}=\frac{g}{||\vec{v}||} \vec{v}$, we have $$\nabla{g}{L}=\frac{\nabla...
2016/02/26
[ "https://math.stackexchange.com/questions/1673276", "https://math.stackexchange.com", "https://math.stackexchange.com/users/311922/" ]
**Hint.** Apply the chain rule, using the fact that $$f(\vec{v})=\frac{\vec{v}}{||\vec{v}||} = F(\vec{v})\vec{v}$$ where $$F(\vec{v})= \frac{1}{\sqrt{\Vert \vec{v} \Vert^2}}$$ and $$h(\vec{v})=\Vert \vec{v} \Vert^2= (\vec{v},\vec{v})$$ is a bilinear map so its Fréchet derivative is $$h^\prime(\vec{v}).\vec{r} = 2 (\ve...
The ''derivative'' of a vector function of a vector is not a single number, but a matrix that contains all the partial derivative of the vector function with respect to the components of the independent vector, called the [Jacobian matrix](https://en.wikipedia.org/wiki/Jacobian_matrix_and_determinant#Jacobian_matrix). ...
23,286,254
I am newbie to Python and need to convert a list to dictionary. I know that we can convert a list of tuples to a dictionary. This is the input list: ``` L = [1,term1, 3, term2, x, term3,... z, termN] ``` and I want to convert this list to a list of tuples (or directly to a dictionary) like this: ``` [(1, term1),...
2014/04/25
[ "https://Stackoverflow.com/questions/23286254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` >>> L = [1, "term1", 3, "term2", 4, "term3", 5, "termN"] # Create an iterator >>> it = iter(L) # zip the iterator with itself >>> zip(it, it) [(1, 'term1'), (3, 'term2'), (4, 'term3'), (5, 'termN')] ``` You want to group three items at a time? ``` >>> zip(it, it, it) ``` You want to group N items at a time? `...
The below code will take care of both even and odd sized list : ``` [set(L[i:i+2]) for i in range(0, len(L),2)] ```
23,286,254
I am newbie to Python and need to convert a list to dictionary. I know that we can convert a list of tuples to a dictionary. This is the input list: ``` L = [1,term1, 3, term2, x, term3,... z, termN] ``` and I want to convert this list to a list of tuples (or directly to a dictionary) like this: ``` [(1, term1),...
2014/04/25
[ "https://Stackoverflow.com/questions/23286254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` >>> L = [1, "term1", 3, "term2", 4, "term3", 5, "termN"] # Create an iterator >>> it = iter(L) # zip the iterator with itself >>> zip(it, it) [(1, 'term1'), (3, 'term2'), (4, 'term3'), (5, 'termN')] ``` You want to group three items at a time? ``` >>> zip(it, it, it) ``` You want to group N items at a time? `...
``` [(L[i], L[i+1]) for i in xrange(0, len(L), 2)] ```
23,286,254
I am newbie to Python and need to convert a list to dictionary. I know that we can convert a list of tuples to a dictionary. This is the input list: ``` L = [1,term1, 3, term2, x, term3,... z, termN] ``` and I want to convert this list to a list of tuples (or directly to a dictionary) like this: ``` [(1, term1),...
2014/04/25
[ "https://Stackoverflow.com/questions/23286254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` >>> L = [1, "term1", 3, "term2", 4, "term3", 5, "termN"] # Create an iterator >>> it = iter(L) # zip the iterator with itself >>> zip(it, it) [(1, 'term1'), (3, 'term2'), (4, 'term3'), (5, 'termN')] ``` You want to group three items at a time? ``` >>> zip(it, it, it) ``` You want to group N items at a time? `...
Using slicing? ``` L = [1, "term1", 2, "term2", 3, "term3"] L = zip(L[::2], L[1::2]) print L ```
23,286,254
I am newbie to Python and need to convert a list to dictionary. I know that we can convert a list of tuples to a dictionary. This is the input list: ``` L = [1,term1, 3, term2, x, term3,... z, termN] ``` and I want to convert this list to a list of tuples (or directly to a dictionary) like this: ``` [(1, term1),...
2014/04/25
[ "https://Stackoverflow.com/questions/23286254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` >>> L = [1, "term1", 3, "term2", 4, "term3", 5, "termN"] # Create an iterator >>> it = iter(L) # zip the iterator with itself >>> zip(it, it) [(1, 'term1'), (3, 'term2'), (4, 'term3'), (5, 'termN')] ``` You want to group three items at a time? ``` >>> zip(it, it, it) ``` You want to group N items at a time? `...
Try with the group clustering idiom: ``` zip(*[iter(L)]*2) ``` From <https://docs.python.org/2/library/functions.html>: > > The left-to-right evaluation order of the iterables is guaranteed. > This makes possible an idiom for clustering a data series into > n-length groups using zip(\*[iter(s)]\*n). > > >
23,286,254
I am newbie to Python and need to convert a list to dictionary. I know that we can convert a list of tuples to a dictionary. This is the input list: ``` L = [1,term1, 3, term2, x, term3,... z, termN] ``` and I want to convert this list to a list of tuples (or directly to a dictionary) like this: ``` [(1, term1),...
2014/04/25
[ "https://Stackoverflow.com/questions/23286254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Using slicing? ``` L = [1, "term1", 2, "term2", 3, "term3"] L = zip(L[::2], L[1::2]) print L ```
Try this , ``` >>> L = [1, "term1", 3, "term2", 4, "term3", 5, "termN"] >>> it = iter(L) >>> [(x, next(it)) for x in it ] [(1, 'term1'), (3, 'term2'), (4, 'term3'), (5, 'termN')] >>> ``` OR -- ``` >>> L = [1, "term1", 3, "term2", 4, "term3", 5, "termN"] >>> [i for i in zip(*[iter(L)]*2)] [(1, 'term1'), (3, 'term2'...
23,286,254
I am newbie to Python and need to convert a list to dictionary. I know that we can convert a list of tuples to a dictionary. This is the input list: ``` L = [1,term1, 3, term2, x, term3,... z, termN] ``` and I want to convert this list to a list of tuples (or directly to a dictionary) like this: ``` [(1, term1),...
2014/04/25
[ "https://Stackoverflow.com/questions/23286254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
List directly into a dictionary using `zip` to pair consecutive even and odd elements: ``` m = [ 1, 2, 3, 4, 5, 6, 7, 8 ] d = { x : y for x, y in zip(m[::2], m[1::2]) } ``` or, since you are familiar with the tuple -> dict direction: ``` d = dict(t for t in zip(m[::2], m[1::2])) ``` even: ``` d = dict(zip(m[::2...
The below code will take care of both even and odd sized list : ``` [set(L[i:i+2]) for i in range(0, len(L),2)] ```
23,286,254
I am newbie to Python and need to convert a list to dictionary. I know that we can convert a list of tuples to a dictionary. This is the input list: ``` L = [1,term1, 3, term2, x, term3,... z, termN] ``` and I want to convert this list to a list of tuples (or directly to a dictionary) like this: ``` [(1, term1),...
2014/04/25
[ "https://Stackoverflow.com/questions/23286254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` >>> L = [1, "term1", 3, "term2", 4, "term3", 5, "termN"] # Create an iterator >>> it = iter(L) # zip the iterator with itself >>> zip(it, it) [(1, 'term1'), (3, 'term2'), (4, 'term3'), (5, 'termN')] ``` You want to group three items at a time? ``` >>> zip(it, it, it) ``` You want to group N items at a time? `...
Try this , ``` >>> L = [1, "term1", 3, "term2", 4, "term3", 5, "termN"] >>> it = iter(L) >>> [(x, next(it)) for x in it ] [(1, 'term1'), (3, 'term2'), (4, 'term3'), (5, 'termN')] >>> ``` OR -- ``` >>> L = [1, "term1", 3, "term2", 4, "term3", 5, "termN"] >>> [i for i in zip(*[iter(L)]*2)] [(1, 'term1'), (3, 'term2'...
23,286,254
I am newbie to Python and need to convert a list to dictionary. I know that we can convert a list of tuples to a dictionary. This is the input list: ``` L = [1,term1, 3, term2, x, term3,... z, termN] ``` and I want to convert this list to a list of tuples (or directly to a dictionary) like this: ``` [(1, term1),...
2014/04/25
[ "https://Stackoverflow.com/questions/23286254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Using slicing? ``` L = [1, "term1", 2, "term2", 3, "term3"] L = zip(L[::2], L[1::2]) print L ```
The below code will take care of both even and odd sized list : ``` [set(L[i:i+2]) for i in range(0, len(L),2)] ```
23,286,254
I am newbie to Python and need to convert a list to dictionary. I know that we can convert a list of tuples to a dictionary. This is the input list: ``` L = [1,term1, 3, term2, x, term3,... z, termN] ``` and I want to convert this list to a list of tuples (or directly to a dictionary) like this: ``` [(1, term1),...
2014/04/25
[ "https://Stackoverflow.com/questions/23286254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Try with the group clustering idiom: ``` zip(*[iter(L)]*2) ``` From <https://docs.python.org/2/library/functions.html>: > > The left-to-right evaluation order of the iterables is guaranteed. > This makes possible an idiom for clustering a data series into > n-length groups using zip(\*[iter(s)]\*n). > > >
The below code will take care of both even and odd sized list : ``` [set(L[i:i+2]) for i in range(0, len(L),2)] ```
23,286,254
I am newbie to Python and need to convert a list to dictionary. I know that we can convert a list of tuples to a dictionary. This is the input list: ``` L = [1,term1, 3, term2, x, term3,... z, termN] ``` and I want to convert this list to a list of tuples (or directly to a dictionary) like this: ``` [(1, term1),...
2014/04/25
[ "https://Stackoverflow.com/questions/23286254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
List directly into a dictionary using `zip` to pair consecutive even and odd elements: ``` m = [ 1, 2, 3, 4, 5, 6, 7, 8 ] d = { x : y for x, y in zip(m[::2], m[1::2]) } ``` or, since you are familiar with the tuple -> dict direction: ``` d = dict(t for t in zip(m[::2], m[1::2])) ``` even: ``` d = dict(zip(m[::2...
Using slicing? ``` L = [1, "term1", 2, "term2", 3, "term3"] L = zip(L[::2], L[1::2]) print L ```
22,206,044
I followed a number of posts on SO, and finally I can draw a conclusion that when we have something like : ``` Person name; ``` `name` is an object of class `person`. It becomes instance when instantiate it : ``` name=new Person(); ``` I am a beginner in C++, and so far I have seen we can access the functions a...
2014/03/05
[ "https://Stackoverflow.com/questions/22206044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1820722/" ]
Object and instance are two words for the same thing.
"Object" and "instance" are almost interchangeable. In C++, an object is formally any region of storage. "Instance" is not a formally defined term, but we typically refer to "instances of type `X`", most commonly used with class types. ``` Foo f; ``` This declaration creates an object named `f`. The object's type is...
22,206,044
I followed a number of posts on SO, and finally I can draw a conclusion that when we have something like : ``` Person name; ``` `name` is an object of class `person`. It becomes instance when instantiate it : ``` name=new Person(); ``` I am a beginner in C++, and so far I have seen we can access the functions a...
2014/03/05
[ "https://Stackoverflow.com/questions/22206044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1820722/" ]
In C++ "object" and "instance" are used nearly interchangably. There is a general programming design pattern of `class` and `instance`. The `class` holds the information about all `instance`s in that `class`. In C++ when you declare a `class` or `struct`, the compiler makes code that describes how you create an `inst...
Object and instance are two words for the same thing.
22,206,044
I followed a number of posts on SO, and finally I can draw a conclusion that when we have something like : ``` Person name; ``` `name` is an object of class `person`. It becomes instance when instantiate it : ``` name=new Person(); ``` I am a beginner in C++, and so far I have seen we can access the functions a...
2014/03/05
[ "https://Stackoverflow.com/questions/22206044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1820722/" ]
Object and instance are two words for the same thing.
It is very simple but very important Take a general example: what is the general meaning of object? its nothing but which occupies some space right....keep that in mind we now talk about Object in java or C++ example: here I am creating Object     **Student std=new Student();** where **Student** is a **Class** and ...
22,206,044
I followed a number of posts on SO, and finally I can draw a conclusion that when we have something like : ``` Person name; ``` `name` is an object of class `person`. It becomes instance when instantiate it : ``` name=new Person(); ``` I am a beginner in C++, and so far I have seen we can access the functions a...
2014/03/05
[ "https://Stackoverflow.com/questions/22206044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1820722/" ]
First, you should know that there is no difference between "object" and "instance". They are synonyms. In C++, you also call instances of primitive types like `int` or `double` "objects". One of the design principles of C++ is that custom types (i.e. classes) can be made to behave exactly like primitive types. In fact,...
"Object" and "instance" are almost interchangeable. In C++, an object is formally any region of storage. "Instance" is not a formally defined term, but we typically refer to "instances of type `X`", most commonly used with class types. ``` Foo f; ``` This declaration creates an object named `f`. The object's type is...
22,206,044
I followed a number of posts on SO, and finally I can draw a conclusion that when we have something like : ``` Person name; ``` `name` is an object of class `person`. It becomes instance when instantiate it : ``` name=new Person(); ``` I am a beginner in C++, and so far I have seen we can access the functions a...
2014/03/05
[ "https://Stackoverflow.com/questions/22206044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1820722/" ]
In C++ "object" and "instance" are used nearly interchangably. There is a general programming design pattern of `class` and `instance`. The `class` holds the information about all `instance`s in that `class`. In C++ when you declare a `class` or `struct`, the compiler makes code that describes how you create an `inst...
"Object" and "instance" are almost interchangeable. In C++, an object is formally any region of storage. "Instance" is not a formally defined term, but we typically refer to "instances of type `X`", most commonly used with class types. ``` Foo f; ``` This declaration creates an object named `f`. The object's type is...
22,206,044
I followed a number of posts on SO, and finally I can draw a conclusion that when we have something like : ``` Person name; ``` `name` is an object of class `person`. It becomes instance when instantiate it : ``` name=new Person(); ``` I am a beginner in C++, and so far I have seen we can access the functions a...
2014/03/05
[ "https://Stackoverflow.com/questions/22206044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1820722/" ]
In C++ "object" and "instance" are used nearly interchangably. There is a general programming design pattern of `class` and `instance`. The `class` holds the information about all `instance`s in that `class`. In C++ when you declare a `class` or `struct`, the compiler makes code that describes how you create an `inst...
First, you should know that there is no difference between "object" and "instance". They are synonyms. In C++, you also call instances of primitive types like `int` or `double` "objects". One of the design principles of C++ is that custom types (i.e. classes) can be made to behave exactly like primitive types. In fact,...
22,206,044
I followed a number of posts on SO, and finally I can draw a conclusion that when we have something like : ``` Person name; ``` `name` is an object of class `person`. It becomes instance when instantiate it : ``` name=new Person(); ``` I am a beginner in C++, and so far I have seen we can access the functions a...
2014/03/05
[ "https://Stackoverflow.com/questions/22206044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1820722/" ]
First, you should know that there is no difference between "object" and "instance". They are synonyms. In C++, you also call instances of primitive types like `int` or `double` "objects". One of the design principles of C++ is that custom types (i.e. classes) can be made to behave exactly like primitive types. In fact,...
It is very simple but very important Take a general example: what is the general meaning of object? its nothing but which occupies some space right....keep that in mind we now talk about Object in java or C++ example: here I am creating Object     **Student std=new Student();** where **Student** is a **Class** and ...
22,206,044
I followed a number of posts on SO, and finally I can draw a conclusion that when we have something like : ``` Person name; ``` `name` is an object of class `person`. It becomes instance when instantiate it : ``` name=new Person(); ``` I am a beginner in C++, and so far I have seen we can access the functions a...
2014/03/05
[ "https://Stackoverflow.com/questions/22206044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1820722/" ]
In C++ "object" and "instance" are used nearly interchangably. There is a general programming design pattern of `class` and `instance`. The `class` holds the information about all `instance`s in that `class`. In C++ when you declare a `class` or `struct`, the compiler makes code that describes how you create an `inst...
It is very simple but very important Take a general example: what is the general meaning of object? its nothing but which occupies some space right....keep that in mind we now talk about Object in java or C++ example: here I am creating Object     **Student std=new Student();** where **Student** is a **Class** and ...
67,405,791
I just updated Android Studio to version 4.2. I was surprised to not see the Gradle tasks in my project. In the previous version, 4.1.3, I could see the tasks as shown here: [![working in version 4.1.3](https://i.stack.imgur.com/7fhMP.png)](https://i.stack.imgur.com/7fhMP.png) But now I only see the dependencies in ...
2021/05/05
[ "https://Stackoverflow.com/questions/67405791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4424400/" ]
Inside your android studio, select File option in toolbar -> then click on Settings option. 1. From settings, select the last option "Experimental" 2. Within there, select **Uncheck the option** that I have shared the screenshot below. 3. Then click Apply.[![enter image description here](https://i.stack.imgur.com/1sj0...
This solution works for me Go to File -> Settings -> Experimental and uncheck Do not build Gradle task list during Gradle sync, then sync the project File -> Sync Project with Gradle Files.
67,405,791
I just updated Android Studio to version 4.2. I was surprised to not see the Gradle tasks in my project. In the previous version, 4.1.3, I could see the tasks as shown here: [![working in version 4.1.3](https://i.stack.imgur.com/7fhMP.png)](https://i.stack.imgur.com/7fhMP.png) But now I only see the dependencies in ...
2021/05/05
[ "https://Stackoverflow.com/questions/67405791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4424400/" ]
**Solution 1:** You can alternatively use the below gradle command to get all the tasks and run those in terminal ``` ./gradlew tasks --all ``` **Solution 2.** You can also create run configuration to run the tasks like below: Step 1: [![enter image description here](https://i.stack.imgur.com/EYUAn.png)](https:/...
This solution works for me Go to File -> Settings -> Experimental and uncheck Do not build Gradle task list during Gradle sync, then sync the project File -> Sync Project with Gradle Files.
67,405,791
I just updated Android Studio to version 4.2. I was surprised to not see the Gradle tasks in my project. In the previous version, 4.1.3, I could see the tasks as shown here: [![working in version 4.1.3](https://i.stack.imgur.com/7fhMP.png)](https://i.stack.imgur.com/7fhMP.png) But now I only see the dependencies in ...
2021/05/05
[ "https://Stackoverflow.com/questions/67405791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4424400/" ]
Go to `File -> Settings -> Experimental` and uncheck `Do not build Gradle task list during Gradle sync`, then sync the project `File -> Sync Project with Gradle Files`. If the problem is still there, just reboot Android Studio. 1.[![Do not build Gradle task list during Gradle sync](https://i.stack.imgur.com/TYDcw.png)...
I had a similar issue and I solved it by executing the following terminal command in my Android Studio Terminal: ``` ./gradlew tasks --all ```
67,405,791
I just updated Android Studio to version 4.2. I was surprised to not see the Gradle tasks in my project. In the previous version, 4.1.3, I could see the tasks as shown here: [![working in version 4.1.3](https://i.stack.imgur.com/7fhMP.png)](https://i.stack.imgur.com/7fhMP.png) But now I only see the dependencies in ...
2021/05/05
[ "https://Stackoverflow.com/questions/67405791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4424400/" ]
OK, I found why I got this behaviour in android studio 4.2. It is intended behaviour. I found the answer in this post: <https://issuetracker.google.com/issues/185420705>. > > Gradle task list is large and slow to populate in Android projects. > This feature by default is disabled for performance reasons. You can > r...
This solution works for me Go to File -> Settings -> Experimental and uncheck Do not build Gradle task list during Gradle sync, then sync the project File -> Sync Project with Gradle Files.
67,405,791
I just updated Android Studio to version 4.2. I was surprised to not see the Gradle tasks in my project. In the previous version, 4.1.3, I could see the tasks as shown here: [![working in version 4.1.3](https://i.stack.imgur.com/7fhMP.png)](https://i.stack.imgur.com/7fhMP.png) But now I only see the dependencies in ...
2021/05/05
[ "https://Stackoverflow.com/questions/67405791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4424400/" ]
OK, I found why I got this behaviour in android studio 4.2. It is intended behaviour. I found the answer in this post: <https://issuetracker.google.com/issues/185420705>. > > Gradle task list is large and slow to populate in Android projects. > This feature by default is disabled for performance reasons. You can > r...
Go to `File -> Settings -> Experimental` and uncheck `Do not build Gradle task list during Gradle sync`, then sync the project `File -> Sync Project with Gradle Files`. If the problem is still there, just reboot Android Studio. 1.[![Do not build Gradle task list during Gradle sync](https://i.stack.imgur.com/TYDcw.png)...
67,405,791
I just updated Android Studio to version 4.2. I was surprised to not see the Gradle tasks in my project. In the previous version, 4.1.3, I could see the tasks as shown here: [![working in version 4.1.3](https://i.stack.imgur.com/7fhMP.png)](https://i.stack.imgur.com/7fhMP.png) But now I only see the dependencies in ...
2021/05/05
[ "https://Stackoverflow.com/questions/67405791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4424400/" ]
Go to `File -> Settings -> Experimental` and uncheck `Do not build Gradle task list during Gradle sync`, then sync the project `File -> Sync Project with Gradle Files`. If the problem is still there, just reboot Android Studio. 1.[![Do not build Gradle task list during Gradle sync](https://i.stack.imgur.com/TYDcw.png)...
This solution works for me Go to File -> Settings -> Experimental and uncheck Do not build Gradle task list during Gradle sync, then sync the project File -> Sync Project with Gradle Files.
67,405,791
I just updated Android Studio to version 4.2. I was surprised to not see the Gradle tasks in my project. In the previous version, 4.1.3, I could see the tasks as shown here: [![working in version 4.1.3](https://i.stack.imgur.com/7fhMP.png)](https://i.stack.imgur.com/7fhMP.png) But now I only see the dependencies in ...
2021/05/05
[ "https://Stackoverflow.com/questions/67405791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4424400/" ]
**Solution 1:** You can alternatively use the below gradle command to get all the tasks and run those in terminal ``` ./gradlew tasks --all ``` **Solution 2.** You can also create run configuration to run the tasks like below: Step 1: [![enter image description here](https://i.stack.imgur.com/EYUAn.png)](https:/...
I had a similar issue and I solved it by executing the following terminal command in my Android Studio Terminal: ``` ./gradlew tasks --all ```