qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
55,120,998 | I'm trying to render a child component by mapping multiple props at the same time. What I'd like to do is:
```
const Parent = props => {
const whatever = props.(***need to pass both props***).map((firstProp, secondProp) => (
<Child
key={//}
firstProp={firstProp}
secondProp={secondProp}
/>
... | 2019/03/12 | [
"https://Stackoverflow.com/questions/55120998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11109408/"
] | You can use `android:textDirection="rtl"` so no matter if the text is in Hebrew or English it will start from the right side of your view and won't jump to the other direction when you change the language.
**Note -** I think that `android:gravity` didn't work for you because Hebrew is written rtl and English is writte... | If your system language is RTL, You can force ltr languages to align as rtl by using
```
android:textDirection="locale"
``` |
55,120,998 | I'm trying to render a child component by mapping multiple props at the same time. What I'd like to do is:
```
const Parent = props => {
const whatever = props.(***need to pass both props***).map((firstProp, secondProp) => (
<Child
key={//}
firstProp={firstProp}
secondProp={secondProp}
/>
... | 2019/03/12 | [
"https://Stackoverflow.com/questions/55120998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11109408/"
] | Use
```
android:textAlignment="viewEnd"
```
and text will be aligned regardless of its content, but still depended on the layout direction.
The Documentation [here](https://developer.android.com/reference/android/view/View#attr_android:textAlignment):
>
> Align to the end of the view, which is ALIGN\_RIGHT if the... | If your system language is RTL, You can force ltr languages to align as rtl by using
```
android:textDirection="locale"
``` |
3,395,662 | I know some of the differences such as garbage collection and 64-bit support, but I have a book based on 1.x and I was wondering if I would be wasting my time learning off of that, and then, stepping up to 2.1 after reading? | 2010/08/03 | [
"https://Stackoverflow.com/questions/3395662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/403965/"
] | 2.0 vs. 1.0 isn't a very useful distinction as the lines are considerably more blurred. Dreamlax's answer is correct, but only when applied to the syntax (and, even then, there are some holes).
In particular, there is the syntax of the language to consider **and** there is also the ABI; the actual binary format to con... | Many Objective-C programmers learned version 1 before learning version 2. You would not be wasting your time learning from that book, but once you've finished with it and you're comfortable with version 1, then you can move on to learning version 2. If you ever have to target older Mac OS X systems it is important to k... |
61,947,062 | I use Recyclerview , as you can see its left aligned and there is [no margin before the first card](https://i.stack.imgur.com/mvyOs.png) , and no bottom margin before the last card ([last card button not shown](https://i.stack.imgur.com/Un7Af.png)), how can I fix that? I added padding on the card but it didn't work wit... | 2020/05/22 | [
"https://Stackoverflow.com/questions/61947062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12193088/"
] | In RecyclerView tag, set both `layout_width` and `layout_height` to `match_parent` instead of hardcoding them.
Remove these two lines from the item layout:
```
app:layout_constraintHeight_max="wrap"
app:layout_constraintWidth_max="wrap"
``` | You shouldn't fix max height and width of container remove that `app:layout_constraintHeight_max="wrap"` and `app:layout_constraintWidth_max="wrap"` Try this
```
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-... |
146,904 | I'm trying to use Dolphin as file chooser for Firefox in Archlinux instead of Nautilus. I've read [this](https://bbs.archlinux.org/viewtopic.php?id=87574) but it did not solve my problem. The config seems related to firefox as
```
xdg-mime query default inode/directory
dolphin.desktop
```
Which is right. Also
```... | 2014/07/28 | [
"https://unix.stackexchange.com/questions/146904",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/44398/"
] | Currently (2018-09-25) there exists no user-configurable way to change this behaviour in Firefox.
This is a known bug: [Firefox does not use default file manager](https://bugzilla.mozilla.org/show_bug.cgi?id=1285711)
It was first reported on Bugzilla on 2016-07-08.
At the time of writing this bug is unassigned and un... | Type `about:config` in the address bar
Search for `ui.allow_platform_file_picker`
Toggle it to **true**
Restart Firefox. |
146,904 | I'm trying to use Dolphin as file chooser for Firefox in Archlinux instead of Nautilus. I've read [this](https://bbs.archlinux.org/viewtopic.php?id=87574) but it did not solve my problem. The config seems related to firefox as
```
xdg-mime query default inode/directory
dolphin.desktop
```
Which is right. Also
```... | 2014/07/28 | [
"https://unix.stackexchange.com/questions/146904",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/44398/"
] | I'd have a similar problem running Manjaro 4.18.9-1. After install nautilus for a test, firefox started to open folders with nautilus, I removed nautilus and firefox then opened folders with Atom.
At least for me, this solution worked:
* Close firefox
* Go to your file manager (Thunar in my case), right click on a fo... | Type `about:config` in the address bar
Search for `ui.allow_platform_file_picker`
Toggle it to **true**
Restart Firefox. |
146,904 | I'm trying to use Dolphin as file chooser for Firefox in Archlinux instead of Nautilus. I've read [this](https://bbs.archlinux.org/viewtopic.php?id=87574) but it did not solve my problem. The config seems related to firefox as
```
xdg-mime query default inode/directory
dolphin.desktop
```
Which is right. Also
```... | 2014/07/28 | [
"https://unix.stackexchange.com/questions/146904",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/44398/"
] | Currently (2018-09-25) there exists no user-configurable way to change this behaviour in Firefox.
This is a known bug: [Firefox does not use default file manager](https://bugzilla.mozilla.org/show_bug.cgi?id=1285711)
It was first reported on Bugzilla on 2016-07-08.
At the time of writing this bug is unassigned and un... | Firefox use GIO's GAppInfo. GIO's behaviour is slightly different from xdg-mime's.
By adding `inode/directory=ranger.desktop` in `$HOME/.config/mimeapps.list`, my firefox can open directory properly.
You can check the diffents between `xdg-mime query default inode/directory` and `gio mime inode/directory`. |
146,904 | I'm trying to use Dolphin as file chooser for Firefox in Archlinux instead of Nautilus. I've read [this](https://bbs.archlinux.org/viewtopic.php?id=87574) but it did not solve my problem. The config seems related to firefox as
```
xdg-mime query default inode/directory
dolphin.desktop
```
Which is right. Also
```... | 2014/07/28 | [
"https://unix.stackexchange.com/questions/146904",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/44398/"
] | I'd have a similar problem running Manjaro 4.18.9-1. After install nautilus for a test, firefox started to open folders with nautilus, I removed nautilus and firefox then opened folders with Atom.
At least for me, this solution worked:
* Close firefox
* Go to your file manager (Thunar in my case), right click on a fo... | Firefox use GIO's GAppInfo. GIO's behaviour is slightly different from xdg-mime's.
By adding `inode/directory=ranger.desktop` in `$HOME/.config/mimeapps.list`, my firefox can open directory properly.
You can check the diffents between `xdg-mime query default inode/directory` and `gio mime inode/directory`. |
1,673,942 | Let $p(x, y)$ and $q(x, y)$ are real polynomials in $x, y\in \mathbb{R}$ and $p(x, y)\ne0$ and $q(x, y)\ne0$.
Why does $$(x^2+y^2)p(x, y)^2\ne q(x, y)^2$$ for all $x, y\in \mathbb{R}$ | 2016/02/27 | [
"https://math.stackexchange.com/questions/1673942",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/226800/"
] | Hint: Take the square root of both sides. There are some signs you need to think about, but basically can $\sqrt{x^2+y^2}p(x,y)$ ever be a polynomial for $p\ne 0\,?$ | Assume equality holds, i.e.
$$(x^2 + y^2) p(x, y)^2 = q(x, y)^2$$
**Hint:** Can you make the LHS zero by choosing some $x$ and $y$? What would that mean for $q(x, y)$?
---
EDIT: Assuming you meant $p \neq 0$ and $q \neq 0$ as polynomial, as JLA points out in the comments, the hint above is not correct. Here is a slig... |
1,673,942 | Let $p(x, y)$ and $q(x, y)$ are real polynomials in $x, y\in \mathbb{R}$ and $p(x, y)\ne0$ and $q(x, y)\ne0$.
Why does $$(x^2+y^2)p(x, y)^2\ne q(x, y)^2$$ for all $x, y\in \mathbb{R}$ | 2016/02/27 | [
"https://math.stackexchange.com/questions/1673942",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/226800/"
] | $\mathbb{R}[x,y]$ (the real polynomials) is what we call a *factorial ring* i.e. a ring where every $q\not=0$ can be decomposed uniquely as
$$
q=\lambda\prod\_{i\in I} p\_i^{\nu\_i(q)}
$$
where $\lambda$ is invertible (here is a non-zero real) and $p\_i$ is a complete family of irreducibles (see all standard texts).
N... | Assume equality holds, i.e.
$$(x^2 + y^2) p(x, y)^2 = q(x, y)^2$$
**Hint:** Can you make the LHS zero by choosing some $x$ and $y$? What would that mean for $q(x, y)$?
---
EDIT: Assuming you meant $p \neq 0$ and $q \neq 0$ as polynomial, as JLA points out in the comments, the hint above is not correct. Here is a slig... |
1,673,942 | Let $p(x, y)$ and $q(x, y)$ are real polynomials in $x, y\in \mathbb{R}$ and $p(x, y)\ne0$ and $q(x, y)\ne0$.
Why does $$(x^2+y^2)p(x, y)^2\ne q(x, y)^2$$ for all $x, y\in \mathbb{R}$ | 2016/02/27 | [
"https://math.stackexchange.com/questions/1673942",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/226800/"
] | Consider both sides of the equations as polynomials in $x$, and use the Fundamental Theorem of Algebra to factorise each side into linear factors of the form $(x-f\_k(y))$.
Note then that the multiplicity of the factor $(x+iy)$ is odd on the left-hand side (one factor from $(x^2+y^2)$, plus double its multiplicity in ... | Assume equality holds, i.e.
$$(x^2 + y^2) p(x, y)^2 = q(x, y)^2$$
**Hint:** Can you make the LHS zero by choosing some $x$ and $y$? What would that mean for $q(x, y)$?
---
EDIT: Assuming you meant $p \neq 0$ and $q \neq 0$ as polynomial, as JLA points out in the comments, the hint above is not correct. Here is a slig... |
1,673,942 | Let $p(x, y)$ and $q(x, y)$ are real polynomials in $x, y\in \mathbb{R}$ and $p(x, y)\ne0$ and $q(x, y)\ne0$.
Why does $$(x^2+y^2)p(x, y)^2\ne q(x, y)^2$$ for all $x, y\in \mathbb{R}$ | 2016/02/27 | [
"https://math.stackexchange.com/questions/1673942",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/226800/"
] | $\mathbb{R}[x,y]$ (the real polynomials) is what we call a *factorial ring* i.e. a ring where every $q\not=0$ can be decomposed uniquely as
$$
q=\lambda\prod\_{i\in I} p\_i^{\nu\_i(q)}
$$
where $\lambda$ is invertible (here is a non-zero real) and $p\_i$ is a complete family of irreducibles (see all standard texts).
N... | Hint: Take the square root of both sides. There are some signs you need to think about, but basically can $\sqrt{x^2+y^2}p(x,y)$ ever be a polynomial for $p\ne 0\,?$ |
1,673,942 | Let $p(x, y)$ and $q(x, y)$ are real polynomials in $x, y\in \mathbb{R}$ and $p(x, y)\ne0$ and $q(x, y)\ne0$.
Why does $$(x^2+y^2)p(x, y)^2\ne q(x, y)^2$$ for all $x, y\in \mathbb{R}$ | 2016/02/27 | [
"https://math.stackexchange.com/questions/1673942",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/226800/"
] | $\mathbb{R}[x,y]$ (the real polynomials) is what we call a *factorial ring* i.e. a ring where every $q\not=0$ can be decomposed uniquely as
$$
q=\lambda\prod\_{i\in I} p\_i^{\nu\_i(q)}
$$
where $\lambda$ is invertible (here is a non-zero real) and $p\_i$ is a complete family of irreducibles (see all standard texts).
N... | Consider both sides of the equations as polynomials in $x$, and use the Fundamental Theorem of Algebra to factorise each side into linear factors of the form $(x-f\_k(y))$.
Note then that the multiplicity of the factor $(x+iy)$ is odd on the left-hand side (one factor from $(x^2+y^2)$, plus double its multiplicity in ... |
38,870,307 | 1. Make a new UWP project (on windows) and make a new page. Run the project, a blank form appears with a control box, I can press minimise and the page is minimised. Great!
2. I want to minimise the page from code. I put a button on the page. in the button handler I have:
```
Private Sub button_Click(sender As Object... | 2016/08/10 | [
"https://Stackoverflow.com/questions/38870307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/367076/"
] | Why on earth are you reimplementing the wheel and not just using datetime?
```
>>> import datetime
>>> start = datetime.date(2016,1,1)
>>> end = datetime.date(2016,2,28)
>>> end-start
datetime.timedelta(58)
>>> delta = end-start
>>> delta.days
58
``` | Your `DaysforMonths` will calculate current month as it already over.
For example: `DaysForMonth(01, 2016)` will return 31, but should return 0. Jenuary is not over yet.
You should not count current month.
Also (if possible) please follow [pep8](https://www.python.org/dev/peps/pep-0008/) when using python. |
38,870,307 | 1. Make a new UWP project (on windows) and make a new page. Run the project, a blank form appears with a control box, I can press minimise and the page is minimised. Great!
2. I want to minimise the page from code. I put a button on the page. in the button handler I have:
```
Private Sub button_Click(sender As Object... | 2016/08/10 | [
"https://Stackoverflow.com/questions/38870307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/367076/"
] | Why on earth are you reimplementing the wheel and not just using datetime?
```
>>> import datetime
>>> start = datetime.date(2016,1,1)
>>> end = datetime.date(2016,2,28)
>>> end-start
datetime.timedelta(58)
>>> delta = end-start
>>> delta.days
58
``` | Below is the final code and it works for all the scenario. The intention was not to use datetime function, since I am learning Python and new to programming :)
```
##Variable Declaration####################
daysofMonths = [31,28,31,30,31,30,31,31,30,31,30,31]
FinalCount = 0
####### Step 1: Leap Year Function##########... |
38,870,307 | 1. Make a new UWP project (on windows) and make a new page. Run the project, a blank form appears with a control box, I can press minimise and the page is minimised. Great!
2. I want to minimise the page from code. I put a button on the page. in the button handler I have:
```
Private Sub button_Click(sender As Object... | 2016/08/10 | [
"https://Stackoverflow.com/questions/38870307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/367076/"
] | Below is the final code and it works for all the scenario. The intention was not to use datetime function, since I am learning Python and new to programming :)
```
##Variable Declaration####################
daysofMonths = [31,28,31,30,31,30,31,31,30,31,30,31]
FinalCount = 0
####### Step 1: Leap Year Function##########... | Your `DaysforMonths` will calculate current month as it already over.
For example: `DaysForMonth(01, 2016)` will return 31, but should return 0. Jenuary is not over yet.
You should not count current month.
Also (if possible) please follow [pep8](https://www.python.org/dev/peps/pep-0008/) when using python. |
28,568,187 | I have the following code to display some buttons and dropdown menus.
```
<div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group" role="group" aria-label="Toolbar Group">
<button type="button" class="btn btn-default as-btn-text as-add-btn">Add</button>
... | 2015/02/17 | [
"https://Stackoverflow.com/questions/28568187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/985012/"
] | The predicate function you pass to [`_.filter`](http://underscorejs.org/#filter) is supposed to return `true` if the value is to be included but your predicate:
```
function(n) {moment(n.date).isAfter(moment(timeCreated).subtract(110, 'days'))}
```
always returns `undefined` because it doesn't have a `return`. JavaS... | ```
for (var e = 0; e < arrayOfObjects.length; e++) {
var objects = arrayOfObjects[e];
if (moment(objects.date).isAfter(moment(timeCreated).subtract(100, 'days'))) {
var goodDates = [];
goodDates.push(objects);
console.log(goodDates);
}
}
``` |
575,215 | I'm doing the exercises to TAOCP Volume 1 Edition 3 and have trouble understanding the syntax used in the answer to the following exercise.
Chapter 1 Exercise 8
Computing the greatest common divisor of positive integers m & n by specifying Tj,sj,aj,bj
Let your input be represented by the string ambn (m a's followed ... | 2009/02/22 | [
"https://Stackoverflow.com/questions/575215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16584/"
] | Here's an [implementation](http://readingtaocp.wordpress.com/2008/09/13/markov-algorithms-in-scala/) of that exercise answer. Perhaps it helps.
By the way, the table seems to describe a [Markov algorithm](http://en.wikipedia.org/wiki/Markov_algorithm).
As far as I understand so far, you start with the first command s... | The superscript for gcd(m,n) is due to how numbers are being represented in this table.
For example: m => a^m
n => b^n
gcd(m,n) => a^gcd(m,n)
It looks to be like Euclids algorithm is being implemented.
i.e.
```
gcd(m,n):
if n==0:
return m
return gcd(n,m%n)
```
The numbers are represented as powers so as t... |
575,215 | I'm doing the exercises to TAOCP Volume 1 Edition 3 and have trouble understanding the syntax used in the answer to the following exercise.
Chapter 1 Exercise 8
Computing the greatest common divisor of positive integers m & n by specifying Tj,sj,aj,bj
Let your input be represented by the string ambn (m a's followed ... | 2009/02/22 | [
"https://Stackoverflow.com/questions/575215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16584/"
] | Here's an [implementation](http://readingtaocp.wordpress.com/2008/09/13/markov-algorithms-in-scala/) of that exercise answer. Perhaps it helps.
By the way, the table seems to describe a [Markov algorithm](http://en.wikipedia.org/wiki/Markov_algorithm).
As far as I understand so far, you start with the first command s... | the notion of am is probably a notion of input string in the state machine context.
Such notion is used to refer to `m` instances of consecutive `a`, i.e.:
>
> a4 = aaaa
>
> b7 = bbbbbbb
>
> a4b7a3 = aaaabbbbbbbaaa
>
>
>
And what agcd(m,n) means is that after running the (solution) state machine, the res... |
64,921,405 | I have a huge string in the memory (a few hundred megabytes, there is no way I can load it partially), I wonder whether there is some easy way to split this string into lines divided by Environment.NewLine:
a) without duplicating this structure in the memory (if I use string.Split it will duplicate it)
b) with some def... | 2020/11/19 | [
"https://Stackoverflow.com/questions/64921405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/155011/"
] | You can try *enumerating* lines, e.g.
```
private static IEnumerable<string> LinesFromString(string value) {
if (string.IsNullOrEmpty(value))
yield break;
int last = 0;
while (true) {
int next = value.IndexOf(Environment.NewLine, last);
if (next < 0) {
yield return value.Substring(last);
... | Could you not save the string to a temp file, use `String.Spilt()` via a `StreamReader`, then, finally, delete the file? |
29,309,994 | I would like to create a batch file that sets the `HTTPS proxy`, or respectively any proxy for IE. And i would like it without any window, command line or log. Just in plain background. Please excuse my low knowledge of Windows, due to me preferring rather Mac and Ubuntu. I would like the setup Adequately on a Windows ... | 2015/03/27 | [
"https://Stackoverflow.com/questions/29309994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3647078/"
] | `without any window, command line or log` - the only option left is a pure magic..
To automatize the proxy settings you can edit the [registry](https://support.microsoft.com/en-us/kb/819961?wa=wsignin1.0) :
```
reg ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v "ProxyServer" /d ... | ```
@echo off
```
hides the command prompt
good luck |
18,542,038 | How can I continuously input password values using javascript onclick function into password field?
I have two 'Blue' and 'Red' images that work with the onclick function and have the values below;
```
Blue= w3!
Red= T4.
```
When I click on the Blue image it inputs the value 'w3!' into the password field. But when ... | 2013/08/30 | [
"https://Stackoverflow.com/questions/18542038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2727096/"
] | Use `+=`
```
function myblue()
{
x=document.getElementById("password"); // Find the element
x.value += "w3!"; // add the content
}
function myred()
{
x=document.getElementById("password"); // Find the element
x.value += "T4"; // add the content
}
``` | ```
function myblue()
{
x=document.getElementById("password"); // Find the element
x.value += "w3!"; // add the content
}
```
that solution, of course, appends the string meanining it could be "w3!w3!w3!T4!" depending on how often you click it.
```
function myblue()
{
x=document.getElementById("password");... |
6,788,230 | During a recent interview one of my friends was asked a question to reverse a string using only a single line of code.
The string is already stored in a `char*` variable.
I tried using recursion, but it never reduced to a single line of code.
Could anyone help me with this? | 2011/07/22 | [
"https://Stackoverflow.com/questions/6788230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/857641/"
] | ```
char str[] = "test";
std::reverse(str, str + std::strlen(str));
``` | It requires an ugly construct involving a while loop with character pointer arithmetic and both post-increment and post-decrement operators. Never, ever use such hideous code except in obfuscation contests. (No, not even in interviews. If they ask you such useless trivia, chances are they are equally clueless about oth... |
6,788,230 | During a recent interview one of my friends was asked a question to reverse a string using only a single line of code.
The string is already stored in a `char*` variable.
I tried using recursion, but it never reduced to a single line of code.
Could anyone help me with this? | 2011/07/22 | [
"https://Stackoverflow.com/questions/6788230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/857641/"
] | 1. Write a program which works.
2. Condense it all onto a single line. You don't need to have linefeeds between statements! | It requires an ugly construct involving a while loop with character pointer arithmetic and both post-increment and post-decrement operators. Never, ever use such hideous code except in obfuscation contests. (No, not even in interviews. If they ask you such useless trivia, chances are they are equally clueless about oth... |
6,788,230 | During a recent interview one of my friends was asked a question to reverse a string using only a single line of code.
The string is already stored in a `char*` variable.
I tried using recursion, but it never reduced to a single line of code.
Could anyone help me with this? | 2011/07/22 | [
"https://Stackoverflow.com/questions/6788230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/857641/"
] | If you really want it in C, and `strlen` is allowed, this will work:
```
for( char *p = str, *q = str + strlen(str) - 1; p < q; *p ^= *q, *q ^= *p, *p++ ^= *q-- );
```
I do not recommend you to use this in any actual program... Anyone got an idea how to get rid of the `strlen`?
Edit: *even more beautiful*:
```
for... | It requires an ugly construct involving a while loop with character pointer arithmetic and both post-increment and post-decrement operators. Never, ever use such hideous code except in obfuscation contests. (No, not even in interviews. If they ask you such useless trivia, chances are they are equally clueless about oth... |
6,788,230 | During a recent interview one of my friends was asked a question to reverse a string using only a single line of code.
The string is already stored in a `char*` variable.
I tried using recursion, but it never reduced to a single line of code.
Could anyone help me with this? | 2011/07/22 | [
"https://Stackoverflow.com/questions/6788230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/857641/"
] | This seems to work fine
```
void reverse(char *s, int len) { \
if(len <= 1) \
return; \
char t; \
char *e = s + len - 1; \
while(s < e) { \
t = *s; \
*s = *e; \
*e = t; \
e--; \
s++; \
} \
}
```
Note that his code is all in one line. Prefer code clarity. If you can put a function's... | It requires an ugly construct involving a while loop with character pointer arithmetic and both post-increment and post-decrement operators. Never, ever use such hideous code except in obfuscation contests. (No, not even in interviews. If they ask you such useless trivia, chances are they are equally clueless about oth... |
6,788,230 | During a recent interview one of my friends was asked a question to reverse a string using only a single line of code.
The string is already stored in a `char*` variable.
I tried using recursion, but it never reduced to a single line of code.
Could anyone help me with this? | 2011/07/22 | [
"https://Stackoverflow.com/questions/6788230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/857641/"
] | 1. Write a program which works.
2. Condense it all onto a single line. You don't need to have linefeeds between statements! | ```
char str[] = "test";
std::reverse(str, str + std::strlen(str));
``` |
6,788,230 | During a recent interview one of my friends was asked a question to reverse a string using only a single line of code.
The string is already stored in a `char*` variable.
I tried using recursion, but it never reduced to a single line of code.
Could anyone help me with this? | 2011/07/22 | [
"https://Stackoverflow.com/questions/6788230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/857641/"
] | If you really want it in C, and `strlen` is allowed, this will work:
```
for( char *p = str, *q = str + strlen(str) - 1; p < q; *p ^= *q, *q ^= *p, *p++ ^= *q-- );
```
I do not recommend you to use this in any actual program... Anyone got an idea how to get rid of the `strlen`?
Edit: *even more beautiful*:
```
for... | ```
char str[] = "test";
std::reverse(str, str + std::strlen(str));
``` |
6,788,230 | During a recent interview one of my friends was asked a question to reverse a string using only a single line of code.
The string is already stored in a `char*` variable.
I tried using recursion, but it never reduced to a single line of code.
Could anyone help me with this? | 2011/07/22 | [
"https://Stackoverflow.com/questions/6788230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/857641/"
] | ```
char str[] = "test";
std::reverse(str, str + std::strlen(str));
``` | This seems to work fine
```
void reverse(char *s, int len) { \
if(len <= 1) \
return; \
char t; \
char *e = s + len - 1; \
while(s < e) { \
t = *s; \
*s = *e; \
*e = t; \
e--; \
s++; \
} \
}
```
Note that his code is all in one line. Prefer code clarity. If you can put a function's... |
6,788,230 | During a recent interview one of my friends was asked a question to reverse a string using only a single line of code.
The string is already stored in a `char*` variable.
I tried using recursion, but it never reduced to a single line of code.
Could anyone help me with this? | 2011/07/22 | [
"https://Stackoverflow.com/questions/6788230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/857641/"
] | 1. Write a program which works.
2. Condense it all onto a single line. You don't need to have linefeeds between statements! | If you really want it in C, and `strlen` is allowed, this will work:
```
for( char *p = str, *q = str + strlen(str) - 1; p < q; *p ^= *q, *q ^= *p, *p++ ^= *q-- );
```
I do not recommend you to use this in any actual program... Anyone got an idea how to get rid of the `strlen`?
Edit: *even more beautiful*:
```
for... |
6,788,230 | During a recent interview one of my friends was asked a question to reverse a string using only a single line of code.
The string is already stored in a `char*` variable.
I tried using recursion, but it never reduced to a single line of code.
Could anyone help me with this? | 2011/07/22 | [
"https://Stackoverflow.com/questions/6788230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/857641/"
] | 1. Write a program which works.
2. Condense it all onto a single line. You don't need to have linefeeds between statements! | This seems to work fine
```
void reverse(char *s, int len) { \
if(len <= 1) \
return; \
char t; \
char *e = s + len - 1; \
while(s < e) { \
t = *s; \
*s = *e; \
*e = t; \
e--; \
s++; \
} \
}
```
Note that his code is all in one line. Prefer code clarity. If you can put a function's... |
6,788,230 | During a recent interview one of my friends was asked a question to reverse a string using only a single line of code.
The string is already stored in a `char*` variable.
I tried using recursion, but it never reduced to a single line of code.
Could anyone help me with this? | 2011/07/22 | [
"https://Stackoverflow.com/questions/6788230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/857641/"
] | If you really want it in C, and `strlen` is allowed, this will work:
```
for( char *p = str, *q = str + strlen(str) - 1; p < q; *p ^= *q, *q ^= *p, *p++ ^= *q-- );
```
I do not recommend you to use this in any actual program... Anyone got an idea how to get rid of the `strlen`?
Edit: *even more beautiful*:
```
for... | This seems to work fine
```
void reverse(char *s, int len) { \
if(len <= 1) \
return; \
char t; \
char *e = s + len - 1; \
while(s < e) { \
t = *s; \
*s = *e; \
*e = t; \
e--; \
s++; \
} \
}
```
Note that his code is all in one line. Prefer code clarity. If you can put a function's... |
22,718,476 | I'm not sure what I changed in my app, but Im not able to clear the badges number anymore.
I put code the following code:
```
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
```
in:
```
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)l... | 2014/03/28 | [
"https://Stackoverflow.com/questions/22718476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You're calling it in `didFinishLaunchingWithOptions` that way it'll only get cleared on launching the app.
Have you tried killing the app from the multitasking menu and launching it again?
Also try and move `setApplicationIconBadgeNumber` in `applicationDidBecomeActive` . | Set it to -1 like this:
```
application.applicationIconBadgeNumber = -1;
```
or like this:
```
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:-1];
``` |
5,559,712 | Is there a reliable way to `JSON.stringify` a JavaScript object that guarantees that the ceated JSON string is the same across all browsers, Node.js and so on, given that the JavaScript object is the same?
I want to hash JavaScript objects like
```
{
signed_data: object_to_sign,
signature: md5(JSON.stringify(ob... | 2011/04/05 | [
"https://Stackoverflow.com/questions/5559712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/263061/"
] | You could normalise the result of `stringify()` by applying rules such as:
* remove unnecessary whitespace
* sort attribute names in hashes
* well-defined consistent quoting style
* normalise string contents (so "\u0041" and "A" become the same)
This would leave you with a canonical JSON representation of your object... | You may find [bencode](https://en.wikipedia.org/wiki/Bencode) suitable for your needs. It's cross-platform, and the encoding is guaranteed to be the same from every implementation.
The downside is it doesn't support nulls or booleans. But that may be okay for you if you do something like transforming e.g., bools -> `0... |
5,559,712 | Is there a reliable way to `JSON.stringify` a JavaScript object that guarantees that the ceated JSON string is the same across all browsers, Node.js and so on, given that the JavaScript object is the same?
I want to hash JavaScript objects like
```
{
signed_data: object_to_sign,
signature: md5(JSON.stringify(ob... | 2011/04/05 | [
"https://Stackoverflow.com/questions/5559712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/263061/"
] | You're asking for an implementation of something across multiple languages to be the same... you're almost certainly out of luck. You have two options:
* check www.json.org implementations to see if they might be more standardized
* roll your own in each language (use json.org implementations as a base and there shoul... | After trying some hash algorithms and JSON-to-string methods, I found this to work the best (Sorry, it is typescript, can of course be rewritten to javascript):
```
// From: https://stackoverflow.com/questions/5467129/sort-javascript-object-by-key
function sortObjectKeys(obj){
if(obj == null || obj == undefined){
... |
5,559,712 | Is there a reliable way to `JSON.stringify` a JavaScript object that guarantees that the ceated JSON string is the same across all browsers, Node.js and so on, given that the JavaScript object is the same?
I want to hash JavaScript objects like
```
{
signed_data: object_to_sign,
signature: md5(JSON.stringify(ob... | 2011/04/05 | [
"https://Stackoverflow.com/questions/5559712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/263061/"
] | You're asking for an implementation of something across multiple languages to be the same... you're almost certainly out of luck. You have two options:
* check www.json.org implementations to see if they might be more standardized
* roll your own in each language (use json.org implementations as a base and there shoul... | You could normalise the result of `stringify()` by applying rules such as:
* remove unnecessary whitespace
* sort attribute names in hashes
* well-defined consistent quoting style
* normalise string contents (so "\u0041" and "A" become the same)
This would leave you with a canonical JSON representation of your object... |
5,559,712 | Is there a reliable way to `JSON.stringify` a JavaScript object that guarantees that the ceated JSON string is the same across all browsers, Node.js and so on, given that the JavaScript object is the same?
I want to hash JavaScript objects like
```
{
signed_data: object_to_sign,
signature: md5(JSON.stringify(ob... | 2011/04/05 | [
"https://Stackoverflow.com/questions/5559712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/263061/"
] | This is an old question, but I thought I'd add a current solution to this question for any google referees.
The best way to sign and hash JSON objects now is to use [JSON Web Tokens](http://jwt.io/). This allows for an object to be signed, hashed and then verified by others based on the signature. It's offered for a b... | You could normalise the result of `stringify()` by applying rules such as:
* remove unnecessary whitespace
* sort attribute names in hashes
* well-defined consistent quoting style
* normalise string contents (so "\u0041" and "A" become the same)
This would leave you with a canonical JSON representation of your object... |
5,559,712 | Is there a reliable way to `JSON.stringify` a JavaScript object that guarantees that the ceated JSON string is the same across all browsers, Node.js and so on, given that the JavaScript object is the same?
I want to hash JavaScript objects like
```
{
signed_data: object_to_sign,
signature: md5(JSON.stringify(ob... | 2011/04/05 | [
"https://Stackoverflow.com/questions/5559712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/263061/"
] | After trying some hash algorithms and JSON-to-string methods, I found this to work the best (Sorry, it is typescript, can of course be rewritten to javascript):
```
// From: https://stackoverflow.com/questions/5467129/sort-javascript-object-by-key
function sortObjectKeys(obj){
if(obj == null || obj == undefined){
... | You may find [bencode](https://en.wikipedia.org/wiki/Bencode) suitable for your needs. It's cross-platform, and the encoding is guaranteed to be the same from every implementation.
The downside is it doesn't support nulls or booleans. But that may be okay for you if you do something like transforming e.g., bools -> `0... |
5,559,712 | Is there a reliable way to `JSON.stringify` a JavaScript object that guarantees that the ceated JSON string is the same across all browsers, Node.js and so on, given that the JavaScript object is the same?
I want to hash JavaScript objects like
```
{
signed_data: object_to_sign,
signature: md5(JSON.stringify(ob... | 2011/04/05 | [
"https://Stackoverflow.com/questions/5559712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/263061/"
] | You're asking for an implementation of something across multiple languages to be the same... you're almost certainly out of luck. You have two options:
* check www.json.org implementations to see if they might be more standardized
* roll your own in each language (use json.org implementations as a base and there shoul... | You may find [bencode](https://en.wikipedia.org/wiki/Bencode) suitable for your needs. It's cross-platform, and the encoding is guaranteed to be the same from every implementation.
The downside is it doesn't support nulls or booleans. But that may be okay for you if you do something like transforming e.g., bools -> `0... |
5,559,712 | Is there a reliable way to `JSON.stringify` a JavaScript object that guarantees that the ceated JSON string is the same across all browsers, Node.js and so on, given that the JavaScript object is the same?
I want to hash JavaScript objects like
```
{
signed_data: object_to_sign,
signature: md5(JSON.stringify(ob... | 2011/04/05 | [
"https://Stackoverflow.com/questions/5559712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/263061/"
] | You might be interested in npm package [**object-hash**](https://www.npmjs.com/package/object-hash), which seems to have a rather good activity & reliability level.
```
var hash = require('object-hash');
var testobj1 = {a: 1, b: 2};
var testobj2 = {b: 2, a: 1};
var testobj3 = {b: 2, a: "1"};
console.log(hash(testobj... | This is an old question, but I thought I'd add a current solution to this question for any google referees.
The best way to sign and hash JSON objects now is to use [JSON Web Tokens](http://jwt.io/). This allows for an object to be signed, hashed and then verified by others based on the signature. It's offered for a b... |
5,559,712 | Is there a reliable way to `JSON.stringify` a JavaScript object that guarantees that the ceated JSON string is the same across all browsers, Node.js and so on, given that the JavaScript object is the same?
I want to hash JavaScript objects like
```
{
signed_data: object_to_sign,
signature: md5(JSON.stringify(ob... | 2011/04/05 | [
"https://Stackoverflow.com/questions/5559712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/263061/"
] | This is an old question, but I thought I'd add a current solution to this question for any google referees.
The best way to sign and hash JSON objects now is to use [JSON Web Tokens](http://jwt.io/). This allows for an object to be signed, hashed and then verified by others based on the signature. It's offered for a b... | You may find [bencode](https://en.wikipedia.org/wiki/Bencode) suitable for your needs. It's cross-platform, and the encoding is guaranteed to be the same from every implementation.
The downside is it doesn't support nulls or booleans. But that may be okay for you if you do something like transforming e.g., bools -> `0... |
5,559,712 | Is there a reliable way to `JSON.stringify` a JavaScript object that guarantees that the ceated JSON string is the same across all browsers, Node.js and so on, given that the JavaScript object is the same?
I want to hash JavaScript objects like
```
{
signed_data: object_to_sign,
signature: md5(JSON.stringify(ob... | 2011/04/05 | [
"https://Stackoverflow.com/questions/5559712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/263061/"
] | You might be interested in npm package [**object-hash**](https://www.npmjs.com/package/object-hash), which seems to have a rather good activity & reliability level.
```
var hash = require('object-hash');
var testobj1 = {a: 1, b: 2};
var testobj2 = {b: 2, a: 1};
var testobj3 = {b: 2, a: "1"};
console.log(hash(testobj... | You could normalise the result of `stringify()` by applying rules such as:
* remove unnecessary whitespace
* sort attribute names in hashes
* well-defined consistent quoting style
* normalise string contents (so "\u0041" and "A" become the same)
This would leave you with a canonical JSON representation of your object... |
5,559,712 | Is there a reliable way to `JSON.stringify` a JavaScript object that guarantees that the ceated JSON string is the same across all browsers, Node.js and so on, given that the JavaScript object is the same?
I want to hash JavaScript objects like
```
{
signed_data: object_to_sign,
signature: md5(JSON.stringify(ob... | 2011/04/05 | [
"https://Stackoverflow.com/questions/5559712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/263061/"
] | You might be interested in npm package [**object-hash**](https://www.npmjs.com/package/object-hash), which seems to have a rather good activity & reliability level.
```
var hash = require('object-hash');
var testobj1 = {a: 1, b: 2};
var testobj2 = {b: 2, a: 1};
var testobj3 = {b: 2, a: "1"};
console.log(hash(testobj... | After trying some hash algorithms and JSON-to-string methods, I found this to work the best (Sorry, it is typescript, can of course be rewritten to javascript):
```
// From: https://stackoverflow.com/questions/5467129/sort-javascript-object-by-key
function sortObjectKeys(obj){
if(obj == null || obj == undefined){
... |
21,783,606 | I'm using Capybara with the Selenium webdriver in my testing suite. I've noticed that when all tests are complete, Selenium closes the browser by binding to `at_exit`. However, this causes an issue for my web application displays a "Are you sure you want to navigate away" dialog `onunload` (Please don't judge. This is ... | 2014/02/14 | [
"https://Stackoverflow.com/questions/21783606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/228014/"
] | If you are using a unit test framework like JUnit or TestNG, then what I do is use Configuration annoations like @AfterTest or @AfterClass to quit the browser. This way, while the test is running the browser is always up. It's not until the @Test block is finished that the test case will close the browser instance.
If... | Like it was mentioned, calling driver.Quit() should solve the problem, but if the pop-up window is causing an issue that prevents the browser from closing, then eliminate the instance. A simple solution is to wrap your test inside of a using clause.
```
using (IWebDriver driver = new FirefoxDriver())
{
//Perform ... |
21,783,606 | I'm using Capybara with the Selenium webdriver in my testing suite. I've noticed that when all tests are complete, Selenium closes the browser by binding to `at_exit`. However, this causes an issue for my web application displays a "Are you sure you want to navigate away" dialog `onunload` (Please don't judge. This is ... | 2014/02/14 | [
"https://Stackoverflow.com/questions/21783606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/228014/"
] | Is it possible for you to switch context `at_exit` and accept or dismiss the alert. Something like this
```
at_exit do
page.driver.browser.switch_to.alert.accept
#or
page.driver.browser.switch_to.alert.dismiss
end
``` | Like it was mentioned, calling driver.Quit() should solve the problem, but if the pop-up window is causing an issue that prevents the browser from closing, then eliminate the instance. A simple solution is to wrap your test inside of a using clause.
```
using (IWebDriver driver = new FirefoxDriver())
{
//Perform ... |
21,783,606 | I'm using Capybara with the Selenium webdriver in my testing suite. I've noticed that when all tests are complete, Selenium closes the browser by binding to `at_exit`. However, this causes an issue for my web application displays a "Are you sure you want to navigate away" dialog `onunload` (Please don't judge. This is ... | 2014/02/14 | [
"https://Stackoverflow.com/questions/21783606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/228014/"
] | As I mentioned in the OP update it appears that Capybara navigates to about:blank as the end of each Cucumber scenario. After talking with jnicklas from the Capybara team it appears that the best way to handle this is to implement a Cucumber `after` handler which navigates away before Capybara tries to and handle the a... | Like it was mentioned, calling driver.Quit() should solve the problem, but if the pop-up window is causing an issue that prevents the browser from closing, then eliminate the instance. A simple solution is to wrap your test inside of a using clause.
```
using (IWebDriver driver = new FirefoxDriver())
{
//Perform ... |
21,783,606 | I'm using Capybara with the Selenium webdriver in my testing suite. I've noticed that when all tests are complete, Selenium closes the browser by binding to `at_exit`. However, this causes an issue for my web application displays a "Are you sure you want to navigate away" dialog `onunload` (Please don't judge. This is ... | 2014/02/14 | [
"https://Stackoverflow.com/questions/21783606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/228014/"
] | Is it possible for you to switch context `at_exit` and accept or dismiss the alert. Something like this
```
at_exit do
page.driver.browser.switch_to.alert.accept
#or
page.driver.browser.switch_to.alert.dismiss
end
``` | If you are using a unit test framework like JUnit or TestNG, then what I do is use Configuration annoations like @AfterTest or @AfterClass to quit the browser. This way, while the test is running the browser is always up. It's not until the @Test block is finished that the test case will close the browser instance.
If... |
21,783,606 | I'm using Capybara with the Selenium webdriver in my testing suite. I've noticed that when all tests are complete, Selenium closes the browser by binding to `at_exit`. However, this causes an issue for my web application displays a "Are you sure you want to navigate away" dialog `onunload` (Please don't judge. This is ... | 2014/02/14 | [
"https://Stackoverflow.com/questions/21783606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/228014/"
] | As I mentioned in the OP update it appears that Capybara navigates to about:blank as the end of each Cucumber scenario. After talking with jnicklas from the Capybara team it appears that the best way to handle this is to implement a Cucumber `after` handler which navigates away before Capybara tries to and handle the a... | If you are using a unit test framework like JUnit or TestNG, then what I do is use Configuration annoations like @AfterTest or @AfterClass to quit the browser. This way, while the test is running the browser is always up. It's not until the @Test block is finished that the test case will close the browser instance.
If... |
7,909 | My mother was in a panic this morning. She called me over to help her with her garden because many of her tomato plants had suddenly developed yellow leaves, many of which (but not all) also have brown spots.
Here are the facts and observations:
* Developed almost overnight (few if any were yellow the previous day)
*... | 2013/07/13 | [
"https://gardening.stackexchange.com/questions/7909",
"https://gardening.stackexchange.com",
"https://gardening.stackexchange.com/users/920/"
] | Looking closely at the last picture, there are clear dark concentric circles around the black spots which is textbook early blight. It is a trademark of the disease. Blight has been bad, really bad this year.
Your best chance is unfortunately to pull the plants and save any remaining healthy plants. Then going forward... | You've just described my weather and tomato plants. The best I can figure, all the rain and humidity has provided the perfect conditions for fungus to thrive. I'm thinking Septoria lycopersici.
From: <http://pubs.ext.vt.edu/450/450-711/450-711.html>
>
> Septoria leaf spot of tomato, caused by the fungus Septoria lyc... |
7,909 | My mother was in a panic this morning. She called me over to help her with her garden because many of her tomato plants had suddenly developed yellow leaves, many of which (but not all) also have brown spots.
Here are the facts and observations:
* Developed almost overnight (few if any were yellow the previous day)
*... | 2013/07/13 | [
"https://gardening.stackexchange.com/questions/7909",
"https://gardening.stackexchange.com",
"https://gardening.stackexchange.com/users/920/"
] | That is [Early Blight, *Alternaria solani*](http://en.wikipedia.org/wiki/Alternaria_solani). The earlier you treat, the better the control, as a strong infection will build up resistance to the fungicide.
### Here's what to do:
* **Remove all leaves showing signs** of early blight (yellowing, dry margin, large to sma... | You've just described my weather and tomato plants. The best I can figure, all the rain and humidity has provided the perfect conditions for fungus to thrive. I'm thinking Septoria lycopersici.
From: <http://pubs.ext.vt.edu/450/450-711/450-711.html>
>
> Septoria leaf spot of tomato, caused by the fungus Septoria lyc... |
7,909 | My mother was in a panic this morning. She called me over to help her with her garden because many of her tomato plants had suddenly developed yellow leaves, many of which (but not all) also have brown spots.
Here are the facts and observations:
* Developed almost overnight (few if any were yellow the previous day)
*... | 2013/07/13 | [
"https://gardening.stackexchange.com/questions/7909",
"https://gardening.stackexchange.com",
"https://gardening.stackexchange.com/users/920/"
] | Looking closely at the last picture, there are clear dark concentric circles around the black spots which is textbook early blight. It is a trademark of the disease. Blight has been bad, really bad this year.
Your best chance is unfortunately to pull the plants and save any remaining healthy plants. Then going forward... | My goodness...based on the two pictures, pruning would definitely help the air-flow. Make sure you clean your pruners with alcohol between each plant pruned. FYI, it takes ONE fungal spore to infect a plant. The spores are in the soil and watering will splash the spore onto leaves. Once the plant has been infected ther... |
7,909 | My mother was in a panic this morning. She called me over to help her with her garden because many of her tomato plants had suddenly developed yellow leaves, many of which (but not all) also have brown spots.
Here are the facts and observations:
* Developed almost overnight (few if any were yellow the previous day)
*... | 2013/07/13 | [
"https://gardening.stackexchange.com/questions/7909",
"https://gardening.stackexchange.com",
"https://gardening.stackexchange.com/users/920/"
] | Looking closely at the last picture, there are clear dark concentric circles around the black spots which is textbook early blight. It is a trademark of the disease. Blight has been bad, really bad this year.
Your best chance is unfortunately to pull the plants and save any remaining healthy plants. Then going forward... | That is [Early Blight, *Alternaria solani*](http://en.wikipedia.org/wiki/Alternaria_solani). The earlier you treat, the better the control, as a strong infection will build up resistance to the fungicide.
### Here's what to do:
* **Remove all leaves showing signs** of early blight (yellowing, dry margin, large to sma... |
7,909 | My mother was in a panic this morning. She called me over to help her with her garden because many of her tomato plants had suddenly developed yellow leaves, many of which (but not all) also have brown spots.
Here are the facts and observations:
* Developed almost overnight (few if any were yellow the previous day)
*... | 2013/07/13 | [
"https://gardening.stackexchange.com/questions/7909",
"https://gardening.stackexchange.com",
"https://gardening.stackexchange.com/users/920/"
] | That is [Early Blight, *Alternaria solani*](http://en.wikipedia.org/wiki/Alternaria_solani). The earlier you treat, the better the control, as a strong infection will build up resistance to the fungicide.
### Here's what to do:
* **Remove all leaves showing signs** of early blight (yellowing, dry margin, large to sma... | My goodness...based on the two pictures, pruning would definitely help the air-flow. Make sure you clean your pruners with alcohol between each plant pruned. FYI, it takes ONE fungal spore to infect a plant. The spores are in the soil and watering will splash the spore onto leaves. Once the plant has been infected ther... |
50,117,935 | I am trying to display text inside a container. The value of the text itself is formatted but when I add it to the block the format is condensed and it overflows past the box.
How can I keep the format of the text as well as add a scrollbar in the container to keep it from overflowing?
[![enter image description here... | 2018/05/01 | [
"https://Stackoverflow.com/questions/50117935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2249815/"
] | use `overflow-y` for the container not the `span`, and use `<pre>` to display formatted code :
```css
.container {
/* Add shadows to create the "card" effect */
box-shadow: 0 2px 2px 0 rgba(0,0,0,0.2);
transition: 0.3s;
height: 50vh;
overflow-y: scroll;
}
```
```html
<div class="container">
... | You can use `pre` to keep the formatting and then set the `overflow` to `scroll`
I made a [codepen example here](https://codepen.io/anon/pen/YLZbGL)
The first block of lorem ipsum is styled, the next is default `pre` to show how it looks without any styling.
Is this what you want? |
50,954,682 | I ran over some problem with `PrintWriter`. I wrote some code that simply takes some input from a file and outputs it to another one.
Though a file is created, the file remains empty. The wanted input can be easily printed out in the console, which means the FileInputStream is working correctly.
Why is PrintWriter no... | 2018/06/20 | [
"https://Stackoverflow.com/questions/50954682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8951449/"
] | Make sure you always close your `OutputStreams`:
```
while(scanner.hasNext()) {
String s = scanner.nextLine();
outputStream.print(s+"\n");
System.out.println("Test "+s); //d.h. das Problem liegt am outputstream
}
outputStream.close();
scanner.close();... | When dealing with IO which requires cleanup, I prefer to use auto resource cleanup. This is all you need at the most basic level:
```
public static void writeInToOut(InputStream in, OutputStream out) {
try(PrintWriter outputStream = new PrintWriter(out);
Scanner scanner = new Scanner(in)) {
while(s... |
11,944,363 | when I created my project with the standard MVC4 template, there was ALOT of javascript included, e.g: jquery-obtrusive, jquery-validate, knockout, the entire jQuery UI.
How much of this is worth keeping and how much is throw away? I've noticed when you create a strongly typed Controller the create.cshtml view generat... | 2012/08/14 | [
"https://Stackoverflow.com/questions/11944363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/314963/"
] | >
> What exactly does this file do?
>
>
>
`jqueryval` is not a file it is a reference to a bundle.
A bundle in MVC4 is a collection of scripts, styles or other files bundled together into a single bundle.
You will have a `BundleConfig.cs` file in the `App_Start` folder, which contains the settings of which file ... | MVC4 and .Net Framework 4.5 offer bundling and minification techniques that reduce the number of request to the server and size of requested CSS and JavaScript library, which improve page loading time in Simple word page performance is increases and page is loaded faster.
System.Web.Optimization class offers the bundl... |
431,532 | My brain cells seem to be dying but this one is bothering me. What is the phrase that means something that you lose in process? Similar to occupational hazard? Or by product or side effect?
Example:
>
> Poor people and animals are ———- of capitalism.
>
>
>
So *poor people* and *animals* are the subject and *capi... | 2018/02/17 | [
"https://english.stackexchange.com/questions/431532",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/102194/"
] | Consider *fallout*.
>
> **fallout** *noun*
> 2 The adverse results of a situation or action.
> ‘The prosecutors must also consider the possible negative economic fallout that likely will result at a time when the economy is already struggling.’
> [- ODO](https://en.oxforddictionaries.com/definition/fallout)
>
>
... | Victim? or maybe casualty? Something that is badly affected by a situation. |
431,532 | My brain cells seem to be dying but this one is bothering me. What is the phrase that means something that you lose in process? Similar to occupational hazard? Or by product or side effect?
Example:
>
> Poor people and animals are ———- of capitalism.
>
>
>
So *poor people* and *animals* are the subject and *capi... | 2018/02/17 | [
"https://english.stackexchange.com/questions/431532",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/102194/"
] | I would say the answer is in the question and that the best word is 'sacrifice' or 'sacrificial victim'.
>
> Poor people and animals are **sacrificial victims** of capitalism.
>
>
>
They are surrendered, in a sacrificial way :
>
> Sacrifice : a. The destruction or surrender of something valued or desired for th... | Victim? or maybe casualty? Something that is badly affected by a situation. |
431,532 | My brain cells seem to be dying but this one is bothering me. What is the phrase that means something that you lose in process? Similar to occupational hazard? Or by product or side effect?
Example:
>
> Poor people and animals are ———- of capitalism.
>
>
>
So *poor people* and *animals* are the subject and *capi... | 2018/02/17 | [
"https://english.stackexchange.com/questions/431532",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/102194/"
] | Perhaps the best phrase for your situation is ***collateral damage***:
>
> [Merriam-Webster](https://www.merriam-webster.com/dictionary/collateral%20damage):
> injury inflicted on something other than an intended target;
> *specifically*: civilian casualties of a military operation
>
>
> [Collins English Dictiona... | Victim? or maybe casualty? Something that is badly affected by a situation. |
18,736,897 | I have the following javascript code
```
date.getMonth());
```
This returns me the name of the month in English, how can I get the languages in Italian or in an another language. What does the language option depend on? I mean, what determines the language of the returned variable, and how can I change this languag... | 2013/09/11 | [
"https://Stackoverflow.com/questions/18736897",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/808265/"
] | The getMonth() method returns the month (from 0 to 11) for the specified date, according to local time.
then create a month array as per required language..
Try this:-
```
<html>
<body>
<p id="demo">Click the button to display the name of this month.</p>
<button onclick="myFunction()">Try it</button>
<script>
fun... | Date.getMonth() does not return the name of the month, it returns an integer 0..11 representing January..December
If you want the name of the month in your locale language, then see this SO question and the different answers [Get month name from Date](https://stackoverflow.com/questions/1643320/get-month-name-from-dat... |
18,736,897 | I have the following javascript code
```
date.getMonth());
```
This returns me the name of the month in English, how can I get the languages in Italian or in an another language. What does the language option depend on? I mean, what determines the language of the returned variable, and how can I change this languag... | 2013/09/11 | [
"https://Stackoverflow.com/questions/18736897",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/808265/"
] | The getMonth() method returns the month (from 0 to 11) for the specified date, according to local time.
then create a month array as per required language..
Try this:-
```
<html>
<body>
<p id="demo">Click the button to display the name of this month.</p>
<button onclick="myFunction()">Try it</button>
<script>
fun... | I believe that instead of reinventing the wheel you can use a solid library.
>
> **Moment.js**
>
>
> A javascript date library for parsing, validating, manipulating, and formatting dates.
>
>
> <http://momentjs.com/>
>
>
>
If you really need to rewrite it then simply create an array of month names and based o... |
18,736,897 | I have the following javascript code
```
date.getMonth());
```
This returns me the name of the month in English, how can I get the languages in Italian or in an another language. What does the language option depend on? I mean, what determines the language of the returned variable, and how can I change this languag... | 2013/09/11 | [
"https://Stackoverflow.com/questions/18736897",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/808265/"
] | I believe that instead of reinventing the wheel you can use a solid library.
>
> **Moment.js**
>
>
> A javascript date library for parsing, validating, manipulating, and formatting dates.
>
>
> <http://momentjs.com/>
>
>
>
If you really need to rewrite it then simply create an array of month names and based o... | Date.getMonth() does not return the name of the month, it returns an integer 0..11 representing January..December
If you want the name of the month in your locale language, then see this SO question and the different answers [Get month name from Date](https://stackoverflow.com/questions/1643320/get-month-name-from-dat... |
10,925,115 | As I understand, the location of the `virtual` function pointer table in an object is compiler dependent.
Are there any pros/cons of placing this pointer at the beginning of the object vs at the end or vice-versa? | 2012/06/07 | [
"https://Stackoverflow.com/questions/10925115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/581003/"
] | The mere existence of a virtual function table is compiler dependent (but all compilers do), and the location is not mandated either... In all compilers of which I know the details, the vptr is stored in the beginning of the object. The reason is that it provides a uniform location. Consider a class hierarchy:
```
str... | Yes it is completely implementation dependent.
For a simple inheritance hierarchy it is located at the beginning of the object but for a complex hierarchy it won't be.
Anyhow, any source code you write should not rely on where it is located, in fact any code you write should not rely on even existence of a virtua... |
39,282 | The 5th definition of **[smooth](http://www.macmillandictionary.com/dictionary/british/smooth)** in Macmillan:
>
> ***showing disapproval*** relaxed and confident in a way that usually
> persuades people to do things. This word shows that you do not trust
> people like this
>
>
>
> >
> > Steven's a bit too **sm... | 2014/11/12 | [
"https://ell.stackexchange.com/questions/39282",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/2312/"
] | Yeah, I think the dictionary is applying negative connotations inappropriately here.
I agree with the *relaxed and confident* definition, but leave it at that; it can be used for either good or bad purposes. | Really, the word in these cases are perceived from a perspective.
Just to make a case and build my argument.
The definition you provided would be more like a con artist.
The example you gave below is more like a negotiator.
Given that both a con artist and negotiator do essentially the same thing, persuede people, t... |
33,149,127 | After reconstructing an old piece of code I once wrote, then forgot, now rewritten... I am putting it here as a wiki for all to use :-)
So, basically: If you got memory leaks in a complex Android app, containing images and cross-references. How would you go and find which (type of) objects are leaking? There are a few... | 2015/10/15 | [
"https://Stackoverflow.com/questions/33149127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4226806/"
] | [LeakCanary](https://github.com/square/leakcanary) is a 3rd party library which automatically detects memory leaks, after adding the dependency you can add the following line to your application class:
```
LeakCanary.install(this);
```
The library provides a nice notification & trace of the leak, you can also define... | My solution in one class: "MemCheck"
To monitor any object, just call:
```
MemCheck.add( this ); // in any class constructor
```
This will "monitor" the number of objects allocated, and most importantly - Deallocated.
To log the leaks at any required time, call:
```
MemCheck.countAndLog();
```
As an alternative... |
14,709,472 | In matlab if I've a context menu with handle `cxmenu_Options` which is linked to different three `uicontrol` objects.
**Inside the context menu callback function:**
**Code Demo:**
```
function demoOnContextMenus
hFigure = figure;
hControl = uicontrol( ...
'Parent' , hFigure , ...
'S... | 2013/02/05 | [
"https://Stackoverflow.com/questions/14709472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/807495/"
] | There are two ways to access the handle:
`gco` returns the handle of the currently selected object. Thus `tag = get(gco,'tag')` will return `IamControl`.
Alternatively, you can pass the handle directly to the callback (in case the hierarchy becomes more complicated, since `gco` will only give you the top-level handle... | Using Matlab's guide environment I have found another way to determine the caller.
The command gco (get current object) simply did the job.
In my case the context menu provides the option to open a path specified in an "Edit Text" object in Windows Explorer.
```
function open_in_browser_Callback(hObject, eventdata, ... |
130,750 | The Lubavitcher Rebbe, in one of his letters (letter no. 184, dated from 7 Shvat, 5705), cites the Rebbe Rayatz (The Tzemach Tzedek) and says:
>
> A word spoken is public knowledge; in writing, it is for the entire world, and in print, it is for generations after generations.’”
>
>
>
The Rebbe quotes the Tzemach ... | 2022/08/28 | [
"https://judaism.stackexchange.com/questions/130750",
"https://judaism.stackexchange.com",
"https://judaism.stackexchange.com/users/27180/"
] | The source can be find on Hebrewbooks [here](https://hebrewbooks.org/pdfpager.aspx?req=31602&st=&pgnum=448&hilite=) (3rd paragraph)
[](https://i.stack.imgur.com/Ikupb.jpg)
>
> So I received from our master our teacher, the holy Rabbi, the Tzemach Tz... | [](https://i.stack.imgur.com/2IjJU.jpg)
[](https://i.stack.imgur.com/lDNRg.jpg)
This is the actual letter published from volume 2 that is quoted. |
30,893,578 | I have an existing Objective-C project and I want to add a new Xcode 7 UI testing target with [OHHTTPStubs](https://github.com/AliSoftware/OHHTTPStubs) as a dependency.
I added the new (Swift 2.0) UI testing target in Xcode, then added this to my `Podfile`:
```
target 'FooUITests' do
pod 'OHHTTPStubs', '4.0.1'
en... | 2015/06/17 | [
"https://Stackoverflow.com/questions/30893578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17294/"
] | Turns out all I needed to do was tell Cocoapods to `use_frameworks!` (for the Swift target only) in the `Podfile`:
```
target 'FooUITests' do
use_frameworks!
pod 'OHHTTPStubs', '4.0.1'
end
``` | Seems to work using CocoaPods 0.38.0.beta.2, check <https://github.com/CocoaPods/CocoaPods/issues/3709> |
30,893,578 | I have an existing Objective-C project and I want to add a new Xcode 7 UI testing target with [OHHTTPStubs](https://github.com/AliSoftware/OHHTTPStubs) as a dependency.
I added the new (Swift 2.0) UI testing target in Xcode, then added this to my `Podfile`:
```
target 'FooUITests' do
pod 'OHHTTPStubs', '4.0.1'
en... | 2015/06/17 | [
"https://Stackoverflow.com/questions/30893578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17294/"
] | Turns out all I needed to do was tell Cocoapods to `use_frameworks!` (for the Swift target only) in the `Podfile`:
```
target 'FooUITests' do
use_frameworks!
pod 'OHHTTPStubs', '4.0.1'
end
``` | Adding a `[CP] Embed Pods Frameworks` Run Script build phase to my test target fixed this for me, as described [in this CocoaPods GitHub issue](https://github.com/CocoaPods/CocoaPods/issues/5250).
Note that in your regular target, your Build Phases section contains both `[CP] Copy Pods Resources` (which runs `"${SRCRO... |
30,893,578 | I have an existing Objective-C project and I want to add a new Xcode 7 UI testing target with [OHHTTPStubs](https://github.com/AliSoftware/OHHTTPStubs) as a dependency.
I added the new (Swift 2.0) UI testing target in Xcode, then added this to my `Podfile`:
```
target 'FooUITests' do
pod 'OHHTTPStubs', '4.0.1'
en... | 2015/06/17 | [
"https://Stackoverflow.com/questions/30893578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17294/"
] | Adding a `[CP] Embed Pods Frameworks` Run Script build phase to my test target fixed this for me, as described [in this CocoaPods GitHub issue](https://github.com/CocoaPods/CocoaPods/issues/5250).
Note that in your regular target, your Build Phases section contains both `[CP] Copy Pods Resources` (which runs `"${SRCRO... | Seems to work using CocoaPods 0.38.0.beta.2, check <https://github.com/CocoaPods/CocoaPods/issues/3709> |
17,531,331 | I have the following code on visual studio 2012, and I have also changed the properties to manual positioning.
```
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender... | 2013/07/08 | [
"https://Stackoverflow.com/questions/17531331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2460162/"
] | Typically, it would be better to just set this up in the Form's designer.
Set [`StartPosition`](http://msdn.microsoft.com/en-us/library/system.windows.forms.form.startposition.aspx) to [`FormStartPosition.Manual`](http://msdn.microsoft.com/en-us/library/system.windows.forms.formstartposition.aspx), and the `Location` ... | I didn't see this line `I have also changed the properties to manual positioning` before, if so, there is no reason for your code not working unless the `Form1_Load` is not registered with `Load` event of your form. |
12,091,006 | Can you embed a google apps service on your tumblr blog, if you do not have your own domain? | 2012/08/23 | [
"https://Stackoverflow.com/questions/12091006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1619619/"
] | No. You cannot embed an Apps Script web app in an external site. You can only do it on a Google Site. | Yes it is possible I have installed google comments and google follower on my tumblr blog. |
8,436,882 | I have searched through the other questions and none of them seem to apply
exactly.
I am writing a program that finds a route through a maze,
the only real thing im having a problem with is this one compiler error.
It has to do with the one function I have the returns a Node ( struct).
Header file: (I cut the defi... | 2011/12/08 | [
"https://Stackoverflow.com/questions/8436882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1088450/"
] | In the cpp file, `Node` is not in global scope. It's nested inside `Graph` as such, you need to qualify it in a return type:
```
Graph::Node* Graph::find(int id){
// ...
}
```
Inside the function, you're in the scope of `Graph` again, as such you do not need to qualify it. | You have both Node and Element defined as structs inside the class Graph. It would be better to define them outside the class Graph. You can define a separate Node class and store the element struct as its private members. The error happens because Node is a private member of Graph, which can be accessed as Graph::Node... |
21,641,888 | How would you search through an entire string and display each item found in a div?
The thing I'm searching for is a license code which starts with NVOS and ends with ". I'd like to extract the entire code except for the "
The thing I want to parse would be like NVOS-ABCD-EFG-HIJK-LM52P" but I don't want the " includ... | 2014/02/08 | [
"https://Stackoverflow.com/questions/21641888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2475432/"
] | The `qout` queue in the subprocess gets full. The data you put in it from `foo()` doesn't fit in the buffer of the OS's pipes used internally, so the subprocess blocks trying to fit more data. But the parent process is not reading this data: it is simply blocked too, waiting for the subprocess to finish. This is a typi... | There must be a limit on the size of queues. Consider the following modification:
```
from multiprocessing import Process, Queue
def foo(qin,qout):
while True:
bar = qin.get()
if bar is None:
break
#qout.put({'bar':bar})
if __name__=='__main__':
import sys
qin=Queue()... |
21,641,888 | How would you search through an entire string and display each item found in a div?
The thing I'm searching for is a license code which starts with NVOS and ends with ". I'd like to extract the entire code except for the "
The thing I want to parse would be like NVOS-ABCD-EFG-HIJK-LM52P" but I don't want the " includ... | 2014/02/08 | [
"https://Stackoverflow.com/questions/21641888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2475432/"
] | The `qout` queue in the subprocess gets full. The data you put in it from `foo()` doesn't fit in the buffer of the OS's pipes used internally, so the subprocess blocks trying to fit more data. But the parent process is not reading this data: it is simply blocked too, waiting for the subprocess to finish. This is a typi... | I had the same problem on `python3` when tried to put strings into a queue of total size about 5000 cahrs.
In my project there was a host process that sets up a queue and starts subprocess, then joins. Afrer `join` host process reads form the queue. When subprocess producess too much data, host hungs on `join`. I fixe... |
21,641,888 | How would you search through an entire string and display each item found in a div?
The thing I'm searching for is a license code which starts with NVOS and ends with ". I'd like to extract the entire code except for the "
The thing I want to parse would be like NVOS-ABCD-EFG-HIJK-LM52P" but I don't want the " includ... | 2014/02/08 | [
"https://Stackoverflow.com/questions/21641888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2475432/"
] | The `qout` queue in the subprocess gets full. The data you put in it from `foo()` doesn't fit in the buffer of the OS's pipes used internally, so the subprocess blocks trying to fit more data. But the parent process is not reading this data: it is simply blocked too, waiting for the subprocess to finish. This is a typi... | I was trying to `.get()` an async worker after the pool had closed
indentation error outside of a with block
**i had this**
```
with multiprocessing.Pool() as pool:
async_results = list()
for job in jobs:
async_results.append(
pool.apply_async(
_worker_func,
... |
21,641,888 | How would you search through an entire string and display each item found in a div?
The thing I'm searching for is a license code which starts with NVOS and ends with ". I'd like to extract the entire code except for the "
The thing I want to parse would be like NVOS-ABCD-EFG-HIJK-LM52P" but I don't want the " includ... | 2014/02/08 | [
"https://Stackoverflow.com/questions/21641888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2475432/"
] | There must be a limit on the size of queues. Consider the following modification:
```
from multiprocessing import Process, Queue
def foo(qin,qout):
while True:
bar = qin.get()
if bar is None:
break
#qout.put({'bar':bar})
if __name__=='__main__':
import sys
qin=Queue()... | I was trying to `.get()` an async worker after the pool had closed
indentation error outside of a with block
**i had this**
```
with multiprocessing.Pool() as pool:
async_results = list()
for job in jobs:
async_results.append(
pool.apply_async(
_worker_func,
... |
21,641,888 | How would you search through an entire string and display each item found in a div?
The thing I'm searching for is a license code which starts with NVOS and ends with ". I'd like to extract the entire code except for the "
The thing I want to parse would be like NVOS-ABCD-EFG-HIJK-LM52P" but I don't want the " includ... | 2014/02/08 | [
"https://Stackoverflow.com/questions/21641888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2475432/"
] | I had the same problem on `python3` when tried to put strings into a queue of total size about 5000 cahrs.
In my project there was a host process that sets up a queue and starts subprocess, then joins. Afrer `join` host process reads form the queue. When subprocess producess too much data, host hungs on `join`. I fixe... | I was trying to `.get()` an async worker after the pool had closed
indentation error outside of a with block
**i had this**
```
with multiprocessing.Pool() as pool:
async_results = list()
for job in jobs:
async_results.append(
pool.apply_async(
_worker_func,
... |
4,933,256 | I am trying to build a word-based-game application in Java. I browsed through some existing questions and got some idea how to get wordlist. Some of the questions I have referred to:
[How to pick a random english word from a list](https://stackoverflow.com/questions/594273/random-word-generator)
[Random word selectio... | 2011/02/08 | [
"https://Stackoverflow.com/questions/4933256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/139909/"
] | Stick the word list into an array or `ArrayList`, and pick a random index. `ArrayList` is easier to work with since it can grow dynamically as you're reading your dictionary file. | you could use List or even an String array and fill it with big words list and then generate random number and then select the word from the list using that random number as index. |
4,933,256 | I am trying to build a word-based-game application in Java. I browsed through some existing questions and got some idea how to get wordlist. Some of the questions I have referred to:
[How to pick a random english word from a list](https://stackoverflow.com/questions/594273/random-word-generator)
[Random word selectio... | 2011/02/08 | [
"https://Stackoverflow.com/questions/4933256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/139909/"
] | Stick the word list into an array or `ArrayList`, and pick a random index. `ArrayList` is easier to work with since it can grow dynamically as you're reading your dictionary file. | 1. Your proposed Map does not achieve you goal, because HashMaps allow you to access a value associated with a given key, doesn't allow you to access a key associated with value. So if you use a HashMap, it should be `Map<Integer, String>`
2. The primary benefit of a HashMap over other data structures is the constant l... |
57,798,433 | I'm in the process of upgrading from elasticsearch 1.7 to 6.7. One of the changes is the removal of filtered query in favor of a bool query.
I am looking for help to convert the below query.
I have tried to change "and" to "must" and "filtered" to "bool"
Here is the code:
```
{
"size": 0,
"_source": false,... | 2019/09/05 | [
"https://Stackoverflow.com/questions/57798433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5660746/"
] | Simply like this:
```
{
"size": 0,
"_source": false,
"query": {
"bool": {
"filter": [
{
"geo_distance": {
"distance": "50mi",
"location": "35.323312, -23.14848"
}
},
{
"term": {
"id_from_store": 99
}
... | Query should be structured like below. No need to add bool and must for each query
```
query" : {
"bool" : {
"must": [
{"geo_distance":<your_query>},
{"term":<your_query>},
{"term":<your_query>},
{"range":<your_query>}
]
... |
2,432,292 | >
> Prove that $\forall n \ge 4$, $n^{3} + n < 3^{n}$
>
>
>
**My attempt**: Base case is trivial.
Suppose $ \ n \ge 4$, $n^{3} + n < 3^{n}$. Then,
$$ (n+1)^{3} + (n+1) = n^3 + n + 3n^2 + 3n + 1 +1 < 3^{n} + 3n^2 + 3n + 2 \\< 3\cdot 3^{n} + 3n^2 + 3n +2.$$
Not sure how to get rid of $3n^2 + 3n +2$. | 2017/09/16 | [
"https://math.stackexchange.com/questions/2432292",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] | Hint:
$$ 3n^2+3n+2<n^3+n<3^n. $$ | You proved correctly that $(n+1)^3+(n+1)<3^n+3n^2+3n+2$. So, prove now that$$(\forall n\geqslant4):3n^2+3n+2\leqslant2\times3^n.$$This is easy to do using induction again. |
2,432,292 | >
> Prove that $\forall n \ge 4$, $n^{3} + n < 3^{n}$
>
>
>
**My attempt**: Base case is trivial.
Suppose $ \ n \ge 4$, $n^{3} + n < 3^{n}$. Then,
$$ (n+1)^{3} + (n+1) = n^3 + n + 3n^2 + 3n + 1 +1 < 3^{n} + 3n^2 + 3n + 2 \\< 3\cdot 3^{n} + 3n^2 + 3n +2.$$
Not sure how to get rid of $3n^2 + 3n +2$. | 2017/09/16 | [
"https://math.stackexchange.com/questions/2432292",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] | Hint:
$$ 3n^2+3n+2<n^3+n<3^n. $$ | Because for $n\geq4$ we have:
$$3^n=(1+2)^n\geq1+2n+\frac{n(n-1)}{2}\cdot2^2+\frac{n(n-1)(n-2)}{6}\cdot2^3+$$
$$+\frac{n(n-1)(n-2)(n-3)}{24}\cdot2^4>n^3+n.$$
The last inequality is true because it's
$$3+6n+6n^2-6n+4n^3-12n^2+8n+2n^4-12n^3+22n^2-12n>3n^3+3n$$ or
$$2n^4-11n^3+16n^2-7n+3>0$$ or
$$2n^4-8n^3-3n^3+12n^2+4n^... |
2,432,292 | >
> Prove that $\forall n \ge 4$, $n^{3} + n < 3^{n}$
>
>
>
**My attempt**: Base case is trivial.
Suppose $ \ n \ge 4$, $n^{3} + n < 3^{n}$. Then,
$$ (n+1)^{3} + (n+1) = n^3 + n + 3n^2 + 3n + 1 +1 < 3^{n} + 3n^2 + 3n + 2 \\< 3\cdot 3^{n} + 3n^2 + 3n +2.$$
Not sure how to get rid of $3n^2 + 3n +2$. | 2017/09/16 | [
"https://math.stackexchange.com/questions/2432292",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] | Hint:
$$ 3n^2+3n+2<n^3+n<3^n. $$ | By the binomial theorem, $3^n = (1+2)^n \ge \binom{n}{1}+ \binom{n}{4}2^4$ for $n \ge 4$.
So, it's enough to prove that $\binom{n}{1}+ \binom{n}{4}2^4 > n^3+n$ (\*).
This simplifies to $2 n^3 - 15 n^2 + 22 n - 12 > 0$.
The largest critical point of $2 x^3 - 15 x^2 + 22 x - 12$ is at $x \approx 4.1$. Also (\*) is tru... |
2,432,292 | >
> Prove that $\forall n \ge 4$, $n^{3} + n < 3^{n}$
>
>
>
**My attempt**: Base case is trivial.
Suppose $ \ n \ge 4$, $n^{3} + n < 3^{n}$. Then,
$$ (n+1)^{3} + (n+1) = n^3 + n + 3n^2 + 3n + 1 +1 < 3^{n} + 3n^2 + 3n + 2 \\< 3\cdot 3^{n} + 3n^2 + 3n +2.$$
Not sure how to get rid of $3n^2 + 3n +2$. | 2017/09/16 | [
"https://math.stackexchange.com/questions/2432292",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] | Because for $n\geq4$ we have:
$$3^n=(1+2)^n\geq1+2n+\frac{n(n-1)}{2}\cdot2^2+\frac{n(n-1)(n-2)}{6}\cdot2^3+$$
$$+\frac{n(n-1)(n-2)(n-3)}{24}\cdot2^4>n^3+n.$$
The last inequality is true because it's
$$3+6n+6n^2-6n+4n^3-12n^2+8n+2n^4-12n^3+22n^2-12n>3n^3+3n$$ or
$$2n^4-11n^3+16n^2-7n+3>0$$ or
$$2n^4-8n^3-3n^3+12n^2+4n^... | You proved correctly that $(n+1)^3+(n+1)<3^n+3n^2+3n+2$. So, prove now that$$(\forall n\geqslant4):3n^2+3n+2\leqslant2\times3^n.$$This is easy to do using induction again. |
2,432,292 | >
> Prove that $\forall n \ge 4$, $n^{3} + n < 3^{n}$
>
>
>
**My attempt**: Base case is trivial.
Suppose $ \ n \ge 4$, $n^{3} + n < 3^{n}$. Then,
$$ (n+1)^{3} + (n+1) = n^3 + n + 3n^2 + 3n + 1 +1 < 3^{n} + 3n^2 + 3n + 2 \\< 3\cdot 3^{n} + 3n^2 + 3n +2.$$
Not sure how to get rid of $3n^2 + 3n +2$. | 2017/09/16 | [
"https://math.stackexchange.com/questions/2432292",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] | Because for $n\geq4$ we have:
$$3^n=(1+2)^n\geq1+2n+\frac{n(n-1)}{2}\cdot2^2+\frac{n(n-1)(n-2)}{6}\cdot2^3+$$
$$+\frac{n(n-1)(n-2)(n-3)}{24}\cdot2^4>n^3+n.$$
The last inequality is true because it's
$$3+6n+6n^2-6n+4n^3-12n^2+8n+2n^4-12n^3+22n^2-12n>3n^3+3n$$ or
$$2n^4-11n^3+16n^2-7n+3>0$$ or
$$2n^4-8n^3-3n^3+12n^2+4n^... | By the binomial theorem, $3^n = (1+2)^n \ge \binom{n}{1}+ \binom{n}{4}2^4$ for $n \ge 4$.
So, it's enough to prove that $\binom{n}{1}+ \binom{n}{4}2^4 > n^3+n$ (\*).
This simplifies to $2 n^3 - 15 n^2 + 22 n - 12 > 0$.
The largest critical point of $2 x^3 - 15 x^2 + 22 x - 12$ is at $x \approx 4.1$. Also (\*) is tru... |
69,334,082 | im new in the community !
im trying to run a function with main function and its not working for me.
when im calling to the function it is work pretty good and with the main function calling its not.
pleae help me to solve my problem.
```
def main():
is_valid_input()
if __name__ == "__main__":
main()
def is_... | 2021/09/26 | [
"https://Stackoverflow.com/questions/69334082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17007410/"
] | In script mode, your `is_valid_input` function is undefined when `main()` will be run. Place this block at the very end of your code (after the definition of `is_valid_input`):
```
if __name__ == "__main__":
main()
```
Regarding your code *per se*, I am not sure what you want to do exactly, but below is a way to... | The answer provided by [@mozway](https://stackoverflow.com/users/16343464/mozway) is perfect. If you are looking to see the returned value in the terminal then catch the returned boolean value from the function `is_valid_input` and print it. |
293,650 | OK, so i just need a little advice. I own a Fujitsu Esprimo Mobile v6535 machine with these specs:
4GB RAM
Pentium(R) Dual-Core CPU T4300 @ 2.10GHz × 2
Unknown graphics driver (found somewhere on the net i have an Intel GL40 chipset and Mobile
intel®GMA 4500M graphics )
500GB disk
Will it run smoothly according to t... | 2013/05/10 | [
"https://askubuntu.com/questions/293650",
"https://askubuntu.com",
"https://askubuntu.com/users/157534/"
] | Yes you can. But I would go with Ubuntu 13.04, specially if it will be the only OS on your system. For more info about 13.04 check out the [Release Notes](https://wiki.ubuntu.com/RaringRingtail/ReleaseNotes)
To download 13.04 [32Bit](http://ftp.ticklers.org/releases.ubuntu.org/releases//raring/ubuntu-13.04-desktop-i3... | Yes, should be just fine... I'm running Ubuntu on a compaq 6710b, Intel centrino and 2GB of RAM...
have a look at this: [Installation/SystemRequirements](https://help.ubuntu.com/community/Installation/SystemRequirements) |
293,650 | OK, so i just need a little advice. I own a Fujitsu Esprimo Mobile v6535 machine with these specs:
4GB RAM
Pentium(R) Dual-Core CPU T4300 @ 2.10GHz × 2
Unknown graphics driver (found somewhere on the net i have an Intel GL40 chipset and Mobile
intel®GMA 4500M graphics )
500GB disk
Will it run smoothly according to t... | 2013/05/10 | [
"https://askubuntu.com/questions/293650",
"https://askubuntu.com",
"https://askubuntu.com/users/157534/"
] | Yes you can. But I would go with Ubuntu 13.04, specially if it will be the only OS on your system. For more info about 13.04 check out the [Release Notes](https://wiki.ubuntu.com/RaringRingtail/ReleaseNotes)
To download 13.04 [32Bit](http://ftp.ticklers.org/releases.ubuntu.org/releases//raring/ubuntu-13.04-desktop-i3... | Yes. You can check the [System Requirements](https://help.ubuntu.com/community/Installation/SystemRequirements) if you want. |
28,841,415 | Is there a way to detect what a cell use to contain before it was changed. I'm trying to perform actions based on what the previous value was in a cell. I know there's Worksheet\_Change but the Target it uses is the new value. | 2015/03/03 | [
"https://Stackoverflow.com/questions/28841415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4484829/"
] | You can undo the change, populate the undone value to a variable then redo the change like so:
```
Private Sub Worksheet_Change(ByVal Target As Range)
Dim OldValue As Variant, NewValue As Variant
NewValue = Target.Value
Application.EnableEvents = False
Application.Undo
OldValue = Target.Value
Target.Value = NewValue
A... | We must **remember** what was in there. Say cell **B9** was of interest. In a *Standard Module* include the single line:
```
Public OldValue As Variant
```
and in the worksheet code area:
```
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("B9")) Is Nothing Then Exit Sub
v = T... |
2,231,573 | using iphone sdk 3.1.2.
Is there anyway of knowing if a Bluetooth headset is connected to the device? Don't need any info except if its connected or not. This is different from knowing if one was plugged in or not which one can do via a Property Listener of an Audio Session.
Thanks | 2010/02/09 | [
"https://Stackoverflow.com/questions/2231573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/261157/"
] | Call this method to find out the bluetooth headset is connected or not.
First import this framework `#import <AVFoundation/AVFoundation.h>`
```
- (BOOL) isBluetoothHeadsetConnected
{
AVAudioSession *session = [AVAudioSession sharedInstance];
AVAudioSessionRouteDescription *routeDescription = [ses... | Have you looked at the: [kAudioSessionProperty\_AudioRoute](http://developer.apple.com/iphone/library/documentation/AudioToolbox/Reference/AudioSessionServicesReference/Reference/reference.html#//apple_ref/doc/c_ref/kAudioSessionProperty_AudioRoute)?
Also see this post:
[How can I find out if an external headset is c... |
18,528,631 | Trying to get through Michael Hartl's tutorial; encountering issues here.
I've just created the application.
Here is what I am presented with when I run 'bundle exec rspec spec/requests/static\_pages\_spec.rb'
```
Corey-M-Kimball:sample_app coreymkimball$ bundle exec rspec spec/requests/static_pages_spec.rb
/Users/... | 2013/08/30 | [
"https://Stackoverflow.com/questions/18528631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2698988/"
] | Rewrite your Gemfile. Change 'selenium-webdriver' to '~> 2.35.1', reinstall bundle and everything has to be OK! | I think, the problem might be similar to this one: [zip/zip (LoadError) - Breaking guard or rails 4.0](https://stackoverflow.com/questions/18526638)
Seems like it's a bug in selenium-webdriver gem, that has beed solved in the latest versions. So try updating your Gemfile and your bundle. |
18,528,631 | Trying to get through Michael Hartl's tutorial; encountering issues here.
I've just created the application.
Here is what I am presented with when I run 'bundle exec rspec spec/requests/static\_pages\_spec.rb'
```
Corey-M-Kimball:sample_app coreymkimball$ bundle exec rspec spec/requests/static_pages_spec.rb
/Users/... | 2013/08/30 | [
"https://Stackoverflow.com/questions/18528631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2698988/"
] | I think, the problem might be similar to this one: [zip/zip (LoadError) - Breaking guard or rails 4.0](https://stackoverflow.com/questions/18526638)
Seems like it's a bug in selenium-webdriver gem, that has beed solved in the latest versions. So try updating your Gemfile and your bundle. | I used the above answer (by user Arsenii Prohorchik) and it worked for me. I noticed that the result of following his suggestion to rewite the gemfile caused the following changes when running "bundle update"
Installing rubyzip (0.9.9)
Installing websocket (1.0.7)
Installing selenium-webdriver (2.35.1)
This fi... |
18,528,631 | Trying to get through Michael Hartl's tutorial; encountering issues here.
I've just created the application.
Here is what I am presented with when I run 'bundle exec rspec spec/requests/static\_pages\_spec.rb'
```
Corey-M-Kimball:sample_app coreymkimball$ bundle exec rspec spec/requests/static_pages_spec.rb
/Users/... | 2013/08/30 | [
"https://Stackoverflow.com/questions/18528631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2698988/"
] | Rewrite your Gemfile. Change 'selenium-webdriver' to '~> 2.35.1', reinstall bundle and everything has to be OK! | I used the above answer (by user Arsenii Prohorchik) and it worked for me. I noticed that the result of following his suggestion to rewite the gemfile caused the following changes when running "bundle update"
Installing rubyzip (0.9.9)
Installing websocket (1.0.7)
Installing selenium-webdriver (2.35.1)
This fi... |
1,358,984 | I am drawing a `NSString` using `drawAtPoint` (`drawInRect`, that makes no big difference).
There is a parameter to set the line break mode, but has anyone an idea how to append "..." to strings if they are truncated?
One option is, to check whether the string is short enough. If that is not the case, iteratively remo... | 2009/08/31 | [
"https://Stackoverflow.com/questions/1358984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/164165/"
] | You'd better to use another `NSString` method:
```
- (CGSize)drawAtPoint:(CGPoint)point
forWidth:(CGFloat)width
withFont:(UIFont *)font
lineBreakMode:(UILineBreakMode)lineBreakMode
```
And specify `UILineBreakModeTailTruncation` as `lineBreakMode`. | You can use the `NSStringDrawingTruncatesLastVisibleLine` option with the `NSStringDrawingUsesLineFragmentOrigin` value.
```
[_text drawWithRect:_textRect options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil];
``` |
1,358,984 | I am drawing a `NSString` using `drawAtPoint` (`drawInRect`, that makes no big difference).
There is a parameter to set the line break mode, but has anyone an idea how to append "..." to strings if they are truncated?
One option is, to check whether the string is short enough. If that is not the case, iteratively remo... | 2009/08/31 | [
"https://Stackoverflow.com/questions/1358984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/164165/"
] | You'd better to use another `NSString` method:
```
- (CGSize)drawAtPoint:(CGPoint)point
forWidth:(CGFloat)width
withFont:(UIFont *)font
lineBreakMode:(UILineBreakMode)lineBreakMode
```
And specify `UILineBreakModeTailTruncation` as `lineBreakMode`. | Updating answer since `drawAtPoint:forWidth:withFont:lineBreakMode:` has been deprecated since iOS 7.0. Instead, you can now use `drawInRect:withAttributes:`
`NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail;
NSDictionary *textAttribute... |
1,358,984 | I am drawing a `NSString` using `drawAtPoint` (`drawInRect`, that makes no big difference).
There is a parameter to set the line break mode, but has anyone an idea how to append "..." to strings if they are truncated?
One option is, to check whether the string is short enough. If that is not the case, iteratively remo... | 2009/08/31 | [
"https://Stackoverflow.com/questions/1358984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/164165/"
] | Updating answer since `drawAtPoint:forWidth:withFont:lineBreakMode:` has been deprecated since iOS 7.0. Instead, you can now use `drawInRect:withAttributes:`
`NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail;
NSDictionary *textAttribute... | You can use the `NSStringDrawingTruncatesLastVisibleLine` option with the `NSStringDrawingUsesLineFragmentOrigin` value.
```
[_text drawWithRect:_textRect options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil];
``` |
83,279 | I had enabled a views accordion for a field in view. On displaying it in a page its not working and I got an error "$(...).accordion is not a function". Can any one help me in solving this? | 2013/08/22 | [
"https://drupal.stackexchange.com/questions/83279",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/20043/"
] | Install the [jQuery Update](https://www.drupal.org/project/jquery_update) module and set jQuery of your website to `1.7+`. | It seems like your jQuery libraries are creating conflict. Try to use 'jQuery' instead of '$'.
Else you can use a simple line of code to avoid jQuery library conflict.
<https://forum.jquery.com/topic/multiple-versions-of-jquery-on-the-same-page>.
This link would be helpful. |
83,279 | I had enabled a views accordion for a field in view. On displaying it in a page its not working and I got an error "$(...).accordion is not a function". Can any one help me in solving this? | 2013/08/22 | [
"https://drupal.stackexchange.com/questions/83279",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/20043/"
] | Install the [jQuery Update](https://www.drupal.org/project/jquery_update) module and set jQuery of your website to `1.7+`. | Exactly what Astha said, example:
```
<script type="text/javascript">
jQuery.noConflict();
jQuery(function(){
var H = jQuery(".owl-item").height();
jQuery(".plate").height(H);
});
</script>
```
Every `jQuery` used to be a `$`. |
102,676 | [BeEF](http://en.wikipedia.org/wiki/BeEF_%28Browser_Exploitation_Framework%29) - the browser exploitation framework. I think (thought) I had a basic working understanding of how it works. Recently, though, I was watching, [this DEFCON talk](https://www.youtube.com/watch?v=xDslqMCaLZM), where a hacker used a man-in-the-... | 2015/10/14 | [
"https://security.stackexchange.com/questions/102676",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/89177/"
] | BeEF is best run from the MITMf tool -- both are available in most versions (especially recent) of Kali Linux. MITMf has an extension to BeEF not found in other places called [BeEFAutorun](http://sign0f4.blogspot.com/2014/08/new-mitmf-plugin-beefautorun-and-misc.html). Both BeEFAutorun and [BeEF Autorun Rule Engine (AR... | I don't know if this is his method, but you can associate a window.open event to a click action and call window.focus which effectively gives you a pop-under window. That can be useful to keep your hook while they go about their business in a different window. Having a poisoned javascript file in the cache can allow yo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.