qid int64 1 74.6M | question stringlengths 45 24.2k | date stringlengths 10 10 | metadata stringlengths 101 178 | response_j stringlengths 32 23.2k | response_k stringlengths 21 13.2k |
|---|---|---|---|---|---|
53,473,475 | What does `_` mean in this example code:
```
if (_(abc.content).has("abc")){
console.log("abc found");
}
```
Many people say "\_" means a private member, but if `abc` or `content` is a private member, shouldn't we use `_abc.content` or `abc._content`?
Thank you | 2018/11/26 | ['https://Stackoverflow.com/questions/53473475', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7025179/'] | For that to be valid, `_` must refer to a *function*. Perhaps the script is using [`underscore`](https://underscorejs.org/#has), in which case `_(abc.content).has("abc")` returns a Boolean - `true` if the `abc.content` object has a *key* of `abc`, and `false` otherwise:
```js
const abc = { content: { key1: 'foo', abc:... | \_ is a valid variable name in JavaScript and can be used in any way you want just like i, a, x, length, time, date or any other variable name you can come up with.
Personally I usually use underscore as a variable in a function parameter list when I wont be using that variable in the function body.
```
const func = ... |
53,473,475 | What does `_` mean in this example code:
```
if (_(abc.content).has("abc")){
console.log("abc found");
}
```
Many people say "\_" means a private member, but if `abc` or `content` is a private member, shouldn't we use `_abc.content` or `abc._content`?
Thank you | 2018/11/26 | ['https://Stackoverflow.com/questions/53473475', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7025179/'] | That's just a variable name. You are right, conventions suggest that underscore refer to private members in an object such as:
```
const num = 2;
function Multiply(num) {
this._multiplier = 2;
this._input = num;
this.start = function(){
return this._multiplier * this._input;
}
}
const produc... | \_ is a valid variable name in JavaScript and can be used in any way you want just like i, a, x, length, time, date or any other variable name you can come up with.
Personally I usually use underscore as a variable in a function parameter list when I wont be using that variable in the function body.
```
const func = ... |
36,599,890 | The below code is written in swift class
```
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
dim(.In, alpha: dimLevel, speed: dimSpeed)
}
@IBAction func unwindFromEditAboutUs(segue: UIStoryboardSegue)
{
dim(.Out, speed:dimSpeed)
}
```
I want to call this class functions from... | 2016/04/13 | ['https://Stackoverflow.com/questions/36599890', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5680983/'] | Simply import swift class in objective C Project
```
#import"ProjectName-Swift.h"
``` | You should make bridge to do this kind of stuff. [Refer this link](https://stackoverflow.com/questions/24078043/call-swift-function-from-objective-c-class) or [this link](http://ericasadun.com/2014/08/21/swift-calling-swift-functions-from-objective-c/) and this [apple documentation](https://developer.apple.com/library/... |
17,375,379 | I trying to build an app with 4 tabs. Every tab has a different fragment linked to it. The issue is that I want to make a custom listView for each fragment, but it ends with some unsolvable error... I have talked to other developers, but I still can't make one that works! It's really frustrating!
**I have:**
* A Main... | 2013/06/29 | ['https://Stackoverflow.com/questions/17375379', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2533633/'] | ```
public class Fragment1test extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
//This layout contains your list view
View view = inflater.inflate(R.layou... | Fragments don't use `setContentView(int)`, so you can't use that, use the `inflater` in `public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)` and return the view inflated. As for `findViewById(int)` do it like this `getActivity().findViewById(int)`. |
17,375,379 | I trying to build an app with 4 tabs. Every tab has a different fragment linked to it. The issue is that I want to make a custom listView for each fragment, but it ends with some unsolvable error... I have talked to other developers, but I still can't make one that works! It's really frustrating!
**I have:**
* A Main... | 2013/06/29 | ['https://Stackoverflow.com/questions/17375379', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2533633/'] | ```
public class fragmentpassword extends Fragment {
String[] name={"A","B","C","D"};
int [] image={R.drawable.ic_drawer,R.drawable.ic_drawer,R.drawable.ic_drawer,R.drawable.ic_drawer};
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInsta... | Fragments don't use `setContentView(int)`, so you can't use that, use the `inflater` in `public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)` and return the view inflated. As for `findViewById(int)` do it like this `getActivity().findViewById(int)`. |
17,375,379 | I trying to build an app with 4 tabs. Every tab has a different fragment linked to it. The issue is that I want to make a custom listView for each fragment, but it ends with some unsolvable error... I have talked to other developers, but I still can't make one that works! It's really frustrating!
**I have:**
* A Main... | 2013/06/29 | ['https://Stackoverflow.com/questions/17375379', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2533633/'] | ```
public class Fragment1test extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
//This layout contains your list view
View view = inflater.inflate(R.layou... | ```
public class fragmentpassword extends Fragment {
String[] name={"A","B","C","D"};
int [] image={R.drawable.ic_drawer,R.drawable.ic_drawer,R.drawable.ic_drawer,R.drawable.ic_drawer};
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInsta... |
80,120 | Can we use multi element wing for slow flight planes, like F1 multi element rear wing?
**If we know that pressure act prependicular to the surface why this two upper elements are "almost" vertical?**
**It seems to me that they produce "tons" of drag instead lift.Resultant force point to far back,instead down!**
[![e... | 2020/08/06 | ['https://aviation.stackexchange.com/questions/80120', 'https://aviation.stackexchange.com', 'https://aviation.stackexchange.com/users/-1/'] | Excellent application inverted on the drag racer, which brings home the point perfectly. If you have enough excess thrust, devices like these can dramaticly increase Coefficient of Lift, but at the cost if loss of lift efficiency, or lower lift to drag ratio.
In the case of the dragster, more propulsion efficiency is ... | This looks very much like a Formula Student/Formula SAE wing!
The idea of the multi-element wing is for all three elements to act together, rather than as seperate sections. If you look at all of the elements joined together (imagine there are no slot gaps), the suction surface should form a constant curve\* which is ... |
80,120 | Can we use multi element wing for slow flight planes, like F1 multi element rear wing?
**If we know that pressure act prependicular to the surface why this two upper elements are "almost" vertical?**
**It seems to me that they produce "tons" of drag instead lift.Resultant force point to far back,instead down!**
[![e... | 2020/08/06 | ['https://aviation.stackexchange.com/questions/80120', 'https://aviation.stackexchange.com', 'https://aviation.stackexchange.com/users/-1/'] | Excellent application inverted on the drag racer, which brings home the point perfectly. If you have enough excess thrust, devices like these can dramaticly increase Coefficient of Lift, but at the cost if loss of lift efficiency, or lower lift to drag ratio.
In the case of the dragster, more propulsion efficiency is ... | No, it is not if you are not limited in wing area and / or wingspan.
The other answers already do a splendid job explaining how this multi-element airfoil works and that it creates a lot of drag.
Now look at [slow flight airplanes](https://aviation.stackexchange.com/questions/23929/why-would-maximum-fly-time-enduranc... |
43,757,177 | I am experiencing some performance related issues (works ok most of the time, and from time to time there's a spike in the response time from 100ms to 4/5s with no apparent reason) in services implemented in OSB. One of the hypothesis to explain this situation is the fact that the JVM could be performing a Full GC duri... | 2017/05/03 | ['https://Stackoverflow.com/questions/43757177', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/944245/'] | The documentation [says as much](https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr005.html#BABHFCDD):
>
> The flight recording generated with Heap Statistics enabled will start and end with an old GC. Select that old GC in the list of GCs, and then choose the General tab to see the GC Reas... | If you enable Heap Statistics in the recording wizard, the JVM will stop the application and sweep the heap to collect information about it. If you want to be sure of low overhead (1%), use the default recording template (without modifications). |
43,757,177 | I am experiencing some performance related issues (works ok most of the time, and from time to time there's a spike in the response time from 100ms to 4/5s with no apparent reason) in services implemented in OSB. One of the hypothesis to explain this situation is the fact that the JVM could be performing a Full GC duri... | 2017/05/03 | ['https://Stackoverflow.com/questions/43757177', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/944245/'] | The documentation [says as much](https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr005.html#BABHFCDD):
>
> The flight recording generated with Heap Statistics enabled will start and end with an old GC. Select that old GC in the list of GCs, and then choose the General tab to see the GC Reas... | Yes, JFR recording does run Full GC at regular interval. INitially we also wondered about the same but below documentation gives proper details.
<https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr005.html>
```
The flight recording generated with Heap Statistics enabled will start and end wi... |
43,757,177 | I am experiencing some performance related issues (works ok most of the time, and from time to time there's a spike in the response time from 100ms to 4/5s with no apparent reason) in services implemented in OSB. One of the hypothesis to explain this situation is the fact that the JVM could be performing a Full GC duri... | 2017/05/03 | ['https://Stackoverflow.com/questions/43757177', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/944245/'] | If you enable Heap Statistics in the recording wizard, the JVM will stop the application and sweep the heap to collect information about it. If you want to be sure of low overhead (1%), use the default recording template (without modifications). | Yes, JFR recording does run Full GC at regular interval. INitially we also wondered about the same but below documentation gives proper details.
<https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr005.html>
```
The flight recording generated with Heap Statistics enabled will start and end wi... |
34,492,643 | I'm running a wildfly 10 app on RedHat Openshift.
It is running a very small web service with no database or anything special, and it works OK.
After a bit (an hour, 2 maybe) the app stops responding to 'rhc ssh appname' with the error:
>
> /Library/Ruby/Gems/2.0.0/gems/net-ssh-2.9.2/lib/net/ssh/transport/packet\_s... | 2015/12/28 | ['https://Stackoverflow.com/questions/34492643', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1022260/'] | SFTP into your app and look at the log files. I use WinSCP on windows. | As suggested above, this is most likely your gear running out of memory. I would suggest that you stop/start your gear, and then check for memory limit violations (<https://developers.openshift.com/en/troubleshooting-faq.html#_why_is_my_application_restarting_automatically_or_having_memory_issues>), you can also change... |
5,927,010 | I am trying to write a script that goes through an entire folder of text files, matching a string pattern. What I want is the count of patterns matched in each file. In unix it could be done by `grep -c <pattern> *`. where the `-c` option returns you the count. Is there any way to get that count using perl regex?
Ple... | 2011/05/08 | ['https://Stackoverflow.com/questions/5927010', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/743810/'] | ```
my $grep_count = grep (/PATTERN/, @array);
```
Or for a file:
```
perl -we "print scalar grep /PATTERN/, <>;" file.txt
```
<http://perldoc.perl.org/functions/grep.html> | Not that I know of, but just write it, when you open each file, use `while` to go through each of its lines, and use =~ against each line (with your pattern), if matched, then add 1 to your counter. |
13,046,319 | I wrote a basic hello world program in haskel and tried to compile it with:
ghc filename.hs. It produces .hi and .o files but no executable and displays
this error in the linker:
>
> marox@IT-marox:~/Marox$ ghc tupel.hs
>
> Linking tupel ...
>
> /usr/bin/ld: --hash-size=31: unknown option
>
> /usr/bin/ld:... | 2012/10/24 | ['https://Stackoverflow.com/questions/13046319', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1770728/'] | Have you `binutils-gold` installed? If yes, this is the problem (since the [gold linker](http://en.wikipedia.org/wiki/Gold_%28linker%29) does not support `--hash-size` AFAIK).
Possible solutions:
1. remove gold
2. your `ld` probably links to `ld.gold`, so change the symlink to `ld.ld`
3. tell the haskell compiler exp... | Update - gold on Ubuntu 12.10 appears to move GNU ld to ld.bfd. To fix this problem I deleted the ld link as recommended and remade the link with
```
ln -s ld.bfd ld
```
ghc compilations are now going through.
(Couldn't see how to subvert the settings file in usr/lib/ghc, as the entry is for gcc which passes thro... |
27,757,203 | I am trying to insert a DATE value into my table however I get the following error:
```
SQL Error: ORA-00984: column not allowed here
00984. 00000 - "column not allowed here"
```
this is my statement:
```
INSERT INTO TstResults (tstcode, EmpID, fname, sname, tstDate, tstRslt)
VALUES ((Select tstcode from Tests whe... | 2015/01/03 | ['https://Stackoverflow.com/questions/27757203', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4413868/'] | Use single inverted commas around the date.
```
INSERT INTO TstResults (tstcode, EmpID, fname, sname, tstDate, tstRslt)
VALUES
( (Select tstcode from Tests where Freq ='6mnths'), (Select EmpID from Employees where fname = 'Sam'), 'Sam', 'Fisher', '01-JUN-15', 'A');
``` | You are missing quotes around the date:
```
INSERT INTO TstResults (tstcode, EmpID, fname, sname, tstDate, tstRslt)
VALUES ((Select tstcode from Tests where Freq ='6mnths')
,(Select EmpID from Employees where fname = 'Sam')
,'Sam'
,'Fisher'
,'01-JUN-15'
,'A');
``` |
27,757,203 | I am trying to insert a DATE value into my table however I get the following error:
```
SQL Error: ORA-00984: column not allowed here
00984. 00000 - "column not allowed here"
```
this is my statement:
```
INSERT INTO TstResults (tstcode, EmpID, fname, sname, tstDate, tstRslt)
VALUES ((Select tstcode from Tests whe... | 2015/01/03 | ['https://Stackoverflow.com/questions/27757203', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4413868/'] | As explained by *a\_horse\_with\_no\_name* in a comment above, for hard-coded date, you might want to use a [*date literal*](https://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements003.htm#SQLRF51062) : `DATE '2015-06-15'`
On the other hand, Oracle can convert from *strings* to date too. Either *implicitly*... | You are missing quotes around the date:
```
INSERT INTO TstResults (tstcode, EmpID, fname, sname, tstDate, tstRslt)
VALUES ((Select tstcode from Tests where Freq ='6mnths')
,(Select EmpID from Employees where fname = 'Sam')
,'Sam'
,'Fisher'
,'01-JUN-15'
,'A');
``` |
44,313,448 | I know how to decode a JSON string and get the data from one dimensional array but how to get the data from the nested array?
Below is my code:
```
$data = json_decode($json);
```
and below is the JSON return value:
```
{
"area_metadata": [
{
"name": "A",
"label_location": {
... | 2017/06/01 | ['https://Stackoverflow.com/questions/44313448', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5483868/'] | *The JSON you provided (in your question) is malformed and using `json_decode()` on it will result in `NULL`. Thus nothing will happen when you try to access the decoded object because it doesn't exist.*
The full JSON you provided is valid and the reason why your code didn't yield any results is because in `items` the... | It would be easier to help if you post all the JSON data or link to a screenshot of it. Try:
```
$items[0]['locations'][0]['area'];
```
Single quotes on strings, no quotes on numbers. |
2,944,175 | Let $A$ be a (maybe unbounded) linear operator on a Hilbert space $\mathcal{H}$. If $A-\lambda$ is not injective, $\lambda$ is an eigenvalue. It simply means that $A$ does not change the "direction" of some vectors and so the vectors form an invariant subspace. The rest of the spectrum of $A$ consists of $\lambda$ such... | 2018/10/06 | ['https://math.stackexchange.com/questions/2944175', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/601011/'] | Fredholm was the first to define a general linear operator in the latter part of the 19th century. He converted partial differential equations to integral equations, and he studied these operators through what is now known as a resolvent equation. Fredholm connected the singularities of the resolvent $(L-\lambda I)^{-1... | You can think of them in many ways. One way is to view your operator $A$ as a pointwise limit of operators $A\_n$ with discrete spectrum. As $n$ gets larger the eigenvalues get denser in the parts of continuous spectrum and the associated eigenspaces split up and spread themselves out over this part.
A good example o... |
22,895,562 | I have an assignment for college,
anyway i need to make this pattern
OutPut:
```
*
**
***
****
*****
******
*******
********
*********
**********
```
Here's my code:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Problem_11
{
c... | 2014/04/06 | ['https://Stackoverflow.com/questions/22895562', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3415389/'] | You don't need an inner loop, use the [string](http://msdn.microsoft.com/en-us/library/xsa4321w%28v=vs.110%29.aspx) overload that let's you repeat a char
```
for (int i = 1; i <= 10; i++)
{
Console.WriteLine(String.Format("{0}\n", new String('*', i));
}
``` | Your loop will never end once it's compiled as there's no condition, but that's another issue. One problem is the semi-colon was outside the parenthesis in the nested for loop.
```
for (string o = "*";;)
``` |
22,895,562 | I have an assignment for college,
anyway i need to make this pattern
OutPut:
```
*
**
***
****
*****
******
*******
********
*********
**********
```
Here's my code:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Problem_11
{
c... | 2014/04/06 | ['https://Stackoverflow.com/questions/22895562', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3415389/'] | You can *simplify* your solution:
```
...
static void Main(string[] args) {
// More natural to declare loop variable (int i) in the loop
for (int i = 1; i <= 10; ++i)
Console.WriteLine(new String('*', i)); // <- No inner loop required
Console.ReadLine();
}
...
``` | Your loop will never end once it's compiled as there's no condition, but that's another issue. One problem is the semi-colon was outside the parenthesis in the nested for loop.
```
for (string o = "*";;)
``` |
22,895,562 | I have an assignment for college,
anyway i need to make this pattern
OutPut:
```
*
**
***
****
*****
******
*******
********
*********
**********
```
Here's my code:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Problem_11
{
c... | 2014/04/06 | ['https://Stackoverflow.com/questions/22895562', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3415389/'] | try this code
```
for (int i = 0; i < 10; i++)
{
for (int j = 0; j <=i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
``` | Your loop will never end once it's compiled as there's no condition, but that's another issue. One problem is the semi-colon was outside the parenthesis in the nested for loop.
```
for (string o = "*";;)
``` |
22,895,562 | I have an assignment for college,
anyway i need to make this pattern
OutPut:
```
*
**
***
****
*****
******
*******
********
*********
**********
```
Here's my code:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Problem_11
{
c... | 2014/04/06 | ['https://Stackoverflow.com/questions/22895562', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3415389/'] | You don't need an inner loop, use the [string](http://msdn.microsoft.com/en-us/library/xsa4321w%28v=vs.110%29.aspx) overload that let's you repeat a char
```
for (int i = 1; i <= 10; i++)
{
Console.WriteLine(String.Format("{0}\n", new String('*', i));
}
``` | You can *simplify* your solution:
```
...
static void Main(string[] args) {
// More natural to declare loop variable (int i) in the loop
for (int i = 1; i <= 10; ++i)
Console.WriteLine(new String('*', i)); // <- No inner loop required
Console.ReadLine();
}
...
``` |
22,895,562 | I have an assignment for college,
anyway i need to make this pattern
OutPut:
```
*
**
***
****
*****
******
*******
********
*********
**********
```
Here's my code:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Problem_11
{
c... | 2014/04/06 | ['https://Stackoverflow.com/questions/22895562', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3415389/'] | You don't need an inner loop, use the [string](http://msdn.microsoft.com/en-us/library/xsa4321w%28v=vs.110%29.aspx) overload that let's you repeat a char
```
for (int i = 1; i <= 10; i++)
{
Console.WriteLine(String.Format("{0}\n", new String('*', i));
}
``` | Just change the inner for loop:
```
for (int j = 0; j < i; j++)
{
Console.Write("*");
}
``` |
22,895,562 | I have an assignment for college,
anyway i need to make this pattern
OutPut:
```
*
**
***
****
*****
******
*******
********
*********
**********
```
Here's my code:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Problem_11
{
c... | 2014/04/06 | ['https://Stackoverflow.com/questions/22895562', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3415389/'] | try this code
```
for (int i = 0; i < 10; i++)
{
for (int j = 0; j <=i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
``` | You can *simplify* your solution:
```
...
static void Main(string[] args) {
// More natural to declare loop variable (int i) in the loop
for (int i = 1; i <= 10; ++i)
Console.WriteLine(new String('*', i)); // <- No inner loop required
Console.ReadLine();
}
...
``` |
22,895,562 | I have an assignment for college,
anyway i need to make this pattern
OutPut:
```
*
**
***
****
*****
******
*******
********
*********
**********
```
Here's my code:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Problem_11
{
c... | 2014/04/06 | ['https://Stackoverflow.com/questions/22895562', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3415389/'] | You can *simplify* your solution:
```
...
static void Main(string[] args) {
// More natural to declare loop variable (int i) in the loop
for (int i = 1; i <= 10; ++i)
Console.WriteLine(new String('*', i)); // <- No inner loop required
Console.ReadLine();
}
...
``` | Just change the inner for loop:
```
for (int j = 0; j < i; j++)
{
Console.Write("*");
}
``` |
22,895,562 | I have an assignment for college,
anyway i need to make this pattern
OutPut:
```
*
**
***
****
*****
******
*******
********
*********
**********
```
Here's my code:
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Problem_11
{
c... | 2014/04/06 | ['https://Stackoverflow.com/questions/22895562', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3415389/'] | try this code
```
for (int i = 0; i < 10; i++)
{
for (int j = 0; j <=i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
``` | Just change the inner for loop:
```
for (int j = 0; j < i; j++)
{
Console.Write("*");
}
``` |
60,497,943 | I have a table as follows:
```
ID | col1 | Date Time
1 | WA | 2/11/20
1 | CI | 1/11/20
2 | CI | 2/11/20
2 | WA | 3/11/20
3 | WA | 2/10/20
3 | WA | 1/11/20
3 | WA | 2/11/20
4 | WA | 1/10/20
4 | CI | 2/10/20
4 | SA | 3/10/20
```
I want to find all ID values for which... | 2020/03/02 | ['https://Stackoverflow.com/questions/60497943', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10096621/'] | There are several problems here.
1. **You `delete[]` instead of `free`.**
`strdup` comes from the C library. [The documentation](https://en.cppreference.com/w/c/experimental/dynamic/strdup) tells us how to clean it up.
Microsoft's similar `_strdup` [works the same way](https://learn.microsoft.com/en-us/cpp/c-runtime... | There are many different allocation schemes out there. Too many to just guess or assume how to free things. So you first look up the documentation on the function. Even just googling something like "msdn \_strdup" often gets there or close (for stuff that comes with Windows / Visual Studio / Microsoft).
<https://learn... |
3,870,947 | I am new to analysis and following is the question:
Show that the sequence $\frac{n+1}{n}$ is monotone, bounded and find its limit.
The way I approached it is the following:
**To show that it is monotone,**
We can write the sequence as $a\_n = 1 + \frac{1}{n}$. Since $n\_{2} > n\_{1}$, we have that $\frac{1}{n\_2}<... | 2020/10/18 | ['https://math.stackexchange.com/questions/3870947', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/'] | What you did is just fine. Of course, we are not aware of which theorems you can use. Yes, there is a theorem that says that a bounded and decreasing sequence always converges and that its limit is then the infimum of the set of its terms. And, yes, in order to use it, you will have to prove that$$\inf\left\{\frac{n+1}... | Your monotonicity and boundedness proofs are very fine.
For the limit existence you can use the theorem "an increasing (resp. decreasing) sequence upper (resp. lower) bounded is convergent".
But in this case $|x\_n-1|=\frac 1n\to 0$ is quite obvious and you do not need much more. |
3,870,947 | I am new to analysis and following is the question:
Show that the sequence $\frac{n+1}{n}$ is monotone, bounded and find its limit.
The way I approached it is the following:
**To show that it is monotone,**
We can write the sequence as $a\_n = 1 + \frac{1}{n}$. Since $n\_{2} > n\_{1}$, we have that $\frac{1}{n\_2}<... | 2020/10/18 | ['https://math.stackexchange.com/questions/3870947', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/'] | Answers to 1 and 2 are fine.
But you ask a *really* good question about how do you know what you can accept as obvious or not.
You should have early one spent half a lesson (or told to read) axioms and definitions of the rational/real field.
You therefore have Axiom: if $a < b$ the $a+m < b+m$ for all $m$, and if $c... | Your monotonicity and boundedness proofs are very fine.
For the limit existence you can use the theorem "an increasing (resp. decreasing) sequence upper (resp. lower) bounded is convergent".
But in this case $|x\_n-1|=\frac 1n\to 0$ is quite obvious and you do not need much more. |
3,870,947 | I am new to analysis and following is the question:
Show that the sequence $\frac{n+1}{n}$ is monotone, bounded and find its limit.
The way I approached it is the following:
**To show that it is monotone,**
We can write the sequence as $a\_n = 1 + \frac{1}{n}$. Since $n\_{2} > n\_{1}$, we have that $\frac{1}{n\_2}<... | 2020/10/18 | ['https://math.stackexchange.com/questions/3870947', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/'] | Answers to 1 and 2 are fine.
But you ask a *really* good question about how do you know what you can accept as obvious or not.
You should have early one spent half a lesson (or told to read) axioms and definitions of the rational/real field.
You therefore have Axiom: if $a < b$ the $a+m < b+m$ for all $m$, and if $c... | What you did is just fine. Of course, we are not aware of which theorems you can use. Yes, there is a theorem that says that a bounded and decreasing sequence always converges and that its limit is then the infimum of the set of its terms. And, yes, in order to use it, you will have to prove that$$\inf\left\{\frac{n+1}... |
3,870,947 | I am new to analysis and following is the question:
Show that the sequence $\frac{n+1}{n}$ is monotone, bounded and find its limit.
The way I approached it is the following:
**To show that it is monotone,**
We can write the sequence as $a\_n = 1 + \frac{1}{n}$. Since $n\_{2} > n\_{1}$, we have that $\frac{1}{n\_2}<... | 2020/10/18 | ['https://math.stackexchange.com/questions/3870947', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/'] | What you did is just fine. Of course, we are not aware of which theorems you can use. Yes, there is a theorem that says that a bounded and decreasing sequence always converges and that its limit is then the infimum of the set of its terms. And, yes, in order to use it, you will have to prove that$$\inf\left\{\frac{n+1}... | You did the proofs for monotonicity and boundedness totally fine.
For the third proof, you can use the **Monotone Convergence Theorem** which states that **if a sequence is a bounded, decreasing sequence, then the limit of the sequence exists at the greatest lower bound (or infimum) of the sequence.**
In other words,... |
3,870,947 | I am new to analysis and following is the question:
Show that the sequence $\frac{n+1}{n}$ is monotone, bounded and find its limit.
The way I approached it is the following:
**To show that it is monotone,**
We can write the sequence as $a\_n = 1 + \frac{1}{n}$. Since $n\_{2} > n\_{1}$, we have that $\frac{1}{n\_2}<... | 2020/10/18 | ['https://math.stackexchange.com/questions/3870947', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/'] | What you did is just fine. Of course, we are not aware of which theorems you can use. Yes, there is a theorem that says that a bounded and decreasing sequence always converges and that its limit is then the infimum of the set of its terms. And, yes, in order to use it, you will have to prove that$$\inf\left\{\frac{n+1}... | **Monotone:**
$$n<m\implies \frac1n>\frac1m\implies\frac1n+1>\frac1m+1$$
is sufficiently formal.
**Bounded:**
$$n> 0\implies \frac1n>0\implies \frac1n+1>1$$
is sufficiently formal.
**Limit:**
It is pretty obvious that $\dfrac1n+1$ can be made as close as you want to $1$. This intuition can be validated formally ... |
3,870,947 | I am new to analysis and following is the question:
Show that the sequence $\frac{n+1}{n}$ is monotone, bounded and find its limit.
The way I approached it is the following:
**To show that it is monotone,**
We can write the sequence as $a\_n = 1 + \frac{1}{n}$. Since $n\_{2} > n\_{1}$, we have that $\frac{1}{n\_2}<... | 2020/10/18 | ['https://math.stackexchange.com/questions/3870947', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/'] | Answers to 1 and 2 are fine.
But you ask a *really* good question about how do you know what you can accept as obvious or not.
You should have early one spent half a lesson (or told to read) axioms and definitions of the rational/real field.
You therefore have Axiom: if $a < b$ the $a+m < b+m$ for all $m$, and if $c... | You did the proofs for monotonicity and boundedness totally fine.
For the third proof, you can use the **Monotone Convergence Theorem** which states that **if a sequence is a bounded, decreasing sequence, then the limit of the sequence exists at the greatest lower bound (or infimum) of the sequence.**
In other words,... |
3,870,947 | I am new to analysis and following is the question:
Show that the sequence $\frac{n+1}{n}$ is monotone, bounded and find its limit.
The way I approached it is the following:
**To show that it is monotone,**
We can write the sequence as $a\_n = 1 + \frac{1}{n}$. Since $n\_{2} > n\_{1}$, we have that $\frac{1}{n\_2}<... | 2020/10/18 | ['https://math.stackexchange.com/questions/3870947', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/'] | Answers to 1 and 2 are fine.
But you ask a *really* good question about how do you know what you can accept as obvious or not.
You should have early one spent half a lesson (or told to read) axioms and definitions of the rational/real field.
You therefore have Axiom: if $a < b$ the $a+m < b+m$ for all $m$, and if $c... | **Monotone:**
$$n<m\implies \frac1n>\frac1m\implies\frac1n+1>\frac1m+1$$
is sufficiently formal.
**Bounded:**
$$n> 0\implies \frac1n>0\implies \frac1n+1>1$$
is sufficiently formal.
**Limit:**
It is pretty obvious that $\dfrac1n+1$ can be made as close as you want to $1$. This intuition can be validated formally ... |
8,191 | The perennial concern about low quality questions and low quality answers is resurfacing again. It is my impression (not backed by data) that many VLQ answers are posted by rep 1 unregistered people. This seems to be true also of some low quality questions.
Is there data or could data be obtained to back up or refute ... | 2016/07/22 | ['https://english.meta.stackexchange.com/questions/8191', 'https://english.meta.stackexchange.com', 'https://english.meta.stackexchange.com/users/121061/'] | A strain on the community? How hard is a downvote on a poorly written question? | I can understand why you've proposed "taking mandatory English quiz". Yes, it is frustrating to see all those low-quality posts and find that we are not doing enough to prevent or slow down the influx of low-quality posts. My question is "Is there anything we can do?"
One user once proposed all questions be *put on h... |
8,191 | The perennial concern about low quality questions and low quality answers is resurfacing again. It is my impression (not backed by data) that many VLQ answers are posted by rep 1 unregistered people. This seems to be true also of some low quality questions.
Is there data or could data be obtained to back up or refute ... | 2016/07/22 | ['https://english.meta.stackexchange.com/questions/8191', 'https://english.meta.stackexchange.com', 'https://english.meta.stackexchange.com/users/121061/'] | A strain on the community? How hard is a downvote on a poorly written question? | My account is two years old, but I started off few months ago.
I'm not a native English speaker, and I have made mistakes a lot.
If such a quiz was mandatory, I wouldn't even have joined at all. |
8,191 | The perennial concern about low quality questions and low quality answers is resurfacing again. It is my impression (not backed by data) that many VLQ answers are posted by rep 1 unregistered people. This seems to be true also of some low quality questions.
Is there data or could data be obtained to back up or refute ... | 2016/07/22 | ['https://english.meta.stackexchange.com/questions/8191', 'https://english.meta.stackexchange.com', 'https://english.meta.stackexchange.com/users/121061/'] | A strain on the community? How hard is a downvote on a poorly written question? | To answer your question of why it hasn't been done yet: It had not been requested before.
The number of downvotes here indicates that the community does not support this plan. Therefore, it is safe to conclude that it won't be implemented. |
8,191 | The perennial concern about low quality questions and low quality answers is resurfacing again. It is my impression (not backed by data) that many VLQ answers are posted by rep 1 unregistered people. This seems to be true also of some low quality questions.
Is there data or could data be obtained to back up or refute ... | 2016/07/22 | ['https://english.meta.stackexchange.com/questions/8191', 'https://english.meta.stackexchange.com', 'https://english.meta.stackexchange.com/users/121061/'] | My account is two years old, but I started off few months ago.
I'm not a native English speaker, and I have made mistakes a lot.
If such a quiz was mandatory, I wouldn't even have joined at all. | I can understand why you've proposed "taking mandatory English quiz". Yes, it is frustrating to see all those low-quality posts and find that we are not doing enough to prevent or slow down the influx of low-quality posts. My question is "Is there anything we can do?"
One user once proposed all questions be *put on h... |
8,191 | The perennial concern about low quality questions and low quality answers is resurfacing again. It is my impression (not backed by data) that many VLQ answers are posted by rep 1 unregistered people. This seems to be true also of some low quality questions.
Is there data or could data be obtained to back up or refute ... | 2016/07/22 | ['https://english.meta.stackexchange.com/questions/8191', 'https://english.meta.stackexchange.com', 'https://english.meta.stackexchange.com/users/121061/'] | To answer your question of why it hasn't been done yet: It had not been requested before.
The number of downvotes here indicates that the community does not support this plan. Therefore, it is safe to conclude that it won't be implemented. | I can understand why you've proposed "taking mandatory English quiz". Yes, it is frustrating to see all those low-quality posts and find that we are not doing enough to prevent or slow down the influx of low-quality posts. My question is "Is there anything we can do?"
One user once proposed all questions be *put on h... |
21,090,499 | I am new to PHP. I have a problem. I have a simple HTML form where when I select the country from select / option list provided, i want PHP to echo message on country I selected. Also I want PHP include function to list the form specific to that country name (by concatanating). Can someone please help me by pointing wh... | 2014/01/13 | ['https://Stackoverflow.com/questions/21090499', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3189978/'] | First check that a value has been given to `$_POST['country_chosen']` with `isset()`. Then remove that extra semi-colon that is causing a syntax error (in your `include()`) statement:
```
if(isset($_POST['country_chosen'])){
$country_selected = $_POST['country_chosen'];
echo "You have chosen to view outlets in... | ```
if(!empty($_POST['country_chosen'])){
$country_selected = $_POST['country_chosen'];
echo "You have chosen to view outlets in " . $country_selected;
require "inc/OutletsIn".$country_selected.".php";
//no brackets required
} else { /* throw error */ }
``` |
21,090,499 | I am new to PHP. I have a problem. I have a simple HTML form where when I select the country from select / option list provided, i want PHP to echo message on country I selected. Also I want PHP include function to list the form specific to that country name (by concatanating). Can someone please help me by pointing wh... | 2014/01/13 | ['https://Stackoverflow.com/questions/21090499', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3189978/'] | First check that a value has been given to `$_POST['country_chosen']` with `isset()`. Then remove that extra semi-colon that is causing a syntax error (in your `include()`) statement:
```
if(isset($_POST['country_chosen'])){
$country_selected = $_POST['country_chosen'];
echo "You have chosen to view outlets in... | Here is your updated code, just copy & replace :
**component\_project\_in\_countries.php**
```
<pre>
<form name="form1" method="post" action="component_project_in_countries.php">
<label for="country">View outlets in which country? </label>
<select name="country_chosen" onchange="docume... |
23,683,604 | I made a script in order to create this "slideshow": <http://jsfiddle.net/LWBJG/2/>
yet I can not go back to the last slide if I hit "previous" when it is on the first slide
I tried using the last-child selector but had no success
I also tried resetting the count directly like so:
```
if(count==1){
count=2... | 2014/05/15 | ['https://Stackoverflow.com/questions/23683604', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1114993/'] | First you need to hide all the other `.slideshow img` elements not being shown when your page first loads. You can do that multiple ways, but here's an example:
```
$(".slideshow img:not(:nth-child(" + count + "))").hide();
```
Next, you need to hide the current showing slide when going to the previous one:
```
$("... | You simply were not fading out in the prev loop like you were in the next button loop.
```
$(".slideshow :nth-child("+count+")").fadeOut()
```
Also, in the css, i put the following code:
```
.slideshow > img:not(:first-child) { display:none;}
```
This makes only the first img appear as default, and then the othe... |
23,683,604 | I made a script in order to create this "slideshow": <http://jsfiddle.net/LWBJG/2/>
yet I can not go back to the last slide if I hit "previous" when it is on the first slide
I tried using the last-child selector but had no success
I also tried resetting the count directly like so:
```
if(count==1){
count=2... | 2014/05/15 | ['https://Stackoverflow.com/questions/23683604', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1114993/'] | First you need to hide all the other `.slideshow img` elements not being shown when your page first loads. You can do that multiple ways, but here's an example:
```
$(".slideshow img:not(:nth-child(" + count + "))").hide();
```
Next, you need to hide the current showing slide when going to the previous one:
```
$("... | Using multiple `fadeIn()`s might lead to a mess. In your case, if you really want to do so, you can first `fadeOut()` all images before `fadeIn()` the desired one. This solves the problem.
```
$(".slideshow img").fadeOut();
$(".slideshow :nth-child("+count+")").fadeIn();
```
`hide()` should also work. |
23,683,604 | I made a script in order to create this "slideshow": <http://jsfiddle.net/LWBJG/2/>
yet I can not go back to the last slide if I hit "previous" when it is on the first slide
I tried using the last-child selector but had no success
I also tried resetting the count directly like so:
```
if(count==1){
count=2... | 2014/05/15 | ['https://Stackoverflow.com/questions/23683604', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1114993/'] | First you need to hide all the other `.slideshow img` elements not being shown when your page first loads. You can do that multiple ways, but here's an example:
```
$(".slideshow img:not(:nth-child(" + count + "))").hide();
```
Next, you need to hide the current showing slide when going to the previous one:
```
$("... | Yes i know, i'am late to the party, but I played around a bit. Maybe someone will find the solution useful later on.
Here is a demo: <http://jsfiddle.net/NicoO/LWBJG/25/>
```
var $slideContainer = $(".slideshow")
var totalSlides = getAllSlides().length;
var slideIndex = 0;
function getAllSlides(){
return $slideC... |
14,469,396 | I'm trying to get download manager request working and I'm getting a strange error. Here's the code:
```
package com.vsnetworks.vswebkads;
import java.io.File;
import android.net.Uri;
import android.os.Bundle;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.DownloadManager;
import... | 2013/01/22 | ['https://Stackoverflow.com/questions/14469396', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1756493/'] | In this case, the error appears to be device related. When we switched testing to a nexus 10, the code worked and this error did not appear. | Check your server logs, sometimes the DownloadManager initiates a partial download request (which cause the misleading double log output "Initiating request for download". Your server has to handle this request properly, otherwise you get this error. See my answer for this question:
[Can't resume download](https://stac... |
28,654,728 | First of all, I'm not a Java programmer and I'm just modifying existing code to suit my needs so please bear with me because of my very limited knowledge in Java.
This is a part of my code:
```
public String getIp() throws Exception {
URL whatismyip = new URL("http://checkip.amazonaws.com");
BufferedReader in... | 2015/02/22 | ['https://Stackoverflow.com/questions/28654728', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1919069/'] | From the `NSBox` [documentation](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSBox_Class/#//apple_ref/occ/instm/NSBox/setFillColor:):
>
> **Special Considerations**
>
>
> Functional only when the receiver’s box type (`boxType`) is `NSBoxCustom` and its border type (`... | set **Box Type** to **Custom** , as in the attachment:
[](https://i.stack.imgur.com/ASB1c.png) |
63,768,916 | I'm trying to use the cvlib package which use yolov3 model to recognize objects on images on windows 10.
Let's take an easy example:
```
import cvlib as cv
import time
from cvlib.object_detection import draw_bbox
inittimer=time.time()
bbox, label, conf = cv.detect_common_objects(img,confidence=0.5,model='yolov3-worke... | 2020/09/06 | ['https://Stackoverflow.com/questions/63768916', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/13350827/'] | You can verify if opencv is using CUDA or not. This can be done using the following
```
import cv2
print(cv2.cuda.getCudaEnabledDeviceCount())
```
This should get you the number of CUDA enabled devices in your machine. You should also check the build information by using the following
```
import cv2
print cv2.getBu... | ```
workon opencv_cuda
cd opencv
mkdir build ... |
63,768,916 | I'm trying to use the cvlib package which use yolov3 model to recognize objects on images on windows 10.
Let's take an easy example:
```
import cvlib as cv
import time
from cvlib.object_detection import draw_bbox
inittimer=time.time()
bbox, label, conf = cv.detect_common_objects(img,confidence=0.5,model='yolov3-worke... | 2020/09/06 | ['https://Stackoverflow.com/questions/63768916', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/13350827/'] | I got it! The problem come from the fact that I created a new `Net` object for each itteration.
Here is the related issue on github where you can follow it: <https://github.com/opencv/opencv/issues/16348>
With a custom function, it now works at ~60 fps. Be aware that cvlib is, maybe, not done for real time computatio... | You can verify if opencv is using CUDA or not. This can be done using the following
```
import cv2
print(cv2.cuda.getCudaEnabledDeviceCount())
```
This should get you the number of CUDA enabled devices in your machine. You should also check the build information by using the following
```
import cv2
print cv2.getBu... |
63,768,916 | I'm trying to use the cvlib package which use yolov3 model to recognize objects on images on windows 10.
Let's take an easy example:
```
import cvlib as cv
import time
from cvlib.object_detection import draw_bbox
inittimer=time.time()
bbox, label, conf = cv.detect_common_objects(img,confidence=0.5,model='yolov3-worke... | 2020/09/06 | ['https://Stackoverflow.com/questions/63768916', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/13350827/'] | I got it! The problem come from the fact that I created a new `Net` object for each itteration.
Here is the related issue on github where you can follow it: <https://github.com/opencv/opencv/issues/16348>
With a custom function, it now works at ~60 fps. Be aware that cvlib is, maybe, not done for real time computatio... | ```
workon opencv_cuda
cd opencv
mkdir build ... |
58,511,850 | I have the following object:
```
[{animal: 1, hasLegs: true},{animal: 1, hasTail: false},
{animal: 2, hasLegs: true},{animal: 2, hasTail: true},{animal: 3}]
```
I would like to restructure it to the following:
```
[
{ animal:1, info: { hasLegs: true, hasTail: false },
{ animal:2, info: { hasLegs: true, hasTail... | 2019/10/22 | ['https://Stackoverflow.com/questions/58511850', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2762175/'] | This is a similar answer, but should be slightly more performant since it takes advantage of map hashing instead of doing a find for each entry.
```js
const data = [{animal: 1, hasLegs: true},{animal: 1, hasTail: false},
{animal: 2, hasLegs: true},{animal: 2, hasTail: true},{animal: 3}]
const infoMap = data.reduce(... | ```js
const array = [{ animal: 1, hasLegs: true }, { animal: 1, hasTail: false },
{ animal: 2, hasLegs: true }, { animal: 2, hasTail: true }, { animal: 3 }];
const result = [];
array.forEach(obj => {
let newEntry = null;
if (result.findIndex(entry => entry.animal === obj.animal) === -1) {
newEntry = { a... |
58,511,850 | I have the following object:
```
[{animal: 1, hasLegs: true},{animal: 1, hasTail: false},
{animal: 2, hasLegs: true},{animal: 2, hasTail: true},{animal: 3}]
```
I would like to restructure it to the following:
```
[
{ animal:1, info: { hasLegs: true, hasTail: false },
{ animal:2, info: { hasLegs: true, hasTail... | 2019/10/22 | ['https://Stackoverflow.com/questions/58511850', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2762175/'] | I would suggest creating a lookup object from the initial array. This way, you don't need to look through the entire array on every element (which would make it `O(n²)`).
So given our list beforehand:
```js
const animals = [
{ animal: 1, hasLegs: true },
{ animal: 1, hasTail: false },
{ animal: 2, hasLegs: true... | ```js
const array = [{ animal: 1, hasLegs: true }, { animal: 1, hasTail: false },
{ animal: 2, hasLegs: true }, { animal: 2, hasTail: true }, { animal: 3 }];
const result = [];
array.forEach(obj => {
let newEntry = null;
if (result.findIndex(entry => entry.animal === obj.animal) === -1) {
newEntry = { a... |
58,511,850 | I have the following object:
```
[{animal: 1, hasLegs: true},{animal: 1, hasTail: false},
{animal: 2, hasLegs: true},{animal: 2, hasTail: true},{animal: 3}]
```
I would like to restructure it to the following:
```
[
{ animal:1, info: { hasLegs: true, hasTail: false },
{ animal:2, info: { hasLegs: true, hasTail... | 2019/10/22 | ['https://Stackoverflow.com/questions/58511850', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2762175/'] | I would suggest creating a lookup object from the initial array. This way, you don't need to look through the entire array on every element (which would make it `O(n²)`).
So given our list beforehand:
```js
const animals = [
{ animal: 1, hasLegs: true },
{ animal: 1, hasTail: false },
{ animal: 2, hasLegs: true... | This is a similar answer, but should be slightly more performant since it takes advantage of map hashing instead of doing a find for each entry.
```js
const data = [{animal: 1, hasLegs: true},{animal: 1, hasTail: false},
{animal: 2, hasLegs: true},{animal: 2, hasTail: true},{animal: 3}]
const infoMap = data.reduce(... |
70,713,408 | How do I select/copy info from web with Selenium and copy into IntelliJ to String? I'm using IntelliJ in Java. I am trying to use:
```
Navegador.getInstance().instanciaNavegador().findElement(By.xpath("//div[@id='cpf']/span[2]")).sendKeys(Keys.chord(Keys.CONTROL, "v"));
``` | 2022/01/14 | ['https://Stackoverflow.com/questions/70713408', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/17934597/'] | As [Kraigolas commented](https://stackoverflow.com/questions/70713383/for-loop-to-replace-value-in-one-dataframe-with-x-if-it-appears-in-another-dataf#comment125009505_70713383), you can easily do this without looping.
Check if elements are in another array with [`np.in1d`](https://numpy.org/doc/stable/reference/gener... | Given question with `dataframe` in title, variables `df1` and `df2` together with `col1` and `col2` probably is related to [pandas](/questions/tagged/pandas "show questions tagged 'pandas'") or [numpy](/questions/tagged/numpy "show questions tagged 'numpy'").
Without any further context provided, like code, we can onl... |
40,620 | I have a Visualforce page to collect the Name and Email of clients. My Visualforce page looks like this:
```
<apex:page Controller="WebsiteController" >
<apex:sectionHeader title="Registration" subtitle="Please fill in the details"/>
<apex:form >
<apex:pageMessages />
<apex:pageBlock title="Email u... | 2014/06/16 | ['https://salesforce.stackexchange.com/questions/40620', 'https://salesforce.stackexchange.com', 'https://salesforce.stackexchange.com/users/8737/'] | `LargestRevision.size()` will never return `null`.
The `size()` method will return `0` if the list is empty.
From the [documentation](https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_list.htm):
>
> **size()**
>
> Returns the number of elements in the list.
>
>
> **Signature**... | You should replace the first part of the if with
```
if(LargestRevision!=null and LargestRevision.size()!=0){
clonedQuteLink.Revision_Number__c=LargestRevision.get(0).Revision_Number__c+1;
clonedQuteLink.Quote_Link__c = quoteLink.Quote_Link__c;
}
```
because if LargestRevision is null ... |
69,084,365 | I'm using the below code to open an URL. Downloading a PDF from React native webview after opening on Android gives:
>
> "invaild pdf format or corrupted"
>
>
>
but it works fine on iOS.
```
<WebView
renderToHardwareTextureAndroid={true}
startInLoadingState={isLoading}
renderLoading={() =... | 2021/09/07 | ['https://Stackoverflow.com/questions/69084365', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/16477546/'] | If you want full control over subscriptions, you can create a custom `Publisher` and `Subscription`.
`Publisher`'s `func receive<S: Subscriber>(subscriber: S)` method is the one that gets called when the publisher receives a new subscriber.
If you simply want to make a network request when this happens, you just need... | You can handle publisher events and inject side effect to track subscriptions, like
```
class LoginService {
static func generateLoginPublisher(onSubscription: @escaping (Subscription) -> Void) -> AnyPublisher<Client, NetworkError> {
return PassthroughSubject<Client, NetworkError>()
.handleEvents(receiveSu... |
69,084,365 | I'm using the below code to open an URL. Downloading a PDF from React native webview after opening on Android gives:
>
> "invaild pdf format or corrupted"
>
>
>
but it works fine on iOS.
```
<WebView
renderToHardwareTextureAndroid={true}
startInLoadingState={isLoading}
renderLoading={() =... | 2021/09/07 | ['https://Stackoverflow.com/questions/69084365', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/16477546/'] | I finally solved my problem using `Future` instead of `PassthroughtSubject` as Dávid Pásztor suggested. Using `Future` I don't have to worried about `LoginService.login()` logic finish before I create `loginSubscriber`.
`LoginSevice.login()` method:
```
static func login(_ email: String,_ password: String) -> Future<... | You can handle publisher events and inject side effect to track subscriptions, like
```
class LoginService {
static func generateLoginPublisher(onSubscription: @escaping (Subscription) -> Void) -> AnyPublisher<Client, NetworkError> {
return PassthroughSubject<Client, NetworkError>()
.handleEvents(receiveSu... |
69,084,365 | I'm using the below code to open an URL. Downloading a PDF from React native webview after opening on Android gives:
>
> "invaild pdf format or corrupted"
>
>
>
but it works fine on iOS.
```
<WebView
renderToHardwareTextureAndroid={true}
startInLoadingState={isLoading}
renderLoading={() =... | 2021/09/07 | ['https://Stackoverflow.com/questions/69084365', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/16477546/'] | If you want full control over subscriptions, you can create a custom `Publisher` and `Subscription`.
`Publisher`'s `func receive<S: Subscriber>(subscriber: S)` method is the one that gets called when the publisher receives a new subscriber.
If you simply want to make a network request when this happens, you just need... | I finally solved my problem using `Future` instead of `PassthroughtSubject` as Dávid Pásztor suggested. Using `Future` I don't have to worried about `LoginService.login()` logic finish before I create `loginSubscriber`.
`LoginSevice.login()` method:
```
static func login(_ email: String,_ password: String) -> Future<... |
170,161 | We had wooden Marvin double hung tilt-pac windows installed but all without screens. However, there aren't any screen tracks. On the exterior trim, there is a groove/corner on three sides that would fit a screen (~36x54.5) , but it would have to be secured with hardware somehow. And this trim corner does not extend to ... | 2019/07/30 | ['https://diy.stackexchange.com/questions/170161', 'https://diy.stackexchange.com', 'https://diy.stackexchange.com/users/89457/'] | It does look like that a screen could fit where you're pointing.
I've included a picture of some screen hangers and a lock.[](https://i.stack.imgur.com/KLBnJ.jpg) The hangers would go on the top of the screen and trim allowing the screen to be lifted... | Typical approach for modern screens/windows (as Jack has shown the very vintage approach) is that the screen has a frame (typically aluminum) that has springs on one side or two sides so it can be fitted into the slot by compressing the springs, and when released is held in the slot by spring pressure.
The sill is "tr... |
48,005,916 | I want to try add background image through url But image is not showing.
Here what am I using.
```html
<div style="background-image:url(https://i.amz.mshcdn.com/pr8NZRyZf0Kmz4FSGMkLtxUwZ70=/575x323/filters:quality(90)/https%3A%2F%2Fblueprint-api-production.s3.amazonaws.com%2Fuploads%2Fstory%2Fthumbnail%2F65469... | 2017/12/28 | ['https://Stackoverflow.com/questions/48005916', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9148852/'] | You need to add quotes. In most of the cases it's not mandatory but in your case, it's needed as you have some special characters that can create confusion.
For example, You have a closing `)` inside the URL which made it to be closed before the end.
```html
<div style="background-image:url('https://i.amz.mshcdn.com... | See the [specification](https://www.w3.org/TR/CSS2/syndata.html#uri):
>
> Some characters appearing in an unquoted URI, such as parentheses, white space characters, single quotes (') and double quotes ("), must be escaped with a backslash so that the resulting URI value is a URI token: '(', ')'.
>
>
>
Either:
* ... |
57,924,568 | Need help for the below problem.
How to use loop function to find the number of 'Null' values in each column for a data frame.
Thanks
Example: `df<-data.frame(name=c("Patrik","Tom","Harry","Bose"),
Age=c(45,NA,54,34),
Location=c("NA","CA",NA,"IR"))` | 2019/09/13 | ['https://Stackoverflow.com/questions/57924568', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10045435/'] | Ok, regarding your second code snippet there are several things that I noticed.
You are using the cookie-parser package that you affected to the cookieParser variable but after you use `Cookies.get` but I don't see where `Cookies` is coming from? so maybe what you want to do is `cookieParser.get` but by checking the c... | Let me say you that if you want to store a JWT into a cookie and other extra information it could be stored or not depending on the size of your cookie.
For more information about max size for cookies check this: <https://www.quora.com/What-Is-The-Maximum-Size-Of-Cookie-In-A-Web-Browser>
On another hand, I saw a prob... |
12,941,564 | Thanks for all the help so far. I was able to send the $Email variable to the stdio stream and receive it in the vb script. I am having a problem now with some of the code
```
Option Strict On
Imports MySql.Data.MySqlClient
Imports System.Runtime.Serialization
Module jrConnect
Sub Main(ByVal cmdArgs() As String... | 2012/10/17 | ['https://Stackoverflow.com/questions/12941564', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1748297/'] | From the NSIS manual:
```
nsExec will execute command-line based programs and capture the output
without opening a dos box
```
Your `console.Readline` will expect some kind of interation and since its not connected to stdin/stdout, will fail. Since you dont want the DOS box, and you want to send the email string via... | You are trying to read from stdin but nsExec does not provide any data you can read from stdin. Change the VB program to parse the commandline instead or use [ExecDos](http://nsis.sourceforge.net/ExecDos_plug-in) or [ExecCmd](http://nsis.sourceforge.net/ExecCmd_plug-in) if your child process has to get the data from st... |
10,903,013 | I have an xml document that looks like this:
```
<oldEle userlabel="label1">
<ele1>%02d.jpeg</ele1>
</oldEle>
<oldEle userlabel="label2">
<ele1>%02d.tiff</ele1>
</oldEle>
```
I want it to be this:
```
<JPEG userlabel="label1">
<ele1>%02d.jpeg</ele1>
</JPEG>
<TIFF userlabel="label2">
<ele1>%02d.tiff</ele1>... | 2012/06/05 | ['https://Stackoverflow.com/questions/10903013', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1140072/'] | ```
<xsl:template match="oldNode">
<xsl:choose>
<xsl:when test="contains(ele1,'.jpeg')">
<xsl:element name="JPEG">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:when>
<xsl:when test="contains(ele1,'.tiff')">
<xsl:element na... | **Here is the same answer as to your previous question -- this solves completely the old and the current problem and no recursion is used**:
```
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="my:my">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<m... |
10,903,013 | I have an xml document that looks like this:
```
<oldEle userlabel="label1">
<ele1>%02d.jpeg</ele1>
</oldEle>
<oldEle userlabel="label2">
<ele1>%02d.tiff</ele1>
</oldEle>
```
I want it to be this:
```
<JPEG userlabel="label1">
<ele1>%02d.jpeg</ele1>
</JPEG>
<TIFF userlabel="label2">
<ele1>%02d.tiff</ele1>... | 2012/06/05 | ['https://Stackoverflow.com/questions/10903013', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1140072/'] | The first problem is with your matching template
```
<xsl:template match="//xmlns:oldNode[contains(//xmlsns:oldNode/root:ele1, '.')]">
```
In particular, with the **contains** element you probably don't want the `//oldNode` at the front, as this will start looking for the first **oldNode** relative to the root ele... | **Here is the same answer as to your previous question -- this solves completely the old and the current problem and no recursion is used**:
```
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="my:my">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<m... |
2,295,660 | What is the best way to capture video in a WPF application? I am looking for a way to detect the video devices, and then capture video from the selected one. | 2010/02/19 | ['https://Stackoverflow.com/questions/2295660', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/66071/'] | There is no WPF support for this. You need to use the traditional, expected windows APIs for video capture, such as DXVA. | If you are OK with using ActiveX controls in WPF app, you can use VideoCapX from <http://www.fathsoft.com/videocapx.html> |
4,236,020 | I have a program that accepts HTTP post of files and write all the POST result into a file, I want to write a script to delete the HTTP headers, only leave the binary file data, how to do it?
The file content is below (the data between `Content-Type: application/octet-stream` and `------------KM7cH2GI3cH2Ef1Ij5gL6GI3I... | 2010/11/21 | ['https://Stackoverflow.com/questions/4236020', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/197036/'] | If you use Python, [`email.parser.Parser`](http://docs.python.org/library/email.parser.html#parser-class-api) will allow you to parse a multipart MIME document. | This may be a crazy idea, but I would try stripping the headers with procmail. |
4,236,020 | I have a program that accepts HTTP post of files and write all the POST result into a file, I want to write a script to delete the HTTP headers, only leave the binary file data, how to do it?
The file content is below (the data between `Content-Type: application/octet-stream` and `------------KM7cH2GI3cH2Ef1Ij5gL6GI3I... | 2010/11/21 | ['https://Stackoverflow.com/questions/4236020', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/197036/'] | If you use Python, [`email.parser.Parser`](http://docs.python.org/library/email.parser.html#parser-class-api) will allow you to parse a multipart MIME document. | This probably contains some typos or something, but bear with me anyway. First determine the boundary (`input` is the file containing the data - pipe if necessary):
```
boundary=`grep '^Content-Type: multipart/form-data; boundary=' input|sed 's/.*boundary=//'`
```
Then filter the `Filedata` part:
```
fd='Content-Di... |
4,236,020 | I have a program that accepts HTTP post of files and write all the POST result into a file, I want to write a script to delete the HTTP headers, only leave the binary file data, how to do it?
The file content is below (the data between `Content-Type: application/octet-stream` and `------------KM7cH2GI3cH2Ef1Ij5gL6GI3I... | 2010/11/21 | ['https://Stackoverflow.com/questions/4236020', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/197036/'] | If you use Python, [`email.parser.Parser`](http://docs.python.org/library/email.parser.html#parser-class-api) will allow you to parse a multipart MIME document. | Look at the [Mime::Tools suite](http://search.cpan.org/perldoc?MIME%3a%3aTools) for Perl. It has a rich set of classes; I’m sure you could put something together in just a few lines. |
4,236,020 | I have a program that accepts HTTP post of files and write all the POST result into a file, I want to write a script to delete the HTTP headers, only leave the binary file data, how to do it?
The file content is below (the data between `Content-Type: application/octet-stream` and `------------KM7cH2GI3cH2Ef1Ij5gL6GI3I... | 2010/11/21 | ['https://Stackoverflow.com/questions/4236020', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/197036/'] | You want to do this as the file is going over, or is this something you want to do after the file comes over?
Almost any scripting language should work. My AWK is a bit rusty, but...
```
awk '/^Content-Type: application\/octet-stream/,/^--------/'
```
That should print everything between `application/octet-stream` ... | If you use Python, [`email.parser.Parser`](http://docs.python.org/library/email.parser.html#parser-class-api) will allow you to parse a multipart MIME document. |
4,236,020 | I have a program that accepts HTTP post of files and write all the POST result into a file, I want to write a script to delete the HTTP headers, only leave the binary file data, how to do it?
The file content is below (the data between `Content-Type: application/octet-stream` and `------------KM7cH2GI3cH2Ef1Ij5gL6GI3I... | 2010/11/21 | ['https://Stackoverflow.com/questions/4236020', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/197036/'] | This may be a crazy idea, but I would try stripping the headers with procmail. | This probably contains some typos or something, but bear with me anyway. First determine the boundary (`input` is the file containing the data - pipe if necessary):
```
boundary=`grep '^Content-Type: multipart/form-data; boundary=' input|sed 's/.*boundary=//'`
```
Then filter the `Filedata` part:
```
fd='Content-Di... |
4,236,020 | I have a program that accepts HTTP post of files and write all the POST result into a file, I want to write a script to delete the HTTP headers, only leave the binary file data, how to do it?
The file content is below (the data between `Content-Type: application/octet-stream` and `------------KM7cH2GI3cH2Ef1Ij5gL6GI3I... | 2010/11/21 | ['https://Stackoverflow.com/questions/4236020', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/197036/'] | You want to do this as the file is going over, or is this something you want to do after the file comes over?
Almost any scripting language should work. My AWK is a bit rusty, but...
```
awk '/^Content-Type: application\/octet-stream/,/^--------/'
```
That should print everything between `application/octet-stream` ... | This may be a crazy idea, but I would try stripping the headers with procmail. |
4,236,020 | I have a program that accepts HTTP post of files and write all the POST result into a file, I want to write a script to delete the HTTP headers, only leave the binary file data, how to do it?
The file content is below (the data between `Content-Type: application/octet-stream` and `------------KM7cH2GI3cH2Ef1Ij5gL6GI3I... | 2010/11/21 | ['https://Stackoverflow.com/questions/4236020', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/197036/'] | Look at the [Mime::Tools suite](http://search.cpan.org/perldoc?MIME%3a%3aTools) for Perl. It has a rich set of classes; I’m sure you could put something together in just a few lines. | This probably contains some typos or something, but bear with me anyway. First determine the boundary (`input` is the file containing the data - pipe if necessary):
```
boundary=`grep '^Content-Type: multipart/form-data; boundary=' input|sed 's/.*boundary=//'`
```
Then filter the `Filedata` part:
```
fd='Content-Di... |
4,236,020 | I have a program that accepts HTTP post of files and write all the POST result into a file, I want to write a script to delete the HTTP headers, only leave the binary file data, how to do it?
The file content is below (the data between `Content-Type: application/octet-stream` and `------------KM7cH2GI3cH2Ef1Ij5gL6GI3I... | 2010/11/21 | ['https://Stackoverflow.com/questions/4236020', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/197036/'] | You want to do this as the file is going over, or is this something you want to do after the file comes over?
Almost any scripting language should work. My AWK is a bit rusty, but...
```
awk '/^Content-Type: application\/octet-stream/,/^--------/'
```
That should print everything between `application/octet-stream` ... | This probably contains some typos or something, but bear with me anyway. First determine the boundary (`input` is the file containing the data - pipe if necessary):
```
boundary=`grep '^Content-Type: multipart/form-data; boundary=' input|sed 's/.*boundary=//'`
```
Then filter the `Filedata` part:
```
fd='Content-Di... |
4,236,020 | I have a program that accepts HTTP post of files and write all the POST result into a file, I want to write a script to delete the HTTP headers, only leave the binary file data, how to do it?
The file content is below (the data between `Content-Type: application/octet-stream` and `------------KM7cH2GI3cH2Ef1Ij5gL6GI3I... | 2010/11/21 | ['https://Stackoverflow.com/questions/4236020', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/197036/'] | You want to do this as the file is going over, or is this something you want to do after the file comes over?
Almost any scripting language should work. My AWK is a bit rusty, but...
```
awk '/^Content-Type: application\/octet-stream/,/^--------/'
```
That should print everything between `application/octet-stream` ... | Look at the [Mime::Tools suite](http://search.cpan.org/perldoc?MIME%3a%3aTools) for Perl. It has a rich set of classes; I’m sure you could put something together in just a few lines. |
149,833 | I have added product grid in Magento 2 admin form using this link:
[product grid](http://www.webspeaks.in/2016/05/magento-2-add-products-grid-to-custom-admin-module.html).
But now I am creating admin form using ui component and I am not able to change product grid using ui component. Please help me.
>
> view/adminhtm... | 2016/12/12 | ['https://magento.stackexchange.com/questions/149833', 'https://magento.stackexchange.com', 'https://magento.stackexchange.com/users/44843/'] | Please check this.
**Step 1:
Add the following code in your ui form**
```
<fieldset name="assign_products">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Assign Products</item>
<i... | 1. if you are getting this **getProductsReadonly() on null** type of error try to remove getCategory() check and also remove getId() check than products grid will be shown
2. Namespace\Module\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory, //your custom collection ? can you please give example
... |
17,616,338 | I have ViewModel and Model as below
```
public class MyViewModel
{
public List<MyModel> MyItems { get; set; }
/* There are many other properties*/
}
public class MyModel
{
public string MyType { get; set; }
public decimal value1 { get; set; }
public decimal v... | 2013/07/12 | ['https://Stackoverflow.com/questions/17616338', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/461535/'] | The HtmlHelpers in Razor works better by indexer. You have to do:
```
@for (var i = 0; i < Model.MyItems.Count; ++i)
{
<tr>
<td>@Model.MyItems[i]</td>
<td>@Html.TextBoxFor(m => m.MyItems[i])</td>
<td></td>
</tr>
}
``` | You are already parsing your list in the `@foreach` loop, so you just need `<td>@Html.TextBoxFor(myItem.value1)</td>` |
18,371,339 | With javascript, how do we remove the @gmail.com or @aol.com from a string so that what only remains is the name?
```
var string = "johndoe@yahoo.com";
```
Will be just "johdoe"? I tried with split but it did not end well. thanks. | 2013/08/22 | ['https://Stackoverflow.com/questions/18371339', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2522342/'] | And another alternative using [split](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split):
```
var email = "john.doe@email.com";
var sp = email.split('@');
console.log(sp[0]); // john.doe
console.log(sp[1]); // email.com
``` | Try it using [`substring()`](http://www.w3schools.com/jsref/jsref_substring.asp) and [`indexOf()`](http://www.w3schools.com/jsref/jsref_indexof.asp)
```
var name = email.substring(0, email.indexOf("@"));
``` |
18,371,339 | With javascript, how do we remove the @gmail.com or @aol.com from a string so that what only remains is the name?
```
var string = "johndoe@yahoo.com";
```
Will be just "johdoe"? I tried with split but it did not end well. thanks. | 2013/08/22 | ['https://Stackoverflow.com/questions/18371339', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2522342/'] | And another alternative using [split](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split):
```
var email = "john.doe@email.com";
var sp = email.split('@');
console.log(sp[0]); // john.doe
console.log(sp[1]); // email.com
``` | As shown in [How to remove or get domain name from an e-mail address in Javascript?](https://www.4codev.com/javascript/how-to-remove-or-get-domain-name-from-an-e-mail-address-in-javascript-idpx2198110465829791878.html), you can do it using the following code:
```
const getDomainFromEmail = email => {
let emailDomain... |
18,371,339 | With javascript, how do we remove the @gmail.com or @aol.com from a string so that what only remains is the name?
```
var string = "johndoe@yahoo.com";
```
Will be just "johdoe"? I tried with split but it did not end well. thanks. | 2013/08/22 | ['https://Stackoverflow.com/questions/18371339', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2522342/'] | ```
var email = "john.doe@example.com";
var name = email.substring(0, email.lastIndexOf("@"));
var domain = email.substring(email.lastIndexOf("@") +1);
console.log( name ); // john.doe
console.log( domain ); // example.com
```
The above will also work for ***valid* names** containing `@` ([tools.ietf.org/html/rf... | Try it using [`substring()`](http://www.w3schools.com/jsref/jsref_substring.asp) and [`indexOf()`](http://www.w3schools.com/jsref/jsref_indexof.asp)
```
var name = email.substring(0, email.indexOf("@"));
``` |
18,371,339 | With javascript, how do we remove the @gmail.com or @aol.com from a string so that what only remains is the name?
```
var string = "johndoe@yahoo.com";
```
Will be just "johdoe"? I tried with split but it did not end well. thanks. | 2013/08/22 | ['https://Stackoverflow.com/questions/18371339', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2522342/'] | ```
var email = "john.doe@example.com";
var name = email.substring(0, email.lastIndexOf("@"));
var domain = email.substring(email.lastIndexOf("@") +1);
console.log( name ); // john.doe
console.log( domain ); // example.com
```
The above will also work for ***valid* names** containing `@` ([tools.ietf.org/html/rf... | This is only extract your name and remove the nos and special characters present in your name this will work only if your mail id has your name in it
```
var email = user.email;
var name = email.replace(/@.*/, "");
var noNumbername=name.replace(/[0-9]/g, '');
function capitalizeFirstLetter(string) {
return string.char... |
18,371,339 | With javascript, how do we remove the @gmail.com or @aol.com from a string so that what only remains is the name?
```
var string = "johndoe@yahoo.com";
```
Will be just "johdoe"? I tried with split but it did not end well. thanks. | 2013/08/22 | ['https://Stackoverflow.com/questions/18371339', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2522342/'] | You can try with the replace() and regular expression. You can read more about replace() using regex [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
```
var myEmail = 'johndoe@yahoo.com';
var name= myEmail.replace(/@.*/, "");
console.log(name);
```
This returns... | This simple regex will do the needful.
`/^.*(?=@)/g`.
Example:
```
"johndoe@yahoo.com".match(/^.*(?=@)/g); // returns Array [ "johndoe" ]
``` |
18,371,339 | With javascript, how do we remove the @gmail.com or @aol.com from a string so that what only remains is the name?
```
var string = "johndoe@yahoo.com";
```
Will be just "johdoe"? I tried with split but it did not end well. thanks. | 2013/08/22 | ['https://Stackoverflow.com/questions/18371339', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2522342/'] | You should take note that a valid email address is an incredibly sophisticated object and may contain multiple `@` signs (ref. <http://cr.yp.to/im/address.html>).
>
> "The domain part of an address is everything after the final `@`."
>
>
>
Thus, you should do something equivalent to:
```
var email = "johndoe@yah... | You can try with the replace() and regular expression. You can read more about replace() using regex [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
```
var myEmail = 'johndoe@yahoo.com';
var name= myEmail.replace(/@.*/, "");
console.log(name);
```
This returns... |
18,371,339 | With javascript, how do we remove the @gmail.com or @aol.com from a string so that what only remains is the name?
```
var string = "johndoe@yahoo.com";
```
Will be just "johdoe"? I tried with split but it did not end well. thanks. | 2013/08/22 | ['https://Stackoverflow.com/questions/18371339', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2522342/'] | ```
var email = "john.doe@example.com";
var name = email.substring(0, email.lastIndexOf("@"));
var domain = email.substring(email.lastIndexOf("@") +1);
console.log( name ); // john.doe
console.log( domain ); // example.com
```
The above will also work for ***valid* names** containing `@` ([tools.ietf.org/html/rf... | You should take note that a valid email address is an incredibly sophisticated object and may contain multiple `@` signs (ref. <http://cr.yp.to/im/address.html>).
>
> "The domain part of an address is everything after the final `@`."
>
>
>
Thus, you should do something equivalent to:
```
var email = "johndoe@yah... |
18,371,339 | With javascript, how do we remove the @gmail.com or @aol.com from a string so that what only remains is the name?
```
var string = "johndoe@yahoo.com";
```
Will be just "johdoe"? I tried with split but it did not end well. thanks. | 2013/08/22 | ['https://Stackoverflow.com/questions/18371339', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2522342/'] | ```
var email = "john.doe@example.com";
var name = email.substring(0, email.lastIndexOf("@"));
var domain = email.substring(email.lastIndexOf("@") +1);
console.log( name ); // john.doe
console.log( domain ); // example.com
```
The above will also work for ***valid* names** containing `@` ([tools.ietf.org/html/rf... | This simple regex will do the needful.
`/^.*(?=@)/g`.
Example:
```
"johndoe@yahoo.com".match(/^.*(?=@)/g); // returns Array [ "johndoe" ]
``` |
18,371,339 | With javascript, how do we remove the @gmail.com or @aol.com from a string so that what only remains is the name?
```
var string = "johndoe@yahoo.com";
```
Will be just "johdoe"? I tried with split but it did not end well. thanks. | 2013/08/22 | ['https://Stackoverflow.com/questions/18371339', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2522342/'] | You should take note that a valid email address is an incredibly sophisticated object and may contain multiple `@` signs (ref. <http://cr.yp.to/im/address.html>).
>
> "The domain part of an address is everything after the final `@`."
>
>
>
Thus, you should do something equivalent to:
```
var email = "johndoe@yah... | This simple regex will do the needful.
`/^.*(?=@)/g`.
Example:
```
"johndoe@yahoo.com".match(/^.*(?=@)/g); // returns Array [ "johndoe" ]
``` |
18,371,339 | With javascript, how do we remove the @gmail.com or @aol.com from a string so that what only remains is the name?
```
var string = "johndoe@yahoo.com";
```
Will be just "johdoe"? I tried with split but it did not end well. thanks. | 2013/08/22 | ['https://Stackoverflow.com/questions/18371339', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2522342/'] | ```
var email = "johndoe@yahoo.com";
email=email.replace(/@.*/,""); //returns string (the characters before @)
``` | This simple regex will do the needful.
`/^.*(?=@)/g`.
Example:
```
"johndoe@yahoo.com".match(/^.*(?=@)/g); // returns Array [ "johndoe" ]
``` |
36,416,808 | I have a sprite image I am using and have seen other websites that implement a divisor in theirs. I can't figure out what it means. For instance:
```
background: #fff url("/css/sprite.png") no-repeat scroll -107px -55px / 167px padding-box border-box;
```
What does the "167px" mean? | 2016/04/05 | ['https://Stackoverflow.com/questions/36416808', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/'] | Use below Code:-
```
WebElement element = "Your Element"; // Your element
JavascriptExecutor executor = (JavascriptExecutor) driver;
Object aa=executor.executeScript("var items = {}; for (index = 0; index < arguments[0].attributes.length; ++index) { items[arguments[0].attributes[index].name] = arguments[0].attributes[... | No. There is no way in Selenium WebDriver to access any attribute whose full name you don't know. You can't even enumerate over all attributes of a `WebElement`.
It doesn't look like the jsonwire protocol supports this concept. The GET\_ELEMENT\_ATTRIBUTE command takes a list of attribute names, not a list of attribut... |
36,416,808 | I have a sprite image I am using and have seen other websites that implement a divisor in theirs. I can't figure out what it means. For instance:
```
background: #fff url("/css/sprite.png") no-repeat scroll -107px -55px / 167px padding-box border-box;
```
What does the "167px" mean? | 2016/04/05 | ['https://Stackoverflow.com/questions/36416808', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/'] | No. There is no way in Selenium WebDriver to access any attribute whose full name you don't know. You can't even enumerate over all attributes of a `WebElement`.
It doesn't look like the jsonwire protocol supports this concept. The GET\_ELEMENT\_ATTRIBUTE command takes a list of attribute names, not a list of attribut... | This concept works very well. Try this!
```java
WebElement element = driver.findElement(By.tagName("button"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
Object elementAttributes = executor.executeScript("var items = {}; for (index = 0; index < arguments[0].attributes.length; ++index) { items[argument... |
36,416,808 | I have a sprite image I am using and have seen other websites that implement a divisor in theirs. I can't figure out what it means. For instance:
```
background: #fff url("/css/sprite.png") no-repeat scroll -107px -55px / 167px padding-box border-box;
```
What does the "167px" mean? | 2016/04/05 | ['https://Stackoverflow.com/questions/36416808', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/'] | Use below Code:-
```
WebElement element = "Your Element"; // Your element
JavascriptExecutor executor = (JavascriptExecutor) driver;
Object aa=executor.executeScript("var items = {}; for (index = 0; index < arguments[0].attributes.length; ++index) { items[arguments[0].attributes[index].name] = arguments[0].attributes[... | This concept works very well. Try this!
```java
WebElement element = driver.findElement(By.tagName("button"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
Object elementAttributes = executor.executeScript("var items = {}; for (index = 0; index < arguments[0].attributes.length; ++index) { items[argument... |
2,070,933 | Ok i have sinned, i wrote too much code like this
```
try {
// my code
} catch (Exception ex) {
// doesn't matter
}
```
Now i'm going to cleanup/refactor this.
I'm using NB 6.7 and code completion works fine on first writing, adding all Exception types, etc. Once i have done the above code NB do not give more... | 2010/01/15 | ['https://Stackoverflow.com/questions/2070933', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/114226/'] | The problem is, that your catch-all handler "handles" all the exceptions, so there's not need for Netbeans to show any more hints.
If your exception handlers are already empty and you are planning to refactor them anyway, you can just temporarily remove them.
Tip: Auto-format your code, search for `try` and use brac... | I just can provide the eclipse approach and hope that it's somewhat similiar with netbeans:
1. remove the try/catch statements -> eclipse will show compiler errors
2. use eclipse's quick tip to refactor the correct try/catch (or throw) statements
You may save your existing exception handling code to paste it in after... |
2,070,933 | Ok i have sinned, i wrote too much code like this
```
try {
// my code
} catch (Exception ex) {
// doesn't matter
}
```
Now i'm going to cleanup/refactor this.
I'm using NB 6.7 and code completion works fine on first writing, adding all Exception types, etc. Once i have done the above code NB do not give more... | 2010/01/15 | ['https://Stackoverflow.com/questions/2070933', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/114226/'] | [PMD](http://pmd.sourceforge.net/) identifies all these places where you have empty `catch` blocks (PMD does much more actually). It has NetBeans integration, so give it a try.
After identifying all the places with empty `catch` blocks you will have to consider each one by itself:
* sometimes just log the message
* s... | I just can provide the eclipse approach and hope that it's somewhat similiar with netbeans:
1. remove the try/catch statements -> eclipse will show compiler errors
2. use eclipse's quick tip to refactor the correct try/catch (or throw) statements
You may save your existing exception handling code to paste it in after... |
2,070,933 | Ok i have sinned, i wrote too much code like this
```
try {
// my code
} catch (Exception ex) {
// doesn't matter
}
```
Now i'm going to cleanup/refactor this.
I'm using NB 6.7 and code completion works fine on first writing, adding all Exception types, etc. Once i have done the above code NB do not give more... | 2010/01/15 | ['https://Stackoverflow.com/questions/2070933', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/114226/'] | >
> When you ask for a proposal on how to handle the exceptions ...
>
>
>
There is no generally accepted way to handle them. Otherwise, you bet the java language would have implicitly that behavior.
* Exceptions are not a low-level constraint that one must deal with until the compiler is smart-enough.
* Exceptio... | I just can provide the eclipse approach and hope that it's somewhat similiar with netbeans:
1. remove the try/catch statements -> eclipse will show compiler errors
2. use eclipse's quick tip to refactor the correct try/catch (or throw) statements
You may save your existing exception handling code to paste it in after... |
16,947,535 | I've seen this question asked a couple times but I couldn't find a good answer. I've been stuck for hours on this.
Basically I have usernames saved in a database and when a new user registers I want to check if his username is available - and if it is available add him to the database. And they register through a tex... | 2013/06/05 | ['https://Stackoverflow.com/questions/16947535', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2456977/'] | ```
"SELECT FName FROM Users WHERE FName = @paramUsername"
```
and then you insert the parameter into the cmd like so:
```
cmd.Parameters.Add("paramUsername", System.Data.SqlDbType.VarChar);
cmd.Parameters["paramUsername"].Value = "Theusernameyouarelookingfor";
``` | Check this out:
```
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
string validationQuery = "SELECT * FROM Users WHERE FName = @name";
SqlCommand validationCommand = new SqlCommand(validationQuery, connection);
validationCommand.Parameters.Ad... |
40,455,726 | I have two data sets of xy coordinates. The first one has xy coordinates plus a tag column with my factor levels. I called the `data.frame` `qq` and it looks like this:
```
structure(list(x = c(5109, 5128, 5137, 5185, 5258, 5324, 5387,
5343, 5331, 5347, 5300, 5180, 4109, 4082, 4091, 4139, 4212, 4279,
4291, 4297, 42... | 2016/11/06 | ['https://Stackoverflow.com/questions/40455726', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3215940/'] | what about this:
```
mysppoint <- SpatialPoints(coords = my_points) # create spatial points
qq$tag <- as.factor(qq$tag)
polys = list()
# create one polygon for each factor level
for (lev in levels(qq$tag)){
first_x <- qq$x[qq$tag == lev][1]
first_y <- qq$y[qq$tag == lev][1]
qq <- rbind(qq, data.frame(x = firs... | `lapply()` and `sapply()` help you to use function par level.
```
## a bit edited to make output clear
library(dplyr); library(mgcv)
TAG <- unique(qq$tag)
IN.OUT <- lapply(TAG, function(x) as.matrix(qq[qq$tag==x, 1:2])) %>% # make a matrix par level
sapply(function(x) in.out(x, as.matrix(my_points))) # ... |
40,455,726 | I have two data sets of xy coordinates. The first one has xy coordinates plus a tag column with my factor levels. I called the `data.frame` `qq` and it looks like this:
```
structure(list(x = c(5109, 5128, 5137, 5185, 5258, 5324, 5387,
5343, 5331, 5347, 5300, 5180, 4109, 4082, 4091, 4139, 4212, 4279,
4291, 4297, 42... | 2016/11/06 | ['https://Stackoverflow.com/questions/40455726', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3215940/'] | what about this:
```
mysppoint <- SpatialPoints(coords = my_points) # create spatial points
qq$tag <- as.factor(qq$tag)
polys = list()
# create one polygon for each factor level
for (lev in levels(qq$tag)){
first_x <- qq$x[qq$tag == lev][1]
first_y <- qq$y[qq$tag == lev][1]
qq <- rbind(qq, data.frame(x = firs... | I ended up using `lapply` and a combination of `split` and more `lapply`. So here is the code, please ignore the `extract_coords` helper function, it basically gives me a `dataframe` with the `x`,`y` and tag columns. I also managed to subset the points from the original `your_coords` and count them (returning them as a... |
125,659 | Can you give me the load limit on a 4x6 pine board 18' long used for a swing set? Thank you | 2017/10/23 | ['https://diy.stackexchange.com/questions/125659', 'https://diy.stackexchange.com', 'https://diy.stackexchange.com/users/76916/'] | Assuming it’s “Lodgepole Pine” (Idaho Pine and Ponderosa Pine is slightly less) and it’s grade is a No. 2 and better (no loose or missing knotholes), then a 4x6 spanning 18’ will support about 105 lbs. loaded at the mid-span (slightly higher if it’s loaded at third points or further from the center point). | Better idea instead of the 4x6 use 2 2x8 boards bolted of nailed together. Ive done this on a 18 foot span and it holds 3 large adults (over 200 lbs each) on swings without any flex or bowing. Outdoors i would use a good grade of treated lumber to prevent decay from the elements and longer life. |
19,315,725 | I'm using [SimpleCaptcha](http://simplecaptcha.sourceforge.net/)
My web.xml looks like the one [here](http://simplecaptcha.sourceforge.net/installing.html):
```
<servlet>
<servlet-name>StickyCaptcha</servlet-name>
<servlet-class>nl.captcha.servlet.StickyCaptchaServlet</servlet-class>
<init-param>
... | 2013/10/11 | ['https://Stackoverflow.com/questions/19315725', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2316112/'] | Using `nl.captcha.servlet.SimpleCaptchaServlet` instead of `nl.captcha.servlet.StickyCaptchaServlet` solved the problem
because `StickyCaptchaServlet` uses the SessionId to create the image and `SimpleCaptchaServlet` doesn't | I think you may try:
$("#captcha\_image").attr("src", "/captcha\_generator.jsp");
instead of:
$("#captcha\_image").attr("src", "/captcha?"+d.getTime()); |
104,445 | I see people posted stuff on facebook telling their friends and family to stay safe. My question is shouldnt it be friends and families. Not friends and family.? or are they indicating one family as of their own family? what if the person is married and has kids? wouldnt that be 2 families? | 2016/09/23 | ['https://ell.stackexchange.com/questions/104445', 'https://ell.stackexchange.com', 'https://ell.stackexchange.com/users/42134/'] | A family is a group noun and in the expression "friends and family" the speaker is referring to their own family (meaning the people related to them). Depending on exact context or intent, that could be only people more closely related to them or may include more distant relations.
"Family" can occur in the plural, bu... | As @P. E. Dant commented, "friends and family" has become idiomatic, largely (in my view) to the advertising of cellphone carrier service plans. So it is natural to say, whether grammatical or not.
Otherwise, your question could have two meanings:
>
> 1) **friends and family** - your friends and *your* family
>
>
... |
104,445 | I see people posted stuff on facebook telling their friends and family to stay safe. My question is shouldnt it be friends and families. Not friends and family.? or are they indicating one family as of their own family? what if the person is married and has kids? wouldnt that be 2 families? | 2016/09/23 | ['https://ell.stackexchange.com/questions/104445', 'https://ell.stackexchange.com', 'https://ell.stackexchange.com/users/42134/'] | A family is a group noun and in the expression "friends and family" the speaker is referring to their own family (meaning the people related to them). Depending on exact context or intent, that could be only people more closely related to them or may include more distant relations.
"Family" can occur in the plural, bu... | >
> Family
>
>
>
is used to describe a group of people who are closely related, usually genetically.
The singular also has the underlying meaning of having the speaker's affection
>
> I consider them family.
>
>
> My family includes my uncles, aunties and cousins.
>
>
>
When used this way, "family" can ... |
20,657,710 | I've seen examples using XAML and writing some code in C# - is it possible just using Javascript? | 2013/12/18 | ['https://Stackoverflow.com/questions/20657710', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1129799/'] | Yes. Here is a blog showing how to: <http://blogs.msdn.com/b/davrous/archive/2012/09/05/tutorial-series-using-winjs-amp-winrt-to-build-a-fun-html5-camera-application.aspx> | You can write following method for launch camera
```
function capturePhoto() {
var capture = new Windows.Media.Capture.CameraCaptureUI();
capture.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo)
.then(function (file) {
if (file) {
return file.openAsync(Win... |
12,100,977 | So I can't seem to get an else if to work right.
What I've been doing is writing a unit converter to try and teach myself the basics of programming, I'm kind of new to it. So new as to say this is actually my first working while loop. So I've been writing the code, and then doing as a friend who is somewhat more exper... | 2012/08/23 | ['https://Stackoverflow.com/questions/12100977', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1620762/'] | I ran your code and (after fixing a simple error) it correctly enters the *else if* that you reference.
You may want to echo back what you type in to make sure you are not mistyping your input.
The error was that you have
>
> done
>
>
>
on a line by itself. Presumably you meant to assign a value. | My suggestion: use Nunit and write an unit test for it. Nunit will give expected and actual value and you'll see why this isn't working. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.