qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
930,460 | I am trying to run `buildozer`. While running it gave the following error:
```
Aidl not found, please install it.
```
So I tried to install aidl as described [here](http://thelinuxfaq.com/ubuntu/ubuntu-17-04-zesty-zapus/aidl)
But it gave me the following error
>
> E: Unable to locate package aidl
>
>
>
I hav... | 2017/06/29 | [
"https://askubuntu.com/questions/930460",
"https://askubuntu.com",
"https://askubuntu.com/users/705925/"
] | Finally, I have found the solution. To install `aidl`, you need `libstdc++-6`. Previously I had a lower version of `libstdc++`, which causes problems while installing `aidl`.
To update to `libstdc++-6`, try
```
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install libstdc++6
```
After this,... | I was trying to compile for SDK 28, didn't have `build-tools` folder at all, so I had to run this:
```
~/./.buildozer/android/platform/android-sdk/tools/bin/sdkmanager "build-tools;28.0.0"
```
That command installed build tools with aidl inside `build-tools` folder and fixed the issue. |
930,460 | I am trying to run `buildozer`. While running it gave the following error:
```
Aidl not found, please install it.
```
So I tried to install aidl as described [here](http://thelinuxfaq.com/ubuntu/ubuntu-17-04-zesty-zapus/aidl)
But it gave me the following error
>
> E: Unable to locate package aidl
>
>
>
I hav... | 2017/06/29 | [
"https://askubuntu.com/questions/930460",
"https://askubuntu.com",
"https://askubuntu.com/users/705925/"
] | First of all, there's very specific versions of Cython required so make sure you use the appropriate [Ubuntu dependencies installation from this site](http://buildozer.readthedocs.io/en/latest/installation.html)
For Ubuntu 16.04 it is:
```
sudo pip install --upgrade cython==0.21
sudo dpkg --add-architecture i386
sudo... | I was trying to compile for SDK 28, didn't have `build-tools` folder at all, so I had to run this:
```
~/./.buildozer/android/platform/android-sdk/tools/bin/sdkmanager "build-tools;28.0.0"
```
That command installed build tools with aidl inside `build-tools` folder and fixed the issue. |
462 | I was asked how to save all the magento media assets in Amazon S3. I thought about using a PHP Stream Wrapper like this one: <https://github.com/punkave/aS3StreamWrapper> and just set the media folder to s3:\mybucket\mediaFolder
Does anyone has experience with this?
Or better use something like this: [https://github.... | 2013/02/01 | [
"https://magento.stackexchange.com/questions/462",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/217/"
] | [OnePica's CDN extension](http://www.magentocommerce.com/magento-connect/6274.html) is very handy out of the box for this functionality and supports more than just S3. Quote: "Currently, the extension integrates with Amazon S3, Coral CDN, Mosso/Rackspace Cloud Files, and any CDN, server or service that supports FTP, FT... | [Found another extension built by arkadedigital](https://github.com/arkadedigital/magento-s3) <https://github.com/arkadedigital/magento-s3> |
462 | I was asked how to save all the magento media assets in Amazon S3. I thought about using a PHP Stream Wrapper like this one: <https://github.com/punkave/aS3StreamWrapper> and just set the media folder to s3:\mybucket\mediaFolder
Does anyone has experience with this?
Or better use something like this: [https://github.... | 2013/02/01 | [
"https://magento.stackexchange.com/questions/462",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/217/"
] | it seems these guys find a solution: ( <http://thinkglobal.co/resources/moving-the-magento-media-directory-to-s3/> )
There are 2 possible approaches, one being to have Magento push all media assets to S3 as they are created and the other being to simply mount the media directory to an S3 bucket and let Magento think t... | [OnePica's CDN extension](http://www.magentocommerce.com/magento-connect/6274.html) is very handy out of the box for this functionality and supports more than just S3. Quote: "Currently, the extension integrates with Amazon S3, Coral CDN, Mosso/Rackspace Cloud Files, and any CDN, server or service that supports FTP, FT... |
462 | I was asked how to save all the magento media assets in Amazon S3. I thought about using a PHP Stream Wrapper like this one: <https://github.com/punkave/aS3StreamWrapper> and just set the media folder to s3:\mybucket\mediaFolder
Does anyone has experience with this?
Or better use something like this: [https://github.... | 2013/02/01 | [
"https://magento.stackexchange.com/questions/462",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/217/"
] | [OnePica's CDN extension](http://www.magentocommerce.com/magento-connect/6274.html) is very handy out of the box for this functionality and supports more than just S3. Quote: "Currently, the extension integrates with Amazon S3, Coral CDN, Mosso/Rackspace Cloud Files, and any CDN, server or service that supports FTP, FT... | Well, now that a couple years have gone by I think it's important to note that there are multiple plugins available that will move and serve assets from S3 / CDN.
Google searches turn up plenty of options.
Here's one on GitHub:
<https://github.com/magefm/cdn>
Here's one on Magento's Connect marketplace:
<http://w... |
462 | I was asked how to save all the magento media assets in Amazon S3. I thought about using a PHP Stream Wrapper like this one: <https://github.com/punkave/aS3StreamWrapper> and just set the media folder to s3:\mybucket\mediaFolder
Does anyone has experience with this?
Or better use something like this: [https://github.... | 2013/02/01 | [
"https://magento.stackexchange.com/questions/462",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/217/"
] | [OnePica's CDN extension](http://www.magentocommerce.com/magento-connect/6274.html) is very handy out of the box for this functionality and supports more than just S3. Quote: "Currently, the extension integrates with Amazon S3, Coral CDN, Mosso/Rackspace Cloud Files, and any CDN, server or service that supports FTP, FT... | OnePica's CDN extension is not the solution it only works for product images not to mention you need to set the correct TTL for its own cache life time which will timeout much earlier than default Magento. All you cms wysiwyg image will be in media folder but not using S3, you will end up uploading all your media image... |
462 | I was asked how to save all the magento media assets in Amazon S3. I thought about using a PHP Stream Wrapper like this one: <https://github.com/punkave/aS3StreamWrapper> and just set the media folder to s3:\mybucket\mediaFolder
Does anyone has experience with this?
Or better use something like this: [https://github.... | 2013/02/01 | [
"https://magento.stackexchange.com/questions/462",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/217/"
] | I prefer having a separate "admin" node(admin.example.com) and keeping media folders there. This way you would save yourself with NFS cost as well as issue with syncing etc. any CDN (I use cloudfront) could then be connected with admin node media folders, and be configured for all stores.
Other benefits of using admin... | [Found another extension built by arkadedigital](https://github.com/arkadedigital/magento-s3) <https://github.com/arkadedigital/magento-s3> |
462 | I was asked how to save all the magento media assets in Amazon S3. I thought about using a PHP Stream Wrapper like this one: <https://github.com/punkave/aS3StreamWrapper> and just set the media folder to s3:\mybucket\mediaFolder
Does anyone has experience with this?
Or better use something like this: [https://github.... | 2013/02/01 | [
"https://magento.stackexchange.com/questions/462",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/217/"
] | it seems these guys find a solution: ( <http://thinkglobal.co/resources/moving-the-magento-media-directory-to-s3/> )
There are 2 possible approaches, one being to have Magento push all media assets to S3 as they are created and the other being to simply mount the media directory to an S3 bucket and let Magento think t... | Well, now that a couple years have gone by I think it's important to note that there are multiple plugins available that will move and serve assets from S3 / CDN.
Google searches turn up plenty of options.
Here's one on GitHub:
<https://github.com/magefm/cdn>
Here's one on Magento's Connect marketplace:
<http://w... |
462 | I was asked how to save all the magento media assets in Amazon S3. I thought about using a PHP Stream Wrapper like this one: <https://github.com/punkave/aS3StreamWrapper> and just set the media folder to s3:\mybucket\mediaFolder
Does anyone has experience with this?
Or better use something like this: [https://github.... | 2013/02/01 | [
"https://magento.stackexchange.com/questions/462",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/217/"
] | OnePica's CDN extension is not the solution it only works for product images not to mention you need to set the correct TTL for its own cache life time which will timeout much earlier than default Magento. All you cms wysiwyg image will be in media folder but not using S3, you will end up uploading all your media image... | [Found another extension built by arkadedigital](https://github.com/arkadedigital/magento-s3) <https://github.com/arkadedigital/magento-s3> |
462 | I was asked how to save all the magento media assets in Amazon S3. I thought about using a PHP Stream Wrapper like this one: <https://github.com/punkave/aS3StreamWrapper> and just set the media folder to s3:\mybucket\mediaFolder
Does anyone has experience with this?
Or better use something like this: [https://github.... | 2013/02/01 | [
"https://magento.stackexchange.com/questions/462",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/217/"
] | it seems these guys find a solution: ( <http://thinkglobal.co/resources/moving-the-magento-media-directory-to-s3/> )
There are 2 possible approaches, one being to have Magento push all media assets to S3 as they are created and the other being to simply mount the media directory to an S3 bucket and let Magento think t... | I prefer having a separate "admin" node(admin.example.com) and keeping media folders there. This way you would save yourself with NFS cost as well as issue with syncing etc. any CDN (I use cloudfront) could then be connected with admin node media folders, and be configured for all stores.
Other benefits of using admin... |
462 | I was asked how to save all the magento media assets in Amazon S3. I thought about using a PHP Stream Wrapper like this one: <https://github.com/punkave/aS3StreamWrapper> and just set the media folder to s3:\mybucket\mediaFolder
Does anyone has experience with this?
Or better use something like this: [https://github.... | 2013/02/01 | [
"https://magento.stackexchange.com/questions/462",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/217/"
] | it seems these guys find a solution: ( <http://thinkglobal.co/resources/moving-the-magento-media-directory-to-s3/> )
There are 2 possible approaches, one being to have Magento push all media assets to S3 as they are created and the other being to simply mount the media directory to an S3 bucket and let Magento think t... | OnePica's CDN extension is not the solution it only works for product images not to mention you need to set the correct TTL for its own cache life time which will timeout much earlier than default Magento. All you cms wysiwyg image will be in media folder but not using S3, you will end up uploading all your media image... |
462 | I was asked how to save all the magento media assets in Amazon S3. I thought about using a PHP Stream Wrapper like this one: <https://github.com/punkave/aS3StreamWrapper> and just set the media folder to s3:\mybucket\mediaFolder
Does anyone has experience with this?
Or better use something like this: [https://github.... | 2013/02/01 | [
"https://magento.stackexchange.com/questions/462",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/217/"
] | it seems these guys find a solution: ( <http://thinkglobal.co/resources/moving-the-magento-media-directory-to-s3/> )
There are 2 possible approaches, one being to have Magento push all media assets to S3 as they are created and the other being to simply mount the media directory to an S3 bucket and let Magento think t... | [Found another extension built by arkadedigital](https://github.com/arkadedigital/magento-s3) <https://github.com/arkadedigital/magento-s3> |
28,959,065 | I have to Execute a dynamic SQL `SELECT` Query And put Results into a `#TempTable`.
```
DECLARE @StateId CHAR(3)='StateID';
DECLARE @DeptId CHAR(15)='DeptID';
DECLARE @Query VARCHAR(MAX)='Select Columns With Joins Passed From Front End'
DECLARE @Where VARCHAR(500);
DECLARE @FinalQuery VARCHAR(MAX)='';
SET @W... | 2015/03/10 | [
"https://Stackoverflow.com/questions/28959065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3852595/"
] | try the below example
```
DECLARE @StateId CHAR(3)='StateID';
DECLARE @DeptId CHAR(15)='DeptID';
DECLARE @Query VARCHAR(MAX)='*' -- here you pass your query
DECLARE @Where VARCHAR(500);
DECLARE @FinalQuery VARCHAR(MAX)='';
SET @Where='from tablename where condition';
SET @FinalQuery='SELECT '+@Query+' INTO ... | Please make sure that your query statements is correctly.
Try this in your stored procedure and check the output results ( copy the result and execute it)
```
....
SET @FinalQuery='SELECT '+@Query+' '+@Where+'
PRINT(@FinalQuery)
....
```
You can use the **SQL Profiler** tool to debug |
28,959,065 | I have to Execute a dynamic SQL `SELECT` Query And put Results into a `#TempTable`.
```
DECLARE @StateId CHAR(3)='StateID';
DECLARE @DeptId CHAR(15)='DeptID';
DECLARE @Query VARCHAR(MAX)='Select Columns With Joins Passed From Front End'
DECLARE @Where VARCHAR(500);
DECLARE @FinalQuery VARCHAR(MAX)='';
SET @W... | 2015/03/10 | [
"https://Stackoverflow.com/questions/28959065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3852595/"
] | try the below example
```
DECLARE @StateId CHAR(3)='StateID';
DECLARE @DeptId CHAR(15)='DeptID';
DECLARE @Query VARCHAR(MAX)='*' -- here you pass your query
DECLARE @Where VARCHAR(500);
DECLARE @FinalQuery VARCHAR(MAX)='';
SET @Where='from tablename where condition';
SET @FinalQuery='SELECT '+@Query+' INTO ... | Try this...
First create the temp table which you need for further calculation.
CREATE TABLE #TEMP
(
STATEID INT,
DEPTID INT
)
```
DECLARE @STATEID CHAR(10)='STATEID';
DECLARE @DEPTID CHAR(15)='DEPTID';
DECLARE @QUERY VARCHAR(MAX)='INSERT INTO #TEMP_TABLE
SELECT COLUMNS WITH JOI... |
57,253,051 | I have a matrice (list of list) say `a` and I want to normalize each "row" such that each element corresponds to the fraction of the corresponding row, i.e `[p/sum(p) for p in row]`.
I have the following code
```py
a_norm[:] = a
for i,row in enumerate(a_norm):
b = [p/sum(row) for p in row]
print(b)
a_nor... | 2019/07/29 | [
"https://Stackoverflow.com/questions/57253051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6224975/"
] | try this one:
```
a_norm = [[i / sum(row) for i in row] for row in a]
``` | Mistake you did in making list copy.
use `a_norm = a[:]` instead of `a_norm[:] = a`
You can try:
```
a_norm = a[:]
for i, row in enumerate(a_norm):
b = [p/sum(row) for p in row]
print(b)
a_norm[i] = b
print(a_norm)
``` |
47,603,513 | Im using Android Studio 3 with AppCompat
It doesnt compile with this 3 labels:
```
card_view:cardCornerRadius="6dp"
card_view:cardElevation="10dp"
card_view:cardUseCompatPadding="true"
```
Here is my XML code i do not know what it could be wrong in my dependencies i do have the AppCompat and the CardView:
```
<?xml... | 2017/12/02 | [
"https://Stackoverflow.com/questions/47603513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6929547/"
] | You're declaring the "auto" namespace on this line:
```
xmlns:app="http://schemas.android.com/apk/res-auto"
```
But you're trying to use it like this:
```
card_view:cardCornerRadius="6dp"
card_view:cardElevation="10dp"
card_view:cardUseCompatPadding="true"
```
It doesn't matter which of these two you change, but ... | >
> Try adding this
>
>
>
```
xmlns:card_view="http://schemas.android.com/apk/res-auto"
```
>
> in your code
>
>
>
```
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/a... |
2,358,989 | Let $(X, \mathcal{M})$ be a measurable space and let $f\_1, f\_2, ... : X \longrightarrow [-\infty, \infty]$ be measurable functions. Then $\{x \in X: \lim\limits\_{n \to \infty} f\_n(x) \text{ exists in } [-\infty, \infty]\} \in \mathcal{M}$.
---
My professor gave this as an extra problem during the spring term, an... | 2017/07/14 | [
"https://math.stackexchange.com/questions/2358989",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/406460/"
] | Here is an approach essentially from first principles: we can write
$$ \{x\in X:\lim\_{n\to\infty}f\_n(x)\;\mathrm{exists}\}=A\cup A\_{\infty}\cup A\_{-\infty} $$
where $A\_{\pm\infty}$ are the sets of $x$ such that the limit is equal to $\pm\infty$ respectively, and $A$ is the set of $x$ such that the limit exists and... | For $\lim\_{n \to \infty} f\_n(x)$ to exist (and in $\mathbb{R}$), it is necessary and sufficient that $(f\_n(x))\_n$ is a Cauchy sequence, i.e.
$$\forall \varepsilon >0 : \exists N : \forall n,m \ge N: |f\_n(x) - f\_m(x)| < \varepsilon$$
Denote by $g\_{n,m}: X \to [-\infty,+\infty]$ the function $g\_{n,m}(t) = |f\_n... |
2,358,989 | Let $(X, \mathcal{M})$ be a measurable space and let $f\_1, f\_2, ... : X \longrightarrow [-\infty, \infty]$ be measurable functions. Then $\{x \in X: \lim\limits\_{n \to \infty} f\_n(x) \text{ exists in } [-\infty, \infty]\} \in \mathcal{M}$.
---
My professor gave this as an extra problem during the spring term, an... | 2017/07/14 | [
"https://math.stackexchange.com/questions/2358989",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/406460/"
] | Here is an approach essentially from first principles: we can write
$$ \{x\in X:\lim\_{n\to\infty}f\_n(x)\;\mathrm{exists}\}=A\cup A\_{\infty}\cup A\_{-\infty} $$
where $A\_{\pm\infty}$ are the sets of $x$ such that the limit is equal to $\pm\infty$ respectively, and $A$ is the set of $x$ such that the limit exists and... | Let $A=\{x \in X| \exists \lim\_{n \rightarrow \infty}f\_n(x) \in [- \infty,+ \infty] \}$
Then $A=A\_1 \cup A\_2 \cup A\_3$ where $A\_1=\{x \in X|f\_n(x)$ is Cauchy in $\mathbb{R}$ $\}$
$$A\_2=\{x \in X| \lim\_n f\_n(x) =+ \infty\}$$ $$A\_3=\{x \in X| \lim\_n f\_n(x) =- \infty\}$$
Now if you remember the definition... |
73,277,898 | (This question is similar to [Should ARIA labels provide context?](https://stackoverflow.com/questions/39284454/should-aria-labels-provide-context), but not identical, as I'm talking about buttons and do not have full control over the markup.)
I have some amount of items and buttons that act on those items. Here's a s... | 2022/08/08 | [
"https://Stackoverflow.com/questions/73277898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3972493/"
] | You can certainly use `prefetch_related()` to make the query more efficient, but the reason that your code is slow is because you have DB calls nested within a forloop. You can re-write your queries to essentially do the if-statement and for-loop logic:
```py
def my_view(self):
...
# move your if-statement to... | You can query from the `UserModel` itself like this.
```
due_date = datetime.date.today()
UserModel.objects.prefetch_related("tasks").filter(
tasks__send_email=True, tasks__due_date=due_date
).values_list("email", flat=True)
``` |
12,071,706 | I am having some trouble posting data through AJAX. I created a small save script which determines in which table a POST must be saved (I am using a different form for each table):
```
$(function()
{
$( "#tabs" ).tabs().find( ".ui-tabs-nav" ).sortable({ axis: "x" });
});
function save(target)
{
switch(target... | 2012/08/22 | [
"https://Stackoverflow.com/questions/12071706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1356391/"
] | Well the answer for that is is like this create a folder called input in the app/
and create a file with [any\_name]\_input.rb let say you name it image\_tag\_input.rb
then the code inside the image\_tag\_input.rb look like this
```
class ImageTagInput < SimpleForm::Inputs::Base
## Because image tage doesnot wo... | I would suggest looking at using `f.label` and `f.input_field` instead of `f.input` since it would allow you to place the components as you would like and adding your images where you want them.
Check out the [Simple\_Form](https://github.com/plataformatec/simple_form) documentation for more information and examples.... |
12,071,706 | I am having some trouble posting data through AJAX. I created a small save script which determines in which table a POST must be saved (I am using a different form for each table):
```
$(function()
{
$( "#tabs" ).tabs().find( ".ui-tabs-nav" ).sortable({ axis: "x" });
});
function save(target)
{
switch(target... | 2012/08/22 | [
"https://Stackoverflow.com/questions/12071706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1356391/"
] | I always use wrappers that Simple Form Bootstrap uses.
An example from its default wrapper:
```
SimpleForm.setup do |config|
config.error_notification_class = 'alert alert-danger'
config.button_class = 'btn btn-default'
config.boolean_label_class = nil
# :vertica_from wrapper
config.wrappers :vertical_form... | I would suggest looking at using `f.label` and `f.input_field` instead of `f.input` since it would allow you to place the components as you would like and adding your images where you want them.
Check out the [Simple\_Form](https://github.com/plataformatec/simple_form) documentation for more information and examples.... |
12,071,706 | I am having some trouble posting data through AJAX. I created a small save script which determines in which table a POST must be saved (I am using a different form for each table):
```
$(function()
{
$( "#tabs" ).tabs().find( ".ui-tabs-nav" ).sortable({ axis: "x" });
});
function save(target)
{
switch(target... | 2012/08/22 | [
"https://Stackoverflow.com/questions/12071706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1356391/"
] | Well the answer for that is is like this create a folder called input in the app/
and create a file with [any\_name]\_input.rb let say you name it image\_tag\_input.rb
then the code inside the image\_tag\_input.rb look like this
```
class ImageTagInput < SimpleForm::Inputs::Base
## Because image tage doesnot wo... | I always use wrappers that Simple Form Bootstrap uses.
An example from its default wrapper:
```
SimpleForm.setup do |config|
config.error_notification_class = 'alert alert-danger'
config.button_class = 'btn btn-default'
config.boolean_label_class = nil
# :vertica_from wrapper
config.wrappers :vertical_form... |
9,009,740 | I have a class `Step` derived from `std::vector<unsigned int>`. I need to overload assignment operator because of the deep copy used in assignment of a value returned from a static method. I can't figur out how should I copy all elements of `rhv` to `this` in assignment:
```
class Step : public std::vector<unsigned in... | 2012/01/25 | [
"https://Stackoverflow.com/questions/9009740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/275221/"
] | I'm not 100% sure from your question, but I think you are asking about calling the parent `operator=`. In that case you have two options:
```
std::vector<unsigned int>::operator=(rhv); //either explicitly call the parent assignment op
*static_cast<std::vector<unsigned int>*>(this) = rhv; //or cast this to parentclass ... | Inheriting from standard containers is generally considered a bad idea because they aren't designed to be used as base classes (no virtual destructor among other things). Composition is preferred in pretty much every case.
Assuming you've decided to step into this minefield, you can invoke the parent assignment operat... |
9,009,740 | I have a class `Step` derived from `std::vector<unsigned int>`. I need to overload assignment operator because of the deep copy used in assignment of a value returned from a static method. I can't figur out how should I copy all elements of `rhv` to `this` in assignment:
```
class Step : public std::vector<unsigned in... | 2012/01/25 | [
"https://Stackoverflow.com/questions/9009740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/275221/"
] | Inheriting from standard containers is generally considered a bad idea because they aren't designed to be used as base classes (no virtual destructor among other things). Composition is preferred in pretty much every case.
Assuming you've decided to step into this minefield, you can invoke the parent assignment operat... | In this case you really don't have to overload `operator=` because the default generated one will work just fine (by assigning each member and base class in turn).
If you define your own operator, you can call the base class operator, just like you would call another base class function
```
std::vector<unsigned int>:... |
9,009,740 | I have a class `Step` derived from `std::vector<unsigned int>`. I need to overload assignment operator because of the deep copy used in assignment of a value returned from a static method. I can't figur out how should I copy all elements of `rhv` to `this` in assignment:
```
class Step : public std::vector<unsigned in... | 2012/01/25 | [
"https://Stackoverflow.com/questions/9009740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/275221/"
] | I'm not 100% sure from your question, but I think you are asking about calling the parent `operator=`. In that case you have two options:
```
std::vector<unsigned int>::operator=(rhv); //either explicitly call the parent assignment op
*static_cast<std::vector<unsigned int>*>(this) = rhv; //or cast this to parentclass ... | In this case you really don't have to overload `operator=` because the default generated one will work just fine (by assigning each member and base class in turn).
If you define your own operator, you can call the base class operator, just like you would call another base class function
```
std::vector<unsigned int>:... |
112,431 | ```
pi:~ $ sudo apt-get update
Hit:1 http://archive.raspberrypi.org/debian buster InRelease
Hit:2 http://raspbian.raspberrypi.org/raspbian buster InRelease
Reading package lists... Error!
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dist... | 2020/05/14 | [
"https://raspberrypi.stackexchange.com/questions/112431",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/119728/"
] | There is a problem with your lists of packages which are contained in the repository. You can try to reinitialize the lists under control of the package manager. How to do that you can look at [Raspberry Pi sudo apt-get update not working](https://raspberrypi.stackexchange.com/a/93630/79866). | Try this:
```
sudo rm /var/lib/dpkg/status
sudo touch /var/lib/dpkg/status
```
If that doesn't work try this:
```
sudo rm /var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_buster_main_binary-armhf_Packages
sudo touch /var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_buster_main_binary-armhf_Packag... |
16,012,503 | I have two table like
1) Customer
```
id | name
------+-------------------
1 | xyz1
2 | xyz2
3 | xyz3
4 | xyz4
5 | xyz5
```
2) Products
```
id | name | customer | state
------+-------------+----------+-------
1 | product 1 | 1 |Shipped
2 | ... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16012503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/92039/"
] | ```
select c.name,
sum(case when p.state = 'Pending' then 1 else 0 end) as count_pending,
sum(case when p.state = 'Shipped' then 1 else 0 end) as count_shipped
from customer c
left join products p on p.customer = c.id
group by name;
``` | ```
SELECT
c.id ,
c.name ,
SUM(IF p.state = 'Shipped',1,0) AS count_shipped,
SUM(IF p.state = 'Pending',1,0) AS count_pending
FROM Customer AS c
LEFT JOIN Products AS p ON p.customer = c.id
GROUP BY c.id
``` |
16,012,503 | I have two table like
1) Customer
```
id | name
------+-------------------
1 | xyz1
2 | xyz2
3 | xyz3
4 | xyz4
5 | xyz5
```
2) Products
```
id | name | customer | state
------+-------------+----------+-------
1 | product 1 | 1 |Shipped
2 | ... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16012503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/92039/"
] | ```
select c.name,
sum(case when p.state = 'Pending' then 1 else 0 end) as count_pending,
sum(case when p.state = 'Shipped' then 1 else 0 end) as count_shipped
from customer c
left join products p on p.customer = c.id
group by name;
``` | You can also use COUNT...
```
SELECT c.name
, COUNT(CASE WHEN state = 'shipped' THEN 'foo' END) count_shipped
, COUNT(CASE WHEN state = 'pending' THEN 'foo' END) count_pending
FROM customer c
LEFT
JOIN products p
ON p.customer = c.id
GROUP
BY c.id;
``` |
64,015,215 | [Website screenshot in PC](https://i.stack.imgur.com/UM5zY.png)
[Website screenshot in the mobile device](https://i.stack.imgur.com/ohFNd.png)
Here is the HTML code
```
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://fonts.googleapis.com/css2?family=PT+Sans+Narrow:wght@700&display=swap" rel="stylesheet... | 2020/09/22 | [
"https://Stackoverflow.com/questions/64015215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13784307/"
] | In case anyone else runs into the issue, in my case it was because I was passing the entire URL, i.e.
http://someurl/jenkins/computer/test/slave-agent.jnlp
and what it really wanted was
http://someurl/jenkins/ | Unfortunately, I think it's related to Jenkins upgrade that caused this, and I'm not sure there's a better solution than what I found.
Putting here my solution, but if anyone knows something better, I'd be happy to hear about it :)
* Download the agent.jar
* Download the slave-agent.jnlp and modify it:
+ Change all ... |
64,015,215 | [Website screenshot in PC](https://i.stack.imgur.com/UM5zY.png)
[Website screenshot in the mobile device](https://i.stack.imgur.com/ohFNd.png)
Here is the HTML code
```
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://fonts.googleapis.com/css2?family=PT+Sans+Narrow:wght@700&display=swap" rel="stylesheet... | 2020/09/22 | [
"https://Stackoverflow.com/questions/64015215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13784307/"
] | In case anyone else runs into the issue, in my case it was because I was passing the entire URL, i.e.
http://someurl/jenkins/computer/test/slave-agent.jnlp
and what it really wanted was
http://someurl/jenkins/ | Set global environment variable **jenkins.agent.inboundUrl** to your private adderess (with http/https) + port + suffix (if set).
This value will be used as url in JNLP file. This enables using a private address for inbound tcp agents, separate from Jenkins root URL.
see: <https://issues.jenkins.io/browse/JENKINS-632... |
31,315,800 | I'm working on my Add Materials for my Sales and Inventory. So far I need a validation where when adding a material, Selling Price must be greater than Purchase Price.
Here is my code and I'm getting an error in the if/else statement where the values of my txtPurchasePrice and txtSellingPrice are decimal(18, 2).
---
... | 2015/07/09 | [
"https://Stackoverflow.com/questions/31315800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4158779/"
] | Hwo can a string be greater than another string?
You need to convert the string to a numeric value before you do the comparison.
Since you are dealing with money, you should use `Decimal`:
```
if (Decimal.Parse(txtSellingPrice.Text) >= Decimal.Parse(txtPurchasePrice.Text))
``` | Use Convert.ToDecimal(txtSellingPrice.Text) >= Convert.ToDecimal(txtPurchasePrice.Text)
String value cannot be compared like that |
31,315,800 | I'm working on my Add Materials for my Sales and Inventory. So far I need a validation where when adding a material, Selling Price must be greater than Purchase Price.
Here is my code and I'm getting an error in the if/else statement where the values of my txtPurchasePrice and txtSellingPrice are decimal(18, 2).
---
... | 2015/07/09 | [
"https://Stackoverflow.com/questions/31315800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4158779/"
] | I'm assuming `txtSellingPrice` and `txtPurchasePrice` are `TextBox` controls, hence their `Text` property is of type `string`. You can't use `>=` since that has no semantical meaning. You'll need to parse the text first into `decimal`:
```
var sellingPrice = decimal.Parse(txtSellingPrice.Text);
var purchasePrice = dec... | Use Convert.ToDecimal(txtSellingPrice.Text) >= Convert.ToDecimal(txtPurchasePrice.Text)
String value cannot be compared like that |
31,315,800 | I'm working on my Add Materials for my Sales and Inventory. So far I need a validation where when adding a material, Selling Price must be greater than Purchase Price.
Here is my code and I'm getting an error in the if/else statement where the values of my txtPurchasePrice and txtSellingPrice are decimal(18, 2).
---
... | 2015/07/09 | [
"https://Stackoverflow.com/questions/31315800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4158779/"
] | To compare the numeric value of two strings you have to parse them into a numeric type, e.g. double! | Use Convert.ToDecimal(txtSellingPrice.Text) >= Convert.ToDecimal(txtPurchasePrice.Text)
String value cannot be compared like that |
31,315,800 | I'm working on my Add Materials for my Sales and Inventory. So far I need a validation where when adding a material, Selling Price must be greater than Purchase Price.
Here is my code and I'm getting an error in the if/else statement where the values of my txtPurchasePrice and txtSellingPrice are decimal(18, 2).
---
... | 2015/07/09 | [
"https://Stackoverflow.com/questions/31315800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4158779/"
] | I'm assuming `txtSellingPrice` and `txtPurchasePrice` are `TextBox` controls, hence their `Text` property is of type `string`. You can't use `>=` since that has no semantical meaning. You'll need to parse the text first into `decimal`:
```
var sellingPrice = decimal.Parse(txtSellingPrice.Text);
var purchasePrice = dec... | Hwo can a string be greater than another string?
You need to convert the string to a numeric value before you do the comparison.
Since you are dealing with money, you should use `Decimal`:
```
if (Decimal.Parse(txtSellingPrice.Text) >= Decimal.Parse(txtPurchasePrice.Text))
``` |
31,315,800 | I'm working on my Add Materials for my Sales and Inventory. So far I need a validation where when adding a material, Selling Price must be greater than Purchase Price.
Here is my code and I'm getting an error in the if/else statement where the values of my txtPurchasePrice and txtSellingPrice are decimal(18, 2).
---
... | 2015/07/09 | [
"https://Stackoverflow.com/questions/31315800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4158779/"
] | Hwo can a string be greater than another string?
You need to convert the string to a numeric value before you do the comparison.
Since you are dealing with money, you should use `Decimal`:
```
if (Decimal.Parse(txtSellingPrice.Text) >= Decimal.Parse(txtPurchasePrice.Text))
``` | To compare the numeric value of two strings you have to parse them into a numeric type, e.g. double! |
31,315,800 | I'm working on my Add Materials for my Sales and Inventory. So far I need a validation where when adding a material, Selling Price must be greater than Purchase Price.
Here is my code and I'm getting an error in the if/else statement where the values of my txtPurchasePrice and txtSellingPrice are decimal(18, 2).
---
... | 2015/07/09 | [
"https://Stackoverflow.com/questions/31315800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4158779/"
] | I'm assuming `txtSellingPrice` and `txtPurchasePrice` are `TextBox` controls, hence their `Text` property is of type `string`. You can't use `>=` since that has no semantical meaning. You'll need to parse the text first into `decimal`:
```
var sellingPrice = decimal.Parse(txtSellingPrice.Text);
var purchasePrice = dec... | To compare the numeric value of two strings you have to parse them into a numeric type, e.g. double! |
47,115,224 | I am running into an issue with trying to access a variable (R)'s value from Parent Class(DrawingPanel()) in Child Class(Balloon()).
I have set the public integer R equal to 0 in DrawingPanel()'s class constructor. Like this:
```
public class DrawingPanel extends JPanel implements MouseListener,
MouseMotionListene... | 2017/11/04 | [
"https://Stackoverflow.com/questions/47115224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7151023/"
] | The simplest method might be correlated subqueries:
```
select m.mdate, m.team1,
(select count(*)
from goal g
where g.teamid = m.team1 and g.matchid = m.id
) as team1_goals,
m.team2,
(select count(*)
from goal g
where g.teamid = m.team2 and g.matchid = m.id
) as team2_goals
from game m
O... | OK... found the site and got this to work
```
SELECT g.mdate, g.team1, CASE WHEN g2.score1 IS NULL THEN 0 ELSE g2.score1 END, g.team2, CASE WHEN g3.score2 IS NULL THEN 0 ELSE g3.score2 END
FROM game g LEFT OUTER JOIN
(SELECT matchid, teamid, COUNT(*) score1 from goal group by matchid, teamid) g2 ON g.team1 = g2.... |
31,124,598 | I'm working in a simple application to convert some Unix Timestamp dates to localtime. I'm printing both, UTC time and "E. South America Standard Time" -> (GMT-03:00) Brasilia. The code below runs fine, but seems to mess things with DST:
```
public static void Main (string[] args)
{
long[] timestamps =... | 2015/06/29 | [
"https://Stackoverflow.com/questions/31124598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5062713/"
] | Well, you're probably just missing the fact that the Windows time zone data is not the same as the IANA data that Java is using, and that your two Windows 7 boxes probably have a different set of Windows Updates applied. I wouldn't like to guess at exactly what Mono's using, I'm afraid.
One option you might want to co... | I agree with Jon that Noda Time is much better for this scenario. I highly recommend you go with his implementation.
However, just to explain your results:
* In the last line, you format the `dt` variable as a string. This variable is a `DateTime` type, and its `.Kind` is `DateTimeKind.Unspecified`.
* Your `formatLoc... |
16,012,502 | I have a large xml file with following example content:
```
<transferData version="1.0">
<item id="1885880" itemType="kivihomepagetransfer">
<property name="country_id">
<value>4402</value>
</property>
<property name="rc_maintenance_other"></property>
<property name="claim_right_shareholder"></property>
<property name... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16012502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1610386/"
] | **EDIT:** I figured out the problem. Your XPath is working, but var\_dump/print\_r isn't showing you anything useful. Try the following:
```
$path = '//item[@id="'.$itemId.'"]/property[@name="realtycompany"]/value/text()';
$company = $xml->xpath($path)[0];
print_r((string)$company);
```
---
*Earlier Response*
I ha... | If all you would like to access is the values of elements, it might be easier to use the [Simple HTML DOM](http://simplehtmldom.sourceforge.net/)
```
include('simple_html_dom.php');
$xml = file_get_html('file.xml');
$value = $html->find('property[name=realtycompany]');
echo $value->plaintext;
``` |
16,012,502 | I have a large xml file with following example content:
```
<transferData version="1.0">
<item id="1885880" itemType="kivihomepagetransfer">
<property name="country_id">
<value>4402</value>
</property>
<property name="rc_maintenance_other"></property>
<property name="claim_right_shareholder"></property>
<property name... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16012502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1610386/"
] | **EDIT:** I figured out the problem. Your XPath is working, but var\_dump/print\_r isn't showing you anything useful. Try the following:
```
$path = '//item[@id="'.$itemId.'"]/property[@name="realtycompany"]/value/text()';
$company = $xml->xpath($path)[0];
print_r((string)$company);
```
---
*Earlier Response*
I ha... | You are using the *SimpleXML* extension and its `SimpleXMLElement::xpath()` method specifically to run the xpath query.
However *SimpleXMLElement* xpath query can not return text-nodes (`text()`). In your case, even you write `text()` at the end of the xpath query, it will return the texts parent element-node.
As thi... |
16,012,502 | I have a large xml file with following example content:
```
<transferData version="1.0">
<item id="1885880" itemType="kivihomepagetransfer">
<property name="country_id">
<value>4402</value>
</property>
<property name="rc_maintenance_other"></property>
<property name="claim_right_shareholder"></property>
<property name... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16012502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1610386/"
] | You are using the *SimpleXML* extension and its `SimpleXMLElement::xpath()` method specifically to run the xpath query.
However *SimpleXMLElement* xpath query can not return text-nodes (`text()`). In your case, even you write `text()` at the end of the xpath query, it will return the texts parent element-node.
As thi... | If all you would like to access is the values of elements, it might be easier to use the [Simple HTML DOM](http://simplehtmldom.sourceforge.net/)
```
include('simple_html_dom.php');
$xml = file_get_html('file.xml');
$value = $html->find('property[name=realtycompany]');
echo $value->plaintext;
``` |
27,065,968 | i want to commit my changes, but git hangout, when i run
```
git add .
```
i rerun it using -v option, then i get
```
add 'dev/less/module/basic-structure/eo-featured.less'
add 'dev/less/module/page-content/content/.eo-cv.less.swo'
```
am using vim, that's why i guess that .swo file, i don't know what that is, bu... | 2014/11/21 | [
"https://Stackoverflow.com/questions/27065968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2183299/"
] | If the file was never *committed*, `git rm` won't work.
Running `git status` will show you how to properly unstage this file:
```
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: dev/less/module/basic-structure/eo-featured.less
new file: ... | The `.swo` file isn't tracked by git (unless you already added it in the past), this is why you can't use `git rm` (which only tells git to stop tracking the files).
You just don't want to stage it when using `git add`, and you have two ways to do that:
1. Giving only the files you really want to stage to `git add` (... |
27,065,968 | i want to commit my changes, but git hangout, when i run
```
git add .
```
i rerun it using -v option, then i get
```
add 'dev/less/module/basic-structure/eo-featured.less'
add 'dev/less/module/page-content/content/.eo-cv.less.swo'
```
am using vim, that's why i guess that .swo file, i don't know what that is, bu... | 2014/11/21 | [
"https://Stackoverflow.com/questions/27065968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2183299/"
] | your swo file is very likely created by vim, so called swap file. In vim, you can `:h swap` to check details.
If you don't want vim to generate swap file, you can set the option:
```
set noswf
```
You got error msg when you tried to "delete" the swo file, because, the file hasn't been tracked by git yet, you used `... | The `.swo` file isn't tracked by git (unless you already added it in the past), this is why you can't use `git rm` (which only tells git to stop tracking the files).
You just don't want to stage it when using `git add`, and you have two ways to do that:
1. Giving only the files you really want to stage to `git add` (... |
27,065,968 | i want to commit my changes, but git hangout, when i run
```
git add .
```
i rerun it using -v option, then i get
```
add 'dev/less/module/basic-structure/eo-featured.less'
add 'dev/less/module/page-content/content/.eo-cv.less.swo'
```
am using vim, that's why i guess that .swo file, i don't know what that is, bu... | 2014/11/21 | [
"https://Stackoverflow.com/questions/27065968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2183299/"
] | If the file was never *committed*, `git rm` won't work.
Running `git status` will show you how to properly unstage this file:
```
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: dev/less/module/basic-structure/eo-featured.less
new file: ... | i solved this problem, which i think is an issue, because using -v option, was not provide me with the information i needed.
the problem was because of a huge file, called ctags, that git was trying to add to the staged area, and its taking too long.
i added it to .gitignore along with .\*.swo files, and the problem ... |
27,065,968 | i want to commit my changes, but git hangout, when i run
```
git add .
```
i rerun it using -v option, then i get
```
add 'dev/less/module/basic-structure/eo-featured.less'
add 'dev/less/module/page-content/content/.eo-cv.less.swo'
```
am using vim, that's why i guess that .swo file, i don't know what that is, bu... | 2014/11/21 | [
"https://Stackoverflow.com/questions/27065968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2183299/"
] | your swo file is very likely created by vim, so called swap file. In vim, you can `:h swap` to check details.
If you don't want vim to generate swap file, you can set the option:
```
set noswf
```
You got error msg when you tried to "delete" the swo file, because, the file hasn't been tracked by git yet, you used `... | i solved this problem, which i think is an issue, because using -v option, was not provide me with the information i needed.
the problem was because of a huge file, called ctags, that git was trying to add to the staged area, and its taking too long.
i added it to .gitignore along with .\*.swo files, and the problem ... |
195,085 | I want to create a simple table with tabulary:
```
\documentclass{article}
\usepackage[english]{babel}
\usepackage{tabulary}
\begin{document}
\begin{tabulary}{\linewidth}{|L|L|L|}
A & B & C
\\
Blablab & Blablablabl & Blabl bl bla blabl blablabl blabl blabl bl blab blab bla blabla bl blablabla bla blabla
\\
\end{tabu... | 2014/08/06 | [
"https://tex.stackexchange.com/questions/195085",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/60285/"
] | The `Blablablabl` is too big and tex doesn't hyphenate that. You can over come this by specifying
```
\tymin=60pt
\tymax=\maxdimen
```
Full code:
```
\documentclass{article}
\usepackage[english]{babel}
\usepackage{tabulary,showframe} %% showframe just for demo
\tymin=60pt
\tymax=\maxdimen
\begin{document}
\noinden... | Use of column specifier `l` from `tabular` for the first two columns.
and use of `\noindent` right before `tabulary` environment.

Code
```
\documentclass{article}
\usepackage[english]{babel}
\usepackage{tabulary}
\usepackage[showframe]{geometry}
\... |
56,200,680 | I am currently implementing Run Length Encoding for text compression and my algorithm does return Strings of the following form:
Let's say we have a string as input
```
"AAAAABBBBCCCCCCCC"
```
then my algorithm returns
```
"1A2A3A4A5A1B2B3B4B1C2C3C4C5C6C7C8C"
```
Now I want to apply Java String split to solve t... | 2019/05/18 | [
"https://Stackoverflow.com/questions/56200680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7137698/"
] | ```
public static String getStrfinal(){
StringBuilder sb = new StringBuilder();
char last = 0;
int count = 0;
for(int i = 0; i < str.length(); i++) {
if(i > 0 && last != str.charAt(i)) {
sb.append(count + "" + last);
last = 0;
count = 1;
}
e... | Instead of string Buffer you can use a map it will be much easier and clean to do so.
```
public static void main(String[] args) {
String input = "AAAAABBBBCCCCCCCCAAABBBDDCCCC";
int counter=1;
for(int i=1; i<input.length(); i++) {
if(input.charAt(i-1)==input.charAt(i)) {
counter=co... |
56,200,680 | I am currently implementing Run Length Encoding for text compression and my algorithm does return Strings of the following form:
Let's say we have a string as input
```
"AAAAABBBBCCCCCCCC"
```
then my algorithm returns
```
"1A2A3A4A5A1B2B3B4B1C2C3C4C5C6C7C8C"
```
Now I want to apply Java String split to solve t... | 2019/05/18 | [
"https://Stackoverflow.com/questions/56200680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7137698/"
] | Instead of string Buffer you can use a map it will be much easier and clean to do so.
```
public static void main(String[] args) {
String input = "AAAAABBBBCCCCCCCCAAABBBDDCCCC";
int counter=1;
for(int i=1; i<input.length(); i++) {
if(input.charAt(i-1)==input.charAt(i)) {
counter=co... | This is one of the possible solutions to your question. We can use a LinkedHashMap data structure which is similar to HashMap but it also maintains the order. So, we can traverse the string and store the occurrence of each character as Key-value pair into the map and retrieve easily with its maximum occurrence.
```
pu... |
56,200,680 | I am currently implementing Run Length Encoding for text compression and my algorithm does return Strings of the following form:
Let's say we have a string as input
```
"AAAAABBBBCCCCCCCC"
```
then my algorithm returns
```
"1A2A3A4A5A1B2B3B4B1C2C3C4C5C6C7C8C"
```
Now I want to apply Java String split to solve t... | 2019/05/18 | [
"https://Stackoverflow.com/questions/56200680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7137698/"
] | ```
public static String getStrfinal(){
StringBuilder sb = new StringBuilder();
char last = 0;
int count = 0;
for(int i = 0; i < str.length(); i++) {
if(i > 0 && last != str.charAt(i)) {
sb.append(count + "" + last);
last = 0;
count = 1;
}
e... | Here is one possible solution. It starts with the raw string and simply iterates thru the string.
```java
public static void main(String[] args) {
String input = "AAAABBBCCCCCCCDDDEAAFBBCD";
int index = 0;
StringBuilder sb = new StringBuilder();
while (index < input.length()) {
int ... |
56,200,680 | I am currently implementing Run Length Encoding for text compression and my algorithm does return Strings of the following form:
Let's say we have a string as input
```
"AAAAABBBBCCCCCCCC"
```
then my algorithm returns
```
"1A2A3A4A5A1B2B3B4B1C2C3C4C5C6C7C8C"
```
Now I want to apply Java String split to solve t... | 2019/05/18 | [
"https://Stackoverflow.com/questions/56200680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7137698/"
] | ```
public static String getStrfinal(){
StringBuilder sb = new StringBuilder();
char last = 0;
int count = 0;
for(int i = 0; i < str.length(); i++) {
if(i > 0 && last != str.charAt(i)) {
sb.append(count + "" + last);
last = 0;
count = 1;
}
e... | This is one of the possible solutions to your question. We can use a LinkedHashMap data structure which is similar to HashMap but it also maintains the order. So, we can traverse the string and store the occurrence of each character as Key-value pair into the map and retrieve easily with its maximum occurrence.
```
pu... |
56,200,680 | I am currently implementing Run Length Encoding for text compression and my algorithm does return Strings of the following form:
Let's say we have a string as input
```
"AAAAABBBBCCCCCCCC"
```
then my algorithm returns
```
"1A2A3A4A5A1B2B3B4B1C2C3C4C5C6C7C8C"
```
Now I want to apply Java String split to solve t... | 2019/05/18 | [
"https://Stackoverflow.com/questions/56200680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7137698/"
] | Here is one possible solution. It starts with the raw string and simply iterates thru the string.
```java
public static void main(String[] args) {
String input = "AAAABBBCCCCCCCDDDEAAFBBCD";
int index = 0;
StringBuilder sb = new StringBuilder();
while (index < input.length()) {
int ... | This is one of the possible solutions to your question. We can use a LinkedHashMap data structure which is similar to HashMap but it also maintains the order. So, we can traverse the string and store the occurrence of each character as Key-value pair into the map and retrieve easily with its maximum occurrence.
```
pu... |
57,585,301 | How can I create the sparksession?
```
scala> import org.apache.spark.SparkConf
import org.apache.spark.SparkConf
scala> import org.apache.spark.SparkContext
import org.apache.spark.SparkContext
scala> val conf = SparkSession.builder.master("local").appName("testing").enableHiveSupport().getOrCreate()
<consol... | 2019/08/21 | [
"https://Stackoverflow.com/questions/57585301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11852796/"
] | SparkSession is available in spark 2.x
```
import org.apache.spark.sql.SparkSession
```
Though when you start spark shell SparkSession is already available as `spark` variable. | As undefined\_variable mentioned, you need to run `import org.apache.spark.sql.SparkSession` to access the `SparkSession` class.
It was also mentioned that you don't need to create your own SparkSession in the Spark console because it's already created for you.
[.appName("testing").enableHiveSupport().getOrCreate()
<consol... | 2019/08/21 | [
"https://Stackoverflow.com/questions/57585301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11852796/"
] | SparkSession is available in spark 2.x
```
import org.apache.spark.sql.SparkSession
```
Though when you start spark shell SparkSession is already available as `spark` variable. | Scala Spark:
```
import org.apache.spark.sql.SparkSession
val conf = SparkSession.builder.master("local").appName("testing").enableHiveSupport().getOrCreate()
```
PySpark:
```
from pyspark.sql import SparkSession
spark = SparkSession.builder \
.appName("testing") \
.enableHiveSupport() \
.getOrCreate()
```
A... |
57,585,301 | How can I create the sparksession?
```
scala> import org.apache.spark.SparkConf
import org.apache.spark.SparkConf
scala> import org.apache.spark.SparkContext
import org.apache.spark.SparkContext
scala> val conf = SparkSession.builder.master("local").appName("testing").enableHiveSupport().getOrCreate()
<consol... | 2019/08/21 | [
"https://Stackoverflow.com/questions/57585301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11852796/"
] | As undefined\_variable mentioned, you need to run `import org.apache.spark.sql.SparkSession` to access the `SparkSession` class.
It was also mentioned that you don't need to create your own SparkSession in the Spark console because it's already created for you.
[.appName("testing").enableHiveSupport().getOrCreate()
```
PySpark:
```
from pyspark.sql import SparkSession
spark = SparkSession.builder \
.appName("testing") \
.enableHiveSupport() \
.getOrCreate()
```
A... |
686,079 | **I imagine that no, they aren't, because every process has its own memory space, of course.**
But how does the whole JVM thing actually work? Is there a separate JVM in a separate process for every Java program that I launch? Do Java programs running in a system share anything at all? Are there differences between OS... | 2009/03/26 | [
"https://Stackoverflow.com/questions/686079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] | Depends on the implementation, but yes there are ways things are shared. There is/was work underway to change that, and Sun (via Apple) has done a lot of work in sharing data between instances of the VM. There is a link that discusses some of that [here](http://www.javalobby.org/java/forums/t72620.html?start=30).
To d... | Just to follow on to what Kevin mentioned, there are no JVM implementations that I am aware of that allow you to share static variables across JVM instances. As previous answers have stated (correctly) - each JVM instance is it's own process.
Terracotta (which is a clustering technology, not a JVM) allows for arbitrar... |
686,079 | **I imagine that no, they aren't, because every process has its own memory space, of course.**
But how does the whole JVM thing actually work? Is there a separate JVM in a separate process for every Java program that I launch? Do Java programs running in a system share anything at all? Are there differences between OS... | 2009/03/26 | [
"https://Stackoverflow.com/questions/686079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] | If you want to share variables across JVMs, you could look at clustering products like [Terracotta](http://www.terracotta.org/web/display/orgsite/What+Is+Terracotta). They refer to themselves as "network attached memory" and let you share object references across JVMs using replication technology. | Just to follow on to what Kevin mentioned, there are no JVM implementations that I am aware of that allow you to share static variables across JVM instances. As previous answers have stated (correctly) - each JVM instance is it's own process.
Terracotta (which is a clustering technology, not a JVM) allows for arbitrar... |
686,079 | **I imagine that no, they aren't, because every process has its own memory space, of course.**
But how does the whole JVM thing actually work? Is there a separate JVM in a separate process for every Java program that I launch? Do Java programs running in a system share anything at all? Are there differences between OS... | 2009/03/26 | [
"https://Stackoverflow.com/questions/686079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] | >
> In Java, are static class members
> shared among programs?
>
>
>
A class is defined by its full name and the class loader that loaded it. If the same class is within the same JVM process and the two programs loaded the class through the same class loader then the static members are shared. Classloading rules ... | No, static variables aren't between JVMs. Yes, there's a separate JVM process for each Java app you run.
In some implementations I believe they may share *some* resources (e.g. memory for JITted code of JRE classes) but I'm not sure. I believe there's ongoing work to enable more sharing, but still in a robust way. (Yo... |
686,079 | **I imagine that no, they aren't, because every process has its own memory space, of course.**
But how does the whole JVM thing actually work? Is there a separate JVM in a separate process for every Java program that I launch? Do Java programs running in a system share anything at all? Are there differences between OS... | 2009/03/26 | [
"https://Stackoverflow.com/questions/686079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] | >
> In Java, are static class members
> shared among programs?
>
>
>
A class is defined by its full name and the class loader that loaded it. If the same class is within the same JVM process and the two programs loaded the class through the same class loader then the static members are shared. Classloading rules ... | If you want to share variables across JVMs, you could look at clustering products like [Terracotta](http://www.terracotta.org/web/display/orgsite/What+Is+Terracotta). They refer to themselves as "network attached memory" and let you share object references across JVMs using replication technology. |
686,079 | **I imagine that no, they aren't, because every process has its own memory space, of course.**
But how does the whole JVM thing actually work? Is there a separate JVM in a separate process for every Java program that I launch? Do Java programs running in a system share anything at all? Are there differences between OS... | 2009/03/26 | [
"https://Stackoverflow.com/questions/686079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] | No, static variables aren't between JVMs. Yes, there's a separate JVM process for each Java app you run.
In some implementations I believe they may share *some* resources (e.g. memory for JITted code of JRE classes) but I'm not sure. I believe there's ongoing work to enable more sharing, but still in a robust way. (Yo... | You are correct in your assumption. Yes, each JVM is a separate process. You can confirm this by opening Task Manager when you're running two Java programs (sort processes by name and look for java.exe or javaw.exe).
It is possible to make JVMs connect to each other (with local sockets, for instance), but there's noth... |
686,079 | **I imagine that no, they aren't, because every process has its own memory space, of course.**
But how does the whole JVM thing actually work? Is there a separate JVM in a separate process for every Java program that I launch? Do Java programs running in a system share anything at all? Are there differences between OS... | 2009/03/26 | [
"https://Stackoverflow.com/questions/686079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] | No, static variables aren't between JVMs. Yes, there's a separate JVM process for each Java app you run.
In some implementations I believe they may share *some* resources (e.g. memory for JITted code of JRE classes) but I'm not sure. I believe there's ongoing work to enable more sharing, but still in a robust way. (Yo... | Just to follow on to what Kevin mentioned, there are no JVM implementations that I am aware of that allow you to share static variables across JVM instances. As previous answers have stated (correctly) - each JVM instance is it's own process.
Terracotta (which is a clustering technology, not a JVM) allows for arbitrar... |
686,079 | **I imagine that no, they aren't, because every process has its own memory space, of course.**
But how does the whole JVM thing actually work? Is there a separate JVM in a separate process for every Java program that I launch? Do Java programs running in a system share anything at all? Are there differences between OS... | 2009/03/26 | [
"https://Stackoverflow.com/questions/686079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] | >
> In Java, are static class members
> shared among programs?
>
>
>
A class is defined by its full name and the class loader that loaded it. If the same class is within the same JVM process and the two programs loaded the class through the same class loader then the static members are shared. Classloading rules ... | Just to follow on to what Kevin mentioned, there are no JVM implementations that I am aware of that allow you to share static variables across JVM instances. As previous answers have stated (correctly) - each JVM instance is it's own process.
Terracotta (which is a clustering technology, not a JVM) allows for arbitrar... |
686,079 | **I imagine that no, they aren't, because every process has its own memory space, of course.**
But how does the whole JVM thing actually work? Is there a separate JVM in a separate process for every Java program that I launch? Do Java programs running in a system share anything at all? Are there differences between OS... | 2009/03/26 | [
"https://Stackoverflow.com/questions/686079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] | No, static variables aren't between JVMs. Yes, there's a separate JVM process for each Java app you run.
In some implementations I believe they may share *some* resources (e.g. memory for JITted code of JRE classes) but I'm not sure. I believe there's ongoing work to enable more sharing, but still in a robust way. (Yo... | If you want to share variables across JVMs, you could look at clustering products like [Terracotta](http://www.terracotta.org/web/display/orgsite/What+Is+Terracotta). They refer to themselves as "network attached memory" and let you share object references across JVMs using replication technology. |
686,079 | **I imagine that no, they aren't, because every process has its own memory space, of course.**
But how does the whole JVM thing actually work? Is there a separate JVM in a separate process for every Java program that I launch? Do Java programs running in a system share anything at all? Are there differences between OS... | 2009/03/26 | [
"https://Stackoverflow.com/questions/686079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] | you should probably search more in the area of class loading if your main interest is about how static class members are instantiated.
Different threads on the same VM may have their own static class nember instances if they used separate class loaders.
The classic example here would be [Apache Tomcat](http://tomca... | Just to follow on to what Kevin mentioned, there are no JVM implementations that I am aware of that allow you to share static variables across JVM instances. As previous answers have stated (correctly) - each JVM instance is it's own process.
Terracotta (which is a clustering technology, not a JVM) allows for arbitrar... |
686,079 | **I imagine that no, they aren't, because every process has its own memory space, of course.**
But how does the whole JVM thing actually work? Is there a separate JVM in a separate process for every Java program that I launch? Do Java programs running in a system share anything at all? Are there differences between OS... | 2009/03/26 | [
"https://Stackoverflow.com/questions/686079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] | No, static variables aren't between JVMs. Yes, there's a separate JVM process for each Java app you run.
In some implementations I believe they may share *some* resources (e.g. memory for JITted code of JRE classes) but I'm not sure. I believe there's ongoing work to enable more sharing, but still in a robust way. (Yo... | Depends on the implementation, but yes there are ways things are shared. There is/was work underway to change that, and Sun (via Apple) has done a lot of work in sharing data between instances of the VM. There is a link that discusses some of that [here](http://www.javalobby.org/java/forums/t72620.html?start=30).
To d... |
20,990,726 | I've come across this pattern a few times, but am not sure what it is, or how to Google it.
```
class ApiController < ApplicationController
class InvalidAppToken < RuntimeError ; end
class InvalidUserToken < RuntimeError ; end
...
end
``` | 2014/01/08 | [
"https://Stackoverflow.com/questions/20990726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/173634/"
] | It creates custom errors. Doing this you can raise your personalized errors, then rescue them to better handle the app errors.
```
class MyController < ApiController
begin
unless DoSomething(params[:user_token])
raise InvalidUserToken
[...]
end
rescue InvalidUserToken
# manage this error
... | Here is a good option for searching the web with special symbols considered (most major search engines ignore special characters in searches):
<http://symbolhound.com/?q=ruby+%3C+runtimeerror> |
20,990,726 | I've come across this pattern a few times, but am not sure what it is, or how to Google it.
```
class ApiController < ApplicationController
class InvalidAppToken < RuntimeError ; end
class InvalidUserToken < RuntimeError ; end
...
end
``` | 2014/01/08 | [
"https://Stackoverflow.com/questions/20990726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/173634/"
] | It creates custom errors. Doing this you can raise your personalized errors, then rescue them to better handle the app errors.
```
class MyController < ApiController
begin
unless DoSomething(params[:user_token])
raise InvalidUserToken
[...]
end
rescue InvalidUserToken
# manage this error
... | It simply defines custom types of errors. Could be useful to raise very specific errors in your workflow.
[Have a look at this book](http://www.goodreads.com/book/show/11799211-exceptional-ruby) |
1,004,429 | I'm currently working on a decision problem, and for some reason I am struggling with a system of equations, which should be the easiest part of the problem.
The correct answers are $\left(\frac{2}{11},\frac{1}{11} \right)$ in $(p,q)$
I have managed to compute the following utility functions (they are correct)
$U(R)... | 2014/11/03 | [
"https://math.stackexchange.com/questions/1004429",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/173559/"
] | The systems of equations that you have are U(R)-U(B)=0, U(B)-U(N)=0, and U(R)-U(N)=0. This is a linear system in [p q]. Solve the linear system. :) | you have to solve $p-3q-1=a$,$1-11p-q=a$,$-4p-4q=a$ you can use the Gauss algorithm to do this. Do need a hint?
rewriting your system in the form
$p-3q-a=1$ (1)
$-11p-q-a=-1$ (2)
$-4p-4q-a=0$ (3)
then we get $11(1)+(2)=-34q-12a=10$ and $4(1)+(3)=-16q-5a=4$
now we have
$-34q-12a=10$(I)
$-16q-5a=4$(II)
now... |
1,004,429 | I'm currently working on a decision problem, and for some reason I am struggling with a system of equations, which should be the easiest part of the problem.
The correct answers are $\left(\frac{2}{11},\frac{1}{11} \right)$ in $(p,q)$
I have managed to compute the following utility functions (they are correct)
$U(R)... | 2014/11/03 | [
"https://math.stackexchange.com/questions/1004429",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/173559/"
] | Thanks for the replies everyone, I was just being silly.
I managed to get the value of $q$ through the gauss algorithm but I have realised a much simpler solution.
$p-3q-1=1-11p-q=-4p-4q$
$$12p-1=2q$$
$$p=\frac{1+q}{6}$$
$$1-11\left(\frac{1+q}{6} \right )-q=-4 \left(\frac{1+q}{6} \right)-4q$$
$$\frac{1}{6}=\frac{1... | The systems of equations that you have are U(R)-U(B)=0, U(B)-U(N)=0, and U(R)-U(N)=0. This is a linear system in [p q]. Solve the linear system. :) |
1,004,429 | I'm currently working on a decision problem, and for some reason I am struggling with a system of equations, which should be the easiest part of the problem.
The correct answers are $\left(\frac{2}{11},\frac{1}{11} \right)$ in $(p,q)$
I have managed to compute the following utility functions (they are correct)
$U(R)... | 2014/11/03 | [
"https://math.stackexchange.com/questions/1004429",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/173559/"
] | Thanks for the replies everyone, I was just being silly.
I managed to get the value of $q$ through the gauss algorithm but I have realised a much simpler solution.
$p-3q-1=1-11p-q=-4p-4q$
$$12p-1=2q$$
$$p=\frac{1+q}{6}$$
$$1-11\left(\frac{1+q}{6} \right )-q=-4 \left(\frac{1+q}{6} \right)-4q$$
$$\frac{1}{6}=\frac{1... | you have to solve $p-3q-1=a$,$1-11p-q=a$,$-4p-4q=a$ you can use the Gauss algorithm to do this. Do need a hint?
rewriting your system in the form
$p-3q-a=1$ (1)
$-11p-q-a=-1$ (2)
$-4p-4q-a=0$ (3)
then we get $11(1)+(2)=-34q-12a=10$ and $4(1)+(3)=-16q-5a=4$
now we have
$-34q-12a=10$(I)
$-16q-5a=4$(II)
now... |
12,432,103 | Trying to figure out if there's a more succinct or elegant way to write the code below. I'm replacing any slashes in a text box with dashes, then applying a validation rule to the textbox using a custom format string:
```
var bday = $("#home-birthday");
var bdayVal = bday.val();
bday
.val(bdayVal
.replace(... | 2012/09/14 | [
"https://Stackoverflow.com/questions/12432103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/585152/"
] | ```
$("#home-birthday").val(function(i, val) {
return val.replace(/\//g, '-');
}).rules('add', {mydate: true});
``` | ```
var bday = $("#home-birthday");
bday.val(
bday.val().replace(/\//g, '-')
).rules(
"add",
{mydate: true}
);
``` |
33,275,763 | I have tried to get an answer to this but so far no help has been able to do what I want it to.
I have this piece of code, which is meant to look at the selected row and output it's columns into the corresponding text boxes.
```
private void DataGridView01_SelectionChanged(object sender, EventArgs e)
{
if (Data... | 2015/10/22 | [
"https://Stackoverflow.com/questions/33275763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5462762/"
] | HOOKING UP EVENTS:
It is the most basic thing you need to learn to code in VS. In short it means that the event name, here `DataGridView01_SelectionChanged` is connected to the event. To do so one can either use code or one inserts it into the correct slot of the events pane of the property tab. Select the `DataGridVi... | I use a slightly different approach when trying to get data from a datagridview.
Try doing `personIDTextBox.Text = DataGridView01.SelectedCells[0].Value.ToString();`
but instead of the event being on selection change, switch to `CellClick` and change the property of the the datagridview row selection property to full... |
33,275,763 | I have tried to get an answer to this but so far no help has been able to do what I want it to.
I have this piece of code, which is meant to look at the selected row and output it's columns into the corresponding text boxes.
```
private void DataGridView01_SelectionChanged(object sender, EventArgs e)
{
if (Data... | 2015/10/22 | [
"https://Stackoverflow.com/questions/33275763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5462762/"
] | HOOKING UP EVENTS:
It is the most basic thing you need to learn to code in VS. In short it means that the event name, here `DataGridView01_SelectionChanged` is connected to the event. To do so one can either use code or one inserts it into the correct slot of the events pane of the property tab. Select the `DataGridVi... | If you want to display the datagridview selected rows into corresponding textboxes, fine the below steps ,
**Step 1:**
1. Change the DataGridView Selection mode to **FullRowSelect** in Datagridview property.
2. Create the cell click event in Data grid view using property.
[enter image description here](https://i.stac... |
65,378,235 | I am using viewModel in recycler view, but its not updating only if I enter and exist screen not in screen itself:
```
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
viewModel = ViewModelProvider(requireActivity()).get(RideDataViewModel::class.java)
... | 2020/12/20 | [
"https://Stackoverflow.com/questions/65378235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1075753/"
] | You don't show your adapters code, but you need to set the adapters underlying data/list using the `it` reference before calling `notifyDataSetChanged`
```
if (it.isNotEmpty()) {
no_rides.visibility = View.GONE
rideList.adapter!!.data = it // something similar to set the list in your adapter to the new values... | Where are you setting the list on your adapter? In your LiveData observer you're only calling `notifyDataSetChanged()`, which will only make the RecyclerView redraw the items, but you don't set the items first so it has nothing to redraw.
I don't know how your adapter looks, but something along the lines of the code b... |
25,676,019 | I can't seem to figure out why I keep getting this error! It's my first time dealing with Queues. I'm sure the solution is simple and I'm probably missing something basic. Any guidance/help is greatly appreciated:
```
import java.util.LinkedList;
import java.util.Queue;
public class Josephus{
public static void mai... | 2014/09/04 | [
"https://Stackoverflow.com/questions/25676019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2864969/"
] | Add this line to your `ImageButtons`
```
android:onClick="sendNotification"
``` | Did you change
```
Button yourButton = (ImageButton) findViewById(R.id.btn);
```
to
```
ImageButton yourButton = (ImageButton) findViewById(R.id.btn);
```
Also, if you show us some code we will be able to assist you more in your query. |
29,914,628 | I want to display some text in a label.
The label has a fixed size but the text can vary from one single word to a complete sentence.
Is there a way to automatically resize the text in such a way that it is alway displayed in the largest possible font-size without truncating it?
I'm working through tutorials for ... | 2015/04/28 | [
"https://Stackoverflow.com/questions/29914628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4623459/"
] | Set `minimumScaleFactor` property of `UILabel`.
 | You can change the font size to fit the width of the UILabel (non-multiline):
```
myLabel.adjustsFontSizeToFitWidth = true
``` |
5,711,113 | using mobile detection (js or php), is it possible to display top navi made for mobile only?
also i see a lot of mobile detection in php - where is it supposed to be placed?
```
{php}
function isMobileBrowser($user_agent = '') {
foreach (array('iPhone','Android','Windows CE', 'PPC', 'Smartphone', 'IEMobile', 'Opera ... | 2011/04/19 | [
"https://Stackoverflow.com/questions/5711113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/524666/"
] | Have you tried changing the query to:
```
mysql_query("UPDATE `upcoming` SET `title` = '$title', `date` = '$date', `repeat` = '$repeat', `location` = '$location', `location_link` = '$location_link', `group` = '$group', `group_link` = '$group_link', `notes` = '$notes', `enabled` = '$enabled' WHERE `id` = '$key' LIMIT 1... | [repeat](http://dev.mysql.com/doc/refman/5.0/en/repeat-statement.html) is a keyword in MySQL use back ticks `repeat` to use this. |
5,711,113 | using mobile detection (js or php), is it possible to display top navi made for mobile only?
also i see a lot of mobile detection in php - where is it supposed to be placed?
```
{php}
function isMobileBrowser($user_agent = '') {
foreach (array('iPhone','Android','Windows CE', 'PPC', 'Smartphone', 'IEMobile', 'Opera ... | 2011/04/19 | [
"https://Stackoverflow.com/questions/5711113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/524666/"
] | Have you tried changing the query to:
```
mysql_query("UPDATE `upcoming` SET `title` = '$title', `date` = '$date', `repeat` = '$repeat', `location` = '$location', `location_link` = '$location_link', `group` = '$group', `group_link` = '$group_link', `notes` = '$notes', `enabled` = '$enabled' WHERE `id` = '$key' LIMIT 1... | `GROUP` and `REPEAT` are reserved keywords in MySQL so you have to "escape" it with backticks:
```
`group` = '$group'
`repeat` = '...'
```
Also I'm making an assumption here, but you shouldn't wrap `$key` in quotes because it is an integer value. Also make sure you type cast it to an int by doing `int($key)`. |
5,711,113 | using mobile detection (js or php), is it possible to display top navi made for mobile only?
also i see a lot of mobile detection in php - where is it supposed to be placed?
```
{php}
function isMobileBrowser($user_agent = '') {
foreach (array('iPhone','Android','Windows CE', 'PPC', 'Smartphone', 'IEMobile', 'Opera ... | 2011/04/19 | [
"https://Stackoverflow.com/questions/5711113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/524666/"
] | Have you tried changing the query to:
```
mysql_query("UPDATE `upcoming` SET `title` = '$title', `date` = '$date', `repeat` = '$repeat', `location` = '$location', `location_link` = '$location_link', `group` = '$group', `group_link` = '$group_link', `notes` = '$notes', `enabled` = '$enabled' WHERE `id` = '$key' LIMIT 1... | Repeat is a mySQL reserved word: <http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html>
Try surrounding your column names with backticks. |
5,711,113 | using mobile detection (js or php), is it possible to display top navi made for mobile only?
also i see a lot of mobile detection in php - where is it supposed to be placed?
```
{php}
function isMobileBrowser($user_agent = '') {
foreach (array('iPhone','Android','Windows CE', 'PPC', 'Smartphone', 'IEMobile', 'Opera ... | 2011/04/19 | [
"https://Stackoverflow.com/questions/5711113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/524666/"
] | `GROUP` and `REPEAT` are reserved keywords in MySQL so you have to "escape" it with backticks:
```
`group` = '$group'
`repeat` = '...'
```
Also I'm making an assumption here, but you shouldn't wrap `$key` in quotes because it is an integer value. Also make sure you type cast it to an int by doing `int($key)`. | [repeat](http://dev.mysql.com/doc/refman/5.0/en/repeat-statement.html) is a keyword in MySQL use back ticks `repeat` to use this. |
5,711,113 | using mobile detection (js or php), is it possible to display top navi made for mobile only?
also i see a lot of mobile detection in php - where is it supposed to be placed?
```
{php}
function isMobileBrowser($user_agent = '') {
foreach (array('iPhone','Android','Windows CE', 'PPC', 'Smartphone', 'IEMobile', 'Opera ... | 2011/04/19 | [
"https://Stackoverflow.com/questions/5711113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/524666/"
] | `GROUP` and `REPEAT` are reserved keywords in MySQL so you have to "escape" it with backticks:
```
`group` = '$group'
`repeat` = '...'
```
Also I'm making an assumption here, but you shouldn't wrap `$key` in quotes because it is an integer value. Also make sure you type cast it to an int by doing `int($key)`. | Repeat is a mySQL reserved word: <http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html>
Try surrounding your column names with backticks. |
714,686 | Mina has $5$ more marbles than Kristy,
Kristy has $2$ more marbles than Seb,
altogether they have $30$ marbles.
How many marbles do they have each? | 2014/03/16 | [
"https://math.stackexchange.com/questions/714686",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/135869/"
] | Hint: Construct an equation, given $x = $ the number of marbles that Seb has.
If Seb has $x$ marbles, how many does Kristy have? $\;\;(x + \;?\;)$
And then how many marbles does Mina have? $\;\;[(x +\; ?\;) \;+ \;??]$
Add the number of marbles that Seb has plus those of Kristy, plus those of Mina, and set equal to $... | s = # of marbles that Seb has, k = # of marbles of Kristy, and m = # of marbles of Mina. Then:
m = k + 5, k = s + 2, and so: s + s + 2 + s + 2 + 5 = 30. So 3s + 9 = 30 so 3s = 21 and s = 7.
Seb has 7 marbles, Kristy has 9 marbles, and Mina has 14 marbles. |
44,749,070 | I am trying to autofill text in a range(N6:N125) in excel 2013 via vba. My code works fine when range refers a single cell but not for a range. could you help me to find my mistake? My code is
```
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("N6:N125") = "" Then
Range("N6:N125").value = "My T... | 2017/06/25 | [
"https://Stackoverflow.com/questions/44749070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5892575/"
] | If you want to fill only the empty cells in **N6** through **N125** and some of the cells may already have values, but none have formulas, then a loop is not actually needed:
```
Sub marine()
Dim r As Range, s As String
Set r = Range("N6:N125")
s = "=IF(N6:N125="""",""MyText"",N6:N125)"
r.Value = Evalu... | >
>
> ```
> If Range("N6:N125") = "" Then
>
> ```
>
>
This doesn't do the job. You will need to do this test cell-by-cell. An easier alternative would be this:
```
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Range("N6:N125").SpecialCells(xlCellTypeBlanks).value = "My Tex... |
44,749,070 | I am trying to autofill text in a range(N6:N125) in excel 2013 via vba. My code works fine when range refers a single cell but not for a range. could you help me to find my mistake? My code is
```
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("N6:N125") = "" Then
Range("N6:N125").value = "My T... | 2017/06/25 | [
"https://Stackoverflow.com/questions/44749070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5892575/"
] | If you want to fill only the empty cells in **N6** through **N125** and some of the cells may already have values, but none have formulas, then a loop is not actually needed:
```
Sub marine()
Dim r As Range, s As String
Set r = Range("N6:N125")
s = "=IF(N6:N125="""",""MyText"",N6:N125)"
r.Value = Evalu... | You can use:
```
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Selection
For Each cell In Selection
If cell = "" Then
cell.Value = "My Text"
End If
Next cell
End With
End Sub
```
This code will test each cell in your selection if empty and write "My Text" in it, but if it is not empty it wil... |
30,997 | When playing guitar,especially improvising,is it best to think of the notes a actual lettered notes or Scale degrees related to a tonic ? Since the keys are easily movable , I'm thinking that its better just to know the degree you want to play and knowing where that is related to the tonic. | 2015/03/22 | [
"https://music.stackexchange.com/questions/30997",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/950/"
] | Every guitar player is different so it depends. I have a friend who took piano lessons and read music before learning guitar and she would much rather know the names of the notes.
I play based on sound and feel and knowing where to put my fingers relative to where they are now to get to the note I want next relative ... | I'd memorize the relation of the roots to the tonic for analysis and overview. However, I find it more musical, if I have to try and verbalize, to remember the relation of a note and the current (and sometimes previous and/or next) root. |
30,997 | When playing guitar,especially improvising,is it best to think of the notes a actual lettered notes or Scale degrees related to a tonic ? Since the keys are easily movable , I'm thinking that its better just to know the degree you want to play and knowing where that is related to the tonic. | 2015/03/22 | [
"https://music.stackexchange.com/questions/30997",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/950/"
] | Guitar is a three-dimensional instrument, where you are almost forced to know things in multiple locations.
Here's something I think is of paramount importance: when you learn a tune on guitar, you should always practice playing chord and melody
together. That way you really learn to link the two things together.
It... | I do think some of the answers so far are awesome. Let me please add by indicating something I was taught in music school.
The mode of a sequence of notes is also important, as the mode one is in can actually alter what the ear "hears."
For example the relative minor of CM is Am. The "notes" are exactly the same when... |
30,997 | When playing guitar,especially improvising,is it best to think of the notes a actual lettered notes or Scale degrees related to a tonic ? Since the keys are easily movable , I'm thinking that its better just to know the degree you want to play and knowing where that is related to the tonic. | 2015/03/22 | [
"https://music.stackexchange.com/questions/30997",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/950/"
] | With the guitar being a positional instrument, meaning one can play the same tune in many different keys but retain the same fingering and strings, merely moving where on the neck the tune is played, then knowing note names as the tune unfolds is not necessary. The relationship between the tonic and other notes, as far... | It probably depends on how you 'hear' music.
For example ...
Absolute pitch :
I have recently been playing with a folk vocalist who doen'st play an instrument so we spent a bit of time getting the song into the right key for her. Her first choice was always pretty much the orignal key of a recording she'd learnt fro... |
30,997 | When playing guitar,especially improvising,is it best to think of the notes a actual lettered notes or Scale degrees related to a tonic ? Since the keys are easily movable , I'm thinking that its better just to know the degree you want to play and knowing where that is related to the tonic. | 2015/03/22 | [
"https://music.stackexchange.com/questions/30997",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/950/"
] | Every guitar player is different so it depends. I have a friend who took piano lessons and read music before learning guitar and she would much rather know the names of the notes.
I play based on sound and feel and knowing where to put my fingers relative to where they are now to get to the note I want next relative ... | Good question. It depends on how you interpret music in your mind. I myself prefer scale degrees. If you can easily understand the space between the tonic and the actual notes, then you should choose the scale degrees also. However, you should really keep in mind that you have a good outcome. |
30,997 | When playing guitar,especially improvising,is it best to think of the notes a actual lettered notes or Scale degrees related to a tonic ? Since the keys are easily movable , I'm thinking that its better just to know the degree you want to play and knowing where that is related to the tonic. | 2015/03/22 | [
"https://music.stackexchange.com/questions/30997",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/950/"
] | Every guitar player is different so it depends. I have a friend who took piano lessons and read music before learning guitar and she would much rather know the names of the notes.
I play based on sound and feel and knowing where to put my fingers relative to where they are now to get to the note I want next relative ... | I do think some of the answers so far are awesome. Let me please add by indicating something I was taught in music school.
The mode of a sequence of notes is also important, as the mode one is in can actually alter what the ear "hears."
For example the relative minor of CM is Am. The "notes" are exactly the same when... |
30,997 | When playing guitar,especially improvising,is it best to think of the notes a actual lettered notes or Scale degrees related to a tonic ? Since the keys are easily movable , I'm thinking that its better just to know the degree you want to play and knowing where that is related to the tonic. | 2015/03/22 | [
"https://music.stackexchange.com/questions/30997",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/950/"
] | With the guitar being a positional instrument, meaning one can play the same tune in many different keys but retain the same fingering and strings, merely moving where on the neck the tune is played, then knowing note names as the tune unfolds is not necessary. The relationship between the tonic and other notes, as far... | I'd memorize the relation of the roots to the tonic for analysis and overview. However, I find it more musical, if I have to try and verbalize, to remember the relation of a note and the current (and sometimes previous and/or next) root. |
30,997 | When playing guitar,especially improvising,is it best to think of the notes a actual lettered notes or Scale degrees related to a tonic ? Since the keys are easily movable , I'm thinking that its better just to know the degree you want to play and knowing where that is related to the tonic. | 2015/03/22 | [
"https://music.stackexchange.com/questions/30997",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/950/"
] | With the guitar being a positional instrument, meaning one can play the same tune in many different keys but retain the same fingering and strings, merely moving where on the neck the tune is played, then knowing note names as the tune unfolds is not necessary. The relationship between the tonic and other notes, as far... | Guitar is a three-dimensional instrument, where you are almost forced to know things in multiple locations.
Here's something I think is of paramount importance: when you learn a tune on guitar, you should always practice playing chord and melody
together. That way you really learn to link the two things together.
It... |
30,997 | When playing guitar,especially improvising,is it best to think of the notes a actual lettered notes or Scale degrees related to a tonic ? Since the keys are easily movable , I'm thinking that its better just to know the degree you want to play and knowing where that is related to the tonic. | 2015/03/22 | [
"https://music.stackexchange.com/questions/30997",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/950/"
] | Guitar is a three-dimensional instrument, where you are almost forced to know things in multiple locations.
Here's something I think is of paramount importance: when you learn a tune on guitar, you should always practice playing chord and melody
together. That way you really learn to link the two things together.
It... | I think it would be better to think the scale degrees.
For instance, let's say you play E (V) and then Am (i); if you think in scale degrees, then you will lead the notes that consist the V (E major chord) to the tonic chord (A minor). This way, you make the listener believe that there is some connection between the ... |
30,997 | When playing guitar,especially improvising,is it best to think of the notes a actual lettered notes or Scale degrees related to a tonic ? Since the keys are easily movable , I'm thinking that its better just to know the degree you want to play and knowing where that is related to the tonic. | 2015/03/22 | [
"https://music.stackexchange.com/questions/30997",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/950/"
] | Every guitar player is different so it depends. I have a friend who took piano lessons and read music before learning guitar and she would much rather know the names of the notes.
I play based on sound and feel and knowing where to put my fingers relative to where they are now to get to the note I want next relative ... | I think it would be better to think the scale degrees.
For instance, let's say you play E (V) and then Am (i); if you think in scale degrees, then you will lead the notes that consist the V (E major chord) to the tonic chord (A minor). This way, you make the listener believe that there is some connection between the ... |
30,997 | When playing guitar,especially improvising,is it best to think of the notes a actual lettered notes or Scale degrees related to a tonic ? Since the keys are easily movable , I'm thinking that its better just to know the degree you want to play and knowing where that is related to the tonic. | 2015/03/22 | [
"https://music.stackexchange.com/questions/30997",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/950/"
] | Every guitar player is different so it depends. I have a friend who took piano lessons and read music before learning guitar and she would much rather know the names of the notes.
I play based on sound and feel and knowing where to put my fingers relative to where they are now to get to the note I want next relative ... | It probably depends on how you 'hear' music.
For example ...
Absolute pitch :
I have recently been playing with a folk vocalist who doen'st play an instrument so we spent a bit of time getting the song into the right key for her. Her first choice was always pretty much the orignal key of a recording she'd learnt fro... |
14,167,076 | I was trying to make a function `createscalingwindow` that calls `CreateWindowEx` and writes the address's of the HWND used in `CreateWindowEx` to a vector, followed by it's initial size and position values.
Another function I made called `scalewindowsize` was supposed to take two given windows and scale the size of ... | 2013/01/05 | [
"https://Stackoverflow.com/questions/14167076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1934608/"
] | In both window procedures your sending the parameter HWND to scalewindow; not the global. Thus they're different addresses. Name resolution uses the "closest" variable, which in both cases is the HWND param, not the HWND global you're trying to use.
Example:
```
LRESULT CALLBACK mainproc(HWND mainwin, UINT message, W... | While WhozCraig already answered the question you asked, I'll explain how to get what you really wanted. It all boils down to your decision to store the address of a `HWND` being the wrong decision. Simply store the `HWND` - it is already pointer-sized so you're not wasting any space or performing costly copy operation... |
17,115,420 | I'm learning JS and have to do a trivia game, where each question has 4 possible answers. The questions are given to me in a string with "#", which separates the questions, and "@", which separates each question in its id, its text, and its correct answer.
For the answers I have a string with similar format: idQuestion... | 2013/06/14 | [
"https://Stackoverflow.com/questions/17115420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2484181/"
] | Let me see if I understand your problem correctly...
>
> I know I did it in a very precarious way (I'm using 4 arrays! .\_.),
> but I can't figure another way to do it.
>
>
>
```
var data = '1@1@hello#2@1@foo#1@2@world';
var questions = data.split('#').map(function(q) {
q = q.split('@');
return {
idQues... | Is this what you're looking for?
```
var indexAnswers = strAnswers.split("#");
var auxArray = new Array ();
var auxArray2 = new Array();
var assocAnswers = new Array ();
for (var b=0; b<indexAnswers.length; b++){
auxArray = indexAnswers[b].split("@");
if (auxArray[0].toString() == someId.toString()) {
... |
17,115,420 | I'm learning JS and have to do a trivia game, where each question has 4 possible answers. The questions are given to me in a string with "#", which separates the questions, and "@", which separates each question in its id, its text, and its correct answer.
For the answers I have a string with similar format: idQuestion... | 2013/06/14 | [
"https://Stackoverflow.com/questions/17115420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2484181/"
] | I got pretty lazy while writing it, but this fiddler will show how you can parse it and this turns it into an array of objects so you can work with it easier. There is also a method to easily find an element based on a collection and the id of the element.
There probably is a better way to for the `for` loops but I ca... | Is this what you're looking for?
```
var indexAnswers = strAnswers.split("#");
var auxArray = new Array ();
var auxArray2 = new Array();
var assocAnswers = new Array ();
for (var b=0; b<indexAnswers.length; b++){
auxArray = indexAnswers[b].split("@");
if (auxArray[0].toString() == someId.toString()) {
... |
39,733,402 | So I am new to Django and am currently trying to build registration into my app. I have already followed this [guide](http://code.techandstartup.com/django/registration/#app-download). However I am running into an issue in which the application is not able to find the template somehow.
>
>
> ```
> Traceback:
>
> ``... | 2016/09/27 | [
"https://Stackoverflow.com/questions/39733402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6307675/"
] | Please check that you have defined TEMPLATES\_DIRS properly
In Django 1.8 upwards:
```
TEMPLATES = [
{
'DIRS': [
# insert your TEMPLATE_DIRS here (absolute path)
],
},
]
``` | For Django 1.11.x your TEMPLATES should look like this:
```
`TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': (os.path.join(os.path.dirname(__file__), '..', 'templates').replace('\\','/'),),
'OPTIONS': {
'loaders': (
'django.t... |
52,592,819 | I've distilled this down to as few lines of code as I could to get to the bottom of this issue.
currently these are the config constants below (I'm using a array of length 1 to represent tokenised words I'm doing semantic analysis on.
```
export const top_words = 10000;
export const max_review_length = 1
export cons... | 2018/10/01 | [
"https://Stackoverflow.com/questions/52592819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9063772/"
] | If you are using TypeScript you need to specify what predict() returns in such way:
```
(model.predict(...) as tf.Tensor).print()
```
since predict() can return either a Tensor or Tensor[] | Ok, so one thing thats easy to forget if you're not used to dealing with Python. Python is syncronous!
the model is async so to solve this problem in this code.
history (the result)
```
history.then(result => {
model.predict(tftensor2d([10)).print()
console.log('loss ', result.history.loss)
}
```
otherwise the ... |
27,442,340 | We want to share `.DotSettings` between several solutions. The goal is to have *one* `CodeStyle.DotSettings` that we reference as a layer in all our `X.sln.Dotsettings`. However, I am seeing unexpected behaviour when I add the layer.
I go to "Manage Options", right click "Solution X team-shared" -> "Add Layer" -> "Ope... | 2014/12/12 | [
"https://Stackoverflow.com/questions/27442340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7084/"
] | See the corresponding issue in JetBrains' tracker: [RSRP-339002](https://youtrack.jetbrains.com/issue/RSRP-339002).
Don't remove anything: ReSharper tries to load the file from both paths, so you should be fine. I've been using a similar setup (a shared and versioned DotSettings between multiple solutions) for the pas... | R# keeps both absolute and relative paths to accommodate all scenarios for using the injected file layers. Relative path works for source-control-hosted solutions with injected layer file also checked in to the same source control. Absolute path works for injecting a file from an outside resource, like a global path on... |
14,677,314 | I have four jquery sliders in a page with these scripts:
```
$(document).ready(function(){
$("#information").click(function(){
$("#information_show").slideToggle("medium");
});
});
$(document).ready(function(){
$("#menu").click(function(){
$("#menu_slide").slideToggle("medium");
});
});
$(document).r... | 2013/02/03 | [
"https://Stackoverflow.com/questions/14677314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | First of all, you probably don't want to put your code in that class definition...
```
import numpy as np
def main():
m = np.random.random((3, 4))
mask = (m[2] > 0.5) & (m[2] < 0.8) # put your conditions here
# instead of 0.5 and 0.8 you can use
... | If you can write your condition as a simple function
```
def condition(value):
# return True or False depending on value
```
then you could select your subarrays like this:
```
cond = condition(a[2])
subarray0 = a[0,cond]
subarray1 = a[1,cond]
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.