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 |
|---|---|---|---|---|---|
514,110 | I came across the following probability problem:
Start with $1$ black ball and $1$ white ball in a box. At each step, we will put in a new ball. If there are $a$ black balls and $b$ white balls, we put in a black ball with probability $\dfrac{a}{a+b}$ and a white ball with probability $\dfrac{b}{a+b}$. We do this unti... | 2013/10/04 | [
"https://math.stackexchange.com/questions/514110",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/79379/"
] | You solve $18 u + 14 v = 2 = \gcd(18,14).$ Solve $2 w + 63 z = 1.$ Combine to get $18 x + 14 y + 63 z = 1.$ Then multiply all by $5.$ | **Hint** $\ \color{#c00}{18\!-\!14}\,\mid\, 63\!+\!1 $ $\, \Rightarrow\,\overbrace{16\,(18\!-\! 14)-63 = 1}^{\textstyle 18x + 14y + 63z = 1}.\,$ Scale that by $\,5\,$ to get $\,d=5\,$ on RHS.
**Remark** $\ $ The idea is simply to search for a "small" linear combination $\,n = \color{#c00}{ia+jb}\,$ of two elements $\,... |
2,158,411 | I would like there to be spaces between rows of my table in IE7/8. I did this:
```
.selector tr {
display: block;
padding-bottom: 3px;
}
```
Which works in Firefox but not in IE7/8 where the 3px gap doesn't appear. | 2010/01/28 | [
"https://Stackoverflow.com/questions/2158411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/95944/"
] | Even if this may work in some browsers, changing the `display` of a table row feels like an awful hack. Don't do it.
The only valid, cross-browser way that I know of is to give each `td` some `padding-bottom`, or maybe a transparent `border`:
```
.selector tr td { padding-bottom: 3px }
``` | Why not do:
```
.selector tr td {
display: block;
padding-bottom: 3px;
}
```
If you're also using `<th>` tags then do:
```
.selector tr td, .selector tr th {
display: block;
padding-bottom: 3px;
}
```
You should not need that `display: block;` rule, but perhaps it's overriding something else you h... |
20,848,302 | How can I create a `for` loop for this, in VB.Net? (shown below)
the code below adds values to my chart and is populated by labels that are stored on the windows form.
```
With .Points
.AddXY(0, 0)
.AddXY(1, LblWkEff1.Text)
.AddXY(2, LblWkEff2.Text)
.AddXY(3, LblWkEff3.Text)
.AddXY(4, LblWkEff4.Te... | 2013/12/30 | [
"https://Stackoverflow.com/questions/20848302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3116910/"
] | I had this issue declaring **Composite Keys** on a model class.
If you are wanting an auto-incrementing id field for a composite key (ie. more than 1 `db.Column(..)` definition with `primary_key=True`, then adding `autoincrement=True` fixed the issue for me.
```py
class S3Object(db.Model):
__tablename__ = 's3_obj... | In my case, I just added the id as external parameter, without relying on sqlalchemy |
20,848,302 | How can I create a `for` loop for this, in VB.Net? (shown below)
the code below adds values to my chart and is populated by labels that are stored on the windows form.
```
With .Points
.AddXY(0, 0)
.AddXY(1, LblWkEff1.Text)
.AddXY(2, LblWkEff2.Text)
.AddXY(3, LblWkEff3.Text)
.AddXY(4, LblWkEff4.Te... | 2013/12/30 | [
"https://Stackoverflow.com/questions/20848302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3116910/"
] | So I landed here with an issue that my SQLite table wasn't auto-incrementing the primary key. I have a slightly complex use case where I want to use postgres in production but sqlite for testing to make life a bit easier when continuously deploying.
It turns out SQLite doesn't like columns defined as BigIntegers, and ... | In my case, I just added the id as external parameter, without relying on sqlalchemy |
20,848,302 | How can I create a `for` loop for this, in VB.Net? (shown below)
the code below adds values to my chart and is populated by labels that are stored on the windows form.
```
With .Points
.AddXY(0, 0)
.AddXY(1, LblWkEff1.Text)
.AddXY(2, LblWkEff2.Text)
.AddXY(3, LblWkEff3.Text)
.AddXY(4, LblWkEff4.Te... | 2013/12/30 | [
"https://Stackoverflow.com/questions/20848302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3116910/"
] | Nothing is wrong with the above code. In fact, you don't even need `autoincrement=True` or `db.Sequence('seq_reg_id', start=1, increment=1),` as SQLAlchemy will automatically set the first `Integer` PK column that's not marked as a FK as `autoincrement=True`.
Here, I've put together a working setup based on yours. SQL... | Your id auto increments by default even without setting the autoincrement=True flag.
So there's nothing wrong with using
```
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
```
The error you're getting is as a result of attempting to populate the table with an id attribute. Your insert query should... |
20,848,302 | How can I create a `for` loop for this, in VB.Net? (shown below)
the code below adds values to my chart and is populated by labels that are stored on the windows form.
```
With .Points
.AddXY(0, 0)
.AddXY(1, LblWkEff1.Text)
.AddXY(2, LblWkEff2.Text)
.AddXY(3, LblWkEff3.Text)
.AddXY(4, LblWkEff4.Te... | 2013/12/30 | [
"https://Stackoverflow.com/questions/20848302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3116910/"
] | So I landed here with an issue that my SQLite table wasn't auto-incrementing the primary key. I have a slightly complex use case where I want to use postgres in production but sqlite for testing to make life a bit easier when continuously deploying.
It turns out SQLite doesn't like columns defined as BigIntegers, and ... | You cannot add "autoincrement" flag in column definition, moreover add "\_\_table\_\_args" attribute just after \_\_table\_\_name.
Something like this:
>
>
> ```
> __tablename__ = 'table-name'
> __table_args__ = {'sqlite_autoincrement': True} -> This adds autoincrement to your primary key.
>
> ```
>
>
Tr... |
20,848,302 | How can I create a `for` loop for this, in VB.Net? (shown below)
the code below adds values to my chart and is populated by labels that are stored on the windows form.
```
With .Points
.AddXY(0, 0)
.AddXY(1, LblWkEff1.Text)
.AddXY(2, LblWkEff2.Text)
.AddXY(3, LblWkEff3.Text)
.AddXY(4, LblWkEff4.Te... | 2013/12/30 | [
"https://Stackoverflow.com/questions/20848302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3116910/"
] | Nothing is wrong with the above code. In fact, you don't even need `autoincrement=True` or `db.Sequence('seq_reg_id', start=1, increment=1),` as SQLAlchemy will automatically set the first `Integer` PK column that's not marked as a FK as `autoincrement=True`.
Here, I've put together a working setup based on yours. SQL... | I had this issue declaring **Composite Keys** on a model class.
If you are wanting an auto-incrementing id field for a composite key (ie. more than 1 `db.Column(..)` definition with `primary_key=True`, then adding `autoincrement=True` fixed the issue for me.
```py
class S3Object(db.Model):
__tablename__ = 's3_obj... |
20,848,302 | How can I create a `for` loop for this, in VB.Net? (shown below)
the code below adds values to my chart and is populated by labels that are stored on the windows form.
```
With .Points
.AddXY(0, 0)
.AddXY(1, LblWkEff1.Text)
.AddXY(2, LblWkEff2.Text)
.AddXY(3, LblWkEff3.Text)
.AddXY(4, LblWkEff4.Te... | 2013/12/30 | [
"https://Stackoverflow.com/questions/20848302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3116910/"
] | Nothing is wrong with the above code. In fact, you don't even need `autoincrement=True` or `db.Sequence('seq_reg_id', start=1, increment=1),` as SQLAlchemy will automatically set the first `Integer` PK column that's not marked as a FK as `autoincrement=True`.
Here, I've put together a working setup based on yours. SQL... | So I landed here with an issue that my SQLite table wasn't auto-incrementing the primary key. I have a slightly complex use case where I want to use postgres in production but sqlite for testing to make life a bit easier when continuously deploying.
It turns out SQLite doesn't like columns defined as BigIntegers, and ... |
20,848,302 | How can I create a `for` loop for this, in VB.Net? (shown below)
the code below adds values to my chart and is populated by labels that are stored on the windows form.
```
With .Points
.AddXY(0, 0)
.AddXY(1, LblWkEff1.Text)
.AddXY(2, LblWkEff2.Text)
.AddXY(3, LblWkEff3.Text)
.AddXY(4, LblWkEff4.Te... | 2013/12/30 | [
"https://Stackoverflow.com/questions/20848302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3116910/"
] | I think you do not need the autoincrement once you set ,
```
id = db.Column(db.Integer , primary_key=True , autoincrement=True)
```
I think that it should be ,
```
id = db.Column(db.Integer , primary_key=True)
```
it will give you the uniqueness your looking for . | You cannot add "autoincrement" flag in column definition, moreover add "\_\_table\_\_args" attribute just after \_\_table\_\_name.
Something like this:
>
>
> ```
> __tablename__ = 'table-name'
> __table_args__ = {'sqlite_autoincrement': True} -> This adds autoincrement to your primary key.
>
> ```
>
>
Tr... |
20,848,302 | How can I create a `for` loop for this, in VB.Net? (shown below)
the code below adds values to my chart and is populated by labels that are stored on the windows form.
```
With .Points
.AddXY(0, 0)
.AddXY(1, LblWkEff1.Text)
.AddXY(2, LblWkEff2.Text)
.AddXY(3, LblWkEff3.Text)
.AddXY(4, LblWkEff4.Te... | 2013/12/30 | [
"https://Stackoverflow.com/questions/20848302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3116910/"
] | You cannot add "autoincrement" flag in column definition, moreover add "\_\_table\_\_args" attribute just after \_\_table\_\_name.
Something like this:
>
>
> ```
> __tablename__ = 'table-name'
> __table_args__ = {'sqlite_autoincrement': True} -> This adds autoincrement to your primary key.
>
> ```
>
>
Tr... | In my case, I just added the id as external parameter, without relying on sqlalchemy |
20,848,302 | How can I create a `for` loop for this, in VB.Net? (shown below)
the code below adds values to my chart and is populated by labels that are stored on the windows form.
```
With .Points
.AddXY(0, 0)
.AddXY(1, LblWkEff1.Text)
.AddXY(2, LblWkEff2.Text)
.AddXY(3, LblWkEff3.Text)
.AddXY(4, LblWkEff4.Te... | 2013/12/30 | [
"https://Stackoverflow.com/questions/20848302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3116910/"
] | Nothing is wrong with the above code. In fact, you don't even need `autoincrement=True` or `db.Sequence('seq_reg_id', start=1, increment=1),` as SQLAlchemy will automatically set the first `Integer` PK column that's not marked as a FK as `autoincrement=True`.
Here, I've put together a working setup based on yours. SQL... | I had the same error, even after adding `autoincrement=True`.
The problem was I already had the migration created. So I downgraded to the previous migration, deleted the migration, created the migration again and upgraded.
Then the error was gone.
Hope it helps someone stuck on this.
Wrapping off: Add `autoincremen... |
20,848,302 | How can I create a `for` loop for this, in VB.Net? (shown below)
the code below adds values to my chart and is populated by labels that are stored on the windows form.
```
With .Points
.AddXY(0, 0)
.AddXY(1, LblWkEff1.Text)
.AddXY(2, LblWkEff2.Text)
.AddXY(3, LblWkEff3.Text)
.AddXY(4, LblWkEff4.Te... | 2013/12/30 | [
"https://Stackoverflow.com/questions/20848302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3116910/"
] | I had the same error, even after adding `autoincrement=True`.
The problem was I already had the migration created. So I downgraded to the previous migration, deleted the migration, created the migration again and upgraded.
Then the error was gone.
Hope it helps someone stuck on this.
Wrapping off: Add `autoincremen... | In my case, I just added the id as external parameter, without relying on sqlalchemy |
36,628,326 | First, sorry for bad english...
I created the project spark-spring (<https://github.com/rascorp/spark-spring>) to provide an easy way to put spring context into spark-java framework.
I create a test to check if the server starts and returns a value. Running in my personal computer, all tests run ok, but in travis-ci ... | 2016/04/14 | [
"https://Stackoverflow.com/questions/36628326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6205025/"
] | I found the problem!
The problem occurs because the service methods are not available when the test runs. To fix, I need to call the following code before run the test.
```
/**
* Waits for the spark server to be initialized.
* If it's already initialized will return immediately
*/
Spark.awaitInitialization();
``` | The Travis CI output is saying that one test is failing. Travis CI doesn't necessarily run in the same conditions as your local machine. See what you can do to get that one test to pass on both machines. After all, if you can't get it to pass with Travis, how can you know it will work on any other computer but your own... |
22,268 | I know this is a vague question, please just spend time on it if you are in the mood, I don't need to be flamed for not being more precise.
I'm having a problem with a theme I'm developing, for some reason it breaks the export function of WordPress.
I'm not asking for anyone to solve my problems here, but after havin... | 2011/07/07 | [
"https://wordpress.stackexchange.com/questions/22268",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2071/"
] | The basic idea for debug here is that theme apparently influences something it totally should not. Either something is done in a wrong way or in a wrong place.
1. Check that theme is not running any functionality directly in `functions.php`.
2. Check that all of theme's functionality runs on appropriate hooks.
3. For ... | The problem was that I had this code in one of my theme admin pages:
```
if (isset($_GET['download']))
check_admin_referer('mytheme_options_storage');
```
which got triggered by the export request since that also sets $\_GET['download'] var.
The solution I came up with was to make sure my check only ran when t... |
29,656,203 | I'm trying to trim a string that I get from doing system("dsquery user");
The output is like this from running the command:
```
"CN=Administrator,CN=Users,DC=server,DC=local"
"CN=Guest,CN=Users,DC=server,DC=local"
"CN=krbtgt,CN=Users,DC=server,DC=local"
```
What I'm trying to do is that I need to get ev... | 2015/04/15 | [
"https://Stackoverflow.com/questions/29656203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4058847/"
] | This problem can be solved easily using [regular expressions](http://php.net/manual/en/function.preg-match-all.php):
```
$out = <<<END
"CN=Administrator,CN=Users,DC=server,DC=local"
"CN=Guest,CN=Users,DC=server,DC=local"
"CN=krbtgt,CN=Users,DC=server,DC=local"
END;
$matches = array();
preg_match_all('/CN=... | You need to define $a before using it:
```
$s="CN=Administrator,CN=Users,DC=server,DC=local CN=Guest,CN=Users,DC=server,DC=local CN=krbtgt,CN=Users,DC=server,DC=local";
$t=explode(" ", str_replace('"', "", $s));
$a = array();
for($i=0;isset($t[$i]);$i++){
$y=explode("=", $t[$i]);
$a[]=substr($y[1], 0, strpos($... |
29,656,203 | I'm trying to trim a string that I get from doing system("dsquery user");
The output is like this from running the command:
```
"CN=Administrator,CN=Users,DC=server,DC=local"
"CN=Guest,CN=Users,DC=server,DC=local"
"CN=krbtgt,CN=Users,DC=server,DC=local"
```
What I'm trying to do is that I need to get ev... | 2015/04/15 | [
"https://Stackoverflow.com/questions/29656203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4058847/"
] | This problem can be solved easily using [regular expressions](http://php.net/manual/en/function.preg-match-all.php):
```
$out = <<<END
"CN=Administrator,CN=Users,DC=server,DC=local"
"CN=Guest,CN=Users,DC=server,DC=local"
"CN=krbtgt,CN=Users,DC=server,DC=local"
END;
$matches = array();
preg_match_all('/CN=... | Finally solved it by using regex.
The problem was that the system output only gave me the last line so I needed to change the system to a exec and use the output variable as an array and make a loop through it.
This is the final solution:
```
<?php
$s=exec("dsquery user", $retval);
echo "<br \>";
$matches = array();... |
28,740,686 | I have at least one `UIBarButtonItem's` in every `UIViewController` in my project, everything is in a UINavigationController and the `UINavigationBar` is blue and the `UIBarButtonItem's` should be white.
In the simulator they are white... but in device they are lightgray as you can see in the pictures below:
**Simula... | 2015/02/26 | [
"https://Stackoverflow.com/questions/28740686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1296280/"
] | I found what was wrong.......... In settings there is an option under General/Accessibility/Increase Contrast called Darker colors... I had that turned on which made tint color darker (of course). So silly. | That is most likely due to alpha (transparency) being on for the top NavigationBar. When the content slides under the top bar it shows a percentage of the underlying view causing your whites to not be white.
You can eliminate that by turning transparency on the NavigationBar off:
```
self.navigationController.navigat... |
14,817,070 | We are porting an app from 10.6 to 10.8. I am looking at dylib we load in app. I am facing very unusual crash in **Garbage Collection Work Queue** with following message.
```
malloc: Thread::suspend(): unable to suspend a thread: err = 268435459, Thread 0x111000000: _pthread = 0x108129000, _thread = 0x8b07, _stack_b... | 2013/02/11 | [
"https://Stackoverflow.com/questions/14817070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/993179/"
] | ```
It is expected.
Starting with OSX 10.8, Garbage collection is deprecated. So CG is unable to suspend the threads to perform its duty. As a result you get all the issues you are facing.
If you want to develop for 10.8, you need to convert to ARC (best) or move back to manual reference counting. If you wish to move... | >
> We are porting an app from 10.6 to 10.8.
> Reason for crash turns out to be that garbage collector is not able to suspend the thread.
>
>
>
**It is expected.**
Starting with OSX 10.8, Garbage collection is deprecated. So CG is unable to suspend the threads to perform its duty. As a result you get all the is... |
13,699,784 | Mongoose adds a '\_\_v' property into Schema's for versioning - is it possible to disable this globally or globally hide it from all queries? | 2012/12/04 | [
"https://Stackoverflow.com/questions/13699784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108312/"
] | define a `toObject.transform` function, and make sure you always call `toObject` when getting documents from mongoose.
```
var SomeSchema = new Schema({
<some schema spec>
} , {
toObject: {
transform: function (doc, ret, game) {
delete ret.__v;
}
}
});
``` | You may not want to disable `__v`, other answers provide few links to answer why you shouldn't disable it.
I've used this library to hide the `__v` and `_id`
<https://www.npmjs.com/package/mongoose-hidden>
```
let mongooseHidden = require("mongoose-hidden")();
// This will add `id` in toJSON
yourSchema.set("toJSON"... |
13,699,784 | Mongoose adds a '\_\_v' property into Schema's for versioning - is it possible to disable this globally or globally hide it from all queries? | 2012/12/04 | [
"https://Stackoverflow.com/questions/13699784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108312/"
] | Two ways:
1. `{versionKey: false}`
2. when you query, like `model.findById(id).select('-__v')`
`'-'` means exclude the field | Yes, it is simple, just edit the "schema.js" file that is inside
`"node_modules\mongoose\lib"`
Search for `"options = utils.options ({ ... versionKey: '__v'..."` and change value `"__v"` to `false`.
This will change all post requests. `(versionKey: '__v' => versionKey: false)` |
13,699,784 | Mongoose adds a '\_\_v' property into Schema's for versioning - is it possible to disable this globally or globally hide it from all queries? | 2012/12/04 | [
"https://Stackoverflow.com/questions/13699784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108312/"
] | To disable '\_\_v' property, which is not recommended, use the [`versionKey` schema option](http://mongoosejs.com/docs/guide.html#versionKey):
```
var Schema = new Schema({...}, { versionKey: false });
```
To hide it from all queries, which sometimes can be [not what you want too](https://stackoverflow.com/a/1502557... | define a `toObject.transform` function, and make sure you always call `toObject` when getting documents from mongoose.
```
var SomeSchema = new Schema({
<some schema spec>
} , {
toObject: {
transform: function (doc, ret, game) {
delete ret.__v;
}
}
});
``` |
13,699,784 | Mongoose adds a '\_\_v' property into Schema's for versioning - is it possible to disable this globally or globally hide it from all queries? | 2012/12/04 | [
"https://Stackoverflow.com/questions/13699784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108312/"
] | define a `toObject.transform` function, and make sure you always call `toObject` when getting documents from mongoose.
```
var SomeSchema = new Schema({
<some schema spec>
} , {
toObject: {
transform: function (doc, ret, game) {
delete ret.__v;
}
}
});
``` | You can use a Query Middleware to exclude any field from the output. In your case you can use this:
```
// '/^find/' is a regex that matches queries that start with find
// like find, findOne, findOneAndDelete, findOneAndRemove, findOneAndUpdate
schema.pre(/^find/, function(next) {
// this keyword refers to the cu... |
13,699,784 | Mongoose adds a '\_\_v' property into Schema's for versioning - is it possible to disable this globally or globally hide it from all queries? | 2012/12/04 | [
"https://Stackoverflow.com/questions/13699784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108312/"
] | You can disable the "\_\_v" attribute in your Schema definitions by setting the `versionKey` option to `false`. For example:
```
var widgetSchema = new Schema({ ... attributes ... }, { versionKey: false });
```
I don't think you can globally disable them, but can only do it per Schema. You can read more about Schema... | define a `toObject.transform` function, and make sure you always call `toObject` when getting documents from mongoose.
```
var SomeSchema = new Schema({
<some schema spec>
} , {
toObject: {
transform: function (doc, ret, game) {
delete ret.__v;
}
}
});
``` |
13,699,784 | Mongoose adds a '\_\_v' property into Schema's for versioning - is it possible to disable this globally or globally hide it from all queries? | 2012/12/04 | [
"https://Stackoverflow.com/questions/13699784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108312/"
] | You can disable the "\_\_v" attribute in your Schema definitions by setting the `versionKey` option to `false`. For example:
```
var widgetSchema = new Schema({ ... attributes ... }, { versionKey: false });
```
I don't think you can globally disable them, but can only do it per Schema. You can read more about Schema... | To disable '\_\_v' property, which is not recommended, use the [`versionKey` schema option](http://mongoosejs.com/docs/guide.html#versionKey):
```
var Schema = new Schema({...}, { versionKey: false });
```
To hide it from all queries, which sometimes can be [not what you want too](https://stackoverflow.com/a/1502557... |
13,699,784 | Mongoose adds a '\_\_v' property into Schema's for versioning - is it possible to disable this globally or globally hide it from all queries? | 2012/12/04 | [
"https://Stackoverflow.com/questions/13699784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108312/"
] | You can disable the "\_\_v" attribute in your Schema definitions by setting the `versionKey` option to `false`. For example:
```
var widgetSchema = new Schema({ ... attributes ... }, { versionKey: false });
```
I don't think you can globally disable them, but can only do it per Schema. You can read more about Schema... | You may not want to disable `__v`, other answers provide few links to answer why you shouldn't disable it.
I've used this library to hide the `__v` and `_id`
<https://www.npmjs.com/package/mongoose-hidden>
```
let mongooseHidden = require("mongoose-hidden")();
// This will add `id` in toJSON
yourSchema.set("toJSON"... |
13,699,784 | Mongoose adds a '\_\_v' property into Schema's for versioning - is it possible to disable this globally or globally hide it from all queries? | 2012/12/04 | [
"https://Stackoverflow.com/questions/13699784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108312/"
] | define a `toObject.transform` function, and make sure you always call `toObject` when getting documents from mongoose.
```
var SomeSchema = new Schema({
<some schema spec>
} , {
toObject: {
transform: function (doc, ret, game) {
delete ret.__v;
}
}
});
``` | Try this it will remove \_v from every query response.
```
// transform for sending as json
function omitPrivate(doc, obj) {
delete obj.__v;
return obj;
}
// schema options
var options = {
toJSON: {
transform: omitPrivate
}
};
// schema
var Schema = new Schema({...}, options);
``` |
13,699,784 | Mongoose adds a '\_\_v' property into Schema's for versioning - is it possible to disable this globally or globally hide it from all queries? | 2012/12/04 | [
"https://Stackoverflow.com/questions/13699784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108312/"
] | You can use a Query Middleware to exclude any field from the output. In your case you can use this:
```
// '/^find/' is a regex that matches queries that start with find
// like find, findOne, findOneAndDelete, findOneAndRemove, findOneAndUpdate
schema.pre(/^find/, function(next) {
// this keyword refers to the cu... | Yes, it is simple, just edit the "schema.js" file that is inside
`"node_modules\mongoose\lib"`
Search for `"options = utils.options ({ ... versionKey: '__v'..."` and change value `"__v"` to `false`.
This will change all post requests. `(versionKey: '__v' => versionKey: false)` |
13,699,784 | Mongoose adds a '\_\_v' property into Schema's for versioning - is it possible to disable this globally or globally hide it from all queries? | 2012/12/04 | [
"https://Stackoverflow.com/questions/13699784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108312/"
] | Two ways:
1. `{versionKey: false}`
2. when you query, like `model.findById(id).select('-__v')`
`'-'` means exclude the field | You may not want to disable `__v`, other answers provide few links to answer why you shouldn't disable it.
I've used this library to hide the `__v` and `_id`
<https://www.npmjs.com/package/mongoose-hidden>
```
let mongooseHidden = require("mongoose-hidden")();
// This will add `id` in toJSON
yourSchema.set("toJSON"... |
70,816,429 | I wrote the code below that uses a for loop. I would like to ask if there is a way to vectorize the operation within the second for loop since I intend to work with larger matrices.
```
import numpy as np
num = 5
A = np.array([[1,2,3,4,5], [4,5,6,4,5], [7,8,9,4,5], [10,11,12,4,5], [13,14,15,4,5]])
sm_factor = np.arr... | 2022/01/22 | [
"https://Stackoverflow.com/questions/70816429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13125581/"
] | You can avoid loops for both `d2m` matrix creation and `x_smf` vector computation using [sps.diags](https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.diags.html) for the creation of a sparse tridiagonal matrix that you can cast to array to be able to edit the first and last lines. Your code will look li... | After some research and printout of intermediate results of your loop,
I found the solution:
```
x_smf = np.sum(sm_factor * np.square(d2m @ A.T).sum(axis=0))
```
The result is:
```
324.0
```
By the way: Creation of *dm2* can be shortened to:
```
d2m = np.zeros((num, num), dtype='int')
d2m[0, :4] = [ 2, -5, 4, -... |
5,999,271 | this is a link to a canvas animation
<http://www.html5canvastutorials.com/advanced/html5-canvas-linear-motion-animation/>
now just like with a regular js animation, the speed of it depends on how fast the browser is with js.
so my question is, does canvas have a way of bringing them all to the same level? or is there ... | 2011/05/14 | [
"https://Stackoverflow.com/questions/5999271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/394328/"
] | The problem is that, in Javascript, `setInterval()` does not give you reliable timing, especially if the browser is too slow to update a frame in the time alotted.
So for each frame you have to calculate time elapsed since the previous frame, and use that to update your position.
Here is a live example:
<http://jsfi... | If you want the canvas to render at the same speed use
`setTimeout(doMoreRendering, 1000 / fps)` |
13,188,240 | I was thinking today while reading about the default constructor of classes in C++ and let's say we have this code of the class SortedArray:
```
class SortedArray
{
private:
struct arrayCell
{
int pageID;
int totalNeighbors;
};
};
```
We assign an array of pointers poi... | 2012/11/02 | [
"https://Stackoverflow.com/questions/13188240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1079186/"
] | OLD ANSWER: Im pretty sure that memory is created for that element, if you compile and run it there is no segmentation fault when accessing that memory. The ints will be set to the default value of 0.
Default constructor information can be found [here](http://www.cplusplus.com/doc/tutorial/classes/).
***EDIT:*** The ... | I'm pretty sure it will allocate memory for each object you initialize in your array, with the ints set to their default value (0). |
13,188,240 | I was thinking today while reading about the default constructor of classes in C++ and let's say we have this code of the class SortedArray:
```
class SortedArray
{
private:
struct arrayCell
{
int pageID;
int totalNeighbors;
};
};
```
We assign an array of pointers poi... | 2012/11/02 | [
"https://Stackoverflow.com/questions/13188240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1079186/"
] | If you're talking about pointers of type `SortedArray*` then no.
`SortedArray` is an empty class with a private nested type.
If you allocate instances of the nested type `SortedArray::arrayCell` then the integers will be default-initialized (the value is unspecified). | I'm pretty sure it will allocate memory for each object you initialize in your array, with the ints set to their default value (0). |
13,188,240 | I was thinking today while reading about the default constructor of classes in C++ and let's say we have this code of the class SortedArray:
```
class SortedArray
{
private:
struct arrayCell
{
int pageID;
int totalNeighbors;
};
};
```
We assign an array of pointers poi... | 2012/11/02 | [
"https://Stackoverflow.com/questions/13188240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1079186/"
] | OLD ANSWER: Im pretty sure that memory is created for that element, if you compile and run it there is no segmentation fault when accessing that memory. The ints will be set to the default value of 0.
Default constructor information can be found [here](http://www.cplusplus.com/doc/tutorial/classes/).
***EDIT:*** The ... | If you're talking about pointers of type `SortedArray*` then no.
`SortedArray` is an empty class with a private nested type.
If you allocate instances of the nested type `SortedArray::arrayCell` then the integers will be default-initialized (the value is unspecified). |
67,926,532 | i would like to scrape the header-element from these both links -
For me this 2 sites look absolute identical - pics see below
Why is only the scraping for the second link working and not for the first?
```
import time
import requests
from bs4 import BeautifulSoup
# not working
link = "https://apps.apple.com/us/app/... | 2021/06/10 | [
"https://Stackoverflow.com/questions/67926532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12415855/"
] | The page is sometimes loaded by JavaScript, so `request` *won't* support it.
You can use a `while` loop to check if `header` appears in the `soup` and then `break`
```
import requests
from bs4 import BeautifulSoup
headers = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, lik... | Try this to get whatever fields you wish to grab from those links. curently it fetches the title. You can modify `res.json()['data'][0]['attributes']['name']` to grab any field of your interest. Mkae sure to put the urls within this list `urls_to_scrape`.
```
import json
import requests
from bs4 import BeautifulSoup
f... |
48,836,391 | I have a app in building proccess in some where i need to get data from FirebaseDatabase and show them in custom list view here my code part of it for onDataChange method
```
myDatabase=FirebaseDatabase.getInstance();
myRef= myDatabase.getReference().child("TvSeries");
myAuth = FirebaseAuth.getInstance();... | 2018/02/16 | [
"https://Stackoverflow.com/questions/48836391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7977121/"
] | Your `selectedCategoryList` list is always empty because `onDataChange()` method has an asynchronous behaviour which means that is called even before you are try to add those objects of `DataForRow` class to the list. A quick solve for this problem would be to declare and use your `selectedCategoryList` list only insid... | Firebase works asynchronously. You probably got the data from firebase after you program executed the line with Log. As Tristan mentioned, if you put your Log inside of the listener, it will work |
53,638,887 | I'm learning Laravel, and really OOP in general. I've followed several YouTube tutorial series, that teach you to create a blog in Laravel.
I'm building a task app for a brewery, and I'm trying to define the relationships between the users and the tasks. So I have two models: User.php and Task.php. I had no problem de... | 2018/12/05 | [
"https://Stackoverflow.com/questions/53638887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7502579/"
] | You can just add a second relationship defined on your `Task.php` Model and assign a different agent based on `user_assigned_id`. You can manipulate it as expected via Eloquent.
Task.php
```
public function user() {
return $this->belongsTo('App\User');
}
public function assignedUser() {
return $this->belongsTo('... | ```
public function user()
{
return $this->belongsTo('App\User');
}
// Added an user_assigned_id relationship
public function assignee()
{
return $this->belongsTo('App\User', 'user_assigned_id');
}
```
The relationship is still a `belongsTo`, you just need to provide the column where the foreign key is held... |
8,343,548 | ```
HtmlAnchor[] anchorToConvert = new HtmlAnchor[]{
clickHere,
leavePage};
Button[] buttonToConvert = new Button[]{
login,
register};
i = 0;
for (i = 0; i < anchorToConvert.Length; i++)
{
DataRow[] result = ds.Tables[0].Select("htmlControl LIKE '" + anchorToConvert[i].ID.ToString() + "'");
if (re... | 2011/12/01 | [
"https://Stackoverflow.com/questions/8343548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/671140/"
] | You could use a list and check the type of the control in the list when you're looping through:
```
List<Control> ctrl = new List<Control>();
HtmlAnchor anchor = new HtmlAnchor();
anchor.ID = "myAnchor";
ctrl.Add(anchor);
Button btn = new Button();
btn.ID = "MyBtn";
ctrl.Add(btn);
foreach (Control c in ctrl.ToList(... | Both `HtmlAnchor` and `Button` inherit from [`Web.UI.Control`](http://msdn.microsoft.com/en-us/library/system.web.ui.control.aspx) (though not directly).
If that is the type of the array, both of these types (`HtmlAnchor` and `Button`) can be assign to the array. |
44,890,503 | I have a set of 6 variables for observation representing the Brand of tires in a truck. The brands could be different between tires but usually are all the same.
I need to create a summary variable that lists for each observation all the brands of the tires.
A simple `SELECT CONCAT(BrandP1, ', ', BrandP2...) AS Brand`... | 2017/07/03 | [
"https://Stackoverflow.com/questions/44890503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3577994/"
] | A more elegant solution might be to redesign the "brands" table with your brand and tire position as separate columns. Then you could use a `DISTINCT` `GROUP_CONCAT` to list the brands found/used during each observation. Something like:
```
SELECT ALL
`observation_id`,
GROUP_CONCAT( DISTINCT `tire_brand` SEPA... | I figured it out, in part thanks to @a3r0, although I couldn't create a new table or changing the database schema.
So I went
```
SELECT ALL
ID,
GROUP_CONCAT( DISTINCT Brand SEPARATOR ', ') AS BrandP
FROM (
SELECT ID, Wheel, Brand FROM (
SELECT ID, 'BrandP1' Wheel, BrandP1 Brand FROM Pneumatici
... |
4,421,986 | ```
def my_method(parameter)
if <what should be here?>
puts "parameter is a string"
elsif <and here?>
puts "parameter is a symbol"
end
end
``` | 2010/12/12 | [
"https://Stackoverflow.com/questions/4421986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/247243/"
] | ```
def my_method(parameter)
if parameter.is_a? String
puts "parameter is a string"
elsif parameter.is_a? Symbol
puts "parameter is a symbol"
end
end
```
should solve your issue | ```
if parameter.is_a? String
puts "string"
elsif parameter.is_a? Symbol
puts "symbol"
end
```
I hope this helps. |
4,421,986 | ```
def my_method(parameter)
if <what should be here?>
puts "parameter is a string"
elsif <and here?>
puts "parameter is a symbol"
end
end
``` | 2010/12/12 | [
"https://Stackoverflow.com/questions/4421986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/247243/"
] | ```
def my_method(parameter)
if parameter.is_a? String
puts "parameter is a string"
elsif parameter.is_a? Symbol
puts "parameter is a symbol"
end
end
```
should solve your issue | ```
def my_method(parameter)
if parameter.is_a? String
puts "parameter is a string"
elsif parameter.is_a? Symbol
puts "parameter is a symbol"
end
end
``` |
4,421,986 | ```
def my_method(parameter)
if <what should be here?>
puts "parameter is a string"
elsif <and here?>
puts "parameter is a symbol"
end
end
``` | 2010/12/12 | [
"https://Stackoverflow.com/questions/4421986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/247243/"
] | The simplest form would be:
```
def my_method(parameter)
puts "parameter is a #{parameter.class}"
end
```
But if you actually want to do some processing based on type do this:
```
def my_method(parameter)
puts "parameter is a #{parameter.class}"
case parameter
when Symbol
# process Symbol logic
... | ```
def my_method(parameter)
if parameter.is_a? String
puts "parameter is a string"
elsif parameter.is_a? Symbol
puts "parameter is a symbol"
end
end
```
should solve your issue |
4,421,986 | ```
def my_method(parameter)
if <what should be here?>
puts "parameter is a string"
elsif <and here?>
puts "parameter is a symbol"
end
end
``` | 2010/12/12 | [
"https://Stackoverflow.com/questions/4421986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/247243/"
] | ```
def my_method(parameter)
if parameter.is_a? String
puts "parameter is a string"
elsif parameter.is_a? Symbol
puts "parameter is a symbol"
end
end
```
should solve your issue | ```
if parameter.respond_to? id2name
p "Symbol"
else
p "not a symbol"
```
This will also work , but not an elegant solution. |
4,421,986 | ```
def my_method(parameter)
if <what should be here?>
puts "parameter is a string"
elsif <and here?>
puts "parameter is a symbol"
end
end
``` | 2010/12/12 | [
"https://Stackoverflow.com/questions/4421986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/247243/"
] | ```
if parameter.is_a? String
puts "string"
elsif parameter.is_a? Symbol
puts "symbol"
end
```
I hope this helps. | ```
def my_method(parameter)
if parameter.is_a? String
puts "parameter is a string"
elsif parameter.is_a? Symbol
puts "parameter is a symbol"
end
end
``` |
4,421,986 | ```
def my_method(parameter)
if <what should be here?>
puts "parameter is a string"
elsif <and here?>
puts "parameter is a symbol"
end
end
``` | 2010/12/12 | [
"https://Stackoverflow.com/questions/4421986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/247243/"
] | The simplest form would be:
```
def my_method(parameter)
puts "parameter is a #{parameter.class}"
end
```
But if you actually want to do some processing based on type do this:
```
def my_method(parameter)
puts "parameter is a #{parameter.class}"
case parameter
when Symbol
# process Symbol logic
... | ```
if parameter.is_a? String
puts "string"
elsif parameter.is_a? Symbol
puts "symbol"
end
```
I hope this helps. |
4,421,986 | ```
def my_method(parameter)
if <what should be here?>
puts "parameter is a string"
elsif <and here?>
puts "parameter is a symbol"
end
end
``` | 2010/12/12 | [
"https://Stackoverflow.com/questions/4421986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/247243/"
] | ```
if parameter.is_a? String
puts "string"
elsif parameter.is_a? Symbol
puts "symbol"
end
```
I hope this helps. | ```
if parameter.respond_to? id2name
p "Symbol"
else
p "not a symbol"
```
This will also work , but not an elegant solution. |
4,421,986 | ```
def my_method(parameter)
if <what should be here?>
puts "parameter is a string"
elsif <and here?>
puts "parameter is a symbol"
end
end
``` | 2010/12/12 | [
"https://Stackoverflow.com/questions/4421986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/247243/"
] | The simplest form would be:
```
def my_method(parameter)
puts "parameter is a #{parameter.class}"
end
```
But if you actually want to do some processing based on type do this:
```
def my_method(parameter)
puts "parameter is a #{parameter.class}"
case parameter
when Symbol
# process Symbol logic
... | ```
def my_method(parameter)
if parameter.is_a? String
puts "parameter is a string"
elsif parameter.is_a? Symbol
puts "parameter is a symbol"
end
end
``` |
4,421,986 | ```
def my_method(parameter)
if <what should be here?>
puts "parameter is a string"
elsif <and here?>
puts "parameter is a symbol"
end
end
``` | 2010/12/12 | [
"https://Stackoverflow.com/questions/4421986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/247243/"
] | ```
def my_method(parameter)
if parameter.is_a? String
puts "parameter is a string"
elsif parameter.is_a? Symbol
puts "parameter is a symbol"
end
end
``` | ```
if parameter.respond_to? id2name
p "Symbol"
else
p "not a symbol"
```
This will also work , but not an elegant solution. |
4,421,986 | ```
def my_method(parameter)
if <what should be here?>
puts "parameter is a string"
elsif <and here?>
puts "parameter is a symbol"
end
end
``` | 2010/12/12 | [
"https://Stackoverflow.com/questions/4421986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/247243/"
] | The simplest form would be:
```
def my_method(parameter)
puts "parameter is a #{parameter.class}"
end
```
But if you actually want to do some processing based on type do this:
```
def my_method(parameter)
puts "parameter is a #{parameter.class}"
case parameter
when Symbol
# process Symbol logic
... | ```
if parameter.respond_to? id2name
p "Symbol"
else
p "not a symbol"
```
This will also work , but not an elegant solution. |
17,477,905 | Note: I'm assuming all operators below are left-associative.
`a - b - c` is equal to `a - (b + c)`.
`a / b / c` is equal to `a / (b * c)`.
Are there any similar equivalences for the modulo operator?
I've figured that `a % b % c` is equal to `a % b` if `b <= c` and `a % c` if `b > c && b % c == 0`. However, I ... | 2013/07/04 | [
"https://Stackoverflow.com/questions/17477905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1825413/"
] | Let's take `b = q0*c + r0`
You decompose
```
a = q1 * b + r1
r1 = q2 * c + r2
a = q1 * (q0 * c + r0) + q2 * c + r2
a = (q1 * q0 + q2) * c + q1 * r0 + r2
```
So you can say that
```
r2 = (a - q1 * r0) % c
```
Or in other words
```
(a%b%c) = (a - (a/b)*(b%c)) % c
```
This also works when `b<c`, because `(a... | Chained modulo operators have no particular meaning in general, and the result may actually be ill-defined.
If you think of modulo p as a *projection* from integral numbers to some set `{k, ... k + p - 1}` then chaining two projections may not be clearly defined mathematically since the chaining depends on the choice ... |
42,125,836 | If I have many classes which are pretty similar with each other then, does making them inherit from an abstract class a good option? | 2017/02/08 | [
"https://Stackoverflow.com/questions/42125836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4388482/"
] | You can do that calculation all in one go if all you want is a total of the debits and credits
```
SELECT
SUM(CASE WHEN DebitCredit='H' THEN AmountLC*-1 ELSE AmountLC END) as Total
FROM T1_CSV_Table
WHERE Month='$getMonth' AND TaxCode='A0'
```
>
> NOTE: Your script is at risk of [SQL Injection Attack](https:/... | try this please:
```
SELECT
SUM(IF(DebitCredit='H', DebitCredit, 0) AS NegativeTotal,
SUM(IF(DebitCredit='S', DebitCredit, 0) AS PostiveTotal
FROM T1_CSV_Table
WHERE
MONTH='$getMonth'
AND
TaxCode='A0';
``` |
9,242,110 | I want to use SHA1 function from Linux libraries ([documentation](http://linux.die.net/man/3/sha)) which returns unsigned char pointer. As I understand it creates a new array but doesn't it mean I have to free the memory used for it? And how do I know whether I should use free or delete[]? I guess this particular funct... | 2012/02/11 | [
"https://Stackoverflow.com/questions/9242110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/553941/"
] | Keep in mind while it might have allocated the memory on the heap using `malloc`, it could also be returning a pointer to a static fixed-length array private to the scope of the function. That's not untypical for library functions on Linux, especially those that are not re-entrant. So if you call `free()` on a pointer ... | The only general and correct answer: Read the documentation. Every foreign function that you use must tell you in its documentation what sort of input it expects and what it returns.
If it says that it returns a pointer to memory allocated with `malloc` (or equivalent), you must `free` it yourself.
(Practically, you ... |
9,242,110 | I want to use SHA1 function from Linux libraries ([documentation](http://linux.die.net/man/3/sha)) which returns unsigned char pointer. As I understand it creates a new array but doesn't it mean I have to free the memory used for it? And how do I know whether I should use free or delete[]? I guess this particular funct... | 2012/02/11 | [
"https://Stackoverflow.com/questions/9242110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/553941/"
] | Keep in mind while it might have allocated the memory on the heap using `malloc`, it could also be returning a pointer to a static fixed-length array private to the scope of the function. That's not untypical for library functions on Linux, especially those that are not re-entrant. So if you call `free()` on a pointer ... | You should be using the [evp\_\* functions](http://linux.die.net/man/3/evp_digestinit) rather than those lower level functions that you referenced. There are functions there for destroying and creating the digests. |
9,242,110 | I want to use SHA1 function from Linux libraries ([documentation](http://linux.die.net/man/3/sha)) which returns unsigned char pointer. As I understand it creates a new array but doesn't it mean I have to free the memory used for it? And how do I know whether I should use free or delete[]? I guess this particular funct... | 2012/02/11 | [
"https://Stackoverflow.com/questions/9242110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/553941/"
] | Keep in mind while it might have allocated the memory on the heap using `malloc`, it could also be returning a pointer to a static fixed-length array private to the scope of the function. That's not untypical for library functions on Linux, especially those that are not re-entrant. So if you call `free()` on a pointer ... | `unsigned char *SHA1(const unsigned char *d, unsigned long n,
unsigned char *md);`
According to the documentation, unless `md==0`, the return value is md. If `md==0`, it's placed in a static array, so you don't have to worry about it. I wrote the fallowing to prove the concept.
```
#include <openssl/sha.h>
#include ... |
61,001,855 | Currently, I have a pre-trained model that uses a DataLoader for reading a batch of images for training the model.
```py
self.data_loader = torch.utils.data.DataLoader(dataset, batch_size=batch_size, shuffle=False,
num_workers=1, pin_memory=True)
...
model.eval()
for step, inputs in enumerate(test_loader.data_lo... | 2020/04/02 | [
"https://Stackoverflow.com/questions/61001855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4279650/"
] | You can use do it with [IterableDataset](https://pytorch.org/docs/stable/data.html#torch.utils.data.IterableDataset) :
```
from torch.utils.data import IterableDataset
class MyDataset(IterableDataset):
def __init__(self, image_queue):
self.queue = image_queue
def read_next_image(self):
while se... | I don't know about dataLoader but you can load a single image using following function:
```
def safe_pil_loader(path, from_memory=False):
try:
if from_memory:
img = Image.open(path)
res = img.convert('RGB')
else:
with open(path, 'rb') as f:
img = Image.open(f)
re... |
56,361,744 | I need to know the height of a **React Component** inside another React component. I am aware that the height of an element can be reached by calling `this.cmref.current.clientHeight`. I'm looking for something like this:
child component:
```js
const Comp = () =>{
return(
<div>some other stuff here</div>
... | 2019/05/29 | [
"https://Stackoverflow.com/questions/56361744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11451428/"
] | You'll need to actually ref the div of the child component in order to get the element you want instead of the child component itself. To do this you could pass a function to the child that the child then passes to the div. Working example below:
```js
const Comp = (props) =>{
return(
<div ref={props.onR... | ```
const Comp = React.forwardRef((props, ref) => (
<div ref={ref}> some other stuff here </div>
));
class App extends React.Component{
constructor(props){
super(props);
this.compref = React.createRef();
}
componentDidMount(){
const height = this.compref.clientHeight;
cons... |
20,133,348 | I am developing an android application using Google Places API. Until last night the app was working perfectly fine and I was going to launch it today and suddenly i started getting SSLHandShakeException.
What I dont understand is how did this suddenly happen? I created a new API key with a new package name and I am ge... | 2013/11/21 | [
"https://Stackoverflow.com/questions/20133348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1701593/"
] | Check system **time**. Make sure its up to date. | I did lot of digging and found out numerous ways to go over this problem. However the case with me was my app was running perfectly fine until the day on which i wanted to run it for one last time before publishing it and that was v.suprising. I kept on making changes and wrote different codes to accept any certificate... |
30,541 | Let's suppose the development team is planning the next Sprint. What does it technically mean that a User Story is added to the Sprint Backlog? Is it assigned to a developer or to the whole team? (If it's assigned to the whole development team, then how do we do this in Jira?) | 2020/11/01 | [
"https://pm.stackexchange.com/questions/30541",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/40376/"
] | A "story" does not necessarily correspond 1:1 with a development task. You need to determine *from* the story what needs to be done, and by whom, in order to complete it. | As Bogdan already mentioned: "the team owns all of the stories", & the team should also owns the way to get those stories done. I mean pre-assigning to individual member or pulling when sprint progress are both fine.
One practice in my team is we always have individual owner at story level even when multiple members i... |
30,541 | Let's suppose the development team is planning the next Sprint. What does it technically mean that a User Story is added to the Sprint Backlog? Is it assigned to a developer or to the whole team? (If it's assigned to the whole development team, then how do we do this in Jira?) | 2020/11/01 | [
"https://pm.stackexchange.com/questions/30541",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/40376/"
] | Since you're asking about user stories, not tasks: A user story usually consists of several tasks that can be tackled by different team members, sometimes even different crafts. That means that, while you can certainly assign team members to any of the story's *tasks* (though you don't have to do that, either), **the s... | As Bogdan already mentioned: "the team owns all of the stories", & the team should also owns the way to get those stories done. I mean pre-assigning to individual member or pulling when sprint progress are both fine.
One practice in my team is we always have individual owner at story level even when multiple members i... |
30,541 | Let's suppose the development team is planning the next Sprint. What does it technically mean that a User Story is added to the Sprint Backlog? Is it assigned to a developer or to the whole team? (If it's assigned to the whole development team, then how do we do this in Jira?) | 2020/11/01 | [
"https://pm.stackexchange.com/questions/30541",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/40376/"
] | The November 2020 Scrum Guide says:
>
> The Sprint Backlog is composed of the Sprint Goal (why), the set of Product Backlog items selected for the Sprint (what), as well as an actionable plan for delivering the Increment (how).
>
>
>
In this definition, the unit of work is not defined. That is, the Product Backlo... | We have component ownership (there is a business lead and development lead for each).
We personally didn't automate the assignment of the ticket to DEV lead, but automated to assign to business lead according to the component (first component mentioned in the ticket - responsible assignee - it's set up in the Project'... |
30,541 | Let's suppose the development team is planning the next Sprint. What does it technically mean that a User Story is added to the Sprint Backlog? Is it assigned to a developer or to the whole team? (If it's assigned to the whole development team, then how do we do this in Jira?) | 2020/11/01 | [
"https://pm.stackexchange.com/questions/30541",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/40376/"
] | We have component ownership (there is a business lead and development lead for each).
We personally didn't automate the assignment of the ticket to DEV lead, but automated to assign to business lead according to the component (first component mentioned in the ticket - responsible assignee - it's set up in the Project'... | As Bogdan already mentioned: "the team owns all of the stories", & the team should also owns the way to get those stories done. I mean pre-assigning to individual member or pulling when sprint progress are both fine.
One practice in my team is we always have individual owner at story level even when multiple members i... |
30,541 | Let's suppose the development team is planning the next Sprint. What does it technically mean that a User Story is added to the Sprint Backlog? Is it assigned to a developer or to the whole team? (If it's assigned to the whole development team, then how do we do this in Jira?) | 2020/11/01 | [
"https://pm.stackexchange.com/questions/30541",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/40376/"
] | It's up to the team to create the sprint backlog based on the backlog items chosen by the Product Owner. Some teams do use sprint planning to allocate at least some items to individual developers, other teams adopt a "pull system", meaning items are not pre-allocated and it's up to each individual to pick up items off ... | As Bogdan already mentioned: "the team owns all of the stories", & the team should also owns the way to get those stories done. I mean pre-assigning to individual member or pulling when sprint progress are both fine.
One practice in my team is we always have individual owner at story level even when multiple members i... |
30,541 | Let's suppose the development team is planning the next Sprint. What does it technically mean that a User Story is added to the Sprint Backlog? Is it assigned to a developer or to the whole team? (If it's assigned to the whole development team, then how do we do this in Jira?) | 2020/11/01 | [
"https://pm.stackexchange.com/questions/30541",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/40376/"
] | A "story" does not necessarily correspond 1:1 with a development task. You need to determine *from* the story what needs to be done, and by whom, in order to complete it. | We have component ownership (there is a business lead and development lead for each).
We personally didn't automate the assignment of the ticket to DEV lead, but automated to assign to business lead according to the component (first component mentioned in the ticket - responsible assignee - it's set up in the Project'... |
30,541 | Let's suppose the development team is planning the next Sprint. What does it technically mean that a User Story is added to the Sprint Backlog? Is it assigned to a developer or to the whole team? (If it's assigned to the whole development team, then how do we do this in Jira?) | 2020/11/01 | [
"https://pm.stackexchange.com/questions/30541",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/40376/"
] | When the team plans a sprint, they pull product backlog items or user stories from the top of the backlog and into their sprint. The stories they selected to do that sprint now form the "[sprint backlog](https://www.scrumguides.org/scrum-guide.html#artifacts-sprintbacklog)".
Now, **concerning assignment of these stori... | As Bogdan already mentioned: "the team owns all of the stories", & the team should also owns the way to get those stories done. I mean pre-assigning to individual member or pulling when sprint progress are both fine.
One practice in my team is we always have individual owner at story level even when multiple members i... |
30,541 | Let's suppose the development team is planning the next Sprint. What does it technically mean that a User Story is added to the Sprint Backlog? Is it assigned to a developer or to the whole team? (If it's assigned to the whole development team, then how do we do this in Jira?) | 2020/11/01 | [
"https://pm.stackexchange.com/questions/30541",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/40376/"
] | The November 2020 Scrum Guide says:
>
> The Sprint Backlog is composed of the Sprint Goal (why), the set of Product Backlog items selected for the Sprint (what), as well as an actionable plan for delivering the Increment (how).
>
>
>
In this definition, the unit of work is not defined. That is, the Product Backlo... | As Bogdan already mentioned: "the team owns all of the stories", & the team should also owns the way to get those stories done. I mean pre-assigning to individual member or pulling when sprint progress are both fine.
One practice in my team is we always have individual owner at story level even when multiple members i... |
30,541 | Let's suppose the development team is planning the next Sprint. What does it technically mean that a User Story is added to the Sprint Backlog? Is it assigned to a developer or to the whole team? (If it's assigned to the whole development team, then how do we do this in Jira?) | 2020/11/01 | [
"https://pm.stackexchange.com/questions/30541",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/40376/"
] | When the team plans a sprint, they pull product backlog items or user stories from the top of the backlog and into their sprint. The stories they selected to do that sprint now form the "[sprint backlog](https://www.scrumguides.org/scrum-guide.html#artifacts-sprintbacklog)".
Now, **concerning assignment of these stori... | The November 2020 Scrum Guide says:
>
> The Sprint Backlog is composed of the Sprint Goal (why), the set of Product Backlog items selected for the Sprint (what), as well as an actionable plan for delivering the Increment (how).
>
>
>
In this definition, the unit of work is not defined. That is, the Product Backlo... |
30,541 | Let's suppose the development team is planning the next Sprint. What does it technically mean that a User Story is added to the Sprint Backlog? Is it assigned to a developer or to the whole team? (If it's assigned to the whole development team, then how do we do this in Jira?) | 2020/11/01 | [
"https://pm.stackexchange.com/questions/30541",
"https://pm.stackexchange.com",
"https://pm.stackexchange.com/users/40376/"
] | When the team plans a sprint, they pull product backlog items or user stories from the top of the backlog and into their sprint. The stories they selected to do that sprint now form the "[sprint backlog](https://www.scrumguides.org/scrum-guide.html#artifacts-sprintbacklog)".
Now, **concerning assignment of these stori... | It's up to the team to create the sprint backlog based on the backlog items chosen by the Product Owner. Some teams do use sprint planning to allocate at least some items to individual developers, other teams adopt a "pull system", meaning items are not pre-allocated and it's up to each individual to pick up items off ... |
40,894,960 | I'm aware the general question must have been asked many times, but in attempting the suggested solutions I'm getting nowhere. I'd like to match either a new line character without a preceeding > or a new line character on it's own, but I can't seem to get any of the usual suggestions for matching a blank line to work.... | 2016/11/30 | [
"https://Stackoverflow.com/questions/40894960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1334118/"
] | Your regex is right, but your options are wrong. You just need to turn on the multiline option so that ^ matches beginning of line, instead of beginning of document. You have the "/g" global option on now, which is correct. You just need to add the "/m" also (so it ends up being "/gm"). | Since your regex flavor is PCRE (PHP) you can also use a negative lookbehind for this:
Search for regex:
```
(?<!>)\n
```
and replace using:
```
<br>\n
```
[RegEx Demo](https://regex101.com/r/Vh30n9/6)
Here `(?<!>)` is negative lookbehind that asserts true only if there is no `>` character before `\n`. |
4,422,406 | I'm trying to use JAAS for authentication in my WAR. I understand that my [configuration file](http://download.oracle.com/javase/6/docs/api/javax/security/auth/login/Configuration.html) ([another link](http://download.oracle.com/javase/6/docs/jre/api/security/jaas/spec/com/sun/security/auth/login/ConfigFile.html)) shou... | 2010/12/12 | [
"https://Stackoverflow.com/questions/4422406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187141/"
] | I had the same problem and I wanted to see if I couldn't dynamically set this property based on the current classpath (which would be located inside the war itself).
```
public class SecurityListener implements ServletContextListener {
public SecurityListener() {
}
@Override
public void contextDestroy... | Unfortunately the only way I was able to get it to work was to create a file `jass.conf` and specify it using either:
* In the Tomcat java parameters:
```
-Djava.security.auth.login.config==c:\\path\\To\\file.conf
```
* or from within the Java code:
```
System.setProperty("java.security.auth.login.config","c:\\path... |
4,422,406 | I'm trying to use JAAS for authentication in my WAR. I understand that my [configuration file](http://download.oracle.com/javase/6/docs/api/javax/security/auth/login/Configuration.html) ([another link](http://download.oracle.com/javase/6/docs/jre/api/security/jaas/spec/com/sun/security/auth/login/ConfigFile.html)) shou... | 2010/12/12 | [
"https://Stackoverflow.com/questions/4422406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/187141/"
] | You can encapsulate the client\_jaas.conf in the jar, and use the code to specify the configuration dynamically
```java
System.setProperty("java.security.auth.login.config", XXX.class.getClassLoader().getResource("client_jaas.conf").toString());
``` | Unfortunately the only way I was able to get it to work was to create a file `jass.conf` and specify it using either:
* In the Tomcat java parameters:
```
-Djava.security.auth.login.config==c:\\path\\To\\file.conf
```
* or from within the Java code:
```
System.setProperty("java.security.auth.login.config","c:\\path... |
53,487,888 | We have an Azure-based ASP.NET Web Service that accesses an Azure KeyVault. We are seeing two instances in which a method "hangs" on a first try, and then works a minute or so later.
In both instances, a KeyVault access occurs. In both instances the problem started when we started using the KeyVault in these methods.... | 2018/11/26 | [
"https://Stackoverflow.com/questions/53487888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1806671/"
] | Found the problem, and the solution.
Key Vault access needs to be called from an async task, because there is a multi-second delay.
```
private async Task<string> GetKeyVaultSecretValue(varSecretParms) {
```
I don't understand the underlying technology, however, apparently, if the call is from within a standard cod... | According to your description, it seems that it dues to WebApp that **does not enable Always on** .
>
> By default, web apps are **unloaded** if they are idle for some period of time. This lets the system conserve resources. In Basic or Standard mode, you can enable Always On to keep the app loaded all the time
>
>... |
34,097 | Which photo has the more correct White Balance? For me the second is much better than the first. My understanding is that the R+G+B histogram needs to be as balanced as possible. Is this true, or does it depend?
 | 2013/01/30 | [
"https://photo.stackexchange.com/questions/34097",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/15894/"
] | Without referencing a white object in your photo, we cannot decide which one has a better white balance. In short, white balance is process of removing unrealistic color cast on your image, i.e., correct the white area in your image that captured as gray. So it cannot be judged by histogram. If you know what part of yo... | The technically correct white balance setting is the setting that "cancels out" the color of the lights lighting your scene so that the color of items in your image is the same as the color in real life.
You can't judge white balance from the histogram or anything in the photo without some reference to that item real ... |
34,097 | Which photo has the more correct White Balance? For me the second is much better than the first. My understanding is that the R+G+B histogram needs to be as balanced as possible. Is this true, or does it depend?
 | 2013/01/30 | [
"https://photo.stackexchange.com/questions/34097",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/15894/"
] | Like with photograhps in general, it's down to opinion and there is no real "correct".
[White Balance](http://www.cambridgeincolour.com/tutorials/white-balance.htm) is based on [Colour Temperature](http://en.wikipedia.org/wiki/Color_temperature) where different light source temperatures create unnormal colours (to wha... | The technically correct white balance setting is the setting that "cancels out" the color of the lights lighting your scene so that the color of items in your image is the same as the color in real life.
You can't judge white balance from the histogram or anything in the photo without some reference to that item real ... |
14,243,232 | The following code is in accordance with the CLRS ([Corman, Leiserson, Rivest, Stein — 'Introduction to Algorithms'](https://rads.stackoverflow.com/amzn/click/com/0262033844)) textbook which is supposed to do merge sorting.
I am unable to identify the mistake that is happening, although I know there is something wrong... | 2013/01/09 | [
"https://Stackoverflow.com/questions/14243232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1647278/"
] | ```
void merge(int *a,int p,int q,int r){
int n1 = q - p + 1;
int n2 = r - q;
int* l = malloc((n1+1)*sizeof(int));
int* ri = malloc((n2+1)*sizeof(int));
int i,j;
for(i = 0 ; i < n1 ; i++)
l[i] = a[p+i-1];
for(i = 0 ; i < n2 ; i++)
ri[i] = a[q+i];
```
You are writing the ele... | In the `mergeSort()` code, you have:
```
int q = ( p + r ) / 2;
mergeSort(a,p,q);
mergeSort(a,p+1,r);
merge(a,p,q,r);
```
I think the second `mergeSort` should be `mergeSort(a, q+1, r);`, shouldn't it?
This is separate from and independent of the [analysis](https://stackoverflow.com/a/14243333/15168) by [Daniel Fis... |
11,761,272 | Am experimenting with an anonymous function :
```
var a:Object = new Object() ;
a.b = new Function()
a.b =function()
{
trace("hello");
}
trace(a.b())
```
Output :
hello
undefined
What's undefined ?? | 2012/08/01 | [
"https://Stackoverflow.com/questions/11761272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/809745/"
] | You are having problems with the variable scope. `this` refers to the inner function..
Use this instead:
```
$("input").on("keypress", function () {
var that = this;
setTimeout (function () {
var search_word = $(that).val();
if ( search_word.length > 0 ) {
alert(sea... | You could use keyup, it's fired after the input got the value, so you don't need a timeout.
<http://jsfiddle.net/yF2hU/>
```
$('#foo').bind('keyup', function(e) {
alert($(this).val());
});
``` |
11,761,272 | Am experimenting with an anonymous function :
```
var a:Object = new Object() ;
a.b = new Function()
a.b =function()
{
trace("hello");
}
trace(a.b())
```
Output :
hello
undefined
What's undefined ?? | 2012/08/01 | [
"https://Stackoverflow.com/questions/11761272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/809745/"
] | ```
$("input").on("keypress", function (e) {
alert(String.fromCharCode(e.which));
});
``` | You could use keyup, it's fired after the input got the value, so you don't need a timeout.
<http://jsfiddle.net/yF2hU/>
```
$('#foo').bind('keyup', function(e) {
alert($(this).val());
});
``` |
23,544,661 | Given a template class such as
```
template <class Key, class Value>
class CustomMap {
// standard map implementation here, with (say) 'put', 'contains' and 'get'
};
```
and assuming that I do not care for the `Value` parameter (as I wish to use the map as a set), and that I cannot use standard C++ containers, ... | 2014/05/08 | [
"https://Stackoverflow.com/questions/23544661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15472/"
] | You could use an empty class rather than a mildly confusing alias for `int`:
```
struct nothing {};
CustomMap<std::string, nothing> map;
map.put("test", nothing());
```
I also wouldn't use SHOUTY\_CAPS; as well as being harder to read, they're conventionally reserved for macros, to reduce the danger of the preproces... | Personally, if they HAD to be the same name, I'd probably use a specialization:
```
template <typename T, typename... J>
class OptionalSet;
template <typename T>
class OptionalSet
{
//implementation of non-keyed thing
};
template <typename T, typename J>
class OpionalSet
{
//implimentation of keyed thing
};
```... |
71,086,773 | I am trying to make a function that creates an array from the functions original array, that starts on the second element and multiplies by the previous element.
Example
```
input: [2,3,4,5]
output: [6,12,20]
```
I am trying to use a loop to get this done and here is my code so far
```
def funct(array1):
newar... | 2022/02/11 | [
"https://Stackoverflow.com/questions/71086773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17020069/"
] | As you note, the initial communalities in a factor analysis are the squared multiple correlations (SMC) of each variable by the remaining variables. Using the built-in `attitude` dataset as an example they are easily calculated without additional packages via:
```
1 - 1 / diag(solve(cor(attitude)))
rating complai... | Dataset
-------
Here is the dput for the data I am using, hereafter called `hwk`:
```
hwk <- structure(list(V1 = structure(c(4, 4, 2, 2, 2, 2, 2, 2, 4, 4,
2, 3, 2, 3, 4, 2, 2, 2, 3, 3, 2, 3, 1, 3, 3, 3, 3, 4, 1, 2, 4,
1, 2, 3, 2, 3, 1, 1, 2, 2, 4, 3, 2, 1, 2, 3, 3, 4, 3, 3, 2, 3,
1, 4, 3, 2, 3, 4, 1, 3, 3, 3, 2, 2... |
28,377,536 | I am trying to forward declare a struct A and define a struct B that contains an array of A.
I am getting error stating 'incomplete type not allowed'
This is what I have:
```
struct A;
struct B
{
// something
struct A x[10]; // This where I get the error incomplete type not allowed
};
struct A
{
// something
};
`... | 2015/02/07 | [
"https://Stackoverflow.com/questions/28377536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1874105/"
] | As a work around you can declare a pointer to struct A as this
```
struct B
{
// something
struct A * x;
};
```
This is because if you have a line like
```
struct B b;
```
the `b` will have a member `x[10]`. If you did not fully declare struct A, struct B doesn't know how to allocate 10 struct A elements. In the... | An "incomplete type" ([MSDN](https://msdn.microsoft.com/en-us/library/200xfxh6.aspx)) is a type whose details the compiler doesn't know at a given point in the translation unit. In the declaration of members of `struct B`, the compiler doesn't know the size of the type (`sizeof (struct A)`) and therefore doesn't know h... |
53,146,532 | Active Document is called “FinalDocument”
The following is in a loop (ie. Report1, Report2, etc..)
```
DoCmd.OpenReport ReportName, acPreview, , "Report1”
DoCmd.OutputTo acOutputReport, ReportName, acFormatRTF, “WordDoc1”
ActiveDocument.Content.InsertFile FileName:=WordDoc1, Range:="", _
ConfirmConversions... | 2018/11/04 | [
"https://Stackoverflow.com/questions/53146532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10065120/"
] | You should work with a `Range` object so that you can target the insertion point. First, set the`Range` to the entire document, then "collapse" it to a point - think of it like pressing the right-arrow key to make a selection a blinking cursor at the end of the selection.
For example:
```
Dim rng as Word.Range
Set rn... | Try this:
```
ActiveDocument.ActiveWindow.Selection.InsertFile FileName:=WordDoc1, Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
``` |
73,594,284 | Currently, my histogram plot's x-tick labels are [200. 400. 600. 800. 1000. 1200. 1400.]. It represents the rate in dollars. I want to add $ in prefix of these ticks like [$200 $400 $600 $800 $1000 $1200 $1400].
I tried this `axs.xaxis.get_majorticklocs()` to fetch x-tick labels and `axs.xaxis.set_ticks([f"${amount:.0... | 2022/09/03 | [
"https://Stackoverflow.com/questions/73594284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12442768/"
] | You can do it like this:
```
x = [*range(200,1600,200)]
y = [*range(7)]
fig, ax = plt.subplots()
ax.plot(x,y)
ax.set_xticks(ticks=x, labels=[f"${num}" for num in x])
```
[](https://i.stack.imgur.com/wZyQn.png) | You might be looking for [`set_xticklabels`](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_xticklabels.html), which says:
>
> Set the xaxis' labels with list of string labels.
>
>
>
Here you want to set the ticks to `[200. 400. 600. 800. 1000. 1200. 1400.]` and the labels to your string value... |
73,594,284 | Currently, my histogram plot's x-tick labels are [200. 400. 600. 800. 1000. 1200. 1400.]. It represents the rate in dollars. I want to add $ in prefix of these ticks like [$200 $400 $600 $800 $1000 $1200 $1400].
I tried this `axs.xaxis.get_majorticklocs()` to fetch x-tick labels and `axs.xaxis.set_ticks([f"${amount:.0... | 2022/09/03 | [
"https://Stackoverflow.com/questions/73594284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12442768/"
] | You can use automatic `StrMethodFormatter` like this:
```
import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(100*np.random.rand(20))
# Use automatic StrMethodFormatter
ax.xaxis.set_major_formatter('${x:1.2f}')
plt.show()
```
[, which says:
>
> Set the xaxis' labels with list of string labels.
>
>
>
Here you want to set the ticks to `[200. 400. 600. 800. 1000. 1200. 1400.]` and the labels to your string value... |
73,594,284 | Currently, my histogram plot's x-tick labels are [200. 400. 600. 800. 1000. 1200. 1400.]. It represents the rate in dollars. I want to add $ in prefix of these ticks like [$200 $400 $600 $800 $1000 $1200 $1400].
I tried this `axs.xaxis.get_majorticklocs()` to fetch x-tick labels and `axs.xaxis.set_ticks([f"${amount:.0... | 2022/09/03 | [
"https://Stackoverflow.com/questions/73594284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12442768/"
] | You can use automatic `StrMethodFormatter` like this:
```
import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(100*np.random.rand(20))
# Use automatic StrMethodFormatter
ax.xaxis.set_major_formatter('${x:1.2f}')
plt.show()
```
[]
y = [*range(7)]
fig, ax = plt.subplots()
ax.plot(x,y)
ax.set_xticks(ticks=x, labels=[f"${num}" for num in x])
```
[](https://i.stack.imgur.com/wZyQn.png) |
425,161 | I have just a few tenants on my application right now, but the number is going to increase over time. The processing logic for each tenant is slightly different from each other and right now the logic for each tenant is residing in the same microservice.
From a best practice viewpoint, is it a good idea to create an i... | 2021/04/06 | [
"https://softwareengineering.stackexchange.com/questions/425161",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/389553/"
] | There is no one size fits all answer here.
>
> Right now, I'm finding a bit too many if else cases with my implementation, thinking if there's a better way to do this.
>
>
>
On the spectrum of good to bad for your specific needs, tenanted microservices are on the better end of the spectrum than hardcoded if/else ... | Yes. **IF** the logic is different and not shared. **AND** you buy into the micro-service philosophy in general.
Leave the word tenant out of the equation for a bit. You have two separate operations to perform. The alternative to two separate applications would be one application with multiple modules.
Sure you can d... |
425,161 | I have just a few tenants on my application right now, but the number is going to increase over time. The processing logic for each tenant is slightly different from each other and right now the logic for each tenant is residing in the same microservice.
From a best practice viewpoint, is it a good idea to create an i... | 2021/04/06 | [
"https://softwareengineering.stackexchange.com/questions/425161",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/389553/"
] | The idea behind multi-tenancy is that you have a single application that is shared by multiple customers. Having separate services is antithetical to this approach. That doesn't mean that would be a bad idea in some cases, but that wouldn't be multi-tenancy.
So, what do do with customers that need different features? ... | There is no one size fits all answer here.
>
> Right now, I'm finding a bit too many if else cases with my implementation, thinking if there's a better way to do this.
>
>
>
On the spectrum of good to bad for your specific needs, tenanted microservices are on the better end of the spectrum than hardcoded if/else ... |
425,161 | I have just a few tenants on my application right now, but the number is going to increase over time. The processing logic for each tenant is slightly different from each other and right now the logic for each tenant is residing in the same microservice.
From a best practice viewpoint, is it a good idea to create an i... | 2021/04/06 | [
"https://softwareengineering.stackexchange.com/questions/425161",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/389553/"
] | The idea behind multi-tenancy is that you have a single application that is shared by multiple customers. Having separate services is antithetical to this approach. That doesn't mean that would be a bad idea in some cases, but that wouldn't be multi-tenancy.
So, what do do with customers that need different features? ... | Yes. **IF** the logic is different and not shared. **AND** you buy into the micro-service philosophy in general.
Leave the word tenant out of the equation for a bit. You have two separate operations to perform. The alternative to two separate applications would be one application with multiple modules.
Sure you can d... |
1,954,656 | >
> $$
> \left( \begin{array}
> {ccc}1 & 1 & x \\
> 1 & x & 1 \\
> x & 1 & 1 \\
> \end{array} \right) $$
>
>
> Find the values of $x$ such that the matrix above has rank $1$, $2$ and $3$.
>
>
>
Can I get the matrix to reduced row echelon form, or is there another approach? | 2016/10/05 | [
"https://math.stackexchange.com/questions/1954656",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/375285/"
] | There are many methods, one is to compute its characteristic polynomial.
$$\chi(t) = -t^3 + (x+2) t^2 + (x-1)^2 t - (x-1)^2 (2 + x)$$
Then we see we have rank $3$ when $x \neq 1, -2$, rank $2$ when $x = -2$ and rank $1$ when $x = 1$. | Hint. Compute the determinant by using [Sarrus' rule](https://en.wikipedia.org/wiki/Rule_of_Sarrus). You will find a third degree polynomial which has $1$ as a root (for $x=1$ the matrix has rank $1$). If the determinant is not zero then the rank is $3$. Then consider the case when the determinant is zero.
P.S. The de... |
1,954,656 | >
> $$
> \left( \begin{array}
> {ccc}1 & 1 & x \\
> 1 & x & 1 \\
> x & 1 & 1 \\
> \end{array} \right) $$
>
>
> Find the values of $x$ such that the matrix above has rank $1$, $2$ and $3$.
>
>
>
Can I get the matrix to reduced row echelon form, or is there another approach? | 2016/10/05 | [
"https://math.stackexchange.com/questions/1954656",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/375285/"
] | **Option one:** row echelon form with contingencies: avoid doing anything which requires a decision, for instance dividing by a possibly zero scalar. You might get
\begin{equation}
\begin{pmatrix}
1&1&x\\
0&x-1&1-x\\
0&0&-(x+2)(x-1)\\
\end{pmatrix}
\end{equation}
From this, one may see that if $x\neq 1,-2$ then the m... | Hint. Compute the determinant by using [Sarrus' rule](https://en.wikipedia.org/wiki/Rule_of_Sarrus). You will find a third degree polynomial which has $1$ as a root (for $x=1$ the matrix has rank $1$). If the determinant is not zero then the rank is $3$. Then consider the case when the determinant is zero.
P.S. The de... |
1,954,656 | >
> $$
> \left( \begin{array}
> {ccc}1 & 1 & x \\
> 1 & x & 1 \\
> x & 1 & 1 \\
> \end{array} \right) $$
>
>
> Find the values of $x$ such that the matrix above has rank $1$, $2$ and $3$.
>
>
>
Can I get the matrix to reduced row echelon form, or is there another approach? | 2016/10/05 | [
"https://math.stackexchange.com/questions/1954656",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/375285/"
] | There are many methods, one is to compute its characteristic polynomial.
$$\chi(t) = -t^3 + (x+2) t^2 + (x-1)^2 t - (x-1)^2 (2 + x)$$
Then we see we have rank $3$ when $x \neq 1, -2$, rank $2$ when $x = -2$ and rank $1$ when $x = 1$. | **Option one:** row echelon form with contingencies: avoid doing anything which requires a decision, for instance dividing by a possibly zero scalar. You might get
\begin{equation}
\begin{pmatrix}
1&1&x\\
0&x-1&1-x\\
0&0&-(x+2)(x-1)\\
\end{pmatrix}
\end{equation}
From this, one may see that if $x\neq 1,-2$ then the m... |
29,009,132 | I have a question. I have a menu, when I click on it, it will load content remotely from URL via UIWebView.
When I try on simulator, before loading the content, there's a white background and then loads my HTML Page (which has dark background)
**Demo:**
![https://s3.amazonaws.com/quickcast/6134/84576/quickcast.gif]... | 2015/03/12 | [
"https://Stackoverflow.com/questions/29009132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You cannot set background color to your webView.
You should try following steps:
**1. write following in your viewDidLoad - Setting delegate and hiding webView.**
```
webView.delegate = self
webView.hidden = YES
```
**2. Write delegate - `shouldStartLoadWithRequest` - hiding webView when loading starts.**
```
f... | You could load your own html document, which uses the color you need.
```
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
let htmlString = "<html><body bgcolor=\"#ABCDEF\"></body></html>"
webView.loadHTMLString(htmlString, baseURL: nil)
}
``` |
29,009,132 | I have a question. I have a menu, when I click on it, it will load content remotely from URL via UIWebView.
When I try on simulator, before loading the content, there's a white background and then loads my HTML Page (which has dark background)
**Demo:**
![https://s3.amazonaws.com/quickcast/6134/84576/quickcast.gif]... | 2015/03/12 | [
"https://Stackoverflow.com/questions/29009132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | So, what I did, is, added:
```
myWebView.opaque = false
myWebView.backgroundColor = UIColor.clearColor()
```
and at controller, I unchecked this from "View"
 | You cannot set background color to your webView.
You should try following steps:
**1. write following in your viewDidLoad - Setting delegate and hiding webView.**
```
webView.delegate = self
webView.hidden = YES
```
**2. Write delegate - `shouldStartLoadWithRequest` - hiding webView when loading starts.**
```
f... |
29,009,132 | I have a question. I have a menu, when I click on it, it will load content remotely from URL via UIWebView.
When I try on simulator, before loading the content, there's a white background and then loads my HTML Page (which has dark background)
**Demo:**
![https://s3.amazonaws.com/quickcast/6134/84576/quickcast.gif]... | 2015/03/12 | [
"https://Stackoverflow.com/questions/29009132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | So, what I did, is, added:
```
myWebView.opaque = false
myWebView.backgroundColor = UIColor.clearColor()
```
and at controller, I unchecked this from "View"
 | You could load your own html document, which uses the color you need.
```
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
let htmlString = "<html><body bgcolor=\"#ABCDEF\"></body></html>"
webView.loadHTMLString(htmlString, baseURL: nil)
}
``` |
25,014,207 | I was going through bootstrap site, where they mention this snippet to load bootstrap:
<http://getbootstrap.com/getting-started/>
1. Essentially, the bootstrap javascript and JQuery are loaded just before the body tag. Is this the recommended way to load any external javascript.
2. Are there any scenarios in which ext... | 2014/07/29 | [
"https://Stackoverflow.com/questions/25014207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/507256/"
] | Basically, it doesn't look like you comprehensively check if one type if assignable another via reflection alone. The functionality to check if one type is assignable to another is already implemented in typescript, its just not exposed publicly and there is no real way to get at it without altering the typescript libr... | I'm not sure what a direct comparison to the C# `isAssignableFrom` method would be, but perhaps you could write your own logic to create that function -
```
isAssignableFrom(pullSymbol): boolean {
....
if (typeof pullSymbol === 'string') {
// Is compatible with any type that allows strings
}
..... |
12,184,619 | I'd like to display the last modified image in a directory that ends in a specific way.
I have it working to display the last file in the directory I only don't know how to go about filtering the result to only display the latest in the directory ending in "wide-block.jpg"
```
<?php
$base_url = 'images/folio/web-port... | 2012/08/29 | [
"https://Stackoverflow.com/questions/12184619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1404262/"
] | This should sort it out for you, basically just add another rule to filter in images ending in your required field.
Basically just use the strpos() function to determine if the value you are looking for is in the file name.
Also wrapped the code within a function, allowing bot the desired folder location, and desired... | That is my way, resolving this issue, I am not a programmer, it is try on error product :)
I used it in a wordpress installation and had to install the plugin
**Allow PHP in Posts and Pages**
(thats why the php tags are different, normally instead of [PHP] [/PHP])
---
```
[PHP]
global $path; // path to directory ... |
66,624,195 | I need to print a String letter by letter with a \* between each letter.
I want to find a recursive solution and not an iterative one. The signature must be :
```java
public static String allStar(String a);
``` | 2021/03/14 | [
"https://Stackoverflow.com/questions/66624195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15393507/"
] | Try this where first the string is split into array of strings of each character and then joined together with a `*` character in between them.
```
System.out.println(String.join("*", a.split("")));
``` | ```java
class AllStar {
public static String allStar(String a){
return allStar(0, a, "");
}
public static String allStar(int ch, String a, String res){
if(a.length() == 0){
return res;
}
if(ch == a.length() - 1){
res += a.charAt(ch);
return... |
66,624,195 | I need to print a String letter by letter with a \* between each letter.
I want to find a recursive solution and not an iterative one. The signature must be :
```java
public static String allStar(String a);
``` | 2021/03/14 | [
"https://Stackoverflow.com/questions/66624195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15393507/"
] | Try this where first the string is split into array of strings of each character and then joined together with a `*` character in between them.
```
System.out.println(String.join("*", a.split("")));
``` | try this code :
```
public class Main {
static String Answer = "" ;
public static void main(String[] args) {
Main.SetStarAfterEachLetter("hello!");
System.out.println(Answer);
}
public static void SetStarAfterEachLetter(String letter){
Answer = Answer + letter.charAt(0);
Answer =... |
66,624,195 | I need to print a String letter by letter with a \* between each letter.
I want to find a recursive solution and not an iterative one. The signature must be :
```java
public static String allStar(String a);
``` | 2021/03/14 | [
"https://Stackoverflow.com/questions/66624195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15393507/"
] | Beshambher's answer is a neat and easy way to do it. But if you want to do it recursively then :
```java
public static String allStar(String a) {
if(a == null || a.isEmpty()) {
return "";
}
if(a.length() == 1) {
return a;
}
return a.charAt(0) + "*" + allStar(a.subs... | Example implementation using overloaded functions `addStar(String str)` and `addStar(int pos, String str)`:
```
public static String addStar(String str) {
if (null == str || str.isEmpty()) {
return str;
}
return addStar(0, str);
}
static String addStar(int pos, String str) {
if (pos == str.len... |
66,624,195 | I need to print a String letter by letter with a \* between each letter.
I want to find a recursive solution and not an iterative one. The signature must be :
```java
public static String allStar(String a);
``` | 2021/03/14 | [
"https://Stackoverflow.com/questions/66624195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15393507/"
] | Try this where first the string is split into array of strings of each character and then joined together with a `*` character in between them.
```
System.out.println(String.join("*", a.split("")));
``` | Solution for recursive **print** a string
```
public static void allStar(String a) {
if (a != null && !a.isEmpty()) {
System.out.print(a.charAt(0));
if (a.length() > 1) {
System.out.print('*');
allStar(a.substring(1));
}
}
}
```
Solution for recursive **build**... |
66,624,195 | I need to print a String letter by letter with a \* between each letter.
I want to find a recursive solution and not an iterative one. The signature must be :
```java
public static String allStar(String a);
``` | 2021/03/14 | [
"https://Stackoverflow.com/questions/66624195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15393507/"
] | Beshambher's answer is a neat and easy way to do it. But if you want to do it recursively then :
```java
public static String allStar(String a) {
if(a == null || a.isEmpty()) {
return "";
}
if(a.length() == 1) {
return a;
}
return a.charAt(0) + "*" + allStar(a.subs... | Try this where first the string is split into array of strings of each character and then joined together with a `*` character in between them.
```
System.out.println(String.join("*", a.split("")));
``` |
66,624,195 | I need to print a String letter by letter with a \* between each letter.
I want to find a recursive solution and not an iterative one. The signature must be :
```java
public static String allStar(String a);
``` | 2021/03/14 | [
"https://Stackoverflow.com/questions/66624195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15393507/"
] | Beshambher's answer is a neat and easy way to do it. But if you want to do it recursively then :
```java
public static String allStar(String a) {
if(a == null || a.isEmpty()) {
return "";
}
if(a.length() == 1) {
return a;
}
return a.charAt(0) + "*" + allStar(a.subs... | ```java
class AllStar {
public static String allStar(String a){
return allStar(0, a, "");
}
public static String allStar(int ch, String a, String res){
if(a.length() == 0){
return res;
}
if(ch == a.length() - 1){
res += a.charAt(ch);
return... |
66,624,195 | I need to print a String letter by letter with a \* between each letter.
I want to find a recursive solution and not an iterative one. The signature must be :
```java
public static String allStar(String a);
``` | 2021/03/14 | [
"https://Stackoverflow.com/questions/66624195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15393507/"
] | Try this where first the string is split into array of strings of each character and then joined together with a `*` character in between them.
```
System.out.println(String.join("*", a.split("")));
``` | this is more general answer :
```
import java.util.Scanner;
```
public class Main {
```
static String Answer = "" ;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String word = scanner.nextLine();
Main.SetStarAfterEachLetter(word);
System.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.