qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
16,353,729 | I have some problems with the Pandas apply function, when using multiple columns with the following dataframe
```
df = DataFrame ({'a' : np.random.randn(6),
'b' : ['foo', 'bar'] * 3,
'c' : np.random.randn(6)})
```
and the following function
```
def my_test(a, b):
return a % b
... | 2013/05/03 | [
"https://Stackoverflow.com/questions/16353729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2331506/"
] | If you just want to compute (column a) % (column b), you don't need `apply`, just do it directly:
```
In [7]: df['a'] % df['c']
Out[7]:
0 -1.132022 ... | I have given the comparison of all three discussed above.
**Using values**
```
%timeit df['value'] = df['a'].values % df['c'].values
```
139 µs ± 1.91 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
**Without values**
```
%timeit df['value'] = df['a']%df['c']
```
216 µs ± 1.86 µs per loop (mean ± st... |
16,353,729 | I have some problems with the Pandas apply function, when using multiple columns with the following dataframe
```
df = DataFrame ({'a' : np.random.randn(6),
'b' : ['foo', 'bar'] * 3,
'c' : np.random.randn(6)})
```
and the following function
```
def my_test(a, b):
return a % b
... | 2013/05/03 | [
"https://Stackoverflow.com/questions/16353729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2331506/"
] | Seems you forgot the `''` of your string.
```
In [43]: df['Value'] = df.apply(lambda row: my_test(row['a'], row['c']), axis=1)
In [44]: df
Out[44]:
a b c Value
0 -1.674308 foo 0.343801 0.044698
1 -2.163236 bar -2.046438 -0.116798
2 -0.199115 foo -0... | Let's say we want to apply a function add5 to columns 'a' and 'b' of DataFrame df
```
def add5(x):
return x+5
df[['a', 'b']].apply(add5)
``` |
16,353,729 | I have some problems with the Pandas apply function, when using multiple columns with the following dataframe
```
df = DataFrame ({'a' : np.random.randn(6),
'b' : ['foo', 'bar'] * 3,
'c' : np.random.randn(6)})
```
and the following function
```
def my_test(a, b):
return a % b
... | 2013/05/03 | [
"https://Stackoverflow.com/questions/16353729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2331506/"
] | Seems you forgot the `''` of your string.
```
In [43]: df['Value'] = df.apply(lambda row: my_test(row['a'], row['c']), axis=1)
In [44]: df
Out[44]:
a b c Value
0 -1.674308 foo 0.343801 0.044698
1 -2.163236 bar -2.046438 -0.116798
2 -0.199115 foo -0... | If you just want to compute (column a) % (column b), you don't need `apply`, just do it directly:
```
In [7]: df['a'] % df['c']
Out[7]:
0 -1.132022 ... |
44,137,998 | Auto slash(/) with leading and trailing space in a date value is working fine.
```js
var date = document.getElementById('date');
function checkValue(str, max) {
if (str.charAt(0) !== '0' || str == '00') {
var num = parseInt(str);
if (isNaN(num) || num <= 0 || num > max) num = 1;
... | 2017/05/23 | [
"https://Stackoverflow.com/questions/44137998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4000103/"
] | ```js
var date = document.getElementById('date');
function checkValue(str, max) {
if (str.charAt(0) !== '0' || str == '00') {
var num = parseInt(str);
if (isNaN(num) || num <= 0 || num > max) num = 1;
str = num > parseInt(max.toString().charAt(0))
&& num.toString... | Here's a alternate answer even though [Albzi's answer](https://stackoverflow.com/a/44138117/4760460) works perfectly fine. You can use the `keydown` event and check if backspace or delete is being pressed and `return false` in your event. I also added a `maxlength` of 10 to your `input` element so it does not exceed 10... |
44,137,998 | Auto slash(/) with leading and trailing space in a date value is working fine.
```js
var date = document.getElementById('date');
function checkValue(str, max) {
if (str.charAt(0) !== '0' || str == '00') {
var num = parseInt(str);
if (isNaN(num) || num <= 0 || num > max) num = 1;
... | 2017/05/23 | [
"https://Stackoverflow.com/questions/44137998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4000103/"
] | ```js
var date = document.getElementById('date');
function checkValue(str, max) {
if (str.charAt(0) !== '0' || str == '00') {
var num = parseInt(str);
if (isNaN(num) || num <= 0 || num > max) num = 1;
str = num > parseInt(max.toString().charAt(0))
&& num.toString... | I also had this come up as a requirement for an application that I am building and I implemented my solution like this.
```js
$(document).ready(function () {
Date.prototype.toShortDateString = function() {
return (this.getMonth() + 1) + "/" + this.getDate() + "/" + this.getFullYear();
}
//#regi... |
44,137,998 | Auto slash(/) with leading and trailing space in a date value is working fine.
```js
var date = document.getElementById('date');
function checkValue(str, max) {
if (str.charAt(0) !== '0' || str == '00') {
var num = parseInt(str);
if (isNaN(num) || num <= 0 || num > max) num = 1;
... | 2017/05/23 | [
"https://Stackoverflow.com/questions/44137998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4000103/"
] | ```js
var date = document.getElementById('date');
function checkValue(str, max) {
if (str.charAt(0) !== '0' || str == '00') {
var num = parseInt(str);
if (isNaN(num) || num <= 0 || num > max) num = 1;
str = num > parseInt(max.toString().charAt(0))
&& num.toString... | This is my regex solution for React:
```
// add auto "/" for date, i.e. MM/YY
handleExpInput(e) {
// ignore invalid input
if (!/^\d{0,2}\/?\d{0,2}$/.test(e.target.value)) {
return;
}
let input = e.target.value;
if (/^\d{3,}$/.test(input)) {
input = input.match(new RegExp('.{1,2}', ... |
44,137,998 | Auto slash(/) with leading and trailing space in a date value is working fine.
```js
var date = document.getElementById('date');
function checkValue(str, max) {
if (str.charAt(0) !== '0' || str == '00') {
var num = parseInt(str);
if (isNaN(num) || num <= 0 || num > max) num = 1;
... | 2017/05/23 | [
"https://Stackoverflow.com/questions/44137998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4000103/"
] | Here's a alternate answer even though [Albzi's answer](https://stackoverflow.com/a/44138117/4760460) works perfectly fine. You can use the `keydown` event and check if backspace or delete is being pressed and `return false` in your event. I also added a `maxlength` of 10 to your `input` element so it does not exceed 10... | I also had this come up as a requirement for an application that I am building and I implemented my solution like this.
```js
$(document).ready(function () {
Date.prototype.toShortDateString = function() {
return (this.getMonth() + 1) + "/" + this.getDate() + "/" + this.getFullYear();
}
//#regi... |
44,137,998 | Auto slash(/) with leading and trailing space in a date value is working fine.
```js
var date = document.getElementById('date');
function checkValue(str, max) {
if (str.charAt(0) !== '0' || str == '00') {
var num = parseInt(str);
if (isNaN(num) || num <= 0 || num > max) num = 1;
... | 2017/05/23 | [
"https://Stackoverflow.com/questions/44137998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4000103/"
] | Here's a alternate answer even though [Albzi's answer](https://stackoverflow.com/a/44138117/4760460) works perfectly fine. You can use the `keydown` event and check if backspace or delete is being pressed and `return false` in your event. I also added a `maxlength` of 10 to your `input` element so it does not exceed 10... | This is my regex solution for React:
```
// add auto "/" for date, i.e. MM/YY
handleExpInput(e) {
// ignore invalid input
if (!/^\d{0,2}\/?\d{0,2}$/.test(e.target.value)) {
return;
}
let input = e.target.value;
if (/^\d{3,}$/.test(input)) {
input = input.match(new RegExp('.{1,2}', ... |
44,137,998 | Auto slash(/) with leading and trailing space in a date value is working fine.
```js
var date = document.getElementById('date');
function checkValue(str, max) {
if (str.charAt(0) !== '0' || str == '00') {
var num = parseInt(str);
if (isNaN(num) || num <= 0 || num > max) num = 1;
... | 2017/05/23 | [
"https://Stackoverflow.com/questions/44137998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4000103/"
] | I also had this come up as a requirement for an application that I am building and I implemented my solution like this.
```js
$(document).ready(function () {
Date.prototype.toShortDateString = function() {
return (this.getMonth() + 1) + "/" + this.getDate() + "/" + this.getFullYear();
}
//#regi... | This is my regex solution for React:
```
// add auto "/" for date, i.e. MM/YY
handleExpInput(e) {
// ignore invalid input
if (!/^\d{0,2}\/?\d{0,2}$/.test(e.target.value)) {
return;
}
let input = e.target.value;
if (/^\d{3,}$/.test(input)) {
input = input.match(new RegExp('.{1,2}', ... |
62,003,452 | How do I revert/remove the changes done in an older multi-file commit, but only do it in a single file? I.e. something like
`git revert <commit-specifier> <file>`
except `git revert` does not accept `<file>` argument. None of the following answers addresses this problem:
[Git: Revert old commit on single file](https... | 2020/05/25 | [
"https://Stackoverflow.com/questions/62003452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/155425/"
] | Git is a tool-set, not a solution, so there are multiple solutions. However, one relatively straightforward way is to start with `git revert -n`, which starts the revert but does not *finish* it:
```
git revert -n <commit-specifier>
```
This tries to back out *all* changes to *all* files, of course. You only want to... | You can revert it first:
```
git revert <commit-specifier>
```
then reset HEAD~1:
```
git reset --soft HEAD~1
```
and git add only the file that you want to do the revert:
```
git add -- <revert_file>
```
Now you can commit again
```
git commit --amend
```
remove all the other changes:
```
git checkout -- ... |
62,003,452 | How do I revert/remove the changes done in an older multi-file commit, but only do it in a single file? I.e. something like
`git revert <commit-specifier> <file>`
except `git revert` does not accept `<file>` argument. None of the following answers addresses this problem:
[Git: Revert old commit on single file](https... | 2020/05/25 | [
"https://Stackoverflow.com/questions/62003452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/155425/"
] | Git is a tool-set, not a solution, so there are multiple solutions. However, one relatively straightforward way is to start with `git revert -n`, which starts the revert but does not *finish* it:
```
git revert -n <commit-specifier>
```
This tries to back out *all* changes to *all* files, of course. You only want to... | I accidentally committed a file with a couple of lines of changes and realized after 10 or so commits later. That file should have never been part of any commit. Reverting using any of the suggested answers in this post or any other SO answers was horrible in my case. Ran into lots of merge conflict hell and numerous g... |
62,003,452 | How do I revert/remove the changes done in an older multi-file commit, but only do it in a single file? I.e. something like
`git revert <commit-specifier> <file>`
except `git revert` does not accept `<file>` argument. None of the following answers addresses this problem:
[Git: Revert old commit on single file](https... | 2020/05/25 | [
"https://Stackoverflow.com/questions/62003452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/155425/"
] | You can revert it first:
```
git revert <commit-specifier>
```
then reset HEAD~1:
```
git reset --soft HEAD~1
```
and git add only the file that you want to do the revert:
```
git add -- <revert_file>
```
Now you can commit again
```
git commit --amend
```
remove all the other changes:
```
git checkout -- ... | I accidentally committed a file with a couple of lines of changes and realized after 10 or so commits later. That file should have never been part of any commit. Reverting using any of the suggested answers in this post or any other SO answers was horrible in my case. Ran into lots of merge conflict hell and numerous g... |
26,108 | In the start of my adventure the PCs will not be together. I plan to have all them fight 1-3 encounters alone before finally meeting up. I read in the book about setting encounters but the minimum I saw was a party of three, nothing about being alone. They are of course all lvl 1. Their classes are Figher, Ranger, Sorc... | 2013/06/04 | [
"https://rpg.stackexchange.com/questions/26108",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/8433/"
] | The results are going to be highly variable, and depend on the situation, and depend a lot on the critters facing each PC, along with the way the PCs are built. Any PC built to depend on someone else (for instance, the Sorcerer, depending on his spells, or the Ranger, if he is built for ranged combat) will struggle mor... | Apart from [YogoZuno's excellent answer](https://rpg.stackexchange.com/a/26109/5746), I've found that in practice the challenge a single PC can face safely varies a lot. With only one person fighting, a few unlucky rolls can be all it takes for a player to die. However, sometimes the player will do a lot better than ex... |
26,108 | In the start of my adventure the PCs will not be together. I plan to have all them fight 1-3 encounters alone before finally meeting up. I read in the book about setting encounters but the minimum I saw was a party of three, nothing about being alone. They are of course all lvl 1. Their classes are Figher, Ranger, Sorc... | 2013/06/04 | [
"https://rpg.stackexchange.com/questions/26108",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/8433/"
] | The results are going to be highly variable, and depend on the situation, and depend a lot on the critters facing each PC, along with the way the PCs are built. Any PC built to depend on someone else (for instance, the Sorcerer, depending on his spells, or the Ranger, if he is built for ranged combat) will struggle mor... | At level 1, on their own, they can basically die to anything.
Simple example: take [4 kobolds](http://www.d20pfsrd.com/bestiary/monster-listings/humanoids/kobold) (total CR ~= 1).
* Your sorcerer has 8hp, they deal ~3 pts. damage per successful attack. They have a 50% chance of hitting, so two hit each round. Well ... |
26,108 | In the start of my adventure the PCs will not be together. I plan to have all them fight 1-3 encounters alone before finally meeting up. I read in the book about setting encounters but the minimum I saw was a party of three, nothing about being alone. They are of course all lvl 1. Their classes are Figher, Ranger, Sorc... | 2013/06/04 | [
"https://rpg.stackexchange.com/questions/26108",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/8433/"
] | >
> I want them to fight animals, undead and maybe even demons if possible.
> The theme is mostly dark and dreary foes.
>
>
>
Are just the foes dark or is it a theme in your whole world?
If that is the case then kidnapping might be common and the rangers encounter could be with some peasants whose child has gone... | Apart from [YogoZuno's excellent answer](https://rpg.stackexchange.com/a/26109/5746), I've found that in practice the challenge a single PC can face safely varies a lot. With only one person fighting, a few unlucky rolls can be all it takes for a player to die. However, sometimes the player will do a lot better than ex... |
26,108 | In the start of my adventure the PCs will not be together. I plan to have all them fight 1-3 encounters alone before finally meeting up. I read in the book about setting encounters but the minimum I saw was a party of three, nothing about being alone. They are of course all lvl 1. Their classes are Figher, Ranger, Sorc... | 2013/06/04 | [
"https://rpg.stackexchange.com/questions/26108",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/8433/"
] | >
> I want them to fight animals, undead and maybe even demons if possible.
> The theme is mostly dark and dreary foes.
>
>
>
Are just the foes dark or is it a theme in your whole world?
If that is the case then kidnapping might be common and the rangers encounter could be with some peasants whose child has gone... | At level 1, on their own, they can basically die to anything.
Simple example: take [4 kobolds](http://www.d20pfsrd.com/bestiary/monster-listings/humanoids/kobold) (total CR ~= 1).
* Your sorcerer has 8hp, they deal ~3 pts. damage per successful attack. They have a 50% chance of hitting, so two hit each round. Well ... |
3,510,884 | The harmonic-geometric mean inequality is defined as follows
$$
\frac{n}{\sum\_{i=1}^n \frac{1}{x\_i}} \leq (\Pi\_{i=1}^{n}x\_i)^{\frac{1}{n}}\tag{1}
$$
Given the following linear programming problem
$$
\min \sum\_{i=1}^n \frac{1}{x\_i}\\
\begin{align}
\text{s.t} \,\,\,\,\,\,\,& \Pi\_{i=1}^{n}x\_i=1\\
&x\geq0
\end{al... | 2020/01/16 | [
"https://math.stackexchange.com/questions/3510884",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/494522/"
] | Suppose we have $y\_1, \ldots, y\_n > 0.$ Define $P = \prod\_{i=1}^n y\_i$ and $x\_i = y\_i \cdot P^{-1/n}.$ Then $x\_i \geq 0$ and $\prod\_{i=1}^n x\_i = 1$ so by the result of the optimization problem we have
$$ \sum\_{i=1}^n \frac{1}{x\_i} \geq n$$
Since $x\_i = y\_i \cdot P^{-1/n}$ we have
$$\sum\_{i=1}^n \fra... | Because by AM-GM:
$$\left(\prod\_{i=1}^nx\_i\right)^{\frac{1}{n}}\sum\_{i=1}^n\frac{1}{x\_i}\geq\left(\prod\_{i=1}^nx\_i\right)^{\frac{1}{n}}\cdot n\left(\prod\_{i=1}^n\frac{1}{x\_i}\right)^{\frac{1}{n}}=\frac{n\left(\prod\limits\_{i=1}^nx\_i\right)^{\frac{1}{n}}}{\left(\prod\limits\_{i=1}^nx\_i\right)^{\frac{1}{n}}}=n... |
3,510,884 | The harmonic-geometric mean inequality is defined as follows
$$
\frac{n}{\sum\_{i=1}^n \frac{1}{x\_i}} \leq (\Pi\_{i=1}^{n}x\_i)^{\frac{1}{n}}\tag{1}
$$
Given the following linear programming problem
$$
\min \sum\_{i=1}^n \frac{1}{x\_i}\\
\begin{align}
\text{s.t} \,\,\,\,\,\,\,& \Pi\_{i=1}^{n}x\_i=1\\
&x\geq0
\end{al... | 2020/01/16 | [
"https://math.stackexchange.com/questions/3510884",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/494522/"
] | Suppose we have $y\_1, \ldots, y\_n > 0.$ Define $P = \prod\_{i=1}^n y\_i$ and $x\_i = y\_i \cdot P^{-1/n}.$ Then $x\_i \geq 0$ and $\prod\_{i=1}^n x\_i = 1$ so by the result of the optimization problem we have
$$ \sum\_{i=1}^n \frac{1}{x\_i} \geq n$$
Since $x\_i = y\_i \cdot P^{-1/n}$ we have
$$\sum\_{i=1}^n \fra... | We can use also the TL method:
Since our inequality is homogeneous, we can assume $\prod\limits\_{i=1}^nx\_i=1.$
Thus, we need to prove that:
$$\sum\_{i=1}^n\frac{1}{x\_i}\geq n.$$
Indeed, $$\sum\_{i=1}^n\frac{1}{x\_i}-n=\sum\_{i=1}^n\left(\frac{1}{x\_i}-1+\ln{x\_i}\right)\geq0$$
because easy to show that for any pos... |
1,641,591 | I find myself writing the same argument checking code all the time for number-crunching:
```
def myfun(a, b):
if a < 0:
raise ValueError('a cannot be < 0 (was a=%s)' % a)
# more if.. raise exception stuff here ...
return a + b
```
Is there a better way? I was told not to use 'assert' for these th... | 2009/10/29 | [
"https://Stackoverflow.com/questions/1641591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/198637/"
] | `assert` gets optimized away if you run with `python -O` (modest optimizations, but sometimes nice to have). One preferable alternative if you have patterns that often repeat may be to use decorators -- great way to factor out repetition. E.g., say you have a zillion functions that must be called with arguments by-posi... | You don't want to use assert because your code can be run (and is by default on some systems) in such a way that assert lines are not checked and do not raise errors (`-O` command line flag).
If you're using a lot of variables that are all supposed to have those same properties, why not subclass whatever type you're u... |
1,641,591 | I find myself writing the same argument checking code all the time for number-crunching:
```
def myfun(a, b):
if a < 0:
raise ValueError('a cannot be < 0 (was a=%s)' % a)
# more if.. raise exception stuff here ...
return a + b
```
Is there a better way? I was told not to use 'assert' for these th... | 2009/10/29 | [
"https://Stackoverflow.com/questions/1641591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/198637/"
] | You don't want to use assert because your code can be run (and is by default on some systems) in such a way that assert lines are not checked and do not raise errors (`-O` command line flag).
If you're using a lot of variables that are all supposed to have those same properties, why not subclass whatever type you're u... | I'm not sure if this will answer your question, but it strikes me that checking a lot of arguments at the start of a function isn't very *pythonic*.
What I mean by this is that it is the assumption of most pythonistas that we are all consenting adults, and we trust each other not to do something stupid. Here's how I'd... |
1,641,591 | I find myself writing the same argument checking code all the time for number-crunching:
```
def myfun(a, b):
if a < 0:
raise ValueError('a cannot be < 0 (was a=%s)' % a)
# more if.. raise exception stuff here ...
return a + b
```
Is there a better way? I was told not to use 'assert' for these th... | 2009/10/29 | [
"https://Stackoverflow.com/questions/1641591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/198637/"
] | `assert` gets optimized away if you run with `python -O` (modest optimizations, but sometimes nice to have). One preferable alternative if you have patterns that often repeat may be to use decorators -- great way to factor out repetition. E.g., say you have a zillion functions that must be called with arguments by-posi... | I'm not sure if this will answer your question, but it strikes me that checking a lot of arguments at the start of a function isn't very *pythonic*.
What I mean by this is that it is the assumption of most pythonistas that we are all consenting adults, and we trust each other not to do something stupid. Here's how I'd... |
13,672,482 | Let a module to abstract `Area` operations (bad definition)
```
class Area someShapeType where
area :: someShapeType -> Float
-- module utilities
sumAreas :: Area someShapeType => [someShapeType]
sumAreas = sum . map area
```
Let a **posteriori** explicit shape type modules (good or acceptable definition)
```
da... | 2012/12/02 | [
"https://Stackoverflow.com/questions/13672482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1540749/"
] | Your existential solution is okay. It might be "prettier" to instead use a `GADT`, as in:
```
{-# LANGUAGE GADTs #-}
data Shape where
Shape :: (Surface a) => a -> Shape
```
...and as leftaraoundabout suggests, you may be able to structure your code differently.
But I think you've basically hit up against the [E... | Your first (and bad) way is not pretty, it's Lispy. This is just not possible in a statically typed language; even when you do such a thing in e.g. Java you're actually introducing a seperate quantification step by using base class pointers, which is analoguous to the `data Shape = forall a. Surface a`.
There is dispu... |
13,672,482 | Let a module to abstract `Area` operations (bad definition)
```
class Area someShapeType where
area :: someShapeType -> Float
-- module utilities
sumAreas :: Area someShapeType => [someShapeType]
sumAreas = sum . map area
```
Let a **posteriori** explicit shape type modules (good or acceptable definition)
```
da... | 2012/12/02 | [
"https://Stackoverflow.com/questions/13672482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1540749/"
] | Your existential solution is okay. It might be "prettier" to instead use a `GADT`, as in:
```
{-# LANGUAGE GADTs #-}
data Shape where
Shape :: (Surface a) => a -> Shape
```
...and as leftaraoundabout suggests, you may be able to structure your code differently.
But I think you've basically hit up against the [E... | What you originally did is hit the existential antipattern.
Why use classes here anyways?
```
data Shape = Shape { area :: Double }
data Point = Point Double Double
circle :: Point -> Double -> Shape
circle p r =
Shape $ 2 * pi * r
rectangle :: Point -> Point -> Shape
rectangle (Point x1 y1) (Point x2 y2) =
... |
15,380,739 | I am using the following code reference from Adobe Edge Commons example MixitBaby but I keep getting this error on Chrome & IE10, this works fine on Firefox though.
"Uncaught ReferenceError: EC is not defined"
```
function soundSetup()
{
var assetsPath = "sound/";
EC.Sound.setup(
[
{src... | 2013/03/13 | [
"https://Stackoverflow.com/questions/15380739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1079089/"
] | In string literals, a backslash `\` is used as a prefix for special characters. I'm sure you know about newline (`"\n"`) for example.
If the special character after the backslash is an `x` then it means that the next two characters are hexadecimal digits, and those two digits are the translated by the compiler into a ... | That's a degree sign, encoded as UTF-8 unicode.
You can have a look at a more complete list of characters and what they look like in UTF-8 [here](http://www.utf8-chartable.de/unicode-utf8-table.pl?start=128&number=128&utf8=string-literal&unicodeinhtml=hex). |
15,380,739 | I am using the following code reference from Adobe Edge Commons example MixitBaby but I keep getting this error on Chrome & IE10, this works fine on Firefox though.
"Uncaught ReferenceError: EC is not defined"
```
function soundSetup()
{
var assetsPath = "sound/";
EC.Sound.setup(
[
{src... | 2013/03/13 | [
"https://Stackoverflow.com/questions/15380739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1079089/"
] | That's a degree sign, encoded as UTF-8 unicode.
You can have a look at a more complete list of characters and what they look like in UTF-8 [here](http://www.utf8-chartable.de/unicode-utf8-table.pl?start=128&number=128&utf8=string-literal&unicodeinhtml=hex). | In C, something in the format `\x???` in a string literal, where `???` are numbers, is a *Unicode escape*. It is a way of entering Unicode characters which cannot be entered with a keyboard. In this case, if you look at [this table](http://www.utf8-chartable.de/), you will see that the escape sequence `c2 b0` (written ... |
15,380,739 | I am using the following code reference from Adobe Edge Commons example MixitBaby but I keep getting this error on Chrome & IE10, this works fine on Firefox though.
"Uncaught ReferenceError: EC is not defined"
```
function soundSetup()
{
var assetsPath = "sound/";
EC.Sound.setup(
[
{src... | 2013/03/13 | [
"https://Stackoverflow.com/questions/15380739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1079089/"
] | In string literals, a backslash `\` is used as a prefix for special characters. I'm sure you know about newline (`"\n"`) for example.
If the special character after the backslash is an `x` then it means that the next two characters are hexadecimal digits, and those two digits are the translated by the compiler into a ... | In C, something in the format `\x???` in a string literal, where `???` are numbers, is a *Unicode escape*. It is a way of entering Unicode characters which cannot be entered with a keyboard. In this case, if you look at [this table](http://www.utf8-chartable.de/), you will see that the escape sequence `c2 b0` (written ... |
62,515,551 | I'm trying to add one more index value to the path:
`$.data.library.category[2].book` using `jayway jsonpath` in following Json,
```
"data":{
"library":{
"class":"CRED",
"category":[{
"book":"java 2.0"
},
{
"book":"java 3.0"
}]
}
``... | 2020/06/22 | [
"https://Stackoverflow.com/questions/62515551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13792129/"
] | Path `$.data.library.category[2].book` means that you want to update `3-rd` element in array. But there is no `3-rd` element yet. You need to create it first. You can add new element to array using `$.data.library.category` path. By providing a `Map` object you can define all required keys and values. See below example... | I believe that `Json` class from <https://github.com/karatelabs/karate> can work for you.
Given
```
String json = {
"data": {
"library": {
"class": "CRED",
"category": [
{
"book": "java 2.0"
},
{
"book": "java 3.0"
}
]
}
}
}
```
What y... |
3,852,758 | What calls best emulate [pread/pwrite](http://manpages.ubuntu.com/manpages/lucid/en/man2/pwrite.2.html) in MSVC 10? | 2010/10/04 | [
"https://Stackoverflow.com/questions/3852758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/149482/"
] | At the C runtime library level, look at [fread](http://msdn.microsoft.com/en-US/library/kt0etdcs%28v=VS.80%29.aspx), [fwrite](http://msdn.microsoft.com/en-US/library/h9t88zwz%28v=VS.80%29.aspx) and [fseek](http://msdn.microsoft.com/en-US/library/75yw9bf3%28v=VS.80%29.aspx).
At the Win32 API level, have a look at [Read... | It looks like you just use the **lpOverlapped** parameter to [**ReadFile**](http://msdn.microsoft.com/en-us/library/windows/desktop/aa365467%28v=vs.85%29.aspx)/[**WriteFile**](http://msdn.microsoft.com/en-us/library/windows/desktop/aa365747%28v=vs.85%29.aspx) to pass a pointer to an [**OVERLAPPED**](http://msdn.microso... |
3,852,758 | What calls best emulate [pread/pwrite](http://manpages.ubuntu.com/manpages/lucid/en/man2/pwrite.2.html) in MSVC 10? | 2010/10/04 | [
"https://Stackoverflow.com/questions/3852758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/149482/"
] | At the C runtime library level, look at [fread](http://msdn.microsoft.com/en-US/library/kt0etdcs%28v=VS.80%29.aspx), [fwrite](http://msdn.microsoft.com/en-US/library/h9t88zwz%28v=VS.80%29.aspx) and [fseek](http://msdn.microsoft.com/en-US/library/75yw9bf3%28v=VS.80%29.aspx).
At the Win32 API level, have a look at [Read... | The answer provided by Oren seems correct but doesn't seem to meet the needs. Actually, I too was here for searching the answer but couldn't find it. So, I will update a bit here.
As said,
At the C runtime library level, there are [fread](http://msdn.microsoft.com/en-US/library/kt0etdcs(v=VS.80).aspx), [fwrite](http:... |
3,852,758 | What calls best emulate [pread/pwrite](http://manpages.ubuntu.com/manpages/lucid/en/man2/pwrite.2.html) in MSVC 10? | 2010/10/04 | [
"https://Stackoverflow.com/questions/3852758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/149482/"
] | It looks like you just use the **lpOverlapped** parameter to [**ReadFile**](http://msdn.microsoft.com/en-us/library/windows/desktop/aa365467%28v=vs.85%29.aspx)/[**WriteFile**](http://msdn.microsoft.com/en-us/library/windows/desktop/aa365747%28v=vs.85%29.aspx) to pass a pointer to an [**OVERLAPPED**](http://msdn.microso... | The answer provided by Oren seems correct but doesn't seem to meet the needs. Actually, I too was here for searching the answer but couldn't find it. So, I will update a bit here.
As said,
At the C runtime library level, there are [fread](http://msdn.microsoft.com/en-US/library/kt0etdcs(v=VS.80).aspx), [fwrite](http:... |
65,602,683 | I have a valid HereMaps API Key and I am using python `requests` lib to execute a GET request to a link that is returned after an async call is made. I am trying to execute it like this:
[https://aws-ap-southeast-1.matrix.router.hereapi.com/v8/matrix/01187ff8-7888-4ed6-af88-c8f9be9242d7/status?apiKey={my-api-key}](htt... | 2021/01/06 | [
"https://Stackoverflow.com/questions/65602683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8745534/"
] | There are two authentication methods [available to you for using HERE APIs](https://developer.here.com/documentation/identity-access-management/dev_guide/index.html): API key and OAuth token.
Because of the way credentials are being handled, when you make an asynchronous request, you'll need to disable automatic clien... | Please check the [documentation for the domain name to use for HERE services](https://developer.here.com/documentation/identity-access-management/dev_guide/topics/hosts-mapping.html). For Matrix Routing you should be using `matrix.route.ls.hereapi.com`.
Disclosure: I'm a product manager at HERE Technologies |
32,995,667 | I need to select (count) rows with a specific date formatted by YEAR-MONTH-DAY.
i try
```
$date = $_GET['date'];
// requete qui recupere les evenements
$result = "SELECT COUNT(*) FROM evenement WHERE STR_TO_DATE(start, '%Y-%m-%d') = $date";
// connexion a la base de donnees
try {
$bdd = new PDO('mysql:host=;db... | 2015/10/07 | [
"https://Stackoverflow.com/questions/32995667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3602203/"
] | You should convert your constant to a date, not the column. So, my first attempt would be:
```
SELECT COUNT(*)
FROM evenement
WHERE start = DATE('$date');
```
However, that might not work. You might need to use `str_to_date()` with the appropriate format.
The reason this method is better is because the optimizer ca... | Change like this
```
$result = "SELECT COUNT(*) FROM evenement WHERE DATE_FORMAT(start, '%Y-%m-%d') = '".$date."'";
```
You need to enclose $date in '' quotes, else it will perform subtraction like(2014-10-01 = 2003) |
32,995,667 | I need to select (count) rows with a specific date formatted by YEAR-MONTH-DAY.
i try
```
$date = $_GET['date'];
// requete qui recupere les evenements
$result = "SELECT COUNT(*) FROM evenement WHERE STR_TO_DATE(start, '%Y-%m-%d') = $date";
// connexion a la base de donnees
try {
$bdd = new PDO('mysql:host=;db... | 2015/10/07 | [
"https://Stackoverflow.com/questions/32995667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3602203/"
] | The responses and comments all led to this answer
```
$result = "SELECT COUNT(*) FROM evenement WHERE DATE_FORMAT(DATE(start), '%Y-%m-%d') = DATE('".$date."')"
```
the problem was that the $date variable need DATE($date) and in SELECT need quotes. | Change like this
```
$result = "SELECT COUNT(*) FROM evenement WHERE DATE_FORMAT(start, '%Y-%m-%d') = '".$date."'";
```
You need to enclose $date in '' quotes, else it will perform subtraction like(2014-10-01 = 2003) |
32,995,667 | I need to select (count) rows with a specific date formatted by YEAR-MONTH-DAY.
i try
```
$date = $_GET['date'];
// requete qui recupere les evenements
$result = "SELECT COUNT(*) FROM evenement WHERE STR_TO_DATE(start, '%Y-%m-%d') = $date";
// connexion a la base de donnees
try {
$bdd = new PDO('mysql:host=;db... | 2015/10/07 | [
"https://Stackoverflow.com/questions/32995667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3602203/"
] | The responses and comments all led to this answer
```
$result = "SELECT COUNT(*) FROM evenement WHERE DATE_FORMAT(DATE(start), '%Y-%m-%d') = DATE('".$date."')"
```
the problem was that the $date variable need DATE($date) and in SELECT need quotes. | You should convert your constant to a date, not the column. So, my first attempt would be:
```
SELECT COUNT(*)
FROM evenement
WHERE start = DATE('$date');
```
However, that might not work. You might need to use `str_to_date()` with the appropriate format.
The reason this method is better is because the optimizer ca... |
45,275,379 | i'm learning nodejs and some issues appeared, that emit() and on() is not a function..
here's my emitter.js fie
```js
function Emitter(){
this.events = {};
}
Emitter.prototype.on = function(type, listener){
this.events[type]=this.events[type]||[];
this.events[type].push(listener);
}
Emitter.pr... | 2017/07/24 | [
"https://Stackoverflow.com/questions/45275379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7698574/"
] | You've created a class. Create an instance of it using `new Emitter()`. Also, you have to export and import the `Emitter` class:
```js
// emitter.js
function Emitter(){
this.events = {};
}
Emitter.prototype.on = function(type, listener){
this.events[type]=this.events[type]||[];
this.events[type].push(list... | There are two issues that should be addressed, firstly you need to export the `Emitter` function from the file that it was defined in to be able to `require` it in another file, you can do this simply like this:
```
module.exports = function Emitter() {
this.events = {}
}
// ... etc
```
You also need to use the `... |
21,992,204 | I am following tutorials from [youtube](http://youtu.be/vz1O9nRyZaY). It seems I have encountered an error I can't resolve by myself. The goal is to create a class called BMI, which takes users weight name and height and prints them out..
I'm trying to compile it using g++, and I suspect I'm not doing it right. Usual... | 2014/02/24 | [
"https://Stackoverflow.com/questions/21992204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You need to compile the main.cpp into Main.o and BMI.cpp into BMI.o.
```
g++ -c Main.cpp
g++ -c BMI.cpp
```
Then you need to link both object files into one executable (and link to the Standard C++ lib)
```
g++ -o myprog Main.o BMI.o -lstdc++
```
Run the example with
```
./myprog
```
There seem to be more bugs... | your function return noting in your BMI.cpp
try with this.
```
string BMI::getName() const
{
return newName;
}
int BMI::getHeight() const
{
return newHeight;
}
double BMI::getWeight() const
{
return newWeight;
}
``` |
5,416,594 | From Time to time my visual studio 2010 occupies the executable program in Debug subdirectory.
Thus I have to unload the solution and reload it. Then ReBuild it and then run it.
The all situatuation becomes upseen
I really can't work like that.
I have already unclick in Debug section the
`Enable the Virtual... | 2011/03/24 | [
"https://Stackoverflow.com/questions/5416594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/230348/"
] | Well this is a bit of a workaround but works for me most of the time. This doesn't solve the root cause but the symptoms (the file locking):
Add this as a pre-build event:
```
if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "... | It may also not be Visual Studio locking your executable, check the locks on it with "Unlocker": <http://www.emptyloop.com/unlocker/> |
5,416,594 | From Time to time my visual studio 2010 occupies the executable program in Debug subdirectory.
Thus I have to unload the solution and reload it. Then ReBuild it and then run it.
The all situatuation becomes upseen
I really can't work like that.
I have already unclick in Debug section the
`Enable the Virtual... | 2011/03/24 | [
"https://Stackoverflow.com/questions/5416594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/230348/"
] | Well this is a bit of a workaround but works for me most of the time. This doesn't solve the root cause but the symptoms (the file locking):
Add this as a pre-build event:
```
if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "... | When this happens I open [Process Explorer](http://technet.microsoft.com/en-us/sysinternals/bb896653) and use the Find - Find Handle or Dll menu to find the process which has the file still open. From there I can jump the the handle in the process and close it from within Process Explorer. That works although it is a b... |
608,721 | Suppose $f:[0,1]\to\mathbb{R}$ is continuous,define
$$g:[0,1]\to\mathbb{R},\quad g(x):=\int\_0^1|f(t)-x|dt$$
Show that $g$ attains maximum at $0$ or $1$.
I don't know how to approach, any hints? | 2013/12/16 | [
"https://math.stackexchange.com/questions/608721",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/116072/"
] | Essentially we need to use convexity of g(x). For any $x,t\in(0,1)$, we have
$$
|f(t)-x|\le x|f(t)-1|+(1-x)|f(t)|
$$
Integrate on both sides form $0$ to $1$ with respect to $t$, we obtain
$$
g(x)\le x\cdot g(1)+(1-x)\cdot g(0)
$$.
Now suppose the contrary, if there exists $x\_0\in(0,1)$ such that $g(x\_0)>g(0)$ and... | Show that $g$ is convex. This follows since $x \mapsto |x-c|$ is convex.
Now to show is that $g$ is non-constant. There are two possibilities.
1. Either $f([0,1]) \subset (-\infty, 0]$, or $f([0,1]) \subset [1,\infty)$. And in either of these cases, $g$ is linear with slope $-1$ or $1$.
2. Or, since $f$ is continuous... |
64,031,727 | In an Android studio activity I want to use the EditText input to go to a second activity, my code works, but I have to press twice for this to work, how can I correct this to only press once
```
editText.setInputType(InputType.TYPE_NULL);
editText.setShowSoftInputOnFocus(false);
public void addListenerOnButton() ... | 2020/09/23 | [
"https://Stackoverflow.com/questions/64031727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10548326/"
] | The only difference between `println` and `print` method is that `println` throws the cursor to the next line after printing the desired result whereas `print` method keeps the cursor on the same line.
[More information](https://www.tutorialslink.com/Code-Snippet/Difference-between-Systemoutprintln()-and-Systemoutprin... | I wrote about it and have some examples at the following link:
<https://creatingcoder.com/2020/08/07/println-vs-print/>
Basically, the print method doesn't move the cursor, whereas the println creates a new line. |
29,256,427 | I often use two related collections and want to access the corresponding elements in a foreach loop.
But, there is no ".Index" property, is there a direct way of doing this, WITHOUT incrementing a counter?
```
public void PrepareData()
{
var lines = ReadAllLines(@"\\tsclient\T\Bbtra\wapData.t... | 2015/03/25 | [
"https://Stackoverflow.com/questions/29256427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/439497/"
] | You could use [Enumerable.Zip](https://msdn.microsoft.com/en-us/library/vstudio/dd267698%28v=vs.100%29.aspx) and an anonymous type:
```
string[] names={"Rod", "Jane", "Freddy"}
int[] ages={28,32,26;};
var pairs=names.Zip(ages, (name,age) => new{Name=name, Age=age});
foreach(var pair in pairs)
{
string name=pair.Nam... | I'm thinking you want a [`.Zip`](https://msdn.microsoft.com/en-us/library/vstudio/dd267698%28v=vs.100%29.aspx).
```
var pairs = headers.Zip(values,
(header, value) => new Tuple<string, string>(header, value));
``` |
29,256,427 | I often use two related collections and want to access the corresponding elements in a foreach loop.
But, there is no ".Index" property, is there a direct way of doing this, WITHOUT incrementing a counter?
```
public void PrepareData()
{
var lines = ReadAllLines(@"\\tsclient\T\Bbtra\wapData.t... | 2015/03/25 | [
"https://Stackoverflow.com/questions/29256427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/439497/"
] | I'm thinking you want a [`.Zip`](https://msdn.microsoft.com/en-us/library/vstudio/dd267698%28v=vs.100%29.aspx).
```
var pairs = headers.Zip(values,
(header, value) => new Tuple<string, string>(header, value));
``` | Do it with IndexOf
```
var lines = ReadAllLines(@"\\tsclient\T\Bbtra\wapData.txt");
var headers = lines[0].Split(',');
var values = lines.Last().Split(',');
foreach(var value in values.Skip(1))
{
string message = "Data: " + headers[Array.IndexOf(values, value)] + ' ' + value;
}
```
or maybe with iterators :
``... |
29,256,427 | I often use two related collections and want to access the corresponding elements in a foreach loop.
But, there is no ".Index" property, is there a direct way of doing this, WITHOUT incrementing a counter?
```
public void PrepareData()
{
var lines = ReadAllLines(@"\\tsclient\T\Bbtra\wapData.t... | 2015/03/25 | [
"https://Stackoverflow.com/questions/29256427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/439497/"
] | Yet another variant, use [Select](https://msdn.microsoft.com/en-us/library/bb534869(v=vs.110).aspx) overloading with index like
```
public void PrepareData()
{
var lines = ReadAllLines(@"\\tsclient\T\Bbtra\wapData.txt");
var headers = lines[0].Split(',');
var values = lines.Last().Split(',').Select((el,ind... | I'm thinking you want a [`.Zip`](https://msdn.microsoft.com/en-us/library/vstudio/dd267698%28v=vs.100%29.aspx).
```
var pairs = headers.Zip(values,
(header, value) => new Tuple<string, string>(header, value));
``` |
29,256,427 | I often use two related collections and want to access the corresponding elements in a foreach loop.
But, there is no ".Index" property, is there a direct way of doing this, WITHOUT incrementing a counter?
```
public void PrepareData()
{
var lines = ReadAllLines(@"\\tsclient\T\Bbtra\wapData.t... | 2015/03/25 | [
"https://Stackoverflow.com/questions/29256427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/439497/"
] | You could use [Enumerable.Zip](https://msdn.microsoft.com/en-us/library/vstudio/dd267698%28v=vs.100%29.aspx) and an anonymous type:
```
string[] names={"Rod", "Jane", "Freddy"}
int[] ages={28,32,26;};
var pairs=names.Zip(ages, (name,age) => new{Name=name, Age=age});
foreach(var pair in pairs)
{
string name=pair.Nam... | Do it with IndexOf
```
var lines = ReadAllLines(@"\\tsclient\T\Bbtra\wapData.txt");
var headers = lines[0].Split(',');
var values = lines.Last().Split(',');
foreach(var value in values.Skip(1))
{
string message = "Data: " + headers[Array.IndexOf(values, value)] + ' ' + value;
}
```
or maybe with iterators :
``... |
29,256,427 | I often use two related collections and want to access the corresponding elements in a foreach loop.
But, there is no ".Index" property, is there a direct way of doing this, WITHOUT incrementing a counter?
```
public void PrepareData()
{
var lines = ReadAllLines(@"\\tsclient\T\Bbtra\wapData.t... | 2015/03/25 | [
"https://Stackoverflow.com/questions/29256427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/439497/"
] | You could use [Enumerable.Zip](https://msdn.microsoft.com/en-us/library/vstudio/dd267698%28v=vs.100%29.aspx) and an anonymous type:
```
string[] names={"Rod", "Jane", "Freddy"}
int[] ages={28,32,26;};
var pairs=names.Zip(ages, (name,age) => new{Name=name, Age=age});
foreach(var pair in pairs)
{
string name=pair.Nam... | Yet another variant, use [Select](https://msdn.microsoft.com/en-us/library/bb534869(v=vs.110).aspx) overloading with index like
```
public void PrepareData()
{
var lines = ReadAllLines(@"\\tsclient\T\Bbtra\wapData.txt");
var headers = lines[0].Split(',');
var values = lines.Last().Split(',').Select((el,ind... |
29,256,427 | I often use two related collections and want to access the corresponding elements in a foreach loop.
But, there is no ".Index" property, is there a direct way of doing this, WITHOUT incrementing a counter?
```
public void PrepareData()
{
var lines = ReadAllLines(@"\\tsclient\T\Bbtra\wapData.t... | 2015/03/25 | [
"https://Stackoverflow.com/questions/29256427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/439497/"
] | Yet another variant, use [Select](https://msdn.microsoft.com/en-us/library/bb534869(v=vs.110).aspx) overloading with index like
```
public void PrepareData()
{
var lines = ReadAllLines(@"\\tsclient\T\Bbtra\wapData.txt");
var headers = lines[0].Split(',');
var values = lines.Last().Split(',').Select((el,ind... | Do it with IndexOf
```
var lines = ReadAllLines(@"\\tsclient\T\Bbtra\wapData.txt");
var headers = lines[0].Split(',');
var values = lines.Last().Split(',');
foreach(var value in values.Skip(1))
{
string message = "Data: " + headers[Array.IndexOf(values, value)] + ' ' + value;
}
```
or maybe with iterators :
``... |
64,205,627 | I am facing an issue in IntelliJ when I tried to build my project through maven using
```
mvn clean install
```
I have tried different ways like changing the path of my JDK but nothing worked. Can someone help me out with this issue? | 2020/10/05 | [
"https://Stackoverflow.com/questions/64205627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7688591/"
] | If you really need them, add the dependency in your pom.xml :
```
<!-- https://mvnrepository.com/artifact/org.jetbrains/annotations -->
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>16.0.1</version>
</dependency>
```
( <https://mvnrepository.com/artifact/org.... | I had the same issue and arrived here looking for solutions, but I couldn't find the aforementioned pom.xml. Maybe because I'm not using Maven in my project. But I solved it by editing the *MyProject.iml* file.
I've added the following code inside the `<component>` tags.
```
<orderEntry type="module-library">
<libra... |
64,205,627 | I am facing an issue in IntelliJ when I tried to build my project through maven using
```
mvn clean install
```
I have tried different ways like changing the path of my JDK but nothing worked. Can someone help me out with this issue? | 2020/10/05 | [
"https://Stackoverflow.com/questions/64205627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7688591/"
] | If you really need them, add the dependency in your pom.xml :
```
<!-- https://mvnrepository.com/artifact/org.jetbrains/annotations -->
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>16.0.1</version>
</dependency>
```
( <https://mvnrepository.com/artifact/org.... | For me adding `jetbrains` dependency worked fine.
Provide dependency something like this.
For Gradle:
```
implementation 'org.jetbrains:annotations:16.0.2'
``` |
64,205,627 | I am facing an issue in IntelliJ when I tried to build my project through maven using
```
mvn clean install
```
I have tried different ways like changing the path of my JDK but nothing worked. Can someone help me out with this issue? | 2020/10/05 | [
"https://Stackoverflow.com/questions/64205627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7688591/"
] | If you really need them, add the dependency in your pom.xml :
```
<!-- https://mvnrepository.com/artifact/org.jetbrains/annotations -->
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>16.0.1</version>
</dependency>
```
( <https://mvnrepository.com/artifact/org.... | just put this code in the build gradle and it will work.
**implementation 'org.jetbrains:annotations:16.0.2'** |
64,205,627 | I am facing an issue in IntelliJ when I tried to build my project through maven using
```
mvn clean install
```
I have tried different ways like changing the path of my JDK but nothing worked. Can someone help me out with this issue? | 2020/10/05 | [
"https://Stackoverflow.com/questions/64205627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7688591/"
] | For me adding `jetbrains` dependency worked fine.
Provide dependency something like this.
For Gradle:
```
implementation 'org.jetbrains:annotations:16.0.2'
``` | I had the same issue and arrived here looking for solutions, but I couldn't find the aforementioned pom.xml. Maybe because I'm not using Maven in my project. But I solved it by editing the *MyProject.iml* file.
I've added the following code inside the `<component>` tags.
```
<orderEntry type="module-library">
<libra... |
64,205,627 | I am facing an issue in IntelliJ when I tried to build my project through maven using
```
mvn clean install
```
I have tried different ways like changing the path of my JDK but nothing worked. Can someone help me out with this issue? | 2020/10/05 | [
"https://Stackoverflow.com/questions/64205627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7688591/"
] | just put this code in the build gradle and it will work.
**implementation 'org.jetbrains:annotations:16.0.2'** | I had the same issue and arrived here looking for solutions, but I couldn't find the aforementioned pom.xml. Maybe because I'm not using Maven in my project. But I solved it by editing the *MyProject.iml* file.
I've added the following code inside the `<component>` tags.
```
<orderEntry type="module-library">
<libra... |
64,205,627 | I am facing an issue in IntelliJ when I tried to build my project through maven using
```
mvn clean install
```
I have tried different ways like changing the path of my JDK but nothing worked. Can someone help me out with this issue? | 2020/10/05 | [
"https://Stackoverflow.com/questions/64205627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7688591/"
] | If anyone is using a plain `Kotlin` project (without any build tool such as maven or gradle) in IntelliJ IDEA, then you can add the jetbrain's `jetbrains.annotations` library by following the steps given below:
1. Right click on the module in the `Project` panel on your left hand side, and select the `Open module sett... | I had the same issue and arrived here looking for solutions, but I couldn't find the aforementioned pom.xml. Maybe because I'm not using Maven in my project. But I solved it by editing the *MyProject.iml* file.
I've added the following code inside the `<component>` tags.
```
<orderEntry type="module-library">
<libra... |
64,205,627 | I am facing an issue in IntelliJ when I tried to build my project through maven using
```
mvn clean install
```
I have tried different ways like changing the path of my JDK but nothing worked. Can someone help me out with this issue? | 2020/10/05 | [
"https://Stackoverflow.com/questions/64205627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7688591/"
] | If anyone is using a plain `Kotlin` project (without any build tool such as maven or gradle) in IntelliJ IDEA, then you can add the jetbrain's `jetbrains.annotations` library by following the steps given below:
1. Right click on the module in the `Project` panel on your left hand side, and select the `Open module sett... | For me adding `jetbrains` dependency worked fine.
Provide dependency something like this.
For Gradle:
```
implementation 'org.jetbrains:annotations:16.0.2'
``` |
64,205,627 | I am facing an issue in IntelliJ when I tried to build my project through maven using
```
mvn clean install
```
I have tried different ways like changing the path of my JDK but nothing worked. Can someone help me out with this issue? | 2020/10/05 | [
"https://Stackoverflow.com/questions/64205627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7688591/"
] | If anyone is using a plain `Kotlin` project (without any build tool such as maven or gradle) in IntelliJ IDEA, then you can add the jetbrain's `jetbrains.annotations` library by following the steps given below:
1. Right click on the module in the `Project` panel on your left hand side, and select the `Open module sett... | just put this code in the build gradle and it will work.
**implementation 'org.jetbrains:annotations:16.0.2'** |
280,645 | Having come across a link on stack overflow, I have found the writings of [Miško Hevery](http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/) very engaging reading. So good that I am seeing a new approach to what I previously thought I was doing quite well.
He talks mainly about Dependency Injection,... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6023/"
] | It doesn't provide the information in quite the same way as the Google Testability Explorer, but [NDepend](http://www.ndepend.com/) (non-free) provides a lot of code analysis for .Net assemblies. | You can also use [FXCop](http://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspx).
>
> FxCop is an application that analyzes managed code assemblies (code that targets the .NET Framework common language runtime) and reports information about the assemblies, such as possible design, localization, performance, and... |
280,645 | Having come across a link on stack overflow, I have found the writings of [Miško Hevery](http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/) very engaging reading. So good that I am seeing a new approach to what I previously thought I was doing quite well.
He talks mainly about Dependency Injection,... | 2008/11/11 | [
"https://Stackoverflow.com/questions/280645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6023/"
] | [Pex](http://research.microsoft.com/Pex/default.aspx) is an interesting entry. It has the potential to take testing to a new level, especially when combined with [Code Contracts](http://research.microsoft.com/contracts/). | You can also use [FXCop](http://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspx).
>
> FxCop is an application that analyzes managed code assemblies (code that targets the .NET Framework common language runtime) and reports information about the assemblies, such as possible design, localization, performance, and... |
1,015,270 | I'm a bit confused about the options for using GNU CC on Windows.
If I want to primarily develop console applications (as opposed to GUI apps) what do I need? Where do Cygwin and MinGW figure? For example, if I use the NetBeans IDE C/C++ option, that requires installation of Cygwin.
Are there any options which would ... | 2009/06/18 | [
"https://Stackoverflow.com/questions/1015270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Both MinGW & Cygwin give you the gcc compiler but if you use MinGW you don't need to install Cygwin because it uses native Windows libraries rather than Cygwin libraries
Cygwin is more than just compilers, it tries to provide a UNIX programming environment by building a lot of UNIX libraries on top of Windows SDK. | You can use vc express for concole apps if you wish, or really any compiler for win platform. |
1,015,270 | I'm a bit confused about the options for using GNU CC on Windows.
If I want to primarily develop console applications (as opposed to GUI apps) what do I need? Where do Cygwin and MinGW figure? For example, if I use the NetBeans IDE C/C++ option, that requires installation of Cygwin.
Are there any options which would ... | 2009/06/18 | [
"https://Stackoverflow.com/questions/1015270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | That clarifies things. I'm not particularly interested in a \*nix-like environment. I was more interested in getting a GNU C compiler that conforms closely with C99 (which I believe the latest GCC compiler does) and using it as a C learning exercise (hence console rather than GUI apps)
It appears to me that NetBeans I... | You can use vc express for concole apps if you wish, or really any compiler for win platform. |
1,015,270 | I'm a bit confused about the options for using GNU CC on Windows.
If I want to primarily develop console applications (as opposed to GUI apps) what do I need? Where do Cygwin and MinGW figure? For example, if I use the NetBeans IDE C/C++ option, that requires installation of Cygwin.
Are there any options which would ... | 2009/06/18 | [
"https://Stackoverflow.com/questions/1015270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You could install CodeBlocks IDE oder DevCPP ide. If you do not require special posix api's then you do not need to install cygwin. | That clarifies things. I'm not particularly interested in a \*nix-like environment. I was more interested in getting a GNU C compiler that conforms closely with C99 (which I believe the latest GCC compiler does) and using it as a C learning exercise (hence console rather than GUI apps)
It appears to me that NetBeans I... |
1,015,270 | I'm a bit confused about the options for using GNU CC on Windows.
If I want to primarily develop console applications (as opposed to GUI apps) what do I need? Where do Cygwin and MinGW figure? For example, if I use the NetBeans IDE C/C++ option, that requires installation of Cygwin.
Are there any options which would ... | 2009/06/18 | [
"https://Stackoverflow.com/questions/1015270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Both MinGW & Cygwin give you the gcc compiler but if you use MinGW you don't need to install Cygwin because it uses native Windows libraries rather than Cygwin libraries
Cygwin is more than just compilers, it tries to provide a UNIX programming environment by building a lot of UNIX libraries on top of Windows SDK. | MinGW can support many languages as well as GNU C Compiler. It also comes with msys package that you can simulate UNIX environment. Cygwin does the same thing as msys does. I'd advice you to install MinGW with full msys support. |
1,015,270 | I'm a bit confused about the options for using GNU CC on Windows.
If I want to primarily develop console applications (as opposed to GUI apps) what do I need? Where do Cygwin and MinGW figure? For example, if I use the NetBeans IDE C/C++ option, that requires installation of Cygwin.
Are there any options which would ... | 2009/06/18 | [
"https://Stackoverflow.com/questions/1015270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | That clarifies things. I'm not particularly interested in a \*nix-like environment. I was more interested in getting a GNU C compiler that conforms closely with C99 (which I believe the latest GCC compiler does) and using it as a C learning exercise (hence console rather than GUI apps)
It appears to me that NetBeans I... | MinGW can support many languages as well as GNU C Compiler. It also comes with msys package that you can simulate UNIX environment. Cygwin does the same thing as msys does. I'd advice you to install MinGW with full msys support. |
1,015,270 | I'm a bit confused about the options for using GNU CC on Windows.
If I want to primarily develop console applications (as opposed to GUI apps) what do I need? Where do Cygwin and MinGW figure? For example, if I use the NetBeans IDE C/C++ option, that requires installation of Cygwin.
Are there any options which would ... | 2009/06/18 | [
"https://Stackoverflow.com/questions/1015270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Both MinGW & Cygwin give you the gcc compiler but if you use MinGW you don't need to install Cygwin because it uses native Windows libraries rather than Cygwin libraries
Cygwin is more than just compilers, it tries to provide a UNIX programming environment by building a lot of UNIX libraries on top of Windows SDK. | You really really should check out Visual C++ Express. It makes developing on windows A LOT easier. I it is free and the Visual C++ is the preferred way to develop windows apps. ANd yes, you can make console applications too. |
1,015,270 | I'm a bit confused about the options for using GNU CC on Windows.
If I want to primarily develop console applications (as opposed to GUI apps) what do I need? Where do Cygwin and MinGW figure? For example, if I use the NetBeans IDE C/C++ option, that requires installation of Cygwin.
Are there any options which would ... | 2009/06/18 | [
"https://Stackoverflow.com/questions/1015270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Both MinGW & Cygwin give you the gcc compiler but if you use MinGW you don't need to install Cygwin because it uses native Windows libraries rather than Cygwin libraries
Cygwin is more than just compilers, it tries to provide a UNIX programming environment by building a lot of UNIX libraries on top of Windows SDK. | That clarifies things. I'm not particularly interested in a \*nix-like environment. I was more interested in getting a GNU C compiler that conforms closely with C99 (which I believe the latest GCC compiler does) and using it as a C learning exercise (hence console rather than GUI apps)
It appears to me that NetBeans I... |
1,015,270 | I'm a bit confused about the options for using GNU CC on Windows.
If I want to primarily develop console applications (as opposed to GUI apps) what do I need? Where do Cygwin and MinGW figure? For example, if I use the NetBeans IDE C/C++ option, that requires installation of Cygwin.
Are there any options which would ... | 2009/06/18 | [
"https://Stackoverflow.com/questions/1015270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You could install CodeBlocks IDE oder DevCPP ide. If you do not require special posix api's then you do not need to install cygwin. | You really really should check out Visual C++ Express. It makes developing on windows A LOT easier. I it is free and the Visual C++ is the preferred way to develop windows apps. ANd yes, you can make console applications too. |
1,015,270 | I'm a bit confused about the options for using GNU CC on Windows.
If I want to primarily develop console applications (as opposed to GUI apps) what do I need? Where do Cygwin and MinGW figure? For example, if I use the NetBeans IDE C/C++ option, that requires installation of Cygwin.
Are there any options which would ... | 2009/06/18 | [
"https://Stackoverflow.com/questions/1015270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You could install CodeBlocks IDE oder DevCPP ide. If you do not require special posix api's then you do not need to install cygwin. | You can use vc express for concole apps if you wish, or really any compiler for win platform. |
1,015,270 | I'm a bit confused about the options for using GNU CC on Windows.
If I want to primarily develop console applications (as opposed to GUI apps) what do I need? Where do Cygwin and MinGW figure? For example, if I use the NetBeans IDE C/C++ option, that requires installation of Cygwin.
Are there any options which would ... | 2009/06/18 | [
"https://Stackoverflow.com/questions/1015270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You really really should check out Visual C++ Express. It makes developing on windows A LOT easier. I it is free and the Visual C++ is the preferred way to develop windows apps. ANd yes, you can make console applications too. | MinGW can support many languages as well as GNU C Compiler. It also comes with msys package that you can simulate UNIX environment. Cygwin does the same thing as msys does. I'd advice you to install MinGW with full msys support. |
14,138,066 | I'm all for REST webservices and my company has a policy in place to prefer REST over SOAP.
However, I need to expose a webservice that does not fit into the resource paradigm. It is essentially a calculation, where I need to send a large number of parameters (about 20 fields) and retrieve a number.
I thought about u... | 2013/01/03 | [
"https://Stackoverflow.com/questions/14138066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/492936/"
] | As you mention, REST makes sense when you're exposing [CRUD](http://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operations on resources. Usually these resources are persisted in some database or storage mechanism.
In your case I guess there is no storage or resources (you provide a bunch of numbers and get ... | After some research, I found this article that is really relevant to this discussion:
<http://info.apigee.com/Portals/62317/docs/web%20api.pdf> |
14,138,066 | I'm all for REST webservices and my company has a policy in place to prefer REST over SOAP.
However, I need to expose a webservice that does not fit into the resource paradigm. It is essentially a calculation, where I need to send a large number of parameters (about 20 fields) and retrieve a number.
I thought about u... | 2013/01/03 | [
"https://Stackoverflow.com/questions/14138066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/492936/"
] | As you mention, REST makes sense when you're exposing [CRUD](http://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operations on resources. Usually these resources are persisted in some database or storage mechanism.
In your case I guess there is no storage or resources (you provide a bunch of numbers and get ... | I see no reason why that couldn't be RESTful. Consider a particular calculation run to be a resource with its own identity (`/calculation/ID123`); you can then do a POST to `/calculation` to make a new one, GET/PUT on `/calculation/ID123/paramA` to work with a particular parameter, and GET on `/calculation/ID123/result... |
2,803 | I have gunstock oak flooring and would like to match a piece of pine furniture to it. Any ideas how to achieve this?
I'm open to liquid or gel stains, but would like to avoid veneers as it's pretty large. Where possible, I'd like to avoid buying lots of different stains and mixing them by trial and error.
Related: [... | 2015/11/17 | [
"https://woodworking.stackexchange.com/questions/2803",
"https://woodworking.stackexchange.com",
"https://woodworking.stackexchange.com/users/1154/"
] | As bowlturner said, good luck! There are a number of challenges here.
>
> Where possible, I'd like to avoid buying lots of different stains and mixing them by trial and error.
>
>
>
I'm afraid with this sort of thing generally it's *not* possible without some experimentation. Even if you were matching a fairly co... | Good luck.
However, since pine takes stain fairly well, you can try to match the overall color, but it will still look like stained pine. Your best bet, would be to bring a sample of the color you are trying to match into a store then make it just a little darker. Since Oak tends to start a little darker than pine.
... |
2,803 | I have gunstock oak flooring and would like to match a piece of pine furniture to it. Any ideas how to achieve this?
I'm open to liquid or gel stains, but would like to avoid veneers as it's pretty large. Where possible, I'd like to avoid buying lots of different stains and mixing them by trial and error.
Related: [... | 2015/11/17 | [
"https://woodworking.stackexchange.com/questions/2803",
"https://woodworking.stackexchange.com",
"https://woodworking.stackexchange.com/users/1154/"
] | Good luck.
However, since pine takes stain fairly well, you can try to match the overall color, but it will still look like stained pine. Your best bet, would be to bring a sample of the color you are trying to match into a store then make it just a little darker. Since Oak tends to start a little darker than pine.
... | 50:50 Varathane Early American and Colonial Maple. It is almost an exact match on pine. Made a ton of blends and bought a ton of stain. There’s nothing off the shelf that’s a good match |
2,803 | I have gunstock oak flooring and would like to match a piece of pine furniture to it. Any ideas how to achieve this?
I'm open to liquid or gel stains, but would like to avoid veneers as it's pretty large. Where possible, I'd like to avoid buying lots of different stains and mixing them by trial and error.
Related: [... | 2015/11/17 | [
"https://woodworking.stackexchange.com/questions/2803",
"https://woodworking.stackexchange.com",
"https://woodworking.stackexchange.com/users/1154/"
] | As bowlturner said, good luck! There are a number of challenges here.
>
> Where possible, I'd like to avoid buying lots of different stains and mixing them by trial and error.
>
>
>
I'm afraid with this sort of thing generally it's *not* possible without some experimentation. Even if you were matching a fairly co... | 50:50 Varathane Early American and Colonial Maple. It is almost an exact match on pine. Made a ton of blends and bought a ton of stain. There’s nothing off the shelf that’s a good match |
22,613,134 | I am using SaveFileDialog to save a pdf file.But at the creation of pdf file i am getting this error.
```
The process cannot access the file it is being used by another process c#
```
Here is my code in c#..
```
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "Pdf files (*.pdf)|*.pd... | 2014/03/24 | [
"https://Stackoverflow.com/questions/22613134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3382246/"
] | In webkit based browsers, I remember a timing issue, try using a setInterval like:
```
var tim = setInterval(function(){
$.mobile.loading("show", { text: "Working...", textVisible: true });
clearInterval(tim);
},1);
``` | Did you also add the right CSS?
```
http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.css
```
I've added JQM 1.4.0 and the CSS (1.4.0) as an external resource to your JSFiddle and it seems to be working - [Updated JSFiddle](http://jsfiddle.net/YL9PP/2/). |
54,498,140 | I mounted target device's (Beaglebone Black, ARM arch) root with sshfs, to a folder on host, and trying to cross compile using `--sysroot` option of GCC.
But there's a problem - some include header files are located on target device not just at /usr/include folder, but in its subfolder `arm-linux-gnueabihf`. The same ... | 2019/02/02 | [
"https://Stackoverflow.com/questions/54498140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1028256/"
] | I'm posting results of my investigation as an answer, but will accept if it solves the problem - I haven't got a solution yet )
It appears that the target's GCC was configured with --enable-multiarch, and it adds `arm-linux-gnueabihf` subfolder for that target name.
Good reading about the subject is <https://wiki.deb... | Actually, I don't want to dig into your way because I think it is not a common way to cross compiling.
The way you are cross-compiling is not suggested. There are two common ways to cross-compile an app.
First, creating a virtual environment just like your embedded board with some virtualization apps like `Qemu`. You ... |
13,933,123 | Following is the code where " throw use; " shows an error.Why? How to use throw for user defined exceptions?Give some example?
```
class use extends Exception{
public String toString() {
return "too many exceptions";
}
}
class user{
public static void main(String s[]) {
int i=3;
try {
if(i>1)
... | 2012/12/18 | [
"https://Stackoverflow.com/questions/13933123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1888988/"
] | you need an instance of the exception class to throw it:
```
throw new use();
```
or
```
use a = new use();
throw a;
```
In the future please follow Java naming conventions, it will make your code much more readable. (class names should start with a capital letter). | User defined exceptions can be created and thrown in Java.
By inheriting the Exception class you can create your own exceptions.
And it can be thrown as and when required
Following example shows how to create and throw user defined exceptions
<http://www.csnotes32.com/2014/09/how-to-create-user-defined-exception-in... |
13,933,123 | Following is the code where " throw use; " shows an error.Why? How to use throw for user defined exceptions?Give some example?
```
class use extends Exception{
public String toString() {
return "too many exceptions";
}
}
class user{
public static void main(String s[]) {
int i=3;
try {
if(i>1)
... | 2012/12/18 | [
"https://Stackoverflow.com/questions/13933123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1888988/"
] | you need an instance of the exception class to throw it:
```
throw new use();
```
or
```
use a = new use();
throw a;
```
In the future please follow Java naming conventions, it will make your code much more readable. (class names should start with a capital letter). | And remember, you don't need to roll your own.
```
throw new RuntimeException("Do not instantiate this class");
```
(old question, but I always forget syntax, so stashing on google) |
44,555,110 | I'm reading a CSV file and creating objects based on the values on each line. I can't really name each object something unique so I do:
```
new User(x, y, z);
```
But how can I then find that newly created object? Is there a way to loop through all objects of a specific class (i.e. User)? Or at least find one based ... | 2017/06/14 | [
"https://Stackoverflow.com/questions/44555110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1908781/"
] | >
> Or at least find one based on the ID?
>
>
>
You have an identifier by created `User`?
So you should just store the objects in a `Map` where the key is the `User` id and the value is the `User` object.
With an `Integer` as id, it would give :
```
Map<Integer, User> usersById = new HashMap<>();
for (...)... | First, store the objects into a list.
```
List<User> usersList = new ArrayList<>();
...
... // add each object to usersList
```
Later on, to imitate your `SQL` query, you can do something along the lines of:
```
Optional<User> result = usersList.stream().filter(x -> x.getId() == 1).findFirst();
```
This solut... |
3,583,100 | Suppose $A$ is a $3\times3$ matrix such that $\det(A)=\frac{1}{125}$. Find $\det(5A^{−1})$.
I know that this can also be written as $\det(5/A)$
However, I am struggling to work out what $A$ is
Please help | 2020/03/16 | [
"https://math.stackexchange.com/questions/3583100",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/760139/"
] | You need to know two important properties of the determinant:
* $\det(A^{-1}) = \frac{1}{\det(A)}$
* $\det(\lambda A) = \lambda^n \det(A)$ where $A$ is an $n \times n$ matrix
Since you know $\det(A)$, you can then determine
$$ \det(5 A^{-1}) = 5^3 \det(A^{-1}) = 5^3 \cdot \frac{1}{\frac{1}{125}} = 5^3 \cdot 125$$
... | **Hint:**
$$\text{ det }(5A^{-1})\text{ det }(A)=\text{ det }(5A^{-1}A)=\text{ det }(5I).$$ |
54,671,220 | I have an int array of melodies. If i press the button it plays the whole song but if i put a break after the `delay`, than it just reset the `i`. How do i make it so that only after another button-press it continues? (i'm still a newbie at this sorry and thanks in advance)
```
int buttonPin = 12;
void setup()
{
//... | 2019/02/13 | [
"https://Stackoverflow.com/questions/54671220",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10557540/"
] | Stop the loop while the button press is still held in:
```
int buttonPin = 12;
void setup()
{
// put your setup code here, to run once:
pinMode(buttonPin, INPUT);
}
void loop()
{
// put your main code here, to run repeatedly:
int buttonState = digitalRead(buttonPin);
for(int i = 0; i < sizeof(mariomelo... | I'm guessing that you want to play the melody while the button is pressed, and stop if the button is released.
Then it would be something like:
```
int i = 0;
void loop()
{
if(digitalRead(buttonPin) == HIGH)
{
tone(8, mariomelody[i], 70);
i = (i + 1) % sizeof(mariomelody);
delay();
} ... |
2,581,729 | I'm writing some software that modifies a Windows Server's configuration (things like MS-DNS, IIS, parts of the filesystem). My design has a server process that builds an in-memory object graph of the server configuration state and a client which requests this object graph. The server would then serialize the graph, se... | 2010/04/05 | [
"https://Stackoverflow.com/questions/2581729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/159145/"
] | Object graphs can be used with DataContract serialization.
**Note:** Make sure you're preserving object references, so that you don't end up with multiple copies of the same object in the graph when they should all be the same reference, the default behavior does not preserve identity like this.
This can be done by s... | You got yourself mixed up with the serializers:
* the **XmlSerializer** requires a parameter-less constructor, since when deserializing, the .NET runtime will instantiate a new object of that type and then set its properties
* the **DataContractSerializer** has no such requirement
Check out the [blog post by Dan Rigs... |
18,829,558 | I have a 2-dimensional array of bool like this

The shape won't have any holes -- even if it has -- I'll ignore them. Now I want to find the Polygon embracing my shape:

Is there any algorithm... | 2013/09/16 | [
"https://Stackoverflow.com/questions/18829558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2033412/"
] | You can use a delaunay triangulation and then remove the longest edges. I use the average of all edges multiply with a constant. | After thinking about more a little I found it out and there is a O(n)-way to do it: Search row-wise for the first coordinate that contains at least one adjacent field set true. From there you can definitly take the first step to the right. From now on just walk around the field deciding what direction to walk next base... |
25,950,843 | I'm trying to fit my 'body' background image to the browsers document size.
This code here doesn't change anything in browser when i run it... i see the image but it is repeated twice and the size isn't changing. when debugging i see that the width and height variables are correct but nothing actually happens.... any i... | 2014/09/20 | [
"https://Stackoverflow.com/questions/25950843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2290597/"
] | We had the exactly same problem.
You can rotate it programmatically by the code -
```
if ([UIApplication sharedApplication].statusBarOrientation != UIInterfaceOrientationPortrait) {
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
[[UIDevice currentDevice] setValue:value forKey:@"or... | This code will force the UI back to portrait, assuming that the view controller you're trying to force portrait was already the root view controller (if it wasn't already the root, this code will restore the root view controller but not any other view controllers that have been pushed onto it):
```
UIInterfaceOrientat... |
66,580,485 | I don't understand why SVELTE is calling the function specified in an {#await} block when the values returned by the function are changed.
I've made a little example:
<https://svelte.dev/repl/a962314974eb4a07bd98ecb1c9ccb66c?version=3.35.0>
In brief:
```js
{#await getList() then alist}
{#each alist as item}
... | 2021/03/11 | [
"https://Stackoverflow.com/questions/66580485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3061884/"
] | I think it's because the whole component is rerendered when the state is changed, and as such `getList()` is called again as it's in the render code.
A better solution might be to find how to avoid the whole rerender with [immutable](https://svelte.dev/tutorial/svelte-options), but here's a way to make this work:
```... | A state change does not (normally) cause the entire component to rerender, this is the base tenet of Svelte after all. You can try this by adding a second counter and a button inside the await:
```html
{#await getList() then alist}
<button on:click={() => counter2++}>Clicked {counter2}</button>
...
```
Clicking ... |
44,348,493 | How to configure a Ninja web application running on Heroku to force the use of SSL, that is, redirect all requests to HTTPS? | 2017/06/03 | [
"https://Stackoverflow.com/questions/44348493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/639722/"
] | Here is the class to add in the conf package:
```
public class Filters implements ApplicationFilters {
@Override
public void addFilters (List<Class<? extends Filter>> list) {
list.add (HttpsFilter.class);
}
public static class HttpsFilter implements Filter {
@Override
public Result filter (FilterCh... | If you look good in the ninja framework documentation it is indicated how to configure it to get what you want
<http://www.ninjaframework.org/documentation/configuration_and_modes.html> |
70,071,984 | I have these two arrays:
```
const goodCars = [
{ name: 'ferrari', price: 22000, condition: { isGood: true, isBad: false } },
{ name: 'ford', price: 21000, condition: { isGood: true, isBad: false } },
{ name: 'bmw', price: 20000, condition: { isGood: true, isBad: false } },
];
const badCars = [
{ ... | 2021/11/22 | [
"https://Stackoverflow.com/questions/70071984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1060888/"
] | You shouldn't use nested loops.
Start by copying `goodCars` to `finalCarList`. Then loop over `badCars`. If the car is in `goodCars`, add the bad car as the `toCompareWith` property. Otherwise, push it into `finalCarList`.
```
finalCarList = [...goodCars];
badCars.forEach(bc => {
match = goodCars.find(gc => isCar... | Below is an example using two [`for...of` loops](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of). The outer loop is the first array and the inner loop is the second array using [`.entries()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/en... |
28,073,914 | I'm having an issue decrementing using a do while loop. Everything is broken up into separate files to keep the class & methods/functions separate (as well as keeping the main clear).
The issue I'm having is that it decrements once, but when it loops back through it goes right back to the same value and decrements to ... | 2015/01/21 | [
"https://Stackoverflow.com/questions/28073914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4271411/"
] | You need to add a `break;` statement to break out of the `switch` block.
```
switch (x) {
case 1:
System.out.println("1");
break;
default:
System.out.println("helllo");
break; // <-- add this here
case 2:
System.out.println("Benjamin");
break;
}
```
Ge... | It prints both strings because you do not have a `break` in your `default` case, so it continues into `case 2`, printing Benjamin. You could fix this by adding a `break` or moving `case 2` above the `default` case. |
28,073,914 | I'm having an issue decrementing using a do while loop. Everything is broken up into separate files to keep the class & methods/functions separate (as well as keeping the main clear).
The issue I'm having is that it decrements once, but when it loops back through it goes right back to the same value and decrements to ... | 2015/01/21 | [
"https://Stackoverflow.com/questions/28073914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4271411/"
] | It prints both strings because you do not have a `break` in your `default` case, so it continues into `case 2`, printing Benjamin. You could fix this by adding a `break` or moving `case 2` above the `default` case. | 'switch' case is other form of 'if-then-else', the default case is for the final else part. It is advisable to write default at the end of switch. |
28,073,914 | I'm having an issue decrementing using a do while loop. Everything is broken up into separate files to keep the class & methods/functions separate (as well as keeping the main clear).
The issue I'm having is that it decrements once, but when it loops back through it goes right back to the same value and decrements to ... | 2015/01/21 | [
"https://Stackoverflow.com/questions/28073914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4271411/"
] | It prints both strings because you do not have a `break` in your `default` case, so it continues into `case 2`, printing Benjamin. You could fix this by adding a `break` or moving `case 2` above the `default` case. | Default is checked as last. Thats why it feels like the compiler 'went' back. |
28,073,914 | I'm having an issue decrementing using a do while loop. Everything is broken up into separate files to keep the class & methods/functions separate (as well as keeping the main clear).
The issue I'm having is that it decrements once, but when it loops back through it goes right back to the same value and decrements to ... | 2015/01/21 | [
"https://Stackoverflow.com/questions/28073914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4271411/"
] | You need to add a `break;` statement to break out of the `switch` block.
```
switch (x) {
case 1:
System.out.println("1");
break;
default:
System.out.println("helllo");
break; // <-- add this here
case 2:
System.out.println("Benjamin");
break;
}
```
Ge... | 'switch' case is other form of 'if-then-else', the default case is for the final else part. It is advisable to write default at the end of switch. |
28,073,914 | I'm having an issue decrementing using a do while loop. Everything is broken up into separate files to keep the class & methods/functions separate (as well as keeping the main clear).
The issue I'm having is that it decrements once, but when it loops back through it goes right back to the same value and decrements to ... | 2015/01/21 | [
"https://Stackoverflow.com/questions/28073914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4271411/"
] | You need to add a `break;` statement to break out of the `switch` block.
```
switch (x) {
case 1:
System.out.println("1");
break;
default:
System.out.println("helllo");
break; // <-- add this here
case 2:
System.out.println("Benjamin");
break;
}
```
Ge... | Default is checked as last. Thats why it feels like the compiler 'went' back. |
1,132,077 | This question has been puzzling me for a long time now. I come from a heavy and long C++ background, and since I started programming in C# and dealing with garbage collection I always had the feeling that such 'magic' would come at a cost.
I recently started working in a big MMO project written in Java (server side).... | 2009/07/15 | [
"https://Stackoverflow.com/questions/1132077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839/"
] | Random advice:
Someone mentioned putting dead objects in a queue to be reused instead of letting the GC at them... but be careful, as this means the GC may have more crap to move around when it consolidates the heap, and may not actually help you. Also, the GC is possibly already using techniques like this. Also, I kn... | I agree with all points said above: the garbage collector is great, but it shouldn't be used as a crutch.
I've sat through many wasted hours in code-reviews debating over finer points of the CLR. The best definitive answer is to develop a culture of performance in your organization and actively profile your applicatio... |
1,132,077 | This question has been puzzling me for a long time now. I come from a heavy and long C++ background, and since I started programming in C# and dealing with garbage collection I always had the feeling that such 'magic' would come at a cost.
I recently started working in a big MMO project written in Java (server side).... | 2009/07/15 | [
"https://Stackoverflow.com/questions/1132077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839/"
] | I've seen too many cases where people "optimize" the crap out of their code without much concern for how well it's written or how well it works even. I think the first thought should go towards making code solve the business problem at hand. The code should be well crafted and easily maintainable as well as properly te... | I have the same thought all the time.
The truth is, though we were taught to watch out for unnecessary CPU tacts and memory consumption, the cost of little imperfections in our code just negligible in practice.
If you are aware of that and always watch, I believe you are okay to write not perfect code. If you have st... |
1,132,077 | This question has been puzzling me for a long time now. I come from a heavy and long C++ background, and since I started programming in C# and dealing with garbage collection I always had the feeling that such 'magic' would come at a cost.
I recently started working in a big MMO project written in Java (server side).... | 2009/07/15 | [
"https://Stackoverflow.com/questions/1132077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839/"
] | This is one of those issues where it is really hard to pin down a definitive answer in a way that will help you. The .NET GC is *very* good at tuning itself to the memory needs of you application. Is it good enough that your application can be coded without you needing to worry about memory management? I don't know.
... | You might consider writing a set of object caches. Instead of creating new instances, you could keep a list of available objects somewhere. It would help you avoid the GC. |
1,132,077 | This question has been puzzling me for a long time now. I come from a heavy and long C++ background, and since I started programming in C# and dealing with garbage collection I always had the feeling that such 'magic' would come at a cost.
I recently started working in a big MMO project written in Java (server side).... | 2009/07/15 | [
"https://Stackoverflow.com/questions/1132077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839/"
] | Yes, it's true of .NET as well. Most of us have the luxury of ignoring the details of memory management, but in your case -- or in cases where high volume is causing memory congestion -- then some optimizaition is called for.
One optimization you might consider for your case -- something I've been thinking about writ... | I agree with all points said above: the garbage collector is great, but it shouldn't be used as a crutch.
I've sat through many wasted hours in code-reviews debating over finer points of the CLR. The best definitive answer is to develop a culture of performance in your organization and actively profile your applicatio... |
1,132,077 | This question has been puzzling me for a long time now. I come from a heavy and long C++ background, and since I started programming in C# and dealing with garbage collection I always had the feeling that such 'magic' would come at a cost.
I recently started working in a big MMO project written in Java (server side).... | 2009/07/15 | [
"https://Stackoverflow.com/questions/1132077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839/"
] | Random advice:
Someone mentioned putting dead objects in a queue to be reused instead of letting the GC at them... but be careful, as this means the GC may have more crap to move around when it consolidates the heap, and may not actually help you. Also, the GC is possibly already using techniques like this. Also, I kn... | .NET Memory management is very good and being able to programmatically tweak the GC if you need to is good.
I like the fact that you can create your own Dispose methods on classes by inheriting from IDisposable and tweaking it to your needs. This is great for making sure that connections to networks/files/databases a... |
1,132,077 | This question has been puzzling me for a long time now. I come from a heavy and long C++ background, and since I started programming in C# and dealing with garbage collection I always had the feeling that such 'magic' would come at a cost.
I recently started working in a big MMO project written in Java (server side).... | 2009/07/15 | [
"https://Stackoverflow.com/questions/1132077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839/"
] | This is one of those issues where it is really hard to pin down a definitive answer in a way that will help you. The .NET GC is *very* good at tuning itself to the memory needs of you application. Is it good enough that your application can be coded without you needing to worry about memory management? I don't know.
... | I agree with all points said above: the garbage collector is great, but it shouldn't be used as a crutch.
I've sat through many wasted hours in code-reviews debating over finer points of the CLR. The best definitive answer is to develop a culture of performance in your organization and actively profile your applicatio... |
1,132,077 | This question has been puzzling me for a long time now. I come from a heavy and long C++ background, and since I started programming in C# and dealing with garbage collection I always had the feeling that such 'magic' would come at a cost.
I recently started working in a big MMO project written in Java (server side).... | 2009/07/15 | [
"https://Stackoverflow.com/questions/1132077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839/"
] | This is one of those issues where it is really hard to pin down a definitive answer in a way that will help you. The .NET GC is *very* good at tuning itself to the memory needs of you application. Is it good enough that your application can be coded without you needing to worry about memory management? I don't know.
... | Random advice:
Someone mentioned putting dead objects in a queue to be reused instead of letting the GC at them... but be careful, as this means the GC may have more crap to move around when it consolidates the heap, and may not actually help you. Also, the GC is possibly already using techniques like this. Also, I kn... |
1,132,077 | This question has been puzzling me for a long time now. I come from a heavy and long C++ background, and since I started programming in C# and dealing with garbage collection I always had the feeling that such 'magic' would come at a cost.
I recently started working in a big MMO project written in Java (server side).... | 2009/07/15 | [
"https://Stackoverflow.com/questions/1132077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839/"
] | This is one of those issues where it is really hard to pin down a definitive answer in a way that will help you. The .NET GC is *very* good at tuning itself to the memory needs of you application. Is it good enough that your application can be coded without you needing to worry about memory management? I don't know.
... | Although the Garbage Collector is there, bad code remains bad code. Therefore I would say yes as a .Net developer you should still care about how many objects you create and more importantly writing optimized code.
I have seen a considerable amount of projects get rejected because of this reason in Code Reviews inside... |
1,132,077 | This question has been puzzling me for a long time now. I come from a heavy and long C++ background, and since I started programming in C# and dealing with garbage collection I always had the feeling that such 'magic' would come at a cost.
I recently started working in a big MMO project written in Java (server side).... | 2009/07/15 | [
"https://Stackoverflow.com/questions/1132077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839/"
] | Random advice:
Someone mentioned putting dead objects in a queue to be reused instead of letting the GC at them... but be careful, as this means the GC may have more crap to move around when it consolidates the heap, and may not actually help you. Also, the GC is possibly already using techniques like this. Also, I kn... | I have the same thought all the time.
The truth is, though we were taught to watch out for unnecessary CPU tacts and memory consumption, the cost of little imperfections in our code just negligible in practice.
If you are aware of that and always watch, I believe you are okay to write not perfect code. If you have st... |
1,132,077 | This question has been puzzling me for a long time now. I come from a heavy and long C++ background, and since I started programming in C# and dealing with garbage collection I always had the feeling that such 'magic' would come at a cost.
I recently started working in a big MMO project written in Java (server side).... | 2009/07/15 | [
"https://Stackoverflow.com/questions/1132077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839/"
] | Random advice:
Someone mentioned putting dead objects in a queue to be reused instead of letting the GC at them... but be careful, as this means the GC may have more crap to move around when it consolidates the heap, and may not actually help you. Also, the GC is possibly already using techniques like this. Also, I kn... | Although the Garbage Collector is there, bad code remains bad code. Therefore I would say yes as a .Net developer you should still care about how many objects you create and more importantly writing optimized code.
I have seen a considerable amount of projects get rejected because of this reason in Code Reviews inside... |
41,425,460 | I have two buttons on my right of my navigation bar.
```
extension UIViewController {
func setNavigationBarItem() {
let profileButton = UIBarButtonItem(title: "?", style: .plain, target: self, action: #selector(didTapProfileButton(_:)))
navigationItem.rightBarButtonItems = [addRightBarButtonWithImage(UIIma... | 2017/01/02 | [
"https://Stackoverflow.com/questions/41425460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6665875/"
] | For that you have only one option you need to create `UIButton` instance with design that you want after that create `UIBarButtonItem` instance from that button.
```
let btnProfile = UIButton(frame: CGRect(x: 0, y: 0, width: 25, height: 25))
btnProfile.setTitle("SY", for: .normal)
btnProfile.backgroundColor = UIColor.... | ```
let profileButton = UIButton()
profileButton.frame = CGRect(x:0, y:0, width:30, height:30)
profileButton.setTitle("SY", for: .normal)
profileButton.setTitle("SY", for: .highlighted)
profileButton.backgroundColor = UIColor.yellow
profileButton.layer.cornerRadius = 5.0
profileButton.addTar... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.