qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
14,137,868 | I installed `ZFCUser` successfully. Now I wonder if there is a way to **globally** check for authentication.
As outlined [in the wiki](https://github.com/ZF-Commons/ZfcUser/wiki/How-to-check-if-the-user-is-logged-in) there are several ways to check for auth. They all work but do I have to put the check-if-clause reall... | 2013/01/03 | [
"https://Stackoverflow.com/questions/14137868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1331671/"
] | To be honest, I don't think it is a good idea to block **every** page for a non-authenticated user. How would you access the login page?
That said, you must know the page being accessed, to make a whitelist of pages accessible for anonymous visitors. To start, I'd suggest to include the login page. You can check pages... | Another option might be to create your own abstract controller superclass and implement the onDispatch() method like this:
```
public function onDispatch(MvcEvent $e)
{
// check authentication here
return parent::onDispatch($e);
}
```
You can implement a whitelist there too :). |
14,137,868 | I installed `ZFCUser` successfully. Now I wonder if there is a way to **globally** check for authentication.
As outlined [in the wiki](https://github.com/ZF-Commons/ZfcUser/wiki/How-to-check-if-the-user-is-logged-in) there are several ways to check for auth. They all work but do I have to put the check-if-clause reall... | 2013/01/03 | [
"https://Stackoverflow.com/questions/14137868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1331671/"
] | To be honest, I don't think it is a good idea to block **every** page for a non-authenticated user. How would you access the login page?
That said, you must know the page being accessed, to make a whitelist of pages accessible for anonymous visitors. To start, I'd suggest to include the login page. You can check pages... | On ZF 2.4.2 I do this in Module.php
```
class module {
protected $whitelist = array(
'Application\Controller\Login'
);
public function onBootstrap(MvcEvent $e)
{
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->at... |
14,137,868 | I installed `ZFCUser` successfully. Now I wonder if there is a way to **globally** check for authentication.
As outlined [in the wiki](https://github.com/ZF-Commons/ZfcUser/wiki/How-to-check-if-the-user-is-logged-in) there are several ways to check for auth. They all work but do I have to put the check-if-clause reall... | 2013/01/03 | [
"https://Stackoverflow.com/questions/14137868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1331671/"
] | To be honest, I don't think it is a good idea to block **every** page for a non-authenticated user. How would you access the login page?
That said, you must know the page being accessed, to make a whitelist of pages accessible for anonymous visitors. To start, I'd suggest to include the login page. You can check pages... | You can use ZF2 module [BjyAuthorize](https://github.com/bjyoungblood/BjyAuthorize) to block/allow access to pages based on user roles such as `guest`, `user` etc using `controller guard`, `route guard` etc |
14,137,868 | I installed `ZFCUser` successfully. Now I wonder if there is a way to **globally** check for authentication.
As outlined [in the wiki](https://github.com/ZF-Commons/ZfcUser/wiki/How-to-check-if-the-user-is-logged-in) there are several ways to check for auth. They all work but do I have to put the check-if-clause reall... | 2013/01/03 | [
"https://Stackoverflow.com/questions/14137868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1331671/"
] | To be honest, I don't think it is a good idea to block **every** page for a non-authenticated user. How would you access the login page?
That said, you must know the page being accessed, to make a whitelist of pages accessible for anonymous visitors. To start, I'd suggest to include the login page. You can check pages... | People,
Tip, dont forget the add the "use" to correct RouteMatch statement:
```
use Zend\Mvc\Router\Http\RouteMatch;
```
Here need this:
```
if (!$match instanceof RouteMatch)...
```
If you forget, the if above have inconstant |
14,137,868 | I installed `ZFCUser` successfully. Now I wonder if there is a way to **globally** check for authentication.
As outlined [in the wiki](https://github.com/ZF-Commons/ZfcUser/wiki/How-to-check-if-the-user-is-logged-in) there are several ways to check for auth. They all work but do I have to put the check-if-clause reall... | 2013/01/03 | [
"https://Stackoverflow.com/questions/14137868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1331671/"
] | On ZF 2.4.2 I do this in Module.php
```
class module {
protected $whitelist = array(
'Application\Controller\Login'
);
public function onBootstrap(MvcEvent $e)
{
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->at... | Another option might be to create your own abstract controller superclass and implement the onDispatch() method like this:
```
public function onDispatch(MvcEvent $e)
{
// check authentication here
return parent::onDispatch($e);
}
```
You can implement a whitelist there too :). |
14,137,868 | I installed `ZFCUser` successfully. Now I wonder if there is a way to **globally** check for authentication.
As outlined [in the wiki](https://github.com/ZF-Commons/ZfcUser/wiki/How-to-check-if-the-user-is-logged-in) there are several ways to check for auth. They all work but do I have to put the check-if-clause reall... | 2013/01/03 | [
"https://Stackoverflow.com/questions/14137868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1331671/"
] | You can use ZF2 module [BjyAuthorize](https://github.com/bjyoungblood/BjyAuthorize) to block/allow access to pages based on user roles such as `guest`, `user` etc using `controller guard`, `route guard` etc | Another option might be to create your own abstract controller superclass and implement the onDispatch() method like this:
```
public function onDispatch(MvcEvent $e)
{
// check authentication here
return parent::onDispatch($e);
}
```
You can implement a whitelist there too :). |
14,137,868 | I installed `ZFCUser` successfully. Now I wonder if there is a way to **globally** check for authentication.
As outlined [in the wiki](https://github.com/ZF-Commons/ZfcUser/wiki/How-to-check-if-the-user-is-logged-in) there are several ways to check for auth. They all work but do I have to put the check-if-clause reall... | 2013/01/03 | [
"https://Stackoverflow.com/questions/14137868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1331671/"
] | People,
Tip, dont forget the add the "use" to correct RouteMatch statement:
```
use Zend\Mvc\Router\Http\RouteMatch;
```
Here need this:
```
if (!$match instanceof RouteMatch)...
```
If you forget, the if above have inconstant | Another option might be to create your own abstract controller superclass and implement the onDispatch() method like this:
```
public function onDispatch(MvcEvent $e)
{
// check authentication here
return parent::onDispatch($e);
}
```
You can implement a whitelist there too :). |
3,377,571 | I have this script file in python running on S60:
```
import location
def current_location():
gsm_loc = location.gsm_location()
print gsm_loc
current_location()
```
instead of printing a tuple of mcc, mnc, lac and cellId it prints None.
on top of my python shell I see location between the capabilities included.... | 2010/07/31 | [
"https://Stackoverflow.com/questions/3377571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/324922/"
] | I think I can answer now one part of the problem:
the reason for printing None is because there needed another capability: ReadDeviceData which wasn't included in the capabilities list on top of python shell.
still, remaining the other part of the problem, why this capability wasn't included when I signed PythonScrip... | I have same issue with all necessary scriptshell capabilities: 'PowerMgmnt', '**ReadDeviceData**', 'WriteDeviceData', 'TrustedUI', 'ProtServ', 'SwEvent', 'Network services', 'LocalServices', 'ReadUserData', 'WriteUserData', '**Location**', 'SurroundingsDD', 'UserEnviroment'.
Let's take a look at source code from `Pyth... |
15,711,172 | I'll try to explain my situation as clear as I can.
I'm building a framework. Its system contains following directories:
1) Core - routing, main class (autoloading, configs, constants), requests
2) Helpers
3) Libraries
In index.php, I set all most important configuration variables such as the base url, or in... | 2013/03/29 | [
"https://Stackoverflow.com/questions/15711172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2203484/"
] | If you replace `binding="#{abc}"` by `binding="#{myBean.uiAbc}"`, then you should obviously also change `#{abc.clientId}` elsewhere in the view by `#{myBean.uiAbc.clientId}`.
```
function doSomething(){
$("##{myBean.uiAbc.clientId}").val("hello everyone");
}
```
That the `id` and `binding` need have to be the sa... | Your myth for following is wrong, i.e. to have same id and binding attribute.
```
id="abc" binding="#{abc}"
```
JSF renders component with id which provided by us with preceding by form id. e.g. in your case it will be,
```
:formId:abc
```
to avoid prepending form id just set prependId attribute to false. it wi... |
61,545,680 | SQLAlchemy doc [explain](https://docs.sqlalchemy.org/en/13/dialects/postgresql.html?highlight=partition) how to create a partitioned table. But it does not explains how to create partitions.
So if I have this :
```
#Skipping create_engine and metadata
Base = declarative_base()
class Measure(Base):
__tablename__ ... | 2020/05/01 | [
"https://Stackoverflow.com/questions/61545680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8204956/"
] | You can use a [`MeasureMixin`](https://docs.sqlalchemy.org/en/13/orm/extensions/declarative/mixins.html#mixing-in-columns) that both classes can inherit from.
And then use an [`event`](https://docs.sqlalchemy.org/en/13/core/events.html#sqlalchemy.events.DDLEvents) to attach the table partition.
```
from sqlalchemy imp... | I had a similar problem. I found @moshevi's answer quite useful, and ended up generalising it a bit (as I had many tables to partition).
First, create a metaclass such as this:
```py
from sqlalchemy.ext.declarative import DeclarativeMeta
from sqlalchemy.sql.ddl import DDL
from sqlalchemy import event
class Partition... |
61,545,680 | SQLAlchemy doc [explain](https://docs.sqlalchemy.org/en/13/dialects/postgresql.html?highlight=partition) how to create a partitioned table. But it does not explains how to create partitions.
So if I have this :
```
#Skipping create_engine and metadata
Base = declarative_base()
class Measure(Base):
__tablename__ ... | 2020/05/01 | [
"https://Stackoverflow.com/questions/61545680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8204956/"
] | You can use a [`MeasureMixin`](https://docs.sqlalchemy.org/en/13/orm/extensions/declarative/mixins.html#mixing-in-columns) that both classes can inherit from.
And then use an [`event`](https://docs.sqlalchemy.org/en/13/core/events.html#sqlalchemy.events.DDLEvents) to attach the table partition.
```
from sqlalchemy imp... | For database partitioning (PostgreSQL or MySQL), you can try using the **architect** package. It works with a range of ORM libraties, including SQLAlchemy. Here is an example of PostgreSQL - <https://architect.readthedocs.io/features/partition/postgresql.html>. Several partitioning types are supported, so hopefully it ... |
61,545,680 | SQLAlchemy doc [explain](https://docs.sqlalchemy.org/en/13/dialects/postgresql.html?highlight=partition) how to create a partitioned table. But it does not explains how to create partitions.
So if I have this :
```
#Skipping create_engine and metadata
Base = declarative_base()
class Measure(Base):
__tablename__ ... | 2020/05/01 | [
"https://Stackoverflow.com/questions/61545680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8204956/"
] | You can use a [`MeasureMixin`](https://docs.sqlalchemy.org/en/13/orm/extensions/declarative/mixins.html#mixing-in-columns) that both classes can inherit from.
And then use an [`event`](https://docs.sqlalchemy.org/en/13/core/events.html#sqlalchemy.events.DDLEvents) to attach the table partition.
```
from sqlalchemy imp... | Maybe a bit late, but I would like to share what I built upon @moshevi 's and @Seb 's answers:
In my IoT use-case, I required actual **sub**-partitioning (first level `year`, second level `nodeid`). Also I wanted to generalize it slightly.
This is what I came up with:
```
from sqlalchemy.ext.declarative import Decla... |
61,545,680 | SQLAlchemy doc [explain](https://docs.sqlalchemy.org/en/13/dialects/postgresql.html?highlight=partition) how to create a partitioned table. But it does not explains how to create partitions.
So if I have this :
```
#Skipping create_engine and metadata
Base = declarative_base()
class Measure(Base):
__tablename__ ... | 2020/05/01 | [
"https://Stackoverflow.com/questions/61545680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8204956/"
] | I had a similar problem. I found @moshevi's answer quite useful, and ended up generalising it a bit (as I had many tables to partition).
First, create a metaclass such as this:
```py
from sqlalchemy.ext.declarative import DeclarativeMeta
from sqlalchemy.sql.ddl import DDL
from sqlalchemy import event
class Partition... | For database partitioning (PostgreSQL or MySQL), you can try using the **architect** package. It works with a range of ORM libraties, including SQLAlchemy. Here is an example of PostgreSQL - <https://architect.readthedocs.io/features/partition/postgresql.html>. Several partitioning types are supported, so hopefully it ... |
61,545,680 | SQLAlchemy doc [explain](https://docs.sqlalchemy.org/en/13/dialects/postgresql.html?highlight=partition) how to create a partitioned table. But it does not explains how to create partitions.
So if I have this :
```
#Skipping create_engine and metadata
Base = declarative_base()
class Measure(Base):
__tablename__ ... | 2020/05/01 | [
"https://Stackoverflow.com/questions/61545680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8204956/"
] | Maybe a bit late, but I would like to share what I built upon @moshevi 's and @Seb 's answers:
In my IoT use-case, I required actual **sub**-partitioning (first level `year`, second level `nodeid`). Also I wanted to generalize it slightly.
This is what I came up with:
```
from sqlalchemy.ext.declarative import Decla... | For database partitioning (PostgreSQL or MySQL), you can try using the **architect** package. It works with a range of ORM libraties, including SQLAlchemy. Here is an example of PostgreSQL - <https://architect.readthedocs.io/features/partition/postgresql.html>. Several partitioning types are supported, so hopefully it ... |
51,924,228 | Unity Rigidbody physics are good for basic gravity physics but when it comes to more realistic ball like physics then it doesn't do the trick. I want marble like physics with physics qualities like accelerating downhill, flying off ramps, getting bit by a spinning object or bouncing off walls.
I'm not specifically loo... | 2018/08/20 | [
"https://Stackoverflow.com/questions/51924228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10173592/"
] | What you want here are physics materials.
Set a bounce factor close to 1, and a dynamic friction and static friction factor close to 0. Mess with it a bit until you get the right behavior.
Set the bounce factor combiner to maximum, and the friction factor to minimum to ignore the surface factor, but you can also set ... | Have you tried looking at this demo?
[Unity Roll-A-Ball demo](https://unity3d.com/learn/tutorials/s/roll-ball-tutorial)
I found this was a useful place to start. I know you've tried some physics materials, have you also tried to write your own physics? |
56,684,753 | I need to fetch data from the table and send bulk sms to the customers,to send the sms , the contact number is stored in a variable,i use for each and get the numbers,i manually enter the id and fetching the data , now i need to collect all the datas by giving where 'id'!='o',in query so i will get all the numbers.
N... | 2019/06/20 | [
"https://Stackoverflow.com/questions/56684753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11493771/"
] | This is a general problem with mutable objects. Whatever caching system you use, the goal of a cache is to give again previous value (without computing it) when given the same parameters.
Here you actually pass the exact same object (true identity given by `is` in Python), so no caching system could guess that its cac... | Your example pretty much defeates the purpose of `lru_cache`.. Anyway, the only way I can think of is to add `print_number.cache_clear()` before your second assertion:
```py
assert print_number(obj) == 1
obj.number = 2
print_number.cache_clear()
assert print_number(obj) == 2
``` |
76,255 | DNA is how a species stores genetic information. Somehow the body needs to know what to do with this information. somehow the "machinery" that translates the DNA into proteins needs to be passed along with it.
Could this machinery also be encoded within the DNA? Or does it come automatically from some physical/chemica... | 2018/07/24 | [
"https://biology.stackexchange.com/questions/76255",
"https://biology.stackexchange.com",
"https://biology.stackexchange.com/users/45052/"
] | Your question is very general, but it has a simple answer.
**Yes.** The protein machinery which interacts, reads, structures and manipulates the DNA strands is coded for in the DNA.
By way of example: one enzyme which opens the double helix is called *DNA Helicase B*. Once a DNA strand is accessible, another enzyme '... | The machinery that manipulates and read the DNA (e.g. [helicase](https://en.wikipedia.org/wiki/Helicase), [rRNA](https://en.wikipedia.org/wiki/Ribosomal_RNA) and [RNA polymerase](https://en.wikipedia.org/wiki/RNA_polymerase)) is itself coded in the DNA.
Now, of course, if you put an individual DNA in a bowl of water, ... |
76,255 | DNA is how a species stores genetic information. Somehow the body needs to know what to do with this information. somehow the "machinery" that translates the DNA into proteins needs to be passed along with it.
Could this machinery also be encoded within the DNA? Or does it come automatically from some physical/chemica... | 2018/07/24 | [
"https://biology.stackexchange.com/questions/76255",
"https://biology.stackexchange.com",
"https://biology.stackexchange.com/users/45052/"
] | Your question is very general, but it has a simple answer.
**Yes.** The protein machinery which interacts, reads, structures and manipulates the DNA strands is coded for in the DNA.
By way of example: one enzyme which opens the double helix is called *DNA Helicase B*. Once a DNA strand is accessible, another enzyme '... | >
> Somehow the body needs to know what to do with this information.
>
>
>
No. That's not how it works. Chemicals interact with other chemicals according to their shape. Chemicals do not "know" anything.
>
> somehow the "machinery" that translates the DNA into proteins needs to
> be passed along with it.
>
>
... |
44,955,323 | Can someone tell me why the $\_SESSION array is not getting modified by the code below. The object is to put the date in DoNotShipBefore of each record. It is obviously putting the value somewhere as the output of $Row['DoNotShipBefore'] shows the correct date. But, when the loop is done, it doesn't appear to have take... | 2017/07/06 | [
"https://Stackoverflow.com/questions/44955323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1191567/"
] | What is `cart_array`? Maybe you should use `$_SESSION['cart_array']`? Any PHP notice? | There is nothing in your code that is actually assigning any values in the session array.
```
$_SESSION['some_var'] = "Some Value";
```
But you're not doing that so the session you have remains untouched. |
44,955,323 | Can someone tell me why the $\_SESSION array is not getting modified by the code below. The object is to put the date in DoNotShipBefore of each record. It is obviously putting the value somewhere as the output of $Row['DoNotShipBefore'] shows the correct date. But, when the loop is done, it doesn't appear to have take... | 2017/07/06 | [
"https://Stackoverflow.com/questions/44955323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1191567/"
] | Except when the value is an object, when you assign a variable it makes a copy of the value (internally it uses copy-on-write for efficiency). So `$Row` is a copy of the row in `$_SESSION`. You're modifying that copy, not the original array.
You can use a reference variable to make it refer to the original array, by p... | What is `cart_array`? Maybe you should use `$_SESSION['cart_array']`? Any PHP notice? |
44,955,323 | Can someone tell me why the $\_SESSION array is not getting modified by the code below. The object is to put the date in DoNotShipBefore of each record. It is obviously putting the value somewhere as the output of $Row['DoNotShipBefore'] shows the correct date. But, when the loop is done, it doesn't appear to have take... | 2017/07/06 | [
"https://Stackoverflow.com/questions/44955323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1191567/"
] | Except when the value is an object, when you assign a variable it makes a copy of the value (internally it uses copy-on-write for efficiency). So `$Row` is a copy of the row in `$_SESSION`. You're modifying that copy, not the original array.
You can use a reference variable to make it refer to the original array, by p... | There is nothing in your code that is actually assigning any values in the session array.
```
$_SESSION['some_var'] = "Some Value";
```
But you're not doing that so the session you have remains untouched. |
62,043,569 | In SwiftUI I've created a struct that should create different overlay views depending on some state variables. If any of the state booleans is true, then it should return custom view (either `ErrorOverlay` or `LoadingOverlay` or else an `EmptyView`) like this:
```
struct OverlayContainer: View {
@State var isLoadi... | 2020/05/27 | [
"https://Stackoverflow.com/questions/62043569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2660216/"
] | It should be used Binding instead. Here is possible solution.
```
struct OverlayContainer: View {
@Binding var isLoading: Bool
@Binding var isErrorShown: Bool
var body: some View {
Group {
if(isErrorShown) {
ErrorOverlay()
}
else if(isLoading) {
... | To make it the way you want, use Binding:
```
struct OverlayContainer: View {
@Binding var isLoading: Bool
@Binding var isErrorShown: Bool
func setIsLoading(isLoading: Bool) {
self.isLoading = isLoading
self.isErrorShown = !isLoading
}
func setIsErrorShown(isErrorShown: Bool) {
... |
14,573,824 | I have large matrix (image) and a small template. I would like to convolve the small matrix with the larger matrix. For example, the blue region is the section that I want to be used for convolution. In other words, I can use the convolution for all of the image, but since the CPU time is increased, therefore, I would ... | 2013/01/29 | [
"https://Stackoverflow.com/questions/14573824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1075927/"
] | Hmm.. it seems the better way of doing it is to use some kind of DBMS. Load all your data into database, and you can leverage its indexing, storage and querying facility. Ofcourse this depends on what is your requirement -- and whether or now a DBMS solution suits this | Given that your available memory is > than your dataset and you want very high performance, have you considered Redis? It's well suited to operations on simple data structures and the performance is very fast.
Just be a bit careful about letting java do default serialization when storing values. I've previously run in... |
14,573,824 | I have large matrix (image) and a small template. I would like to convolve the small matrix with the larger matrix. For example, the blue region is the section that I want to be used for convolution. In other words, I can use the convolution for all of the image, but since the CPU time is increased, therefore, I would ... | 2013/01/29 | [
"https://Stackoverflow.com/questions/14573824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1075927/"
] | So, what I would do is just load up each file and store the id into some sort of sorted structure - std::map perhaps [or Java's equivalent, but given that it's probably about 10-20 lines of code to read in the filename and then read the contents of the file into a map, close the file and ask for the next file, I'd prob... | Hmm.. it seems the better way of doing it is to use some kind of DBMS. Load all your data into database, and you can leverage its indexing, storage and querying facility. Ofcourse this depends on what is your requirement -- and whether or now a DBMS solution suits this |
14,573,824 | I have large matrix (image) and a small template. I would like to convolve the small matrix with the larger matrix. For example, the blue region is the section that I want to be used for convolution. In other words, I can use the convolution for all of the image, but since the CPU time is increased, therefore, I would ... | 2013/01/29 | [
"https://Stackoverflow.com/questions/14573824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1075927/"
] | You've made a very poor choice of file format. I would convert the lot from serialized Integers to binary ints written with DataOutputStream.writeInt(), and read them with DataInputStream.readInt(). With buffered streams underneath in both cases. You will save masses of disk space, which will therefore save you I/O tim... | Hmm.. it seems the better way of doing it is to use some kind of DBMS. Load all your data into database, and you can leverage its indexing, storage and querying facility. Ofcourse this depends on what is your requirement -- and whether or now a DBMS solution suits this |
14,573,824 | I have large matrix (image) and a small template. I would like to convolve the small matrix with the larger matrix. For example, the blue region is the section that I want to be used for convolution. In other words, I can use the convolution for all of the image, but since the CPU time is increased, therefore, I would ... | 2013/01/29 | [
"https://Stackoverflow.com/questions/14573824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1075927/"
] | So, what I would do is just load up each file and store the id into some sort of sorted structure - std::map perhaps [or Java's equivalent, but given that it's probably about 10-20 lines of code to read in the filename and then read the contents of the file into a map, close the file and ask for the next file, I'd prob... | Given that your available memory is > than your dataset and you want very high performance, have you considered Redis? It's well suited to operations on simple data structures and the performance is very fast.
Just be a bit careful about letting java do default serialization when storing values. I've previously run in... |
14,573,824 | I have large matrix (image) and a small template. I would like to convolve the small matrix with the larger matrix. For example, the blue region is the section that I want to be used for convolution. In other words, I can use the convolution for all of the image, but since the CPU time is increased, therefore, I would ... | 2013/01/29 | [
"https://Stackoverflow.com/questions/14573824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1075927/"
] | You've made a very poor choice of file format. I would convert the lot from serialized Integers to binary ints written with DataOutputStream.writeInt(), and read them with DataInputStream.readInt(). With buffered streams underneath in both cases. You will save masses of disk space, which will therefore save you I/O tim... | Given that your available memory is > than your dataset and you want very high performance, have you considered Redis? It's well suited to operations on simple data structures and the performance is very fast.
Just be a bit careful about letting java do default serialization when storing values. I've previously run in... |
38,859,527 | Here is an example:
```
int i = 0;
while (i < 11) {
System.out.println(i);
list.add(i);
i++;
}
```
Output should be:
```
0
1
2
3
4
5
6
7
8
9
10
```
The arraylist should have the same values for each index but what if I don't want the 10?
Is it possible "undo" the last execution of the while loop cons... | 2016/08/09 | [
"https://Stackoverflow.com/questions/38859527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6259150/"
] | There are many ways to prevent the execution of 10 with different meanings...
You will have to chnage the code in each case:
Sample 1:
```
int i = 0;
while (i < 11) {
if (i == 10) {
continue; //Skip this iteration
}
System.out.println(i);
list.add(i);
i++;
}
```
Sample 2:
```
int i =... | Sorry, but it is not possible to "undo" an execution of a piece of code, no matter the language you use.
But, you can easily achieve what you want to do. If you just want to not add the last number in your array, just add an if condition. This is the best idea I have for now.
```
int i = 0;
int nb = 11
while (i < nb)... |
38,859,527 | Here is an example:
```
int i = 0;
while (i < 11) {
System.out.println(i);
list.add(i);
i++;
}
```
Output should be:
```
0
1
2
3
4
5
6
7
8
9
10
```
The arraylist should have the same values for each index but what if I don't want the 10?
Is it possible "undo" the last execution of the while loop cons... | 2016/08/09 | [
"https://Stackoverflow.com/questions/38859527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6259150/"
] | There are many ways to prevent the execution of 10 with different meanings...
You will have to chnage the code in each case:
Sample 1:
```
int i = 0;
while (i < 11) {
if (i == 10) {
continue; //Skip this iteration
}
System.out.println(i);
list.add(i);
i++;
}
```
Sample 2:
```
int i =... | You can define for every action how to undo it.
`list.add(i)` can be undone with `list.remove(list.size() - 1)`
Other actions, such as sending mails, are harder to undo, but you could delay the actual sending of the mail to give the user a chance to cancel it...
In some sense, this is quite similar do `ctrl-z` beca... |
38,859,527 | Here is an example:
```
int i = 0;
while (i < 11) {
System.out.println(i);
list.add(i);
i++;
}
```
Output should be:
```
0
1
2
3
4
5
6
7
8
9
10
```
The arraylist should have the same values for each index but what if I don't want the 10?
Is it possible "undo" the last execution of the while loop cons... | 2016/08/09 | [
"https://Stackoverflow.com/questions/38859527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6259150/"
] | You'll always know the last index of the array (`arrayList.size() - 1`). But simply deleting the last item in an array isn't an "undo" but rather a postoperative modification.
There's not an "undo last iteration"-type feature. | Sorry, but it is not possible to "undo" an execution of a piece of code, no matter the language you use.
But, you can easily achieve what you want to do. If you just want to not add the last number in your array, just add an if condition. This is the best idea I have for now.
```
int i = 0;
int nb = 11
while (i < nb)... |
38,859,527 | Here is an example:
```
int i = 0;
while (i < 11) {
System.out.println(i);
list.add(i);
i++;
}
```
Output should be:
```
0
1
2
3
4
5
6
7
8
9
10
```
The arraylist should have the same values for each index but what if I don't want the 10?
Is it possible "undo" the last execution of the while loop cons... | 2016/08/09 | [
"https://Stackoverflow.com/questions/38859527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6259150/"
] | You'll always know the last index of the array (`arrayList.size() - 1`). But simply deleting the last item in an array isn't an "undo" but rather a postoperative modification.
There's not an "undo last iteration"-type feature. | You can define for every action how to undo it.
`list.add(i)` can be undone with `list.remove(list.size() - 1)`
Other actions, such as sending mails, are harder to undo, but you could delay the actual sending of the mail to give the user a chance to cancel it...
In some sense, this is quite similar do `ctrl-z` beca... |
38,859,527 | Here is an example:
```
int i = 0;
while (i < 11) {
System.out.println(i);
list.add(i);
i++;
}
```
Output should be:
```
0
1
2
3
4
5
6
7
8
9
10
```
The arraylist should have the same values for each index but what if I don't want the 10?
Is it possible "undo" the last execution of the while loop cons... | 2016/08/09 | [
"https://Stackoverflow.com/questions/38859527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6259150/"
] | Sorry, but it is not possible to "undo" an execution of a piece of code, no matter the language you use.
But, you can easily achieve what you want to do. If you just want to not add the last number in your array, just add an if condition. This is the best idea I have for now.
```
int i = 0;
int nb = 11
while (i < nb)... | You can define for every action how to undo it.
`list.add(i)` can be undone with `list.remove(list.size() - 1)`
Other actions, such as sending mails, are harder to undo, but you could delay the actual sending of the mail to give the user a chance to cancel it...
In some sense, this is quite similar do `ctrl-z` beca... |
2,363,925 | I was just wondering, if I had an equation like:
$$33 = \left\{a^3 + b^3 + c^3 \mid (a, b, c) \in \mathbb{Z}\right\}$$
What are the values of $(a, b \land c)$. Is there a way of proving or disproving that such integers of $a$, $b$, and $c$ exist to satisfy this equation? Recently the equation:
$$74 = a^3 + b^3 + c^3... | 2017/07/19 | [
"https://math.stackexchange.com/questions/2363925",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/464564/"
] | Note in your case, the max value of $a,b,c$ is achieved when both others are zero, and hence is $33^{1/3} \approx 3.2$, so since they must be integers, you have $a,b,c \in \{0,1,2,3\}$.
Now it is easy to find all combinations of these in 4 variables. Without loss of generality, assume $a \ge b \ge c$, and you get the ... | The set of possible values is tiny, as $4^3>33$ and $2\cdot 3^3>33$. Assuming $a\le b\le c$, you only have to try with
$$\color{green}{1,1,1}\\1,1,2\\\color{green}{1,1,3}\\\color{green}{1,2,2}\\1,2,3\\2,2,2\\\color{green}{2,2,3}.$$
Note that preliminary computation of the parity (odd) further speeds-up the screening. |
72,382,468 | In Google Sheets, I have time stamps with formats like the following:
```
5/25/2022 14:13:05
5/25/2022 13:21:07 EDT
5/25/2022 17:07:39 GMT+01:00
```
I am looking for a regex that will remove everything after the time, so the desired output would be:
```
5/25/2022 14:13:05
5/25/2022 13:21:07
5/25/2022 17:07:39
```
... | 2022/05/25 | [
"https://Stackoverflow.com/questions/72382468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9205480/"
] | With your shown samples, please try following `awk` code.
```
awk '
BEGIN { FS=OFS="\t" }
FNR==1{
print
next
}
{
sum=0
num=split($2,arr,"[:,]")
for(i=2;i<=num;i+=2){
sum+=arr[i]
}
print $1,sum
}
' Input_file
```
Output will be as follows with your shown samples:
```
id string
a1a 82
b2b 104
```
... | You may use this `awk`:
```bash
awk '
BEGIN{FS=OFS="\t"}
NR == 1 {
print
next
}
n = split($2, a, /,/) {
s = 0
for (i=1; i<=n; ++i) {
sub(/[^:]*:/, "", a[i])
s += a[i]+0
}
print $1, s
}' file
id string
a1a 82
b2b 104
``` |
72,382,468 | In Google Sheets, I have time stamps with formats like the following:
```
5/25/2022 14:13:05
5/25/2022 13:21:07 EDT
5/25/2022 17:07:39 GMT+01:00
```
I am looking for a regex that will remove everything after the time, so the desired output would be:
```
5/25/2022 14:13:05
5/25/2022 13:21:07
5/25/2022 17:07:39
```
... | 2022/05/25 | [
"https://Stackoverflow.com/questions/72382468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9205480/"
] | ```
$ awk '
BEGIN { FS=OFS="\t" }
NR>1 {
n = split($2,a,/[:,]/)
sum = 0
for ( i=2; i<=n; i+=2 ) {
sum += a[i]
}
$2 = sum
}
{ print }
' file
id string
a1a 82
b2b 104
``` | You may use this `awk`:
```bash
awk '
BEGIN{FS=OFS="\t"}
NR == 1 {
print
next
}
n = split($2, a, /,/) {
s = 0
for (i=1; i<=n; ++i) {
sub(/[^:]*:/, "", a[i])
s += a[i]+0
}
print $1, s
}' file
id string
a1a 82
b2b 104
``` |
72,382,468 | In Google Sheets, I have time stamps with formats like the following:
```
5/25/2022 14:13:05
5/25/2022 13:21:07 EDT
5/25/2022 17:07:39 GMT+01:00
```
I am looking for a regex that will remove everything after the time, so the desired output would be:
```
5/25/2022 14:13:05
5/25/2022 13:21:07
5/25/2022 17:07:39
```
... | 2022/05/25 | [
"https://Stackoverflow.com/questions/72382468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9205480/"
] | With your shown samples, please try following `awk` code.
```
awk '
BEGIN { FS=OFS="\t" }
FNR==1{
print
next
}
{
sum=0
num=split($2,arr,"[:,]")
for(i=2;i<=num;i+=2){
sum+=arr[i]
}
print $1,sum
}
' Input_file
```
Output will be as follows with your shown samples:
```
id string
a1a 82
b2b 104
```
... | ```
$ awk '
BEGIN { FS=OFS="\t" }
NR>1 {
n = split($2,a,/[:,]/)
sum = 0
for ( i=2; i<=n; i+=2 ) {
sum += a[i]
}
$2 = sum
}
{ print }
' file
id string
a1a 82
b2b 104
``` |
72,382,468 | In Google Sheets, I have time stamps with formats like the following:
```
5/25/2022 14:13:05
5/25/2022 13:21:07 EDT
5/25/2022 17:07:39 GMT+01:00
```
I am looking for a regex that will remove everything after the time, so the desired output would be:
```
5/25/2022 14:13:05
5/25/2022 13:21:07
5/25/2022 17:07:39
```
... | 2022/05/25 | [
"https://Stackoverflow.com/questions/72382468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9205480/"
] | With your shown samples, please try following `awk` code.
```
awk '
BEGIN { FS=OFS="\t" }
FNR==1{
print
next
}
{
sum=0
num=split($2,arr,"[:,]")
for(i=2;i<=num;i+=2){
sum+=arr[i]
}
print $1,sum
}
' Input_file
```
Output will be as follows with your shown samples:
```
id string
a1a 82
b2b 104
```
... | ```
awk -F'[ :,]' 'NR==1{print}NF==7{print$1,$3+$5+$7}' input_file|column -t
id string
a1a 82
b2b 104
``` |
72,382,468 | In Google Sheets, I have time stamps with formats like the following:
```
5/25/2022 14:13:05
5/25/2022 13:21:07 EDT
5/25/2022 17:07:39 GMT+01:00
```
I am looking for a regex that will remove everything after the time, so the desired output would be:
```
5/25/2022 14:13:05
5/25/2022 13:21:07
5/25/2022 17:07:39
```
... | 2022/05/25 | [
"https://Stackoverflow.com/questions/72382468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9205480/"
] | With your shown samples, please try following `awk` code.
```
awk '
BEGIN { FS=OFS="\t" }
FNR==1{
print
next
}
{
sum=0
num=split($2,arr,"[:,]")
for(i=2;i<=num;i+=2){
sum+=arr[i]
}
print $1,sum
}
' Input_file
```
Output will be as follows with your shown samples:
```
id string
a1a 82
b2b 104
```
... | an `awk` solution that requires neither arrays nor loops :
```
< input_file.txt |
{m,g}awk 'BEGIN { FS = "[,]?["(OFS = "\t")" ]*([A-Z][:])?"
_+=++_ } NR<_ || NF=_^($_+= $(_+!!_) + $NF )^!_'
id string
a1a 82
b2b 104
```
The idea is to use `FS` to collect away as much as possible, leaving fields already l... |
72,382,468 | In Google Sheets, I have time stamps with formats like the following:
```
5/25/2022 14:13:05
5/25/2022 13:21:07 EDT
5/25/2022 17:07:39 GMT+01:00
```
I am looking for a regex that will remove everything after the time, so the desired output would be:
```
5/25/2022 14:13:05
5/25/2022 13:21:07
5/25/2022 17:07:39
```
... | 2022/05/25 | [
"https://Stackoverflow.com/questions/72382468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9205480/"
] | ```
$ awk '
BEGIN { FS=OFS="\t" }
NR>1 {
n = split($2,a,/[:,]/)
sum = 0
for ( i=2; i<=n; i+=2 ) {
sum += a[i]
}
$2 = sum
}
{ print }
' file
id string
a1a 82
b2b 104
``` | ```
awk -F'[ :,]' 'NR==1{print}NF==7{print$1,$3+$5+$7}' input_file|column -t
id string
a1a 82
b2b 104
``` |
72,382,468 | In Google Sheets, I have time stamps with formats like the following:
```
5/25/2022 14:13:05
5/25/2022 13:21:07 EDT
5/25/2022 17:07:39 GMT+01:00
```
I am looking for a regex that will remove everything after the time, so the desired output would be:
```
5/25/2022 14:13:05
5/25/2022 13:21:07
5/25/2022 17:07:39
```
... | 2022/05/25 | [
"https://Stackoverflow.com/questions/72382468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9205480/"
] | ```
$ awk '
BEGIN { FS=OFS="\t" }
NR>1 {
n = split($2,a,/[:,]/)
sum = 0
for ( i=2; i<=n; i+=2 ) {
sum += a[i]
}
$2 = sum
}
{ print }
' file
id string
a1a 82
b2b 104
``` | an `awk` solution that requires neither arrays nor loops :
```
< input_file.txt |
{m,g}awk 'BEGIN { FS = "[,]?["(OFS = "\t")" ]*([A-Z][:])?"
_+=++_ } NR<_ || NF=_^($_+= $(_+!!_) + $NF )^!_'
id string
a1a 82
b2b 104
```
The idea is to use `FS` to collect away as much as possible, leaving fields already l... |
32,169,249 | One thing that really annoys me about C++ is that an empty `struct`/`class` takes up space.
So, I have this idea that `std::tuple` (or some variant, since it's (and the compiler's) implementation is highly implementation dependent) might be able to save the day, which it sort of does, but there are issues due to packi... | 2015/08/23 | [
"https://Stackoverflow.com/questions/32169249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1366368/"
] | ```
class GameWindow < Gosu::Window
def initialize (width=800, height=600, fullscreen=false)
super
self.caption = 'Hello'
@message = Gosu::Image.from_text(
self, 'HELLO WORLD', Gosu.default_font_name, 45)
end
def draw
@message.draw(377.5,277.5,0)
end
end
```
Your `@message` is an inst... | I know this is an old question, but I was having this issue earlier today and came up with this solution.
```
def draw_centered_text(text, size, font)
centered_text = Gosu::Image.from_text(text, size, {:width => WIDTH, :align => :center, :font => font})
end
```
The above function converts the passed text to ... |
32,169,249 | One thing that really annoys me about C++ is that an empty `struct`/`class` takes up space.
So, I have this idea that `std::tuple` (or some variant, since it's (and the compiler's) implementation is highly implementation dependent) might be able to save the day, which it sort of does, but there are issues due to packi... | 2015/08/23 | [
"https://Stackoverflow.com/questions/32169249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1366368/"
] | ```
class GameWindow < Gosu::Window
def initialize (width=800, height=600, fullscreen=false)
super
self.caption = 'Hello'
@message = Gosu::Image.from_text(
self, 'HELLO WORLD', Gosu.default_font_name, 45)
end
def draw
@message.draw(377.5,277.5,0)
end
end
```
Your `@message` is an inst... | Better late than never...
No need to convert your text to an image. Just center the text using two parameters available on the Font.draw\_text\_rel method: rel\_x and rel\_y. See your code (modified a bit) below.
See: <https://www.rubydoc.info/gems/gosu/Gosu%2FFont:draw_text_rel>
```
require 'gosu'
class GameWindow... |
34,458,165 | I'd simply like to do something as follows:
```
<div class="container">
<div class="row">
<div class="col-md-4">content</div>
<div class="col-md-4">content</div>
<div class="col-md-4">content</div>
</div>
<div class="row">
<div class="col-md-4">content</div>
<div class="col-md-4">content</div... | 2015/12/24 | [
"https://Stackoverflow.com/questions/34458165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1105116/"
] | You should not concatenate elements like a string, but create and compose react elements. You can generate an array of your elements with content first, then reduce it to groups and wrap with your container:
```
render() {
var content = [
"content 1", "content 2", "content 3", "content 4", "content 5",
... | you cannot put just opening/closing tags inside the arrays, collect your columns inside an array and output them all by one, with valid opening and closing tags:
```
rows.push(<div className="row">{columns}</div>);
``` |
34,458,165 | I'd simply like to do something as follows:
```
<div class="container">
<div class="row">
<div class="col-md-4">content</div>
<div class="col-md-4">content</div>
<div class="col-md-4">content</div>
</div>
<div class="row">
<div class="col-md-4">content</div>
<div class="col-md-4">content</div... | 2015/12/24 | [
"https://Stackoverflow.com/questions/34458165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1105116/"
] | If you're already using [lodash](https://lodash.com/), you might be interested in the [chunk](https://lodash.com/docs#chunk) function:
```
render: function() {
var rows = [<div className="col-md-4">content</div>, ...]
return _.chunk(rows, 3).map(function(group) {
return <div className="row">{group}</div>
... | you cannot put just opening/closing tags inside the arrays, collect your columns inside an array and output them all by one, with valid opening and closing tags:
```
rows.push(<div className="row">{columns}</div>);
``` |
34,458,165 | I'd simply like to do something as follows:
```
<div class="container">
<div class="row">
<div class="col-md-4">content</div>
<div class="col-md-4">content</div>
<div class="col-md-4">content</div>
</div>
<div class="row">
<div class="col-md-4">content</div>
<div class="col-md-4">content</div... | 2015/12/24 | [
"https://Stackoverflow.com/questions/34458165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1105116/"
] | You should not concatenate elements like a string, but create and compose react elements. You can generate an array of your elements with content first, then reduce it to groups and wrap with your container:
```
render() {
var content = [
"content 1", "content 2", "content 3", "content 4", "content 5",
... | If you're already using [lodash](https://lodash.com/), you might be interested in the [chunk](https://lodash.com/docs#chunk) function:
```
render: function() {
var rows = [<div className="col-md-4">content</div>, ...]
return _.chunk(rows, 3).map(function(group) {
return <div className="row">{group}</div>
... |
47,069 | I have an *S3* I'm attempting to import contacts to.
I started with a list I've converted to `.CSV` and then used an online converter to create `.VCF` files from for each of the contacts.
The *S3* will not import the `.CSV` or `.VCF` files. I've combined the `.VCF` files into 1 and it still refuses to import them.
I... | 2013/06/11 | [
"https://android.stackexchange.com/questions/47069",
"https://android.stackexchange.com",
"https://android.stackexchange.com/users/35612/"
] | The reason I had this issue was a badly formatted vcard file. There were many `BEGIN:VCARD` tags that were not closed with `END:CARD` tags. As an example, it looked like this:
```
BEGIN:VCARD
VERSION:3.0
BEGIN:VCARD
# Bunch of fields in here like N, FN, EMAIL, etc.
END:VCARD
```
As you can see, the first `BEGIN:VCAR... | Without finding a way of doing this I ended up bluetoothing all the contacts from the old handset across (A Samsung B2100).
Would be nice to find more information about this buggy/broken feature on the S3. |
26,210,938 | I'm using Talend 5.5.
I have this `ArrayList` (segments\_id) that should be filled by the JSON feed:
```
List <Integer> segments_id = Jsonpath.read(row11.Body,"$.response.data.*.segment_id")
```
The list `segments_id` should hold all the values of the fields *"segment\_id"* from the JSON object (row11.Body):
>
> (... | 2014/10/06 | [
"https://Stackoverflow.com/questions/26210938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2758747/"
] | ```
List(
("eraser","pen"),
("pen","eraser"),
("pen","book"),
("pen","pencil"),
("book","pen"),
("book","pencil"),
("pencil","pen"),
("pencil","book")
).map{case (a, b) => if(a > b) (a, b) else (b, a)}.distinct
``` | This might be helpful
```
//val l = List(...)
(l foldLeft List.empty[(String,String)]){
case (l,a) if !l.contains(a) && !l.contains(a.swap) => a :: l
case (l, _) => l
}
``` |
48,739,516 | I'm trying to create a function that takes two parameter packs of objects. There are two templated base classes and I'd like to pass instances of derived classes to this function. Consider this example.
```
template <int N>
struct First {};
template <int N>
struct Second {};
// there are a few of these
struct FirstI... | 2018/02/12 | [
"https://Stackoverflow.com/questions/48739516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4093378/"
] | It's pretty much next to impossible to define something with two variadic parameter packs. Once a variadic parameter pack gets encountered, it likes to consume all remaining parameters, leaving no crumbs for the second pack to feed on.
However, as I mentioned, in many cases you can use tuples, and with deduction guide... | Why won't you simply pass the class itself as template parameter? Like this:
```
template <int N>
struct First {};
template <int N>
struct Second {};
// there are a few of these
struct FirstImpl : First<5> {};
struct SecondImpl : Second<7> {};
template <typename FirstSpec, typename SecondSpec>
void function(float f... |
48,739,516 | I'm trying to create a function that takes two parameter packs of objects. There are two templated base classes and I'd like to pass instances of derived classes to this function. Consider this example.
```
template <int N>
struct First {};
template <int N>
struct Second {};
// there are a few of these
struct FirstI... | 2018/02/12 | [
"https://Stackoverflow.com/questions/48739516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4093378/"
] | Let's first code a variable template which determines whether a type derives from `First` or not:
```
template <int N>
constexpr std::true_type is_first(First<N> const &) { return {}; }
template <int N>
constexpr std::false_type is_first(Second<N> const &) { return {}; }
template <class T>
constexpr bool is_first_v =... | Why won't you simply pass the class itself as template parameter? Like this:
```
template <int N>
struct First {};
template <int N>
struct Second {};
// there are a few of these
struct FirstImpl : First<5> {};
struct SecondImpl : Second<7> {};
template <typename FirstSpec, typename SecondSpec>
void function(float f... |
48,739,516 | I'm trying to create a function that takes two parameter packs of objects. There are two templated base classes and I'd like to pass instances of derived classes to this function. Consider this example.
```
template <int N>
struct First {};
template <int N>
struct Second {};
// there are a few of these
struct FirstI... | 2018/02/12 | [
"https://Stackoverflow.com/questions/48739516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4093378/"
] | It's pretty much next to impossible to define something with two variadic parameter packs. Once a variadic parameter pack gets encountered, it likes to consume all remaining parameters, leaving no crumbs for the second pack to feed on.
However, as I mentioned, in many cases you can use tuples, and with deduction guide... | Not exactly what you asked but... you could unify the two list using a variadic template-template `int` container (`Cnt`, in the following example) and next detect, for every argument, if is a `First` or a `Second` (see the use of `std::is_same_v`)
The following is a full working example
```
#include <string>
#includ... |
48,739,516 | I'm trying to create a function that takes two parameter packs of objects. There are two templated base classes and I'd like to pass instances of derived classes to this function. Consider this example.
```
template <int N>
struct First {};
template <int N>
struct Second {};
// there are a few of these
struct FirstI... | 2018/02/12 | [
"https://Stackoverflow.com/questions/48739516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4093378/"
] | Let's first code a variable template which determines whether a type derives from `First` or not:
```
template <int N>
constexpr std::true_type is_first(First<N> const &) { return {}; }
template <int N>
constexpr std::false_type is_first(Second<N> const &) { return {}; }
template <class T>
constexpr bool is_first_v =... | Not exactly what you asked but... you could unify the two list using a variadic template-template `int` container (`Cnt`, in the following example) and next detect, for every argument, if is a `First` or a `Second` (see the use of `std::is_same_v`)
The following is a full working example
```
#include <string>
#includ... |
138,821 | I copy OSX system with another SSD, and when want open file, you can see following, that means I can open file with the application in deprecated osx, but I want keep osx for restore oneday. how not show them.And I was confused always.  | 2014/07/13 | [
"https://apple.stackexchange.com/questions/138821",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/84958/"
] | If you don't want the older applications on your backup drive to appear in the Open With menu you could drop the Applications folder of the backup drive in the "Prevent Spotlight from searching these locations" box within the Spotlight Privacy tab within System Preferences.
When Spotlight removes them from the index t... | You should reset your `Open With` menu by rebuilding your *Launch Settings* database.
1. Open Terminal (Applications > Utilities)
2. Copy and paste: `/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user`
3. Hit ente... |
8,651,784 | I am wondering if anyone has developed a "crop" style box that a user can interact with in iOS? Specifically, I am looking for something like:
<http://img192.imageshack.us/img192/8930/customcropbox.jpg>
but without the actual crop functionality.
Any assistance would be great. | 2011/12/28 | [
"https://Stackoverflow.com/questions/8651784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1118659/"
] | If your windows service is on same IIS host server, you can very well use absolute path, say if <http://10.10.10.1/TempFolder/> maps to c:/TempFolder/, in WCF windowsservice when recieving file create new folder in c:/TempFolder/ and store file there, and if its on different machine you can create network share and the... | To get the physical directory name, use
```
Server.MapPath('TempFolder/UserID1');
```
**Update**
As pointed out in the comments, the above solution will only work when using asp.net compatibility in an IIS-hosted solution.
If you don't want to hard-code the directory, for example if this is deployed to different ... |
8,651,784 | I am wondering if anyone has developed a "crop" style box that a user can interact with in iOS? Specifically, I am looking for something like:
<http://img192.imageshack.us/img192/8930/customcropbox.jpg>
but without the actual crop functionality.
Any assistance would be great. | 2011/12/28 | [
"https://Stackoverflow.com/questions/8651784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1118659/"
] | If your windows service is on same IIS host server, you can very well use absolute path, say if <http://10.10.10.1/TempFolder/> maps to c:/TempFolder/, in WCF windowsservice when recieving file create new folder in c:/TempFolder/ and store file there, and if its on different machine you can create network share and the... | This will give a virtual directory of current application.With this you can append your created folder name
```
public string GetIISPath()
{
string urlscheme = System.Web.HttpContext.Current.Request.Url.Scheme;
string host = System.Web.HttpContext.Current.Request.Url.Host;
int port = S... |
17,349,234 | I have a text box that will expand across the screen when I do not use position: absolute;, however upon using it, the text is all in one column per word, and the box is very tiny.
What is causing this? Or what can cause this? I've been trying overflow settings, different sort of positions and z-indexes, etc. | 2013/06/27 | [
"https://Stackoverflow.com/questions/17349234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/756566/"
] | This is a good question because it highlights an important aspect of absolutely positioned elements.
If you don't specify the width of an absolutely positioned element, or if you don't specify the left and right offsets, then the width is computed to be a shrink-to-fit width similar to what is done for table cells.
T... | The element where you have `position:absolute;` is doing as it is expected to do. You should use `position:relative;` to the parent container for this absolutely positioned element. |
51,232,186 | Using Angular `6.0.7`, I am creating an attribute component and injecting a value into it. For this I am following the answer [here](https://stackoverflow.com/questions/38471827/can-an-angular-2-component-be-used-with-an-attribute-selector?rq=1).
I want to know if there is a way, just like in AngularJS, to input a val... | 2018/07/08 | [
"https://Stackoverflow.com/questions/51232186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4551323/"
] | You need to create an input with the same name as the attribute selector. For example,
```
@Component({
selector: '[hello]',
template: `<h1>Hello {{name}}!</h1>`,
styles: [`h1 { font-family: Lato; }`]
})
export class HelloComponent {
@Input() hello: string;
ngOnInit() {
console.log(this.hello);
}
}
... | [You Solution here](https://stackblitz.com/edit/angular-5epekr)
HTML:
app.component.html
```
<form (ngSubmit)="login()"
#loginForm="ngForm"
validateonsubmit ="{{loginForm.valid}}" >
</form>
```
hello.component.html:
```
form is valid : {{validateonsubmit}}
```
TS:
```
import { Component, Input } fr... |
286,866 | How would I go about showing that the vector field $X = x\frac{\partial}{\partial y} - y\frac{\partial}{\partial x}$ is tangent to the unit sphere in $\mathbb{R}^3$? I can see it pictorially but I'm not sure what would be required to actually prove it.
(This isn't homework! I understand the definitions of vector fiel... | 2013/01/25 | [
"https://math.stackexchange.com/questions/286866",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/47744/"
] | The unit sphere in $\Bbb R^3$ is nice in the sense that its tangent spaces admit a simple interpretation: If $r \in S^2$, then
$$T\_r S^2 = \{v \in \Bbb R^3 : r \cdot v = 0 \}.$$
Now we can make the identification
$$x \frac{\partial}{\partial y} - y \frac{\partial}{\partial x} \leftrightarrow (-y, x, 0) \in \Bbb R^3.$$... | Since we're explicitly considering an embedding, you can use the concept of a vector manifold to attack this problem. There are many benefits to doing so: in particular, you can use geometric (clifford) algebra to analyze the problem.
What Henry has done is clever: he's using the normal to the surface to characterize ... |
286,866 | How would I go about showing that the vector field $X = x\frac{\partial}{\partial y} - y\frac{\partial}{\partial x}$ is tangent to the unit sphere in $\mathbb{R}^3$? I can see it pictorially but I'm not sure what would be required to actually prove it.
(This isn't homework! I understand the definitions of vector fiel... | 2013/01/25 | [
"https://math.stackexchange.com/questions/286866",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/47744/"
] | Here's how to make the argument from the comments a little more rigorous from basic properties of tangent bundles. Let $i: S^2 \to \mathbb R^3$ be the inclusion. For every $x \in S^2$ this induces an injection $i\_\* T\_xS^2 \to T\_x \mathbb R^3$. Then asking if a vector field $X$ on $\mathbb R^3$ is tangent to $S^2$ i... | The unit sphere in $\Bbb R^3$ is nice in the sense that its tangent spaces admit a simple interpretation: If $r \in S^2$, then
$$T\_r S^2 = \{v \in \Bbb R^3 : r \cdot v = 0 \}.$$
Now we can make the identification
$$x \frac{\partial}{\partial y} - y \frac{\partial}{\partial x} \leftrightarrow (-y, x, 0) \in \Bbb R^3.$$... |
286,866 | How would I go about showing that the vector field $X = x\frac{\partial}{\partial y} - y\frac{\partial}{\partial x}$ is tangent to the unit sphere in $\mathbb{R}^3$? I can see it pictorially but I'm not sure what would be required to actually prove it.
(This isn't homework! I understand the definitions of vector fiel... | 2013/01/25 | [
"https://math.stackexchange.com/questions/286866",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/47744/"
] | Here's how to make the argument from the comments a little more rigorous from basic properties of tangent bundles. Let $i: S^2 \to \mathbb R^3$ be the inclusion. For every $x \in S^2$ this induces an injection $i\_\* T\_xS^2 \to T\_x \mathbb R^3$. Then asking if a vector field $X$ on $\mathbb R^3$ is tangent to $S^2$ i... | Since we're explicitly considering an embedding, you can use the concept of a vector manifold to attack this problem. There are many benefits to doing so: in particular, you can use geometric (clifford) algebra to analyze the problem.
What Henry has done is clever: he's using the normal to the surface to characterize ... |
12,506,512 | I have 2 types of data,for ex:- I need a single array of students with girls and boys names and also I need to retrieve girls and boys names separately.
can I do this in java with any descriptors? | 2012/09/20 | [
"https://Stackoverflow.com/questions/12506512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1684892/"
] | Try <http://simplehtmldom.sourceforge.net/>.
**Code**:
```
<?php
include('simple_html_dom.php');
$html = str_get_html('<a href="http://www.youtube.com/watch?v=UyxqmghxS6M">Link</a>');
$html->find('a', 0)->rel = 'youtube';
echo $html;
```
**Output**:
```
[username@localhost dom]$ php dom.php
<a href="http://www.yo... | Try the following:
```
//text
$text = "http://site.com/bounty.png a site www.anothersite.com/ http://www.youtube.com/watch?v=UyxqmghxS6M&featured=true here is another site";
//Youtube links
$pattern = "/(http:\/\/){0,1}(www\.){0,1}youtube\.com\/watch\?v=([a-z0-9\-_\|]{11})[^\s]*/i";
$replacement = '<a rel="youtube" h... |
4,812,440 | Over the past couple years, I have seen a lot of articles, opinions on how XML is an overkill or incorrectly used for .
When exactly should I use XML? What specific examples are there that your average programmer may run in to that, without a doubt XML is one of the best solutions? Are there any good articles/books t... | 2011/01/27 | [
"https://Stackoverflow.com/questions/4812440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/400766/"
] | I use xml IFF i need a human readable (for certain definitions of readable), hierarchical, verifiably (schema/relax), interoperable( from app to app or even serialized objects) storage format.
I also use it when the goal is to allow 3rd party tools to transform the data into other presentations (xsl->docbook,xhtml, et... | The beauty of XML is that it allows you to transfer structured information between systems that could not otherwise communicate efficiently. Say between two databases for instance. Thus a valid use for XML can be made in this case and XML parsers and output functions are typically implemented within DBMS solutions. Per... |
4,812,440 | Over the past couple years, I have seen a lot of articles, opinions on how XML is an overkill or incorrectly used for .
When exactly should I use XML? What specific examples are there that your average programmer may run in to that, without a doubt XML is one of the best solutions? Are there any good articles/books t... | 2011/01/27 | [
"https://Stackoverflow.com/questions/4812440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/400766/"
] | XML was designed primarily as a document markup language, and its widespread adoption for exchanging structured data was something of a surprise (to me, at least). It's worth recalling why that adoption happened (compared with pre-existing options such as CSV, ASN.1, or custom formats such as EDI and Swift). It was a f... | For the purposes of cross platform interoperability I like the fact that XML, XPath, XML Schema, XSLT and XHTML etc. are standards defined and maintained by W3. Added to that are a whole raft of XML standards (UBL, GML etc). That gives a high degree of confidence that when I use XML for data exchanges between systems I... |
4,812,440 | Over the past couple years, I have seen a lot of articles, opinions on how XML is an overkill or incorrectly used for .
When exactly should I use XML? What specific examples are there that your average programmer may run in to that, without a doubt XML is one of the best solutions? Are there any good articles/books t... | 2011/01/27 | [
"https://Stackoverflow.com/questions/4812440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/400766/"
] | For the purposes of cross platform interoperability I like the fact that XML, XPath, XML Schema, XSLT and XHTML etc. are standards defined and maintained by W3. Added to that are a whole raft of XML standards (UBL, GML etc). That gives a high degree of confidence that when I use XML for data exchanges between systems I... | A good use seems to be dependency injection (a la the Spring framework). It allows a lot of flexibility in configuring and re-configuring applications, without ever re-building.
This is the only context in which I've used it, and I find it very beneficial. |
4,812,440 | Over the past couple years, I have seen a lot of articles, opinions on how XML is an overkill or incorrectly used for .
When exactly should I use XML? What specific examples are there that your average programmer may run in to that, without a doubt XML is one of the best solutions? Are there any good articles/books t... | 2011/01/27 | [
"https://Stackoverflow.com/questions/4812440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/400766/"
] | A good use seems to be dependency injection (a la the Spring framework). It allows a lot of flexibility in configuring and re-configuring applications, without ever re-building.
This is the only context in which I've used it, and I find it very beneficial. | I'd have to say that I honestly never use XML anymore. If I require storing properties outside the codebase, I use a property file (key=value). When writing web services, I use JSON as the glue that binds my two applications together.
The one exception was for a project where the vendor preferred XML. They are a .NET ... |
4,812,440 | Over the past couple years, I have seen a lot of articles, opinions on how XML is an overkill or incorrectly used for .
When exactly should I use XML? What specific examples are there that your average programmer may run in to that, without a doubt XML is one of the best solutions? Are there any good articles/books t... | 2011/01/27 | [
"https://Stackoverflow.com/questions/4812440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/400766/"
] | XML was designed primarily as a document markup language, and its widespread adoption for exchanging structured data was something of a surprise (to me, at least). It's worth recalling why that adoption happened (compared with pre-existing options such as CSV, ASN.1, or custom formats such as EDI and Swift). It was a f... | I use xml IFF i need a human readable (for certain definitions of readable), hierarchical, verifiably (schema/relax), interoperable( from app to app or even serialized objects) storage format.
I also use it when the goal is to allow 3rd party tools to transform the data into other presentations (xsl->docbook,xhtml, et... |
4,812,440 | Over the past couple years, I have seen a lot of articles, opinions on how XML is an overkill or incorrectly used for .
When exactly should I use XML? What specific examples are there that your average programmer may run in to that, without a doubt XML is one of the best solutions? Are there any good articles/books t... | 2011/01/27 | [
"https://Stackoverflow.com/questions/4812440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/400766/"
] | XML was designed primarily as a document markup language, and its widespread adoption for exchanging structured data was something of a surprise (to me, at least). It's worth recalling why that adoption happened (compared with pre-existing options such as CSV, ASN.1, or custom formats such as EDI and Swift). It was a f... | I'd have to say that I honestly never use XML anymore. If I require storing properties outside the codebase, I use a property file (key=value). When writing web services, I use JSON as the glue that binds my two applications together.
The one exception was for a project where the vendor preferred XML. They are a .NET ... |
4,812,440 | Over the past couple years, I have seen a lot of articles, opinions on how XML is an overkill or incorrectly used for .
When exactly should I use XML? What specific examples are there that your average programmer may run in to that, without a doubt XML is one of the best solutions? Are there any good articles/books t... | 2011/01/27 | [
"https://Stackoverflow.com/questions/4812440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/400766/"
] | XML was designed primarily as a document markup language, and its widespread adoption for exchanging structured data was something of a surprise (to me, at least). It's worth recalling why that adoption happened (compared with pre-existing options such as CSV, ASN.1, or custom formats such as EDI and Swift). It was a f... | A good use seems to be dependency injection (a la the Spring framework). It allows a lot of flexibility in configuring and re-configuring applications, without ever re-building.
This is the only context in which I've used it, and I find it very beneficial. |
4,812,440 | Over the past couple years, I have seen a lot of articles, opinions on how XML is an overkill or incorrectly used for .
When exactly should I use XML? What specific examples are there that your average programmer may run in to that, without a doubt XML is one of the best solutions? Are there any good articles/books t... | 2011/01/27 | [
"https://Stackoverflow.com/questions/4812440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/400766/"
] | I use xml IFF i need a human readable (for certain definitions of readable), hierarchical, verifiably (schema/relax), interoperable( from app to app or even serialized objects) storage format.
I also use it when the goal is to allow 3rd party tools to transform the data into other presentations (xsl->docbook,xhtml, et... | For the purposes of cross platform interoperability I like the fact that XML, XPath, XML Schema, XSLT and XHTML etc. are standards defined and maintained by W3. Added to that are a whole raft of XML standards (UBL, GML etc). That gives a high degree of confidence that when I use XML for data exchanges between systems I... |
4,812,440 | Over the past couple years, I have seen a lot of articles, opinions on how XML is an overkill or incorrectly used for .
When exactly should I use XML? What specific examples are there that your average programmer may run in to that, without a doubt XML is one of the best solutions? Are there any good articles/books t... | 2011/01/27 | [
"https://Stackoverflow.com/questions/4812440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/400766/"
] | The beauty of XML is that it allows you to transfer structured information between systems that could not otherwise communicate efficiently. Say between two databases for instance. Thus a valid use for XML can be made in this case and XML parsers and output functions are typically implemented within DBMS solutions. Per... | I'd have to say that I honestly never use XML anymore. If I require storing properties outside the codebase, I use a property file (key=value). When writing web services, I use JSON as the glue that binds my two applications together.
The one exception was for a project where the vendor preferred XML. They are a .NET ... |
4,812,440 | Over the past couple years, I have seen a lot of articles, opinions on how XML is an overkill or incorrectly used for .
When exactly should I use XML? What specific examples are there that your average programmer may run in to that, without a doubt XML is one of the best solutions? Are there any good articles/books t... | 2011/01/27 | [
"https://Stackoverflow.com/questions/4812440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/400766/"
] | The beauty of XML is that it allows you to transfer structured information between systems that could not otherwise communicate efficiently. Say between two databases for instance. Thus a valid use for XML can be made in this case and XML parsers and output functions are typically implemented within DBMS solutions. Per... | A good use seems to be dependency injection (a la the Spring framework). It allows a lot of flexibility in configuring and re-configuring applications, without ever re-building.
This is the only context in which I've used it, and I find it very beneficial. |
15,519,671 | I am developing an app, which I will deploy on Heroku. The app is only used within an `iframe` on another site, so I don't care about the domain name. I plan to deploy my app on `example.herokuapp.com` instead of using a custom domain on `example.com`.
My app uses cookies, and I want to be sure that others cannot mani... | 2013/03/20 | [
"https://Stackoverflow.com/questions/15519671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/969005/"
] | I just tried to add a cookie from my Heroku app with the response header `Set-Cookie: name=value;Path=/;Domain=.herokuapp.com`, and to my disappointment, I could see the header intact in my browser. So the Heroku infrastructure does not detect and remove this cross-app supercookie.
I see three possible ways to protect... | It seems to me that, as long as you set the cookie for `example.herokuapp.com`, then the cookie is safe from manipulation. The cookie will only be presented to the app running on `example.herokuapp.com` and to `herokuapp.com` (where no app runs). |
15,519,671 | I am developing an app, which I will deploy on Heroku. The app is only used within an `iframe` on another site, so I don't care about the domain name. I plan to deploy my app on `example.herokuapp.com` instead of using a custom domain on `example.com`.
My app uses cookies, and I want to be sure that others cannot mani... | 2013/03/20 | [
"https://Stackoverflow.com/questions/15519671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/969005/"
] | Just wanted to post an update for anyone who ran across this question as I did. I was working on a similar problem, except that I wanted to purposefully allow access to the same cookie from two different heroku apps.
"herokuapp.com" and "herokussl.com" are now on the [Public Suffix List](http://publicsuffix.org/list/)... | I just tried to add a cookie from my Heroku app with the response header `Set-Cookie: name=value;Path=/;Domain=.herokuapp.com`, and to my disappointment, I could see the header intact in my browser. So the Heroku infrastructure does not detect and remove this cross-app supercookie.
I see three possible ways to protect... |
15,519,671 | I am developing an app, which I will deploy on Heroku. The app is only used within an `iframe` on another site, so I don't care about the domain name. I plan to deploy my app on `example.herokuapp.com` instead of using a custom domain on `example.com`.
My app uses cookies, and I want to be sure that others cannot mani... | 2013/03/20 | [
"https://Stackoverflow.com/questions/15519671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/969005/"
] | Just wanted to post an update for anyone who ran across this question as I did. I was working on a similar problem, except that I wanted to purposefully allow access to the same cookie from two different heroku apps.
"herokuapp.com" and "herokussl.com" are now on the [Public Suffix List](http://publicsuffix.org/list/)... | It seems to me that, as long as you set the cookie for `example.herokuapp.com`, then the cookie is safe from manipulation. The cookie will only be presented to the app running on `example.herokuapp.com` and to `herokuapp.com` (where no app runs). |
202,093 | I am trying to improve the quality of my code as well as trying to study the `Heap` data structure. I have implemented a minHeap (Heap in which minimum value nodes have higher priority). Ref: [link1](https://www.geeksforgeeks.org/binary-heap/), [link2](https://www.tutorialspoint.com/data_structures_algorithms/heap_data... | 2018/08/20 | [
"https://codereview.stackexchange.com/questions/202093",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/143321/"
] | Memory management
=================
You never `delete[] arr;`, which leaks memory. Not a good thing! There are multiple ways to fix this:
* Adding correct calls to `delete[] arr;` in the right places (remember exceptions, assignments and so on!), which is rather bug-prone.
Also, `new T[size]` default-constructs `siz... | An addendum to [hoffmale's excellent answer](/a/202102) (read and upvote that one first!):
* Prefer to initialize members, rather than assign them during construction:
```
template<typename T>
MinHeap<T>::MinHeap(size_t n)
: arr{new T[n]},
capacity{n},
length{0}
{
}
```
That's clearer, and allows co... |
202,093 | I am trying to improve the quality of my code as well as trying to study the `Heap` data structure. I have implemented a minHeap (Heap in which minimum value nodes have higher priority). Ref: [link1](https://www.geeksforgeeks.org/binary-heap/), [link2](https://www.tutorialspoint.com/data_structures_algorithms/heap_data... | 2018/08/20 | [
"https://codereview.stackexchange.com/questions/202093",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/143321/"
] | Memory management
=================
You never `delete[] arr;`, which leaks memory. Not a good thing! There are multiple ways to fix this:
* Adding correct calls to `delete[] arr;` in the right places (remember exceptions, assignments and so on!), which is rather bug-prone.
Also, `new T[size]` default-constructs `siz... | ```
class OutofRange {
std::string error = "The index is out of range.";
public:
OutofRange() {}
```
If no user-declared constructors of any kind are provided for a class type (`struct`, `class`, or `union`), the compiler will always declare a [default constructor](https://en.cppreference.com/w/cpp/language/d... |
4,476,279 | I was hoping to find out if there is a command in C++ that will find similar variations to input and accept those as well as the exact answers in an if statement.
For example:
If I have a user type in "Hi"
and the if statement needs to accept "hi" to be valid,
how can I make it also accept that without having to... | 2010/12/18 | [
"https://Stackoverflow.com/questions/4476279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/546726/"
] | How about computing some kind of [edit distance](http://en.wikipedia.org/wiki/Edit_distance). You could weight case changes with a very low distance and accept all inputs that are below a certain threshold. | If there are a lot of variations, and it's cumbersome to enumerate them, you may want to consider running the input through a regex parser. One that's lightweight is [T-Rex](http://tiny-rex.sourceforge.net/). |
4,476,279 | I was hoping to find out if there is a command in C++ that will find similar variations to input and accept those as well as the exact answers in an if statement.
For example:
If I have a user type in "Hi"
and the if statement needs to accept "hi" to be valid,
how can I make it also accept that without having to... | 2010/12/18 | [
"https://Stackoverflow.com/questions/4476279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/546726/"
] | How about computing some kind of [edit distance](http://en.wikipedia.org/wiki/Edit_distance). You could weight case changes with a very low distance and accept all inputs that are below a certain threshold. | Uppercase the strings, then compare the uppercased strings.
Note that theoretically this can run afoul of various national language conventions for uppercasing, which appears to be one reason that the C++ standard library has very poor support for uppercasing (if it can't be done 100% perfectly, then let's not do it).... |
4,476,279 | I was hoping to find out if there is a command in C++ that will find similar variations to input and accept those as well as the exact answers in an if statement.
For example:
If I have a user type in "Hi"
and the if statement needs to accept "hi" to be valid,
how can I make it also accept that without having to... | 2010/12/18 | [
"https://Stackoverflow.com/questions/4476279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/546726/"
] | How about computing some kind of [edit distance](http://en.wikipedia.org/wiki/Edit_distance). You could weight case changes with a very low distance and accept all inputs that are below a certain threshold. | Lowercase the input string.
Then compare:
```
std::string answer;
std::cin >> answer;
std::transform(answer.begin(), answer.end(), answer.begin(), ::tolower);
if (answer == "hi")
{
std::cout << "Wrong answer\n";
}
``` |
2,849,768 | Given $a>0 $, let $\sum\_{n=1}^{\infty}a^{n^{2}}(x-1)^{n}$ check for which values of $x$ as $x\in\mathbb{R}$, the power series converges.
I divided my answer for two diffrent cases:
1. for $0<a<1$, the power series converges for every $x$ - following Cauchy–Hadamard theorem - the radius of convergence is $\infty$.
2... | 2018/07/13 | [
"https://math.stackexchange.com/questions/2849768",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/553764/"
] | Note that$$\sqrt[n]{\bigl|a^{n^2}(x-1)^n\bigr|}=a^n|x-1|.$$If $0<a<1$, then $\lim\_{n\to\infty}a^n|x-1|=0$ and therefore the series converges, for every $x$. If $a=1$, the series converges if $|x-1|<1$ and diverges otherwise. Therefore, the radius of convergence is $1$. Finally, if $a>1$, $\lim\_{n\to\infty}a^n|x-1|=+\... | Note that
$$\limsup\sqrt[n]{a^{n^2}} =\limsup{a^{n}}=\begin{cases}0&|a|<0,\\1&a=1,\\\infty&a>1\end{cases}$$
Hence we have radius of convergence $\infty$, $1$, $0$, respectively. |
2,849,768 | Given $a>0 $, let $\sum\_{n=1}^{\infty}a^{n^{2}}(x-1)^{n}$ check for which values of $x$ as $x\in\mathbb{R}$, the power series converges.
I divided my answer for two diffrent cases:
1. for $0<a<1$, the power series converges for every $x$ - following Cauchy–Hadamard theorem - the radius of convergence is $\infty$.
2... | 2018/07/13 | [
"https://math.stackexchange.com/questions/2849768",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/553764/"
] | For a simpler (if less general and powerful) approach, we know that if a sum $\sum\_{n=1}^{\infty}{c\_n}$ converges, then $\lim\_{n\to\infty}{c\_n}=0$, by considering successive differences of partial sums.
Hence, fixing $a>1$ and supposing that your sequence converges, we must also have $\lim\_{n\to\infty}{a^{n^2}(x-... | Note that
$$\limsup\sqrt[n]{a^{n^2}} =\limsup{a^{n}}=\begin{cases}0&|a|<0,\\1&a=1,\\\infty&a>1\end{cases}$$
Hence we have radius of convergence $\infty$, $1$, $0$, respectively. |
2,849,768 | Given $a>0 $, let $\sum\_{n=1}^{\infty}a^{n^{2}}(x-1)^{n}$ check for which values of $x$ as $x\in\mathbb{R}$, the power series converges.
I divided my answer for two diffrent cases:
1. for $0<a<1$, the power series converges for every $x$ - following Cauchy–Hadamard theorem - the radius of convergence is $\infty$.
2... | 2018/07/13 | [
"https://math.stackexchange.com/questions/2849768",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/553764/"
] | Note that$$\sqrt[n]{\bigl|a^{n^2}(x-1)^n\bigr|}=a^n|x-1|.$$If $0<a<1$, then $\lim\_{n\to\infty}a^n|x-1|=0$ and therefore the series converges, for every $x$. If $a=1$, the series converges if $|x-1|<1$ and diverges otherwise. Therefore, the radius of convergence is $1$. Finally, if $a>1$, $\lim\_{n\to\infty}a^n|x-1|=+\... | For a simpler (if less general and powerful) approach, we know that if a sum $\sum\_{n=1}^{\infty}{c\_n}$ converges, then $\lim\_{n\to\infty}{c\_n}=0$, by considering successive differences of partial sums.
Hence, fixing $a>1$ and supposing that your sequence converges, we must also have $\lim\_{n\to\infty}{a^{n^2}(x-... |
37,654,497 | These are the statments i got after running the grunt serve command from the directory sangam
```
C:\Users\Rohit\Documents\GitHub\sangam>grunt serve
Running "serve" task
Running "clean:server" (clean) task
Running "env:all" (env) task
Running "concurrent:server" (concurrent) task
Running "injector:scripts" (inject... | 2016/06/06 | [
"https://Stackoverflow.com/questions/37654497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6403341/"
] | As written in the [github-issue](https://github.com/Automattic/mongoose/issues/2718) try doing following steps:-
>
> Make sure these two packages are at these versions
>
>
> "mongodb": "^2.1.16",
> "mongoose": "^4.4.12"
>
>
>
```
npm install -g node-gyp
cd /to/your/project-folder
rm -rf node_modules
npm inst... | Try changing `mongoose 4.2.8` into to `package.json` and `npm install` again.
It worked for me locally as well as on heroku. |
37,654,497 | These are the statments i got after running the grunt serve command from the directory sangam
```
C:\Users\Rohit\Documents\GitHub\sangam>grunt serve
Running "serve" task
Running "clean:server" (clean) task
Running "env:all" (env) task
Running "concurrent:server" (concurrent) task
Running "injector:scripts" (inject... | 2016/06/06 | [
"https://Stackoverflow.com/questions/37654497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6403341/"
] | As written in the [github-issue](https://github.com/Automattic/mongoose/issues/2718) try doing following steps:-
>
> Make sure these two packages are at these versions
>
>
> "mongodb": "^2.1.16",
> "mongoose": "^4.4.12"
>
>
>
```
npm install -g node-gyp
cd /to/your/project-folder
rm -rf node_modules
npm inst... | definitely it's important to do a:
```
npm install -g node-gyp
cd /to/your/project-folder
rm -rf node_modules
npm install
``` |
37,654,497 | These are the statments i got after running the grunt serve command from the directory sangam
```
C:\Users\Rohit\Documents\GitHub\sangam>grunt serve
Running "serve" task
Running "clean:server" (clean) task
Running "env:all" (env) task
Running "concurrent:server" (concurrent) task
Running "injector:scripts" (inject... | 2016/06/06 | [
"https://Stackoverflow.com/questions/37654497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6403341/"
] | As written in the [github-issue](https://github.com/Automattic/mongoose/issues/2718) try doing following steps:-
>
> Make sure these two packages are at these versions
>
>
> "mongodb": "^2.1.16",
> "mongoose": "^4.4.12"
>
>
>
```
npm install -g node-gyp
cd /to/your/project-folder
rm -rf node_modules
npm inst... | **what i did**
Just deleted node\_modules folder and run
>
> npm install
>
>
>
it worked fine. |
37,654,497 | These are the statments i got after running the grunt serve command from the directory sangam
```
C:\Users\Rohit\Documents\GitHub\sangam>grunt serve
Running "serve" task
Running "clean:server" (clean) task
Running "env:all" (env) task
Running "concurrent:server" (concurrent) task
Running "injector:scripts" (inject... | 2016/06/06 | [
"https://Stackoverflow.com/questions/37654497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6403341/"
] | Try changing `mongoose 4.2.8` into to `package.json` and `npm install` again.
It worked for me locally as well as on heroku. | definitely it's important to do a:
```
npm install -g node-gyp
cd /to/your/project-folder
rm -rf node_modules
npm install
``` |
37,654,497 | These are the statments i got after running the grunt serve command from the directory sangam
```
C:\Users\Rohit\Documents\GitHub\sangam>grunt serve
Running "serve" task
Running "clean:server" (clean) task
Running "env:all" (env) task
Running "concurrent:server" (concurrent) task
Running "injector:scripts" (inject... | 2016/06/06 | [
"https://Stackoverflow.com/questions/37654497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6403341/"
] | Try changing `mongoose 4.2.8` into to `package.json` and `npm install` again.
It worked for me locally as well as on heroku. | **what i did**
Just deleted node\_modules folder and run
>
> npm install
>
>
>
it worked fine. |
37,654,497 | These are the statments i got after running the grunt serve command from the directory sangam
```
C:\Users\Rohit\Documents\GitHub\sangam>grunt serve
Running "serve" task
Running "clean:server" (clean) task
Running "env:all" (env) task
Running "concurrent:server" (concurrent) task
Running "injector:scripts" (inject... | 2016/06/06 | [
"https://Stackoverflow.com/questions/37654497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6403341/"
] | **what i did**
Just deleted node\_modules folder and run
>
> npm install
>
>
>
it worked fine. | definitely it's important to do a:
```
npm install -g node-gyp
cd /to/your/project-folder
rm -rf node_modules
npm install
``` |
64,698,687 | I have text document contains line name and next line its value.
I wrote this but I can't rewrite the line after replaced it.
```
public bool checkExist(string catName)
{
int saveValue = 0;
bool found = false;
foreach (string line in File.ReadLines(Form1.INCOMES_EXPENSE_VALUES_MONTH + Form1.CurrentMonth.T... | 2020/11/05 | [
"https://Stackoverflow.com/questions/64698687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11796244/"
] | Since you're mutating the objects, it doesn't really get any cleaner than what you have. It can be done using `any` like this, but in my opinion is not any clearer to read:
```
list2.forEach { bar ->
bar.check = bar.check || list1.any { it.brand == bar.brand }
}
```
The above is slightly more efficie... | ```
data class Item(val name: String, val brand: String)
fun main() {
val list1 = listOf(
Item("vga_x", "Asus"),
Item("vga_b", "Asus"),
Item("mobo_x", "MSI"),
Item("memory", "Kingston")
)
val list2 = listOf(
Item("", "MSI"),
Item("", "ASUS"),
Item("... |
26,079,800 | I'm trying to create a mouse in and out effect that shows and disappears DIV's according to the mouse function. I've successfully done this, but the mouseout function flickers on and off when im inside the div instead of staying on.
Heres my sample code:
```
<!doctype html>
<html>
<head>
<meta charset="utf-8">
... | 2014/09/27 | [
"https://Stackoverflow.com/questions/26079800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4048209/"
] | This will allow you to poll any WMI class and get the desired values for the properties. In your case, you would select from [the Win32\_VideoController class](http://msdn.microsoft.com/en-us/library/aa394512(v=vs.85).aspx). Other WMI class can be [found here](http://msdn.microsoft.com/en-us/library/aa394388(v=vs.85).a... | It is possible to get graphics card info using WMI. You need to reference the System.Management and import it.
`WMI is a great library which contains the details about various components required for the system to operate. Hard Disk Drive related information, processor information, Network components and the list goes... |
26,079,800 | I'm trying to create a mouse in and out effect that shows and disappears DIV's according to the mouse function. I've successfully done this, but the mouseout function flickers on and off when im inside the div instead of staying on.
Heres my sample code:
```
<!doctype html>
<html>
<head>
<meta charset="utf-8">
... | 2014/09/27 | [
"https://Stackoverflow.com/questions/26079800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4048209/"
] | This will allow you to poll any WMI class and get the desired values for the properties. In your case, you would select from [the Win32\_VideoController class](http://msdn.microsoft.com/en-us/library/aa394512(v=vs.85).aspx). Other WMI class can be [found here](http://msdn.microsoft.com/en-us/library/aa394388(v=vs.85).a... | "invalid namespace" is not about System.Management, it is because the first parameter of
```
Dim WmiSelect As New ManagementObjectSearcher _("rootCIMV2", "SELECT * FROM
```
is not accepted.
Try to use another constructor without first parameter:
```
Dim WmiSelect As New ManagementObjectSearcher _("SELECT * FROM ... |
25,472,349 | I have a certain number of variables, each capable of attaining certain values, and I need to calculate all possible ways these variables can be assigned. For example, if I have -
```
variable_values = [[0], [0, 1], [0, 1, 2], [1, 2]]
```
i.e. variable 1 can be `0`; variable 2 can be `0` or `1`; variable 3 can be `0... | 2014/08/24 | [
"https://Stackoverflow.com/questions/25472349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/805156/"
] | You can use [`itertools.product`](https://docs.python.org/2/library/itertools.html#itertools.product):
```
>>> variable_values = [[0], [0, 1], [0, 1, 2], [1, 2]]
>>> import itertools
>>> list(itertools.product(*variable_values))
[(0, 0, 0, 1), (0, 0, 0, 2), (0, 0, 1, 1), (0, 0, 1, 2), (0, 0, 2, 1),
(0, 0, 2, 2), (0, ... | ```
from itertools import product,combinations
print [list(x) for x in (product(*variable_values))]
[[0, 0, 0, 1], [0, 0, 0, 2], [0, 0, 1, 1], [0, 0, 1, 2], [0, 0, 2, 1], [0, 0, 2, 2], [0, 1, 0, 1], [0, 1, 0, 2], [0, 1, 1, 1], [0, 1, 1, 2], [0, 1, 2, 1], [0, 1, 2, 2]]
``` |
11,509,254 | I just launched a website powered by Wordpress. I put the Google Analytics tracking code in my header, but for some reason it appears as if each visit might be double firing. I am getting things like a 0% bounce rate, and twice as many "pageviews" as "unique visitors."
<http://www.super-average.com>
Has anyone had e... | 2012/07/16 | [
"https://Stackoverflow.com/questions/11509254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1367053/"
] | Have a look for any references to `_gaq.push(['_trackPageview']);` in your Javascript code - this is featured in the line that sends the pageview info to Google.
We had a problem caused by an otherwise excellent jQuery address history plugin that we found by searching for this line. A further look at SO revealed some... | I had an issue where Google Analytics was included twice in all my pages. One instance was via the code I added manually, but I couldn't figure out where the second instance was coming from.
After a lot of debugging, I noticed that Cloudflare (my CDN) had the Google Analytics app installed. So it was automatically add... |
11,509,254 | I just launched a website powered by Wordpress. I put the Google Analytics tracking code in my header, but for some reason it appears as if each visit might be double firing. I am getting things like a 0% bounce rate, and twice as many "pageviews" as "unique visitors."
<http://www.super-average.com>
Has anyone had e... | 2012/07/16 | [
"https://Stackoverflow.com/questions/11509254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1367053/"
] | could it be that you include your GA codes twice in your page? You might put it in another file and that file is included (implicitly or explicitly) by your page. Though I might be wrong. | I got similar problem, that some Adware called "Yontoo" broke analytics in a way that every page request counted as new visitor. This "Yontoo" installed itself as Chrome extension (or I guess it came with Daemon Tools installer). So if you viewed 20 pages, it has shown 20 unique visitors on page.
Deleting the Chrome e... |
11,509,254 | I just launched a website powered by Wordpress. I put the Google Analytics tracking code in my header, but for some reason it appears as if each visit might be double firing. I am getting things like a 0% bounce rate, and twice as many "pageviews" as "unique visitors."
<http://www.super-average.com>
Has anyone had e... | 2012/07/16 | [
"https://Stackoverflow.com/questions/11509254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1367053/"
] | Your tracking code is correctly deployed, so there shouldn't be any reason for double counting.
You can verify the number of times the visit has been registered by looking at the net panel in firebug or in Google Chrome's developer tools. I've run through the implementation on your site and it seems to only be declari... | I had the same problem with me. The problem was that I had included google analytic in my homepage file as well as a module was triggering the pageview from backend. So you could just check for any module which is triggering from back office, as I am not very sure about wordpress. |
11,509,254 | I just launched a website powered by Wordpress. I put the Google Analytics tracking code in my header, but for some reason it appears as if each visit might be double firing. I am getting things like a 0% bounce rate, and twice as many "pageviews" as "unique visitors."
<http://www.super-average.com>
Has anyone had e... | 2012/07/16 | [
"https://Stackoverflow.com/questions/11509254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1367053/"
] | Your tracking code is correctly deployed, so there shouldn't be any reason for double counting.
You can verify the number of times the visit has been registered by looking at the net panel in firebug or in Google Chrome's developer tools. I've run through the implementation on your site and it seems to only be declari... | I had a similar problem with gtags.js.
I was making a single page application and I followed the documentation :
[Single page application devguide](https://developers.google.com/analytics/devguides/collection/gtagjs/single-page-applications)
But, after a few try, I saw that the page\_view event was duplicated.
After s... |
11,509,254 | I just launched a website powered by Wordpress. I put the Google Analytics tracking code in my header, but for some reason it appears as if each visit might be double firing. I am getting things like a 0% bounce rate, and twice as many "pageviews" as "unique visitors."
<http://www.super-average.com>
Has anyone had e... | 2012/07/16 | [
"https://Stackoverflow.com/questions/11509254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1367053/"
] | Your tracking code is correctly deployed, so there shouldn't be any reason for double counting.
You can verify the number of times the visit has been registered by looking at the net panel in firebug or in Google Chrome's developer tools. I've run through the implementation on your site and it seems to only be declari... | Have a look for any references to `_gaq.push(['_trackPageview']);` in your Javascript code - this is featured in the line that sends the pageview info to Google.
We had a problem caused by an otherwise excellent jQuery address history plugin that we found by searching for this line. A further look at SO revealed some... |
11,509,254 | I just launched a website powered by Wordpress. I put the Google Analytics tracking code in my header, but for some reason it appears as if each visit might be double firing. I am getting things like a 0% bounce rate, and twice as many "pageviews" as "unique visitors."
<http://www.super-average.com>
Has anyone had e... | 2012/07/16 | [
"https://Stackoverflow.com/questions/11509254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1367053/"
] | Your tracking code is correctly deployed, so there shouldn't be any reason for double counting.
You can verify the number of times the visit has been registered by looking at the net panel in firebug or in Google Chrome's developer tools. I've run through the implementation on your site and it seems to only be declari... | I had an issue where Google Analytics was included twice in all my pages. One instance was via the code I added manually, but I couldn't figure out where the second instance was coming from.
After a lot of debugging, I noticed that Cloudflare (my CDN) had the Google Analytics app installed. So it was automatically add... |
11,509,254 | I just launched a website powered by Wordpress. I put the Google Analytics tracking code in my header, but for some reason it appears as if each visit might be double firing. I am getting things like a 0% bounce rate, and twice as many "pageviews" as "unique visitors."
<http://www.super-average.com>
Has anyone had e... | 2012/07/16 | [
"https://Stackoverflow.com/questions/11509254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1367053/"
] | Have a look for any references to `_gaq.push(['_trackPageview']);` in your Javascript code - this is featured in the line that sends the pageview info to Google.
We had a problem caused by an otherwise excellent jQuery address history plugin that we found by searching for this line. A further look at SO revealed some... | I had a similar problem with gtags.js.
I was making a single page application and I followed the documentation :
[Single page application devguide](https://developers.google.com/analytics/devguides/collection/gtagjs/single-page-applications)
But, after a few try, I saw that the page\_view event was duplicated.
After s... |
11,509,254 | I just launched a website powered by Wordpress. I put the Google Analytics tracking code in my header, but for some reason it appears as if each visit might be double firing. I am getting things like a 0% bounce rate, and twice as many "pageviews" as "unique visitors."
<http://www.super-average.com>
Has anyone had e... | 2012/07/16 | [
"https://Stackoverflow.com/questions/11509254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1367053/"
] | Have a look for any references to `_gaq.push(['_trackPageview']);` in your Javascript code - this is featured in the line that sends the pageview info to Google.
We had a problem caused by an otherwise excellent jQuery address history plugin that we found by searching for this line. A further look at SO revealed some... | could it be that you include your GA codes twice in your page? You might put it in another file and that file is included (implicitly or explicitly) by your page. Though I might be wrong. |
11,509,254 | I just launched a website powered by Wordpress. I put the Google Analytics tracking code in my header, but for some reason it appears as if each visit might be double firing. I am getting things like a 0% bounce rate, and twice as many "pageviews" as "unique visitors."
<http://www.super-average.com>
Has anyone had e... | 2012/07/16 | [
"https://Stackoverflow.com/questions/11509254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1367053/"
] | I had an issue where Google Analytics was included twice in all my pages. One instance was via the code I added manually, but I couldn't figure out where the second instance was coming from.
After a lot of debugging, I noticed that Cloudflare (my CDN) had the Google Analytics app installed. So it was automatically add... | I got similar problem, that some Adware called "Yontoo" broke analytics in a way that every page request counted as new visitor. This "Yontoo" installed itself as Chrome extension (or I guess it came with Daemon Tools installer). So if you viewed 20 pages, it has shown 20 unique visitors on page.
Deleting the Chrome e... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.