qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
48,476,431 | I have these fields:
```
field1
field2
field3
field4
this.form = this.formbuilder.group({
'field1' = ['', [<control-specific-validations>]],
'field2' = ['', [<control-specific-validations>]]
}, { validator: isField1GreaterThanField2Validator}
});
```
More validations I need:
```
- field3.value must be greate... | 2018/01/27 | [
"https://Stackoverflow.com/questions/48476431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/401643/"
] | You can use a custom validator to do this. <https://angular.io/guide/form-validation#custom-validators>
Here is a working example of what you want: <https://stackblitz.com/edit/isgreaterthanotherfield-custom-validator>
The validator function itself looks like this:
```
greaterThan(field: string): ValidatorFn {
re... | //your .ts
```
ngOnInit() {
this.myForm = this.fb.group({
field1: 0,
field2: 0,
field3: 0,
}, { validator: this.customValidator }); //a unique validator
}
customValidator(formGroup: FormGroup) {
let errors:any={};
let i:number=0;
let valueBefore:any=null;
Objec... |
1,936,460 | Suppose $f(x)$ is differentiable on $U=(-\infty, 0]$ and $g(x)$ is not differentiable at $V=[0,\infty)$ but is differentiable on $(0,\infty)$. Is the following piecewise function $h(x)$ differentiable?
$$
h(x)=
\begin{cases}
f(x) \text{ for } x\in U\\
g(x) \text{ for } x\in V\\
\end{cases}
$$ Note $U\cap V=\{0\}$ and $... | 2016/09/22 | [
"https://math.stackexchange.com/questions/1936460",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/199120/"
] | $\frac{dy}{dx}$ gives you the slope of the tangent line at any point. Substituting in a value for $x$ into $\frac{dy}{dx}$ gives you the slope at that particular value. Now you have the slope of the line, how do you get the equation of the line? | From high school algebra, you know that to get the equation of a line you need two things: A point on the line and the slope. You're given the $x$-coordinate of a point on the line (and the curve.) So find the $y$-coordinate. Now you need the slope at that point. |
1,936,460 | Suppose $f(x)$ is differentiable on $U=(-\infty, 0]$ and $g(x)$ is not differentiable at $V=[0,\infty)$ but is differentiable on $(0,\infty)$. Is the following piecewise function $h(x)$ differentiable?
$$
h(x)=
\begin{cases}
f(x) \text{ for } x\in U\\
g(x) \text{ for } x\in V\\
\end{cases}
$$ Note $U\cap V=\{0\}$ and $... | 2016/09/22 | [
"https://math.stackexchange.com/questions/1936460",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/199120/"
] | $\frac{dy}{dx}$ gives you the slope of the tangent line at any point. Substituting in a value for $x$ into $\frac{dy}{dx}$ gives you the slope at that particular value. Now you have the slope of the line, how do you get the equation of the line? | Here's how to solve such a problem:
1. Differentiate your function $f(x)$ (as you have done) and insert the value of $x=x\_t$ which represents the point you want to find the tangent line at, i.e., $f'(x\_t)$.
2. You want to find an equation of the form $g(x)=ax+b$, where you already know $a$. To find $b$, simply inse... |
1,936,460 | Suppose $f(x)$ is differentiable on $U=(-\infty, 0]$ and $g(x)$ is not differentiable at $V=[0,\infty)$ but is differentiable on $(0,\infty)$. Is the following piecewise function $h(x)$ differentiable?
$$
h(x)=
\begin{cases}
f(x) \text{ for } x\in U\\
g(x) \text{ for } x\in V\\
\end{cases}
$$ Note $U\cap V=\{0\}$ and $... | 2016/09/22 | [
"https://math.stackexchange.com/questions/1936460",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/199120/"
] | $\frac{dy}{dx}$ gives you the slope of the tangent line at any point. Substituting in a value for $x$ into $\frac{dy}{dx}$ gives you the slope at that particular value. Now you have the slope of the line, how do you get the equation of the line? | The slope of the tangent line is
$$
y'(4/\pi)=2(4/\pi)\sec(\pi/4)-\sec(\pi/4)\tan(\pi/4)=\frac{16}{\sqrt{2}\pi}-\frac{2}{\sqrt{2}}
$$
And the line must go through the point $(\frac{4}{\pi},\frac{16}{\pi^2}\*\frac{2}{\sqrt{2}})$
Can you finish from here? |
49,766,993 | I'm trying to separate the declaration of components. I've created a new file called "Components.ts" and I wrote the declaration codes there and I'm exporting It.
```
import { NgModule } from '@angular/core';
import { Component1} from '../components/Component1.component';
import { Component2} from '../components/Compo... | 2018/04/11 | [
"https://Stackoverflow.com/questions/49766993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5478249/"
] | You are having this issue because you didn't add `float:left` property to the video thumnail div. Try this code.
```
.vp-video-img-w {
position: relative;
overflow: hidden;
float: left;
margin-right: 10px;
width: 30%;
}
``` | Change
```
.vp-video-img-w {
position: relative;
width: 100%;
overflow: hidden;
}
```
to
```
.vp-video-img-w {
position: relative;
width: 100%;
overflow: hidden;
float: left;
}
``` |
49,766,993 | I'm trying to separate the declaration of components. I've created a new file called "Components.ts" and I wrote the declaration codes there and I'm exporting It.
```
import { NgModule } from '@angular/core';
import { Component1} from '../components/Component1.component';
import { Component2} from '../components/Compo... | 2018/04/11 | [
"https://Stackoverflow.com/questions/49766993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5478249/"
] | Try below code:
```css
.header {
padding-top: 20px;
padding-bottom: 20px;
}
.video-embed-container {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
max-width: 100%;
margin-bottom: 0px;
}
.active-iframe-wrapper {
float: left;
width: 100%;
background-color: #f5f5f5;... | Change
```
.vp-video-img-w {
position: relative;
width: 100%;
overflow: hidden;
}
```
to
```
.vp-video-img-w {
position: relative;
width: 100%;
overflow: hidden;
float: left;
}
``` |
51,223,484 | I am trying add a custom back button so that I can perform some tasks before popping the controller. But no matter how hard I tried this function bind with back button doesn't work. I am adding some code to understand
```
-(void)customizeNavigationBar
{
self.navigationController.navigationBarHidden = NO;
self.... | 2018/07/07 | [
"https://Stackoverflow.com/questions/51223484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5540925/"
] | Use `leftbarbutton` item instead of `setBackBarButtonItem`
```
self.navigationItem.leftBarButtonItem = backButton;
``` | Another option is to write your custom code in viewWillDisappear. |
51,223,484 | I am trying add a custom back button so that I can perform some tasks before popping the controller. But no matter how hard I tried this function bind with back button doesn't work. I am adding some code to understand
```
-(void)customizeNavigationBar
{
self.navigationController.navigationBarHidden = NO;
self.... | 2018/07/07 | [
"https://Stackoverflow.com/questions/51223484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5540925/"
] | Use `leftbarbutton` item instead of `setBackBarButtonItem`
```
self.navigationItem.leftBarButtonItem = backButton;
``` | Use this code
```
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
backButton.frame = CGRectMake(0, 0, 15, 15);
[backButton setImage:[UIImage imageNamed:@"backButtonImage"] forState:UIControlStateNormal];
[backButton setTitle:@"Back" forState:UIControlStateNormal];
backButton.imageEdgeInsets = UIEd... |
51,223,484 | I am trying add a custom back button so that I can perform some tasks before popping the controller. But no matter how hard I tried this function bind with back button doesn't work. I am adding some code to understand
```
-(void)customizeNavigationBar
{
self.navigationController.navigationBarHidden = NO;
self.... | 2018/07/07 | [
"https://Stackoverflow.com/questions/51223484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5540925/"
] | When you use the `setLeftBarButtonItem` or `setBackBarButtonItem`, it will take effect on the viewController you’re pushing to but not the current one. That’s why you need to directly set the current `leftBarButtonItem` | Another option is to write your custom code in viewWillDisappear. |
51,223,484 | I am trying add a custom back button so that I can perform some tasks before popping the controller. But no matter how hard I tried this function bind with back button doesn't work. I am adding some code to understand
```
-(void)customizeNavigationBar
{
self.navigationController.navigationBarHidden = NO;
self.... | 2018/07/07 | [
"https://Stackoverflow.com/questions/51223484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5540925/"
] | When you use the `setLeftBarButtonItem` or `setBackBarButtonItem`, it will take effect on the viewController you’re pushing to but not the current one. That’s why you need to directly set the current `leftBarButtonItem` | Use this code
```
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
backButton.frame = CGRectMake(0, 0, 15, 15);
[backButton setImage:[UIImage imageNamed:@"backButtonImage"] forState:UIControlStateNormal];
[backButton setTitle:@"Back" forState:UIControlStateNormal];
backButton.imageEdgeInsets = UIEd... |
1,573,901 | I am wondering about the parameters for constructing a `ConcurrentHashMap`:
* `initialCapacity` is 16 by default (understood).
* `loadFactor` is 0.75 by default.
* `concurrencyLevel` is 16 by default.
My questions are:
* What criteria should be used to adjust `loadFactor` up or down?
* How do we establish the number... | 2009/10/15 | [
"https://Stackoverflow.com/questions/1573901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/117783/"
] | Load Factor is primarily related to the quality of the hash function. The closer to zero the load factor the less likely there are to be collisions even if the hash function isn't so great. The trade off is that the memory footprint is larger. In other words, the HashMap isn't distributing the entries in seperate bucke... | loadFactor: controls when the implementation decides to resize the hashtable. Too high a value will waste space; too low a value will result in expensive resize operations.
concurrencyLevel: tells the implementation to try to optimize for the given number of writing threads. According to the API docs, being off by up ... |
1,573,901 | I am wondering about the parameters for constructing a `ConcurrentHashMap`:
* `initialCapacity` is 16 by default (understood).
* `loadFactor` is 0.75 by default.
* `concurrencyLevel` is 16 by default.
My questions are:
* What criteria should be used to adjust `loadFactor` up or down?
* How do we establish the number... | 2009/10/15 | [
"https://Stackoverflow.com/questions/1573901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/117783/"
] | The short answer: set "initial capacity" to roughly how many mappings you expect to put in the map, and leave the other parameters at their default.
Long answer:
* load factor is the ratio between the
number of "buckets" in the map and
the number of expected elements;
* 0.75 is usually a reasonable compromise-- as I ... | loadFactor: controls when the implementation decides to resize the hashtable. Too high a value will waste space; too low a value will result in expensive resize operations.
concurrencyLevel: tells the implementation to try to optimize for the given number of writing threads. According to the API docs, being off by up ... |
1,573,901 | I am wondering about the parameters for constructing a `ConcurrentHashMap`:
* `initialCapacity` is 16 by default (understood).
* `loadFactor` is 0.75 by default.
* `concurrencyLevel` is 16 by default.
My questions are:
* What criteria should be used to adjust `loadFactor` up or down?
* How do we establish the number... | 2009/10/15 | [
"https://Stackoverflow.com/questions/1573901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/117783/"
] | Load Factor is primarily related to the quality of the hash function. The closer to zero the load factor the less likely there are to be collisions even if the hash function isn't so great. The trade off is that the memory footprint is larger. In other words, the HashMap isn't distributing the entries in seperate bucke... | >
> loadFactor is set to 0.75 by default,
> what criteria should be used to adjust
> this up or down?
>
>
>
You need some background in how hash maps work before you can understand how this works. The map is essentially a series of buckets. Each value in the map gets put in to a bucket depending on what its hash... |
1,573,901 | I am wondering about the parameters for constructing a `ConcurrentHashMap`:
* `initialCapacity` is 16 by default (understood).
* `loadFactor` is 0.75 by default.
* `concurrencyLevel` is 16 by default.
My questions are:
* What criteria should be used to adjust `loadFactor` up or down?
* How do we establish the number... | 2009/10/15 | [
"https://Stackoverflow.com/questions/1573901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/117783/"
] | The short answer: set "initial capacity" to roughly how many mappings you expect to put in the map, and leave the other parameters at their default.
Long answer:
* load factor is the ratio between the
number of "buckets" in the map and
the number of expected elements;
* 0.75 is usually a reasonable compromise-- as I ... | >
> loadFactor is set to 0.75 by default,
> what criteria should be used to adjust
> this up or down?
>
>
>
You need some background in how hash maps work before you can understand how this works. The map is essentially a series of buckets. Each value in the map gets put in to a bucket depending on what its hash... |
1,573,901 | I am wondering about the parameters for constructing a `ConcurrentHashMap`:
* `initialCapacity` is 16 by default (understood).
* `loadFactor` is 0.75 by default.
* `concurrencyLevel` is 16 by default.
My questions are:
* What criteria should be used to adjust `loadFactor` up or down?
* How do we establish the number... | 2009/10/15 | [
"https://Stackoverflow.com/questions/1573901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/117783/"
] | The short answer: set "initial capacity" to roughly how many mappings you expect to put in the map, and leave the other parameters at their default.
Long answer:
* load factor is the ratio between the
number of "buckets" in the map and
the number of expected elements;
* 0.75 is usually a reasonable compromise-- as I ... | Load Factor is primarily related to the quality of the hash function. The closer to zero the load factor the less likely there are to be collisions even if the hash function isn't so great. The trade off is that the memory footprint is larger. In other words, the HashMap isn't distributing the entries in seperate bucke... |
1,878,301 | I have some images inside links that I want to essentially look like this:
```
<a href="/path/to/img.png"><img src="/path/to/img.png" /></a>
```
Clicking on the link should load the image it contains. I'm trying to use CakePHP's HTML helper to do this, as follows:
```
<?php
echo $html->link(
$html->image('img... | 2009/12/10 | [
"https://Stackoverflow.com/questions/1878301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/197560/"
] | This should do the trick:
```
echo $html->image('image.png', array('url' => '/' . IMAGES_URL . 'image.png'));
``` | you can also do this in 1.2
```
echo $html->link(
$html->image('img.png'),
'img.png',
array(),
null,
false
);
```
or in 1.3
```
echo $html->link(
$html->image('img.png'),
'img.png',
array(),
array( 'escape' => false ),
);
``` |
32,673,507 | I'm trying to compare an input of characters with a string that can be of the format "!x" where x is any integer.
What's the easiest way to do this? I tried
```
int result = strcmp(input,"!%d");
```
which did not work. | 2015/09/19 | [
"https://Stackoverflow.com/questions/32673507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2548040/"
] | Here's one way to do it:
```
int is_bang_num(const char *s) {
if (*s != '!') {
return 0;
}
size_t n = strspn(s + 1, "0123456789");
return n > 0 && s[1 + n] == '\0';
}
```
This verifies that the first character is `!`, that it is followed by more characters, and that all of those following cha... | If you want to test that a string matches a format of an exclamation point and then some series of numbers, this regex: "!\d+" will match that. That won't catch if the first number is a zero, which is invalid. This will: "![1,2,3,4,5,6,7,8,9]\d\*". |
32,673,507 | I'm trying to compare an input of characters with a string that can be of the format "!x" where x is any integer.
What's the easiest way to do this? I tried
```
int result = strcmp(input,"!%d");
```
which did not work. | 2015/09/19 | [
"https://Stackoverflow.com/questions/32673507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2548040/"
] | Here's one way to do it:
```
int is_bang_num(const char *s) {
if (*s != '!') {
return 0;
}
size_t n = strspn(s + 1, "0123456789");
return n > 0 && s[1 + n] == '\0';
}
```
This verifies that the first character is `!`, that it is followed by more characters, and that all of those following cha... | You see, `scanf()` family of functions return a value indicating how many parameters where converted.
Even books usually ignore this value and it leads programmers to ignore that it does return a value. One of the consequences of this is *Undefined Behavior* when the `scanf()` function failed and the value was not ini... |
32,673,507 | I'm trying to compare an input of characters with a string that can be of the format "!x" where x is any integer.
What's the easiest way to do this? I tried
```
int result = strcmp(input,"!%d");
```
which did not work. | 2015/09/19 | [
"https://Stackoverflow.com/questions/32673507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2548040/"
] | Here's one way to do it:
```
int is_bang_num(const char *s) {
if (*s != '!') {
return 0;
}
size_t n = strspn(s + 1, "0123456789");
return n > 0 && s[1 + n] == '\0';
}
```
This verifies that the first character is `!`, that it is followed by more characters, and that all of those following cha... | Since the stirng must begin with a ! and follow with an integer, use a qualified `strtol()` which allows a leading sign character. As OP did not specify the range of the integer, let us allow any range.
```
int is_sc_num(const char *str) {
if (*str != '!') return 0;
str++;
// Insure no spaces- something strtol(... |
32,673,507 | I'm trying to compare an input of characters with a string that can be of the format "!x" where x is any integer.
What's the easiest way to do this? I tried
```
int result = strcmp(input,"!%d");
```
which did not work. | 2015/09/19 | [
"https://Stackoverflow.com/questions/32673507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2548040/"
] | You see, `scanf()` family of functions return a value indicating how many parameters where converted.
Even books usually ignore this value and it leads programmers to ignore that it does return a value. One of the consequences of this is *Undefined Behavior* when the `scanf()` function failed and the value was not ini... | If you want to test that a string matches a format of an exclamation point and then some series of numbers, this regex: "!\d+" will match that. That won't catch if the first number is a zero, which is invalid. This will: "![1,2,3,4,5,6,7,8,9]\d\*". |
32,673,507 | I'm trying to compare an input of characters with a string that can be of the format "!x" where x is any integer.
What's the easiest way to do this? I tried
```
int result = strcmp(input,"!%d");
```
which did not work. | 2015/09/19 | [
"https://Stackoverflow.com/questions/32673507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2548040/"
] | Since the stirng must begin with a ! and follow with an integer, use a qualified `strtol()` which allows a leading sign character. As OP did not specify the range of the integer, let us allow any range.
```
int is_sc_num(const char *str) {
if (*str != '!') return 0;
str++;
// Insure no spaces- something strtol(... | If you want to test that a string matches a format of an exclamation point and then some series of numbers, this regex: "!\d+" will match that. That won't catch if the first number is a zero, which is invalid. This will: "![1,2,3,4,5,6,7,8,9]\d\*". |
32,673,507 | I'm trying to compare an input of characters with a string that can be of the format "!x" where x is any integer.
What's the easiest way to do this? I tried
```
int result = strcmp(input,"!%d");
```
which did not work. | 2015/09/19 | [
"https://Stackoverflow.com/questions/32673507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2548040/"
] | You see, `scanf()` family of functions return a value indicating how many parameters where converted.
Even books usually ignore this value and it leads programmers to ignore that it does return a value. One of the consequences of this is *Undefined Behavior* when the `scanf()` function failed and the value was not ini... | Since the stirng must begin with a ! and follow with an integer, use a qualified `strtol()` which allows a leading sign character. As OP did not specify the range of the integer, let us allow any range.
```
int is_sc_num(const char *str) {
if (*str != '!') return 0;
str++;
// Insure no spaces- something strtol(... |
6,393,464 | I have gone through tons of the form\_for nested resource questions and can't get any of the solutions to work for me. I figured its time to ask a personalized question.
I have two models, jobs and questions, jobs has\_many questions and questions belong\_to jobs.
I used scaffolding to create the controllers and mod... | 2011/06/18 | [
"https://Stackoverflow.com/questions/6393464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/583964/"
] | I just pass the URL as an extra option:
```
<%= form_for(@question, :url => job_questions_path(@job)) do %>
```
**EDIT:**
Also try:
```
form_for([@job, @question])
``` | This is how I solved mine :)
In your `questions/_form.html.erb`
```
<%= form_for [@job, @question] do %>
```
For this to work, you need the job's id. You'll pass it as follows:
In the `questions_controller.rb`
```
def new
@job = Job.find(params[job_id])
@question = @job.questions.build
end
```
Build(`.build`... |
16,526,921 | Below I have included some code from my model and my view. It tells me that the $date variable does not exist. I dont understand why it wouldnt. I am changing over from it being objects so thats why some of the old code still has $data-> and why its being changed to $data['']. Regardless its now telling me that $data d... | 2013/05/13 | [
"https://Stackoverflow.com/questions/16526921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/892484/"
] | I was able to figure it out. In my example used above it was saying
```
'value'=>$date['id']
```
Even though I had DATE in my example, I was using DATA in my actual test.
What the actual problem was it that it needs to be...
```
'value'=>'$data["id"]'
``` | Replace:
```
array('name'=>'emax', 'header'=>'Employees' 'value'=>$date['id']),
```
With:
```
array('name'=>'emax', 'header'=>'Employees', 'value'=>$date['id']),
``` |
68,440 | Can anyone please help me on this..
I have a column in my table that stores the duration in an `nvarchar` field formatted as '00:00:00'.
How do I calculate the average duration? I read some other blogs and also used cast techniques like the one below but couldn't solve my problem...
```
cast(cast(avg(cast(CAST(Durat... | 2014/06/17 | [
"https://dba.stackexchange.com/questions/68440",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/38142/"
] | I assume you must have invalid data stored in your `nvarchar` field. I created a simple test to obtain average duration, which works:
```
DECLARE @T TABLE
(
duration NVARCHAR(8)
);
INSERT INTO @T VALUES ('00:00:05');
INSERT INTO @T VALUES ('00:01:04');
INSERT INTO @T VALUES ('00:02:03');
INSERT INTO @T VALUES ('03... | If you can't afford to refactor this field as an integer right now but you need better performance or simplicity for aggregate calculations, you may want to consider a **computed field**:
```
ALTER TABLE timetable ADD DurationSeconds AS DATEDIFF(SECOND, '00:00:00', Duration);
```
You can then index this field if nee... |
68,440 | Can anyone please help me on this..
I have a column in my table that stores the duration in an `nvarchar` field formatted as '00:00:00'.
How do I calculate the average duration? I read some other blogs and also used cast techniques like the one below but couldn't solve my problem...
```
cast(cast(avg(cast(CAST(Durat... | 2014/06/17 | [
"https://dba.stackexchange.com/questions/68440",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/38142/"
] | Store duration in seconds as an integer; then average is quite easy. Right now you're trying to take an average of a string converted to a float converted to a datetime converted to a time. If that doesn't sound wrong to you, read it again. Then consider that `time` represents a point time. What is the average of 3:12 ... | If you can't afford to refactor this field as an integer right now but you need better performance or simplicity for aggregate calculations, you may want to consider a **computed field**:
```
ALTER TABLE timetable ADD DurationSeconds AS DATEDIFF(SECOND, '00:00:00', Duration);
```
You can then index this field if nee... |
20,668,314 | I appreciate ideas on how to stream data from an On-Premise Windows server to a persistent EMR cluster?
**Some Background**
I would like to run a persistent cluster running a MR job much like the WordCount examples that are available. I would like to stream text from a local Windows Server up to the cluster and have ... | 2013/12/18 | [
"https://Stackoverflow.com/questions/20668314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3116818/"
] | When you do a `LEFT JOIN` it's possible that the joined table will have `NULL` for all data:
```
SELECT ... WHERE table_pictures.chapter_id IS NULL
```
So you can do this to find all those where the link doesn't work, or as an inverse, `RIGHT JOIN` and select all those not in the list with a `WHERE ... NOT IN (SELEC... | ```
DELETE FROM table_meta WHERE chapter_id NOT IN(
SELECT chapter_id FROM table_pictures
WHERE table_meta.chapter_id = table_pictures.chapter_id
);
``` |
20,668,314 | I appreciate ideas on how to stream data from an On-Premise Windows server to a persistent EMR cluster?
**Some Background**
I would like to run a persistent cluster running a MR job much like the WordCount examples that are available. I would like to stream text from a local Windows Server up to the cluster and have ... | 2013/12/18 | [
"https://Stackoverflow.com/questions/20668314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3116818/"
] | Here's an example how to negate your `LEFT JOIN` and use it for deleting the data in `table_meta`:
```
DELETE table_meta
FROM table_meta
LEFT JOIN table_pictures ON table_meta.chapter_id = table_pictures.chapter_id
WHERE ISNULL(table_pictures.chapter_id);
``` | When you do a `LEFT JOIN` it's possible that the joined table will have `NULL` for all data:
```
SELECT ... WHERE table_pictures.chapter_id IS NULL
```
So you can do this to find all those where the link doesn't work, or as an inverse, `RIGHT JOIN` and select all those not in the list with a `WHERE ... NOT IN (SELEC... |
20,668,314 | I appreciate ideas on how to stream data from an On-Premise Windows server to a persistent EMR cluster?
**Some Background**
I would like to run a persistent cluster running a MR job much like the WordCount examples that are available. I would like to stream text from a local Windows Server up to the cluster and have ... | 2013/12/18 | [
"https://Stackoverflow.com/questions/20668314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3116818/"
] | Here's an example how to negate your `LEFT JOIN` and use it for deleting the data in `table_meta`:
```
DELETE table_meta
FROM table_meta
LEFT JOIN table_pictures ON table_meta.chapter_id = table_pictures.chapter_id
WHERE ISNULL(table_pictures.chapter_id);
``` | ```
DELETE FROM table_meta WHERE chapter_id NOT IN(
SELECT chapter_id FROM table_pictures
WHERE table_meta.chapter_id = table_pictures.chapter_id
);
``` |
1,817,179 | >
> I need to examine whether the following limit exists, or not.
> $$\lim\_{n \to +\infty} \frac{1}{n^2} \sum\_{k=1}^{n} k \ln\left( \frac{k^2+n^2}{n^2}\right )$$
> If it does, I need to calculate its value.
>
>
>
How to even start this? I've got no idea. | 2016/06/07 | [
"https://math.stackexchange.com/questions/1817179",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/294766/"
] | **An idea:** "Riemann sums" may be a good start.
Massage your current sum into something of the form
$$
\frac{1}{n}\sum\_{k=0}^n \frac{k}{n} \ln \left( 1+\left(\frac{k}{n}\right)^2\right)
$$
and recognize a Riemann sum for the (continuous) function $f\colon[0,1]\to\mathbb{R}$ defined by $f(x) = x\ln(1+x^2)$.
---
**U... | Just to complete [Clement C.'s answer](https://math.stackexchange.com/a/1817181/44121), integration by parts leads to:
$$\begin{eqnarray\*} I=\int\_{0}^{1}x \log(1+x^2)\,dx &=& \left.\frac{x^2}{2}\log(1+x^2)\right|\_{0}^{1}-\int\_{0}^{1}\frac{x^3}{1+x^2}\,dx\\&=&\frac{\log(2)}{2}-\int\_{0}^{1}x\,dx+\int\_{0}^{1}\frac{... |
1,817,179 | >
> I need to examine whether the following limit exists, or not.
> $$\lim\_{n \to +\infty} \frac{1}{n^2} \sum\_{k=1}^{n} k \ln\left( \frac{k^2+n^2}{n^2}\right )$$
> If it does, I need to calculate its value.
>
>
>
How to even start this? I've got no idea. | 2016/06/07 | [
"https://math.stackexchange.com/questions/1817179",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/294766/"
] | **An idea:** "Riemann sums" may be a good start.
Massage your current sum into something of the form
$$
\frac{1}{n}\sum\_{k=0}^n \frac{k}{n} \ln \left( 1+\left(\frac{k}{n}\right)^2\right)
$$
and recognize a Riemann sum for the (continuous) function $f\colon[0,1]\to\mathbb{R}$ defined by $f(x) = x\ln(1+x^2)$.
---
**U... | Another approach. Using [Abel's summation](https://en.wikipedia.org/wiki/Abel%27s_summation_formula) we have $$S=\sum\_{k=0}^{n}k\log\left(1+\left(\frac{k}{n}\right)^{2}\right)=\frac{n\left(n+1\right)\log\left(2\right)}{2}-\int\_{0}^{n}\frac{\left\lfloor t\left(t+1\right)\right\rfloor t}{n^{2}+t^{2}}dt
$$ where $\left... |
1,817,179 | >
> I need to examine whether the following limit exists, or not.
> $$\lim\_{n \to +\infty} \frac{1}{n^2} \sum\_{k=1}^{n} k \ln\left( \frac{k^2+n^2}{n^2}\right )$$
> If it does, I need to calculate its value.
>
>
>
How to even start this? I've got no idea. | 2016/06/07 | [
"https://math.stackexchange.com/questions/1817179",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/294766/"
] | Just to complete [Clement C.'s answer](https://math.stackexchange.com/a/1817181/44121), integration by parts leads to:
$$\begin{eqnarray\*} I=\int\_{0}^{1}x \log(1+x^2)\,dx &=& \left.\frac{x^2}{2}\log(1+x^2)\right|\_{0}^{1}-\int\_{0}^{1}\frac{x^3}{1+x^2}\,dx\\&=&\frac{\log(2)}{2}-\int\_{0}^{1}x\,dx+\int\_{0}^{1}\frac{... | Another approach. Using [Abel's summation](https://en.wikipedia.org/wiki/Abel%27s_summation_formula) we have $$S=\sum\_{k=0}^{n}k\log\left(1+\left(\frac{k}{n}\right)^{2}\right)=\frac{n\left(n+1\right)\log\left(2\right)}{2}-\int\_{0}^{n}\frac{\left\lfloor t\left(t+1\right)\right\rfloor t}{n^{2}+t^{2}}dt
$$ where $\left... |
2,432,050 | Suppose a query "select streetAdr from Address" returns "236 a1 road" "333 a2 road" and 444 a4 road" as 3 rows. How i can display only "236" "333" and "444" in SQL Server. | 2010/03/12 | [
"https://Stackoverflow.com/questions/2432050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/243323/"
] | Try:
```
Select left(yourcolumn, charindex(' ',yourcolumn)) ...
``` | Just to be on the safe side, if any of your addresses should only have a number and nothing else:
```
declare @Address table (AddressLine1 nvarchar(50) NOT NULL)
insert into @Address values ('236 a1 road')
insert into @Address values ('333 a2 road')
insert into @Address values ('444 a4 road')
insert into @Address valu... |
15,171,457 | This is an extension to my [previous question](https://stackoverflow.com/questions/15169663/format-string-by-binary-list) but in a reversed order: that is, with string `-t-c-over----`, is there a way to generate a binary list that all valid letters have `1` and hyphens have `0`:
```
[0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0... | 2013/03/02 | [
"https://Stackoverflow.com/questions/15171457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1021602/"
] | ```
>>> s = '-t-c-over----'
>>> lst = [0 if i == '-' else 1 for i in s]
>>> print lst
[0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0]
```
The list comp checks if a letter is `'-'` - if it is, it puts a `0` in the list, otherwise it puts a `1` in. | You can use this
```
string = "-t-c-over----"
[0 if i == "-" else 1 for i in string]
Output: [0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0]
``` |
15,171,457 | This is an extension to my [previous question](https://stackoverflow.com/questions/15169663/format-string-by-binary-list) but in a reversed order: that is, with string `-t-c-over----`, is there a way to generate a binary list that all valid letters have `1` and hyphens have `0`:
```
[0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0... | 2013/03/02 | [
"https://Stackoverflow.com/questions/15171457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1021602/"
] | ```
>>> s = '-t-c-over----'
>>> lst = [0 if i == '-' else 1 for i in s]
>>> print lst
[0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0]
```
The list comp checks if a letter is `'-'` - if it is, it puts a `0` in the list, otherwise it puts a `1` in. | Another option is use a lambda function and a map function.
```
s = '-t-c-over----'
output = map(lambda x: 0 if x == '-' else 1, s)
```
Edit: Apparently this doesn't work in Python 3.2 so the practical solution would be something like this.
```
s = '-t-c-over----'
output = [0 if x == '-' else 1 for x in s]
``` |
15,171,457 | This is an extension to my [previous question](https://stackoverflow.com/questions/15169663/format-string-by-binary-list) but in a reversed order: that is, with string `-t-c-over----`, is there a way to generate a binary list that all valid letters have `1` and hyphens have `0`:
```
[0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0... | 2013/03/02 | [
"https://Stackoverflow.com/questions/15171457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1021602/"
] | You can use this
```
string = "-t-c-over----"
[0 if i == "-" else 1 for i in string]
Output: [0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0]
``` | Another option is use a lambda function and a map function.
```
s = '-t-c-over----'
output = map(lambda x: 0 if x == '-' else 1, s)
```
Edit: Apparently this doesn't work in Python 3.2 so the practical solution would be something like this.
```
s = '-t-c-over----'
output = [0 if x == '-' else 1 for x in s]
``` |
7,417,747 | I have a Business Object Layer that I use in a couple of other applications and I want to use it on my MVC application. My concern is more a design concern: Is it correct to have something like the following:
```
using Interface.MyOtherProject
public class MyMVCController: Controller
{
[HttpGet]
public string ... | 2011/09/14 | [
"https://Stackoverflow.com/questions/7417747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/752527/"
] | When we had to confront this decision, we went with creating view models that encapsulated/mirrored our business objects. This gives us more control over how the objects should look when serialized in json without having to add view logic in our business layer.
Example: Suppose we had a Person business object:
```
p... | I don't see any glaring design concerns here. To address one specific point in the question:
>
> should I do this in the Model instead and return this string directly from the Model
>
>
>
Do you mean should the model provide the JSON-serialized string? I'd say no. The model is just a representation of a business ... |
58,006,435 | So this is a bit of a strange issue that I can't seem to find reference to anywhere online. Was hoping someone here could shed some light on the following, as well as a potential fix -
I have and Angular CLI application which is compliant with Google's PWA requirements. Everything works just as expected, however some ... | 2019/09/19 | [
"https://Stackoverflow.com/questions/58006435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4453661/"
] | Through messing around with a few different things, I found a workaround for this - doesn't explain why it was not working initially though.
It seems that renaming my folder from `admin/images` to `assets/images` and updating the relevant `resource > files paths` got it working.
If anyone stumbled upon some more insi... | I added below line to ngsw-config.json
```
"/runtime*",
"/main*",
"/style*",
"/polyfill*"
```
It looks like this afterwards
```
{
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/runtime*",
"/main*"... |
14,222,817 | how to display the date in this below format using jQuery.
```
Thursday, January 08, 2013
```
I saw some plugins but wondering if there is a way without using any plugin.
Please advise if there is a straightforward answer using JavaScript, that's fine too. | 2013/01/08 | [
"https://Stackoverflow.com/questions/14222817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/287211/"
] | Here's a quick/simple example of what you're asking for:
**EDIT** - I've update the code for reuse and include the day 0 padding change.
```
var d = new Date();
console.log(formatDate(d));
function formatDate(d){
var months = ["Januaray", "February", "March"]; //you would need to include the rest
var days =... | Simply use [**DateJS**](http://www.datejs.com/) not to reinvent the wheel.
You may read the API documentation here:
* <http://code.google.com/p/datejs/wiki/APIDocumentation> |
14,222,817 | how to display the date in this below format using jQuery.
```
Thursday, January 08, 2013
```
I saw some plugins but wondering if there is a way without using any plugin.
Please advise if there is a straightforward answer using JavaScript, that's fine too. | 2013/01/08 | [
"https://Stackoverflow.com/questions/14222817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/287211/"
] | The simplest answer is to use:
```
date.toLocaleDateString()
```
But, it will use the locale defined by the user's system. The American/English locale fitting your desired output. (I'm not sure about other locales and how they format dates).
So, if you want the date string to **always** be in that format, this wil... | Simply use [**DateJS**](http://www.datejs.com/) not to reinvent the wheel.
You may read the API documentation here:
* <http://code.google.com/p/datejs/wiki/APIDocumentation> |
14,222,817 | how to display the date in this below format using jQuery.
```
Thursday, January 08, 2013
```
I saw some plugins but wondering if there is a way without using any plugin.
Please advise if there is a straightforward answer using JavaScript, that's fine too. | 2013/01/08 | [
"https://Stackoverflow.com/questions/14222817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/287211/"
] | Simply use [**DateJS**](http://www.datejs.com/) not to reinvent the wheel.
You may read the API documentation here:
* <http://code.google.com/p/datejs/wiki/APIDocumentation> | The date methods allow you to retrieve all of the different parts of the date and time as numerical values. In the case of the month of the year and the day of the week, the number that is provided is one less than you would normally expect. The reason for this is that the most common use for these values is to use it ... |
14,222,817 | how to display the date in this below format using jQuery.
```
Thursday, January 08, 2013
```
I saw some plugins but wondering if there is a way without using any plugin.
Please advise if there is a straightforward answer using JavaScript, that's fine too. | 2013/01/08 | [
"https://Stackoverflow.com/questions/14222817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/287211/"
] | Here's a quick/simple example of what you're asking for:
**EDIT** - I've update the code for reuse and include the day 0 padding change.
```
var d = new Date();
console.log(formatDate(d));
function formatDate(d){
var months = ["Januaray", "February", "March"]; //you would need to include the rest
var days =... | The simplest answer is to use:
```
date.toLocaleDateString()
```
But, it will use the locale defined by the user's system. The American/English locale fitting your desired output. (I'm not sure about other locales and how they format dates).
So, if you want the date string to **always** be in that format, this wil... |
14,222,817 | how to display the date in this below format using jQuery.
```
Thursday, January 08, 2013
```
I saw some plugins but wondering if there is a way without using any plugin.
Please advise if there is a straightforward answer using JavaScript, that's fine too. | 2013/01/08 | [
"https://Stackoverflow.com/questions/14222817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/287211/"
] | Here's a quick/simple example of what you're asking for:
**EDIT** - I've update the code for reuse and include the day 0 padding change.
```
var d = new Date();
console.log(formatDate(d));
function formatDate(d){
var months = ["Januaray", "February", "March"]; //you would need to include the rest
var days =... | The date methods allow you to retrieve all of the different parts of the date and time as numerical values. In the case of the month of the year and the day of the week, the number that is provided is one less than you would normally expect. The reason for this is that the most common use for these values is to use it ... |
14,222,817 | how to display the date in this below format using jQuery.
```
Thursday, January 08, 2013
```
I saw some plugins but wondering if there is a way without using any plugin.
Please advise if there is a straightforward answer using JavaScript, that's fine too. | 2013/01/08 | [
"https://Stackoverflow.com/questions/14222817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/287211/"
] | The simplest answer is to use:
```
date.toLocaleDateString()
```
But, it will use the locale defined by the user's system. The American/English locale fitting your desired output. (I'm not sure about other locales and how they format dates).
So, if you want the date string to **always** be in that format, this wil... | The date methods allow you to retrieve all of the different parts of the date and time as numerical values. In the case of the month of the year and the day of the week, the number that is provided is one less than you would normally expect. The reason for this is that the most common use for these values is to use it ... |
3,859 | Esiste una forma di voyeurismo alla rovescia in cui si prova piacere a mostrare nudo il proprio partner. In inglese prende nome da [re Candaule di Lidia](http://www.treccani.it/enciclopedia/candaule/) ed è detta *candaulism*. Per l'italiano non trovo la forma corrispondente su alcun dizionario (né inglese-italiano né m... | 2015/01/13 | [
"https://italian.stackexchange.com/questions/3859",
"https://italian.stackexchange.com",
"https://italian.stackexchange.com/users/37/"
] | [Fondamenti di sessuologia](https://books.google.se/books?id=Vys0RazGiJsC&pg=PA338&dq=Candaulismo&hl=en&sa=X&ei=bpHQVLLxGYToaPDNgsAJ&ved=0CDEQ6AEwAw#v=onepage&q=Candaulismo&f=false) di Salvatore Capodieci, Leonardo Boccadoro (Libreriauniversitaria ed., 2012), p.338:
>
> Triolismo, o triolagnia, o candaulismo, parafil... | Cuckoldismo sembra essere un alternativa a candaulesimo/candaulismo. In effetti questi termini sembrano non essere ancora entrati in dizionari di medicina o psicologia.
[Candaulesimo](http://infatti-italiano.it/candaulesimo):
>
> * Il termine candaulesimo indica la pratica umana di tipo sessuale con la quale il sogg... |
3,859 | Esiste una forma di voyeurismo alla rovescia in cui si prova piacere a mostrare nudo il proprio partner. In inglese prende nome da [re Candaule di Lidia](http://www.treccani.it/enciclopedia/candaule/) ed è detta *candaulism*. Per l'italiano non trovo la forma corrispondente su alcun dizionario (né inglese-italiano né m... | 2015/01/13 | [
"https://italian.stackexchange.com/questions/3859",
"https://italian.stackexchange.com",
"https://italian.stackexchange.com/users/37/"
] | [Fondamenti di sessuologia](https://books.google.se/books?id=Vys0RazGiJsC&pg=PA338&dq=Candaulismo&hl=en&sa=X&ei=bpHQVLLxGYToaPDNgsAJ&ved=0CDEQ6AEwAw#v=onepage&q=Candaulismo&f=false) di Salvatore Capodieci, Leonardo Boccadoro (Libreriauniversitaria ed., 2012), p.338:
>
> Triolismo, o triolagnia, o candaulismo, parafil... | *-ismo* e *-esimo* sono solo dei suffissi che hanno lo stesso identico scopo. Quello più antico e usato nella formazione di nuove parole è *-ismo*. Poche sono le eccezioni che usano *-esimo* (cristian-esimo, feudal-esimo).
Per cui, senza sapere cos'abbiano scelto medici-psicologi propenderei per la forma in *-ismo*.
... |
3,859 | Esiste una forma di voyeurismo alla rovescia in cui si prova piacere a mostrare nudo il proprio partner. In inglese prende nome da [re Candaule di Lidia](http://www.treccani.it/enciclopedia/candaule/) ed è detta *candaulism*. Per l'italiano non trovo la forma corrispondente su alcun dizionario (né inglese-italiano né m... | 2015/01/13 | [
"https://italian.stackexchange.com/questions/3859",
"https://italian.stackexchange.com",
"https://italian.stackexchange.com/users/37/"
] | [Fondamenti di sessuologia](https://books.google.se/books?id=Vys0RazGiJsC&pg=PA338&dq=Candaulismo&hl=en&sa=X&ei=bpHQVLLxGYToaPDNgsAJ&ved=0CDEQ6AEwAw#v=onepage&q=Candaulismo&f=false) di Salvatore Capodieci, Leonardo Boccadoro (Libreriauniversitaria ed., 2012), p.338:
>
> Triolismo, o triolagnia, o candaulismo, parafil... | DaG, la tua domanda era "Vorrei solo sapere se in testi medici, articoli scientifici, saggi pubblicati, documenti ufficiali italiani è comparso finora il termine di cui parliamo".
Posso, invece, rispondere solo dal punto di vista di chi appartenga a comunità in cui ciò si pratica. In nessuna discussione scritta ho vis... |
104,982 | I am planning on building a suit of armor and [animating](http://www.d20pfsrd.com/bestiary/monster-listings/constructs/animated-object/#gargantuan) it via [craft construct](http://www.d20pfsrd.com/feats/item-creation-feats/craft-construct-item-creation) and I was looking for ways to make it tougher as I plan on wearing... | 2017/08/09 | [
"https://rpg.stackexchange.com/questions/104982",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/8933/"
] | You cannot apply fortifying stones to a creature.
-------------------------------------------------
While it is true that there are creatures with hardness (see [animated objects](http://www.d20pfsrd.com/bestiary/monster-listings/constructs/animated-object/)), those are no longer objects but [construct creatures](http... | Core page 208: "Bonuses without a type always stack, unless they are from the same source." Here is an obvious example of untyped bonuses from the same source. Thus, they will not stack.
Additionally, there is no particular reason to believe that the Fortifying Stones effect would apply directly to construct stats. Th... |
153,350 | I'm writing a report on the mathematics of GPS, but I'm wondering what methods the GPS actually uses. What I've done is set up the four sphere equations and solve them using the Newton-Raphson method for four variables (using the Jacobian matrix of partial derivatives). But is this what a GPS receiver actually does, wi... | 2015/07/06 | [
"https://gis.stackexchange.com/questions/153350",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/54773/"
] | After some more research, I found the solution [here](http://osgeo-org.1560.x6.nabble.com/Feature-style-doesn-t-support-contexts-td3896881.html).
The `feature.style` property only accepts the symbolizer as hash style. So, we must use the `styleMap` to create a symbolizer for the current feature
```
var highlight = fu... | One other option would be to define a new Style and assign the stroke width...
but the solution you found looks smarter ;)
```
var highlight = function(feature) {
feature.style = new OpenLayers.Style();
feature.style.strokeWidth = 3;
feature.style.fillColor=context.getFillColor(feature);
vector.drawFeature(feature);
... |
40,970,137 | In this snippet it will generate mixed words and numbers randomly but i'm wondering why it always return zero in second character? if you click refresh button it always return 0 in second position. any idea?
```js
$(function() {
var words = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ0123456789abcdefghiklmnopqrstuvwxyz"
... | 2016/12/05 | [
"https://Stackoverflow.com/questions/40970137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4540183/"
] | `i++` will cause the problem . since you are appending `i++` at the end of every character . and loop will also run only `2 times` .
```js
$(function() {
var words = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ0123456789abcdefghiklmnopqrstuvwxyz"
var myLength = 4;
function Captcha() {
$('#Captcha').html("");
... | The reason is because you're appending `i` to the output string. You're also incrementing `i` twice in each iteration. Try this:
```js
$(function() {
var words = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ0123456789abcdefghiklmnopqrstuvwxyz"
var myLength = 4;
function Captcha() {
$('#Captcha').empty();
... |
13,104,494 | Does JavaScript pass by references or pass by values?
Here is an example from *[JavaScript: The Good Parts](https://en.wikipedia.org/wiki/Douglas_Crockford#Bibliography)*. I am very confused about the `my` parameter for the rectangle function. It is actually `undefined`, and redefined inside the function. There are no... | 2012/10/27 | [
"https://Stackoverflow.com/questions/13104494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1778912/"
] | Primitives are passed by value, and Objects are passed by "copy of a reference".
Specifically, when you pass an object (or array) you are (invisibly) passing a reference to that object, and it is possible to modify the *contents* of that object, but if you attempt to overwrite the reference it will not affect the copy... | In the interest of creating a simple example that uses const...
```
const myRef = { foo: 'bar' };
const myVal = true;
function passes(r, v) {
r.foo = 'baz';
v = false;
}
passes(myRef, myVal);
console.log(myRef, myVal); // Object {foo: "baz"} true
``` |
13,104,494 | Does JavaScript pass by references or pass by values?
Here is an example from *[JavaScript: The Good Parts](https://en.wikipedia.org/wiki/Douglas_Crockford#Bibliography)*. I am very confused about the `my` parameter for the rectangle function. It is actually `undefined`, and redefined inside the function. There are no... | 2012/10/27 | [
"https://Stackoverflow.com/questions/13104494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1778912/"
] | JavaScript is pass by value.
For primitives, primitive's value is passed. For Objects, Object's reference "value" is passed.
Example with Object:
```
var f1 = function(inputObject){
inputObject.a = 2;
}
var f2 = function(){
var inputObject = {"a": 1};
f1(inputObject);
console.log(inputObject.a);
}
... | In practical terms, [Alnitak is correct](https://stackoverflow.com/questions/13104494/does-javascript-pass-by-reference/13104500#13104500) and makes it easy to understand, but ultimately in JavaScript, everything is passed by value.
What is the "value" of an object? It is the object reference.
When you pass in an obj... |
13,104,494 | Does JavaScript pass by references or pass by values?
Here is an example from *[JavaScript: The Good Parts](https://en.wikipedia.org/wiki/Douglas_Crockford#Bibliography)*. I am very confused about the `my` parameter for the rectangle function. It is actually `undefined`, and redefined inside the function. There are no... | 2012/10/27 | [
"https://Stackoverflow.com/questions/13104494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1778912/"
] | Think of it like this:
Whenever you create an *object* in ECMAscript, this object is formed in a mystique *ECMAscript universal place* where no man will ever be able to get. All you get back is a *reference* to that object in this mystique place.
```
var obj = { };
```
Even `obj` is only a reference to the object (... | Function arguments are passed either by-value or by-sharing, but never **ever** by reference in JavaScript!
Call-by-Value
-------------
Primitive types are passed by-value:
```js
var num = 123, str = "foo";
function f(num, str) {
num += 1;
str += "bar";
console.log("inside of f:", num, str);
}
f(num, str);
c... |
13,104,494 | Does JavaScript pass by references or pass by values?
Here is an example from *[JavaScript: The Good Parts](https://en.wikipedia.org/wiki/Douglas_Crockford#Bibliography)*. I am very confused about the `my` parameter for the rectangle function. It is actually `undefined`, and redefined inside the function. There are no... | 2012/10/27 | [
"https://Stackoverflow.com/questions/13104494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1778912/"
] | My two cents.... It's irrelevant whether JavaScript passes parameters by reference or value. What really matters is assignment vs. mutation.
I wrote a longer, [more detailed explanation in this link](https://stackoverflow.com/questions/518000/is-javascript-a-pass-by-reference-or-pass-by-value-language/25117245#2511724... | As with C, ultimately, everything is passed by value. Unlike C, you can't actually back up and pass the location of a variable, because it doesn't have pointers, just references.
And the references it has are all to objects, not variables. There are several ways of achieving the same result, but they have to be done b... |
13,104,494 | Does JavaScript pass by references or pass by values?
Here is an example from *[JavaScript: The Good Parts](https://en.wikipedia.org/wiki/Douglas_Crockford#Bibliography)*. I am very confused about the `my` parameter for the rectangle function. It is actually `undefined`, and redefined inside the function. There are no... | 2012/10/27 | [
"https://Stackoverflow.com/questions/13104494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1778912/"
] | Function arguments are passed either by-value or by-sharing, but never **ever** by reference in JavaScript!
Call-by-Value
-------------
Primitive types are passed by-value:
```js
var num = 123, str = "foo";
function f(num, str) {
num += 1;
str += "bar";
console.log("inside of f:", num, str);
}
f(num, str);
c... | JavaScript is pass by value.
For primitives, primitive's value is passed. For Objects, Object's reference "value" is passed.
Example with Object:
```
var f1 = function(inputObject){
inputObject.a = 2;
}
var f2 = function(){
var inputObject = {"a": 1};
f1(inputObject);
console.log(inputObject.a);
}
... |
13,104,494 | Does JavaScript pass by references or pass by values?
Here is an example from *[JavaScript: The Good Parts](https://en.wikipedia.org/wiki/Douglas_Crockford#Bibliography)*. I am very confused about the `my` parameter for the rectangle function. It is actually `undefined`, and redefined inside the function. There are no... | 2012/10/27 | [
"https://Stackoverflow.com/questions/13104494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1778912/"
] | Think of it like this:
Whenever you create an *object* in ECMAscript, this object is formed in a mystique *ECMAscript universal place* where no man will ever be able to get. All you get back is a *reference* to that object in this mystique place.
```
var obj = { };
```
Even `obj` is only a reference to the object (... | JavaScript is pass by value.
For primitives, primitive's value is passed. For Objects, Object's reference "value" is passed.
Example with Object:
```
var f1 = function(inputObject){
inputObject.a = 2;
}
var f2 = function(){
var inputObject = {"a": 1};
f1(inputObject);
console.log(inputObject.a);
}
... |
13,104,494 | Does JavaScript pass by references or pass by values?
Here is an example from *[JavaScript: The Good Parts](https://en.wikipedia.org/wiki/Douglas_Crockford#Bibliography)*. I am very confused about the `my` parameter for the rectangle function. It is actually `undefined`, and redefined inside the function. There are no... | 2012/10/27 | [
"https://Stackoverflow.com/questions/13104494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1778912/"
] | As with C, ultimately, everything is passed by value. Unlike C, you can't actually back up and pass the location of a variable, because it doesn't have pointers, just references.
And the references it has are all to objects, not variables. There are several ways of achieving the same result, but they have to be done b... | Primitives are passed by value. But in case you only need to read the value of a primitve (and value is not known at the time when function is called) you can pass function which retrieves the value at the moment you need it.
```
function test(value) {
console.log('retrieve value');
console.log(value());
}
// cal... |
13,104,494 | Does JavaScript pass by references or pass by values?
Here is an example from *[JavaScript: The Good Parts](https://en.wikipedia.org/wiki/Douglas_Crockford#Bibliography)*. I am very confused about the `my` parameter for the rectangle function. It is actually `undefined`, and redefined inside the function. There are no... | 2012/10/27 | [
"https://Stackoverflow.com/questions/13104494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1778912/"
] | As with C, ultimately, everything is passed by value. Unlike C, you can't actually back up and pass the location of a variable, because it doesn't have pointers, just references.
And the references it has are all to objects, not variables. There are several ways of achieving the same result, but they have to be done b... | "Global" JavaScript variables are members of the window object. You could access the reference as a member of the window object.
```
var v = "initialized";
function byref(ref) {
window[ref] = "changed by ref";
}
byref((function(){for(r in window){if(window[r]===v){return(r);}}})());
// It could also be called like... |
13,104,494 | Does JavaScript pass by references or pass by values?
Here is an example from *[JavaScript: The Good Parts](https://en.wikipedia.org/wiki/Douglas_Crockford#Bibliography)*. I am very confused about the `my` parameter for the rectangle function. It is actually `undefined`, and redefined inside the function. There are no... | 2012/10/27 | [
"https://Stackoverflow.com/questions/13104494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1778912/"
] | Without purisms, I think that the best way to emulate scalar argument by reference in JavaScript is using object, like previous an answer tells.
However, I do a little bit different:
I've made the object assignment inside function call, so one can see the reference parameters near the function call. It increases the ... | Primitives are passed by value. But in case you only need to read the value of a primitve (and value is not known at the time when function is called) you can pass function which retrieves the value at the moment you need it.
```
function test(value) {
console.log('retrieve value');
console.log(value());
}
// cal... |
13,104,494 | Does JavaScript pass by references or pass by values?
Here is an example from *[JavaScript: The Good Parts](https://en.wikipedia.org/wiki/Douglas_Crockford#Bibliography)*. I am very confused about the `my` parameter for the rectangle function. It is actually `undefined`, and redefined inside the function. There are no... | 2012/10/27 | [
"https://Stackoverflow.com/questions/13104494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1778912/"
] | JavaScript is pass by value.
For primitives, primitive's value is passed. For Objects, Object's reference "value" is passed.
Example with Object:
```
var f1 = function(inputObject){
inputObject.a = 2;
}
var f2 = function(){
var inputObject = {"a": 1};
f1(inputObject);
console.log(inputObject.a);
}
... | "Global" JavaScript variables are members of the window object. You could access the reference as a member of the window object.
```
var v = "initialized";
function byref(ref) {
window[ref] = "changed by ref";
}
byref((function(){for(r in window){if(window[r]===v){return(r);}}})());
// It could also be called like... |
17,099,491 | I have a long running multirow update such as:
```
UPDATE T set C1 = calculation(C2) where C1 is NULL
```
If table is large this update may take many seconds or even minutes.
During this time all other queries on this table fail with "database is locked"
after connection timeout expires (currently my timeout is 5 s... | 2013/06/14 | [
"https://Stackoverflow.com/questions/17099491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/894324/"
] | >
> So, it appears that sqlite treats this update as a transaction, which does not make much sense in this case because all rows are independent.
>
>
>
No, that actually makes perfect sense, because you're not executing multiple, independent updates. You're executing a single update statement. The [fine manual](h... | You mentioned poor performance with LIMIT. Do you have a lastupdated column with an index on it? At the top of your procedure you would get the COMMENCED\_DATETIME and use it for every batch in the run:
```
update foo
set myvalue = 'x', lastupdated = UPDATE_COMMENCED
where id in
(
select id from foo where lastupdated ... |
17,099,491 | I have a long running multirow update such as:
```
UPDATE T set C1 = calculation(C2) where C1 is NULL
```
If table is large this update may take many seconds or even minutes.
During this time all other queries on this table fail with "database is locked"
after connection timeout expires (currently my timeout is 5 s... | 2013/06/14 | [
"https://Stackoverflow.com/questions/17099491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/894324/"
] | >
> So, it appears that sqlite treats this update as a transaction, which does not make much sense in this case because all rows are independent.
>
>
>
No, that actually makes perfect sense, because you're not executing multiple, independent updates. You're executing a single update statement. The [fine manual](h... | I also posted this question at
<http://thread.gmane.org/gmane.comp.db.sqlite.general/81946>
and got several interesting answers, such as:
* divide range of rowid into slices and update one slice at a time
* use AUTOINCREMENT feature to start new update at the place where the previous update ended (by LIMIT 10000)
* cr... |
65,779,401 | I want to create something like this on Swift It's for Alamofire json parse
```js
interface Question {
value: string;
data: [string]
}
interface Advice {
type: string;
data: { value: string }
}
interface CurrentItem {
type: string;
data: Advice | Question | string
}
``` | 2021/01/18 | [
"https://Stackoverflow.com/questions/65779401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14421893/"
] | Use an enum with associated values to represent the different possibilities:
```
enum Data {
case advice (Advice)
case question (Question)
case string (String)
}
```
You can then create your CurrentItem as a Struct
```
struct CurrentItem {
type: String
data: Data
}
```
If you're decoding from JSON you'l... | I think in Swift the way you'd handle a union type like this is with protocols.
```
struct Test {
var value: MyProtocol
}
```
(Note I put `struct` but it can be whatever type of object you need.)
Where `Type1`, `Type2` and `Type3` conform to some shared protocol. Either by construction, or they can be extended ... |
34,879,243 | I got this problem: I found a very cool pen on codepen, I take it, modified, but when I put this in my html page doesn't work with other divs.
Here the pen <https://jsfiddle.net/jtz21sz3/>
```
<canvas id="stage" width="400" height="400">
<p>Your browser doesn't support canvas.</p>
</canvas>
```
everything wo... | 2016/01/19 | [
"https://Stackoverflow.com/questions/34879243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4627712/"
] | Excel's COM interface speaks American so you need to use the US list separators in the formula strings. replace your semicolons with commas and you should be fine.
```
Range rng = activeWorksheet.get_Range("A1");
rng.FormulaArray = "=SUM(A4*C4,A5*C5,A6*C6,A7*C7)/SUM(A4:A7)";
``` | You need to update your formula to an array formula using the FormulaArray property of the range object, using { } and an R1C1 reference.
* <https://msdn.microsoft.com/en-us/library/office/ff837104.aspx>
>
> "=SUM(R4C1\*R4C3;R5C1\*R5C3;R6C1\*R6C3;R7C1\*R7C3)/SUM(R4C1:R7C1)"
>
>
> |
414,783 | I have a file that contains more than 4000 characters and I want to grep the string between the position 148 and 1824. How can I do this? | 2018/01/04 | [
"https://unix.stackexchange.com/questions/414783",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/268827/"
] | You don't use grep. There is a tool that has been designed for precisely this sort of thing: `cut`. To get characters 148 to 1824, do:
```
cut -c 148-1824 file
```
The `-c` flag means select characters. Use `-b` if you want to work on bytes.
If you insist on using `grep`, you would have to do something like this (... | The command below will do the same. I tested it and it works fine. It extracts all characters from the 148th to the 1824th position.
```
awk '{print substr($0,148,1676)}' filename
```
`substr($0,148,1676)}` will take a substring of the current line (`$0`), starting at the 148th character and continuing until the cha... |
414,783 | I have a file that contains more than 4000 characters and I want to grep the string between the position 148 and 1824. How can I do this? | 2018/01/04 | [
"https://unix.stackexchange.com/questions/414783",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/268827/"
] | You don't use grep. There is a tool that has been designed for precisely this sort of thing: `cut`. To get characters 148 to 1824, do:
```
cut -c 148-1824 file
```
The `-c` flag means select characters. Use `-b` if you want to work on bytes.
If you insist on using `grep`, you would have to do something like this (... | To "grep" against a subsection of each line in a file, use awk to extract that subsection and then compare that section against your regular expression.
A simplified example:
```
$ cat input
junkjeffjunk
$ awk '{ piece=substr($0, 5, 4); if (piece ~ /jeff/) print piece; }' input
jeff
```
For your case:
```
awk '{ ... |
414,783 | I have a file that contains more than 4000 characters and I want to grep the string between the position 148 and 1824. How can I do this? | 2018/01/04 | [
"https://unix.stackexchange.com/questions/414783",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/268827/"
] | The command below will do the same. I tested it and it works fine. It extracts all characters from the 148th to the 1824th position.
```
awk '{print substr($0,148,1676)}' filename
```
`substr($0,148,1676)}` will take a substring of the current line (`$0`), starting at the 148th character and continuing until the cha... | To "grep" against a subsection of each line in a file, use awk to extract that subsection and then compare that section against your regular expression.
A simplified example:
```
$ cat input
junkjeffjunk
$ awk '{ piece=substr($0, 5, 4); if (piece ~ /jeff/) print piece; }' input
jeff
```
For your case:
```
awk '{ ... |
73,143,408 | I have the input like this
```
8.8.8.8,678,fog,hat
8.8.4.4,5674,rat,fruit
www.google.com,1234,can,zone
```
I want to split this input in Python so that only the IP address needs to be fetched which I will use for PING purpose. I really appreciate your help in this regard. | 2022/07/27 | [
"https://Stackoverflow.com/questions/73143408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15471384/"
] | This will preferentially select Approved, then Pending, then everything else. If you don't want "everything else" just filter in the WHERE clause.
```
select id,
name,
date,
status
from (
select *,
row_number() over
( partition by id
... | It could also be as easy as the following (provided status is not blank or null)
```
Select Top 1 with ties *
from YourTable
order by row_number() over (partition by id order by Status)
```
**Results**
```
ID NAME DATE STATUS
1 Joe 01-22 Approved
2 Bill 02-22 Approved
3 John 01-22 A... |
831,810 | My database has a parent table with an auto-incrementing primary key identity 'ID', and a normal 'TIMESTAMP column'. I have child tables with a foreign key that refer to the parent 'ID' column.
I want to write a stored procedure that inserts a new column into both the parent and child databases. How would I set the c... | 2009/05/06 | [
"https://Stackoverflow.com/questions/831810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85170/"
] | You can retrieve it from SCOPE\_IDENTITY(). For example:
```
declare @myid int
INSERT INTO table (field) VALUES ('value')
SELECT @myid = SCOPE_IDENTITY()
``` | select scope\_identity(); |
45,021,644 | I have a bunch of websites running on a single instance of Azure App Service, and they're all set to Always On. They all suddenly restarted at the same time, causing everything to go slow for a few minutes as everything hit a cold request.
I would expect this if the service had moved me to a new host, but that didn't... | 2017/07/10 | [
"https://Stackoverflow.com/questions/45021644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32187/"
] | So, it seems the answer to this is "no, you can't really know *why*, you can just infer that it *did*."
I mean, you can add some Application Insights logging like
```
private void Application_End()
{
log.Warn($"The application is shutting down because of '{HostingEnvironment.ShutdownReason}'.");
... | If your service restarted due to OutOfMemoryExceptions Application\_End might not run due to the app crashing.
We moved our ASP.NET 4.8 MVC 5 app to Azure App Services (with windows containers) and were faced with OOMs once we went live. Application crashes were so severe that the Application\_End event was not able t... |
19,220,177 | I need help with writing a regular expression for the following rules:
1. White spaces aren't allowed.
2. The only case where white spaces are allowed is inside brackets `[]`.
I have came up with this expression:
```
[^(\\[\s\\])]
```
But in this case each of the chars: `[`, white space, and `]` is not allowed sep... | 2013/10/07 | [
"https://Stackoverflow.com/questions/19220177",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2853840/"
] | I changed your method `change` a bit to make it work.
From Plunker you can see that on *master* change all children still have old value. So I added `onMasterChange` method
**HTML**
```
<input type="checkbox"
ng-model="master"
ng-change="onMasterChange(master)"></input>
```
I created as default: `$... | It is working, but I believe ng-model is taking precedence over ng-checked. If you remove ng-model from the checkboxes, ng-checked is working as expected.
```
<input type="checkbox" ng-checked="master"></input>
```
<http://plnkr.co/edit/q35JlhOVSGxmu6QW8e98?p=preview>
It is important to note, however, that ng-c... |
353,639 | My university department has a local DNS server that serves all of the computers in the department. I am concerned about the privacy and security implications of this. Posit that I am merely one of the users on a workstation, with no privileged access to the DNS server, or any HTTP proxy.
* Can I make use of the DNS s... | 2012/01/25 | [
"https://serverfault.com/questions/353639",
"https://serverfault.com",
"https://serverfault.com/users/108319/"
] | There's no standard way to query NIC teaming configuration because this is done with proprietary driver-based mechanisms. Broadcom drivers, for example, do it differently than Intel drivers. You'd probably end up needing to parse the proprietary configuration information these drivers store in the registry in order to ... | Wouldn't it make more sense to use a monitoring solution like Nagios? Take a look at <http://nagios.sourceforge.net/docs/3_0/monitoring-windows.html>.
Besides, if this is a brandname server, monitoring can be done using the vendor-provided applications, like Dell OMSA with IT-Assistant for example. |
353,639 | My university department has a local DNS server that serves all of the computers in the department. I am concerned about the privacy and security implications of this. Posit that I am merely one of the users on a workstation, with no privileged access to the DNS server, or any HTTP proxy.
* Can I make use of the DNS s... | 2012/01/25 | [
"https://serverfault.com/questions/353639",
"https://serverfault.com",
"https://serverfault.com/users/108319/"
] | Use the GWMI commandlet in powershell. You can use a -computername parameter to specify the remote machines. I believe the two namespaces you'll want to play with are Win32\_NetworkAdapterConfiguration
Win32\_NetworkAdapterSetting | Wouldn't it make more sense to use a monitoring solution like Nagios? Take a look at <http://nagios.sourceforge.net/docs/3_0/monitoring-windows.html>.
Besides, if this is a brandname server, monitoring can be done using the vendor-provided applications, like Dell OMSA with IT-Assistant for example. |
353,639 | My university department has a local DNS server that serves all of the computers in the department. I am concerned about the privacy and security implications of this. Posit that I am merely one of the users on a workstation, with no privileged access to the DNS server, or any HTTP proxy.
* Can I make use of the DNS s... | 2012/01/25 | [
"https://serverfault.com/questions/353639",
"https://serverfault.com",
"https://serverfault.com/users/108319/"
] | There's no standard way to query NIC teaming configuration because this is done with proprietary driver-based mechanisms. Broadcom drivers, for example, do it differently than Intel drivers. You'd probably end up needing to parse the proprietary configuration information these drivers store in the registry in order to ... | this links may help you.
<http://technet.microsoft.com/en-us/library/bb726987.aspx>
<http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=8781> |
353,639 | My university department has a local DNS server that serves all of the computers in the department. I am concerned about the privacy and security implications of this. Posit that I am merely one of the users on a workstation, with no privileged access to the DNS server, or any HTTP proxy.
* Can I make use of the DNS s... | 2012/01/25 | [
"https://serverfault.com/questions/353639",
"https://serverfault.com",
"https://serverfault.com/users/108319/"
] | There's no standard way to query NIC teaming configuration because this is done with proprietary driver-based mechanisms. Broadcom drivers, for example, do it differently than Intel drivers. You'd probably end up needing to parse the proprietary configuration information these drivers store in the registry in order to ... | Use the GWMI commandlet in powershell. You can use a -computername parameter to specify the remote machines. I believe the two namespaces you'll want to play with are Win32\_NetworkAdapterConfiguration
Win32\_NetworkAdapterSetting |
353,639 | My university department has a local DNS server that serves all of the computers in the department. I am concerned about the privacy and security implications of this. Posit that I am merely one of the users on a workstation, with no privileged access to the DNS server, or any HTTP proxy.
* Can I make use of the DNS s... | 2012/01/25 | [
"https://serverfault.com/questions/353639",
"https://serverfault.com",
"https://serverfault.com/users/108319/"
] | Use the GWMI commandlet in powershell. You can use a -computername parameter to specify the remote machines. I believe the two namespaces you'll want to play with are Win32\_NetworkAdapterConfiguration
Win32\_NetworkAdapterSetting | this links may help you.
<http://technet.microsoft.com/en-us/library/bb726987.aspx>
<http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=8781> |
39,045,211 | When using the Microsoft Dynamics CRM Online 2016 OData API, I ran into a problem
creating a task/phonecall with statecode equal to completed.
Problem Description:
1. create a phone call entity with statecode=1 (Completed)
statuscode=2 (Made)
same idea with task (constants defined [here](https://technet.microsoft.... | 2016/08/19 | [
"https://Stackoverflow.com/questions/39045211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1271991/"
] | The best Moq can do in this case is create a proxy as a derived class of `Jeep` but it cannot override the non-virtual `Type` property. Remember that when you attempt to create a Mock with Moq, the framework generates a class that either implements the target interface or derives from the target class.
[Microsoft Fake... | Since this is a rather generalized question, I'm going to suggest a different approach. Mocking / Faking / Stubbing a class or interface that you don't control is generally difficult. Furthermore, this typically leads to replicating someone else's functionality in your mock instance.
A better approach is to isolate in... |
39,045,211 | When using the Microsoft Dynamics CRM Online 2016 OData API, I ran into a problem
creating a task/phonecall with statecode equal to completed.
Problem Description:
1. create a phone call entity with statecode=1 (Completed)
statuscode=2 (Made)
same idea with task (constants defined [here](https://technet.microsoft.... | 2016/08/19 | [
"https://Stackoverflow.com/questions/39045211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1271991/"
] | The best Moq can do in this case is create a proxy as a derived class of `Jeep` but it cannot override the non-virtual `Type` property. Remember that when you attempt to create a Mock with Moq, the framework generates a class that either implements the target interface or derives from the target class.
[Microsoft Fake... | >
> So my question is: is there a way to setup the Type property when mocking the Jeep class?
>
>
>
The short answer is no, you cannot Mock a non virtual member using Moq.
However, I don't think there's any reason in this case to mock anything, since there isn't any behaviour to mock. The only member you have the... |
39,045,211 | When using the Microsoft Dynamics CRM Online 2016 OData API, I ran into a problem
creating a task/phonecall with statecode equal to completed.
Problem Description:
1. create a phone call entity with statecode=1 (Completed)
statuscode=2 (Made)
same idea with task (constants defined [here](https://technet.microsoft.... | 2016/08/19 | [
"https://Stackoverflow.com/questions/39045211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1271991/"
] | The best Moq can do in this case is create a proxy as a derived class of `Jeep` but it cannot override the non-virtual `Type` property. Remember that when you attempt to create a Mock with Moq, the framework generates a class that either implements the target interface or derives from the target class.
[Microsoft Fake... | disclaimer: I work at Typemock.
By using [Typemock Isolator](http://www.typemock.com/) you will be able to mock non-virtual methods and won't need to change your code in order to do so, in this specific example you can fake an instance of `Jeep` and then modify his methods behavior.
Here is an example for a test that... |
39,045,211 | When using the Microsoft Dynamics CRM Online 2016 OData API, I ran into a problem
creating a task/phonecall with statecode equal to completed.
Problem Description:
1. create a phone call entity with statecode=1 (Completed)
statuscode=2 (Made)
same idea with task (constants defined [here](https://technet.microsoft.... | 2016/08/19 | [
"https://Stackoverflow.com/questions/39045211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1271991/"
] | Since this is a rather generalized question, I'm going to suggest a different approach. Mocking / Faking / Stubbing a class or interface that you don't control is generally difficult. Furthermore, this typically leads to replicating someone else's functionality in your mock instance.
A better approach is to isolate in... | >
> So my question is: is there a way to setup the Type property when mocking the Jeep class?
>
>
>
The short answer is no, you cannot Mock a non virtual member using Moq.
However, I don't think there's any reason in this case to mock anything, since there isn't any behaviour to mock. The only member you have the... |
39,045,211 | When using the Microsoft Dynamics CRM Online 2016 OData API, I ran into a problem
creating a task/phonecall with statecode equal to completed.
Problem Description:
1. create a phone call entity with statecode=1 (Completed)
statuscode=2 (Made)
same idea with task (constants defined [here](https://technet.microsoft.... | 2016/08/19 | [
"https://Stackoverflow.com/questions/39045211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1271991/"
] | Since this is a rather generalized question, I'm going to suggest a different approach. Mocking / Faking / Stubbing a class or interface that you don't control is generally difficult. Furthermore, this typically leads to replicating someone else's functionality in your mock instance.
A better approach is to isolate in... | disclaimer: I work at Typemock.
By using [Typemock Isolator](http://www.typemock.com/) you will be able to mock non-virtual methods and won't need to change your code in order to do so, in this specific example you can fake an instance of `Jeep` and then modify his methods behavior.
Here is an example for a test that... |
24,243,738 | I need to deserialize json for following class.
```
public class Test
{
public string Property { get; set; }
private Test()
{
//NOTHING TO INITIALIZE
}
public Test(string prop)
{
Property = prop;
}
}
```
I can create an instance of Test like
```
var instance = new Test... | 2014/06/16 | [
"https://Stackoverflow.com/questions/24243738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/203262/"
] | You can make Json.Net call the private constructor by marking it with a `[JsonConstructor]` attribute:
```
[JsonConstructor]
private Test()
{
//NOTHING TO INITIALIZE
}
```
Note that the serializer will still use the public setters to populate the object after calling the constructor.
---
Another possible optio... | It doesn't seem like you need to take any extra steps.
Using Json.NET v6.0.8, the following C# program works inside LINQPad:
```
void Main()
{
var o = JsonConvert.DeserializeObject<Test>("{\"Property\":\"Instance\"}");
Debug.Assert(o.Property == "Instance",
"Property value not set when deserializi... |
24,243,738 | I need to deserialize json for following class.
```
public class Test
{
public string Property { get; set; }
private Test()
{
//NOTHING TO INITIALIZE
}
public Test(string prop)
{
Property = prop;
}
}
```
I can create an instance of Test like
```
var instance = new Test... | 2014/06/16 | [
"https://Stackoverflow.com/questions/24243738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/203262/"
] | You can make Json.Net call the private constructor by marking it with a `[JsonConstructor]` attribute:
```
[JsonConstructor]
private Test()
{
//NOTHING TO INITIALIZE
}
```
Note that the serializer will still use the public setters to populate the object after calling the constructor.
---
Another possible optio... | No need to create a Serializer setting and give assign ConstructorHandling here. Please remember to define the `[JsonConstructor]` attribute to the private constructor.
I have similar case with abstract BaseNode.cs and its concrete ComputerNode.cs implementation. You can create the classes, copy/paste the code below an... |
24,243,738 | I need to deserialize json for following class.
```
public class Test
{
public string Property { get; set; }
private Test()
{
//NOTHING TO INITIALIZE
}
public Test(string prop)
{
Property = prop;
}
}
```
I can create an instance of Test like
```
var instance = new Test... | 2014/06/16 | [
"https://Stackoverflow.com/questions/24243738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/203262/"
] | You can make Json.Net call the private constructor by marking it with a `[JsonConstructor]` attribute:
```
[JsonConstructor]
private Test()
{
//NOTHING TO INITIALIZE
}
```
Note that the serializer will still use the public setters to populate the object after calling the constructor.
---
Another possible optio... | Today the short answer is: Rename the constructor parameter `prop` to `property` and your code will work fine.
```cs
public class Test
{
public string Property { get; }
public Test(string property)
{
Property = property;
}
}
Console.WriteLine(
JsonConvert.DeserializeObject(new Test("Instanc... |
24,243,738 | I need to deserialize json for following class.
```
public class Test
{
public string Property { get; set; }
private Test()
{
//NOTHING TO INITIALIZE
}
public Test(string prop)
{
Property = prop;
}
}
```
I can create an instance of Test like
```
var instance = new Test... | 2014/06/16 | [
"https://Stackoverflow.com/questions/24243738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/203262/"
] | You can make Json.Net call the private constructor by marking it with a `[JsonConstructor]` attribute:
```
[JsonConstructor]
private Test()
{
//NOTHING TO INITIALIZE
}
```
Note that the serializer will still use the public setters to populate the object after calling the constructor.
---
Another possible optio... | I discovered today that having a **public** constructor *that takes parameters* and no ***declared*** unparameterized constructor causes NewtonSoft to attempt to call the public constructor, the only one that it can find, since there is no explicit default constructor, and it cannot apparently find and call the default... |
24,243,738 | I need to deserialize json for following class.
```
public class Test
{
public string Property { get; set; }
private Test()
{
//NOTHING TO INITIALIZE
}
public Test(string prop)
{
Property = prop;
}
}
```
I can create an instance of Test like
```
var instance = new Test... | 2014/06/16 | [
"https://Stackoverflow.com/questions/24243738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/203262/"
] | It doesn't seem like you need to take any extra steps.
Using Json.NET v6.0.8, the following C# program works inside LINQPad:
```
void Main()
{
var o = JsonConvert.DeserializeObject<Test>("{\"Property\":\"Instance\"}");
Debug.Assert(o.Property == "Instance",
"Property value not set when deserializi... | Today the short answer is: Rename the constructor parameter `prop` to `property` and your code will work fine.
```cs
public class Test
{
public string Property { get; }
public Test(string property)
{
Property = property;
}
}
Console.WriteLine(
JsonConvert.DeserializeObject(new Test("Instanc... |
24,243,738 | I need to deserialize json for following class.
```
public class Test
{
public string Property { get; set; }
private Test()
{
//NOTHING TO INITIALIZE
}
public Test(string prop)
{
Property = prop;
}
}
```
I can create an instance of Test like
```
var instance = new Test... | 2014/06/16 | [
"https://Stackoverflow.com/questions/24243738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/203262/"
] | It doesn't seem like you need to take any extra steps.
Using Json.NET v6.0.8, the following C# program works inside LINQPad:
```
void Main()
{
var o = JsonConvert.DeserializeObject<Test>("{\"Property\":\"Instance\"}");
Debug.Assert(o.Property == "Instance",
"Property value not set when deserializi... | I discovered today that having a **public** constructor *that takes parameters* and no ***declared*** unparameterized constructor causes NewtonSoft to attempt to call the public constructor, the only one that it can find, since there is no explicit default constructor, and it cannot apparently find and call the default... |
24,243,738 | I need to deserialize json for following class.
```
public class Test
{
public string Property { get; set; }
private Test()
{
//NOTHING TO INITIALIZE
}
public Test(string prop)
{
Property = prop;
}
}
```
I can create an instance of Test like
```
var instance = new Test... | 2014/06/16 | [
"https://Stackoverflow.com/questions/24243738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/203262/"
] | No need to create a Serializer setting and give assign ConstructorHandling here. Please remember to define the `[JsonConstructor]` attribute to the private constructor.
I have similar case with abstract BaseNode.cs and its concrete ComputerNode.cs implementation. You can create the classes, copy/paste the code below an... | Today the short answer is: Rename the constructor parameter `prop` to `property` and your code will work fine.
```cs
public class Test
{
public string Property { get; }
public Test(string property)
{
Property = property;
}
}
Console.WriteLine(
JsonConvert.DeserializeObject(new Test("Instanc... |
24,243,738 | I need to deserialize json for following class.
```
public class Test
{
public string Property { get; set; }
private Test()
{
//NOTHING TO INITIALIZE
}
public Test(string prop)
{
Property = prop;
}
}
```
I can create an instance of Test like
```
var instance = new Test... | 2014/06/16 | [
"https://Stackoverflow.com/questions/24243738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/203262/"
] | No need to create a Serializer setting and give assign ConstructorHandling here. Please remember to define the `[JsonConstructor]` attribute to the private constructor.
I have similar case with abstract BaseNode.cs and its concrete ComputerNode.cs implementation. You can create the classes, copy/paste the code below an... | I discovered today that having a **public** constructor *that takes parameters* and no ***declared*** unparameterized constructor causes NewtonSoft to attempt to call the public constructor, the only one that it can find, since there is no explicit default constructor, and it cannot apparently find and call the default... |
24,243,738 | I need to deserialize json for following class.
```
public class Test
{
public string Property { get; set; }
private Test()
{
//NOTHING TO INITIALIZE
}
public Test(string prop)
{
Property = prop;
}
}
```
I can create an instance of Test like
```
var instance = new Test... | 2014/06/16 | [
"https://Stackoverflow.com/questions/24243738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/203262/"
] | Today the short answer is: Rename the constructor parameter `prop` to `property` and your code will work fine.
```cs
public class Test
{
public string Property { get; }
public Test(string property)
{
Property = property;
}
}
Console.WriteLine(
JsonConvert.DeserializeObject(new Test("Instanc... | I discovered today that having a **public** constructor *that takes parameters* and no ***declared*** unparameterized constructor causes NewtonSoft to attempt to call the public constructor, the only one that it can find, since there is no explicit default constructor, and it cannot apparently find and call the default... |
38,119,661 | I am working on an application where I'm using AppBarLayout with CollapsingToolbarLayout and NestedScrollView. I have successfully implemented this and it is working fine.
Now what i am trying to do is, that on fling(fast swipe up) on the Nestedscrollview it should scroll completely to top. Similarly, on fling(fast sw... | 2016/06/30 | [
"https://Stackoverflow.com/questions/38119661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4298789/"
] | When i was burning my midnight oil this library came like batman
<https://github.com/henrytao-me/smooth-app-bar-layout>
According to which the behavior can be improved by following these steps:
1.Change
```
android.support.design.widget.AppBarLayout
```
to
```
me.henrytao.smoothappbarlayout.SmoothAppBarLayou... | Use support-library 26.0.1 version.
This problem has been solved by google from the support library after version 26.0.0
<https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-1> |
288,063 | I was just migrated from a Windows machine to an Apple, which I was told would be seamless, but it's pretty seamy...
My tech (i.e., husband) told me I should drag-and-drop icons to the desktop to create a shortcut, since there's no dropdown-menu item saying "create shortcut." However, all that did was move the file ou... | 2017/06/26 | [
"https://apple.stackexchange.com/questions/288063",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/-1/"
] | Drag an app to the desktop, and hold both `command` and `option` while you release it. This will create a shortcut much like those on Windows.
You can also try activating Spotlight (Apple's name for the search functionality) by pressing `command + space`. You can then type the first letters of the name of the app you ... | If you press Ctrl while clicking in Finder, you will see an option "Create Alias" this is the shortcut you're talking about. It will be created in the same folder you are in at the moment. After you have this, you can drag it to your Desktop. |
21,161,430 | Is any convinient way to dynamically render some page inside application and then retrieve its contents as `InputStream` or `String`?
For example, the simplest way is:
```
// generate url
Link link = linkSource.createPageRenderLink("SomePageLink");
String urlAsString = link.toAbsoluteURI() + "... | 2014/01/16 | [
"https://Stackoverflow.com/questions/21161430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1479414/"
] | A linked list is not a good data structure for the open set. You have to find the node with the smallest F from it, you can either search through the list in O(n) or insert in sorted position in O(n), either way it's O(n). With a heap it's only O(log n). Updating the G score would remain O(n) (since you have to find th... | 1. Find bottlenecks of your implementation using profiler . [ex. jprofiler is easy to use](http://java.dzone.com/articles/jprofiler-your-java-code-could)
2. Use threads in areas where algorithm can run simultaneously.
3. Profile your JavaVM to run faster.
[Allocate more RAM](http://www.wikihow.com/Allocate-More-RAM-to-... |
21,161,430 | Is any convinient way to dynamically render some page inside application and then retrieve its contents as `InputStream` or `String`?
For example, the simplest way is:
```
// generate url
Link link = linkSource.createPageRenderLink("SomePageLink");
String urlAsString = link.toAbsoluteURI() + "... | 2014/01/16 | [
"https://Stackoverflow.com/questions/21161430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1479414/"
] | A linked list is not a good data structure for the open set. You have to find the node with the smallest F from it, you can either search through the list in O(n) or insert in sorted position in O(n), either way it's O(n). With a heap it's only O(log n). Updating the G score would remain O(n) (since you have to find th... | a) As mentioned, you should use a heap in A\* - either a basic binary heap or a pairing heap which should be theoretically faster.
b) In larger maps, it always happens that you need some time for the algorithm to run (i.e., when you request a path, it will simply have to take some time). What can be done is to use som... |
21,161,430 | Is any convinient way to dynamically render some page inside application and then retrieve its contents as `InputStream` or `String`?
For example, the simplest way is:
```
// generate url
Link link = linkSource.createPageRenderLink("SomePageLink");
String urlAsString = link.toAbsoluteURI() + "... | 2014/01/16 | [
"https://Stackoverflow.com/questions/21161430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1479414/"
] | You can optimize the problem by using a different algorithm, the following page illustrates and compares many different aglorihms and heuristics:
* A\*
* IDA\*
* Djikstra
* JumpPoint
* ...
<http://qiao.github.io/PathFinding.js/visual/>
 | From your implementation it seems that you are using naive A\* algorithm. Use following way:-
>
> 1. A\* is algorithm which is implemented using priority queue similar to BFS.
> 2. Heuristic function is evaluated at each node to define its fitness to be selected as next node to be visited.
> 3. As new node is visited... |
21,161,430 | Is any convinient way to dynamically render some page inside application and then retrieve its contents as `InputStream` or `String`?
For example, the simplest way is:
```
// generate url
Link link = linkSource.createPageRenderLink("SomePageLink");
String urlAsString = link.toAbsoluteURI() + "... | 2014/01/16 | [
"https://Stackoverflow.com/questions/21161430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1479414/"
] | You can optimize the problem by using a different algorithm, the following page illustrates and compares many different aglorihms and heuristics:
* A\*
* IDA\*
* Djikstra
* JumpPoint
* ...
<http://qiao.github.io/PathFinding.js/visual/>
 | a) As mentioned, you should use a heap in A\* - either a basic binary heap or a pairing heap which should be theoretically faster.
b) In larger maps, it always happens that you need some time for the algorithm to run (i.e., when you request a path, it will simply have to take some time). What can be done is to use som... |
21,161,430 | Is any convinient way to dynamically render some page inside application and then retrieve its contents as `InputStream` or `String`?
For example, the simplest way is:
```
// generate url
Link link = linkSource.createPageRenderLink("SomePageLink");
String urlAsString = link.toAbsoluteURI() + "... | 2014/01/16 | [
"https://Stackoverflow.com/questions/21161430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1479414/"
] | A linked list is not a good data structure for the open set. You have to find the node with the smallest F from it, you can either search through the list in O(n) or insert in sorted position in O(n), either way it's O(n). With a heap it's only O(log n). Updating the G score would remain O(n) (since you have to find th... | I built a new pathfinding algorithm. called Fast\* or Fastaer, It is a BFS like A\* but is faster and efficient than A\*, the accuracy is 90% A\*. please see this link for info and demo.
<https://drbendanilloportfolio.wordpress.com/2015/08/14/fastaer-pathfinder/>
It has a fast greedy line tracer, to make path straig... |
21,161,430 | Is any convinient way to dynamically render some page inside application and then retrieve its contents as `InputStream` or `String`?
For example, the simplest way is:
```
// generate url
Link link = linkSource.createPageRenderLink("SomePageLink");
String urlAsString = link.toAbsoluteURI() + "... | 2014/01/16 | [
"https://Stackoverflow.com/questions/21161430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1479414/"
] | You can optimize the problem by using a different algorithm, the following page illustrates and compares many different aglorihms and heuristics:
* A\*
* IDA\*
* Djikstra
* JumpPoint
* ...
<http://qiao.github.io/PathFinding.js/visual/>
 | I built a new pathfinding algorithm. called Fast\* or Fastaer, It is a BFS like A\* but is faster and efficient than A\*, the accuracy is 90% A\*. please see this link for info and demo.
<https://drbendanilloportfolio.wordpress.com/2015/08/14/fastaer-pathfinder/>
It has a fast greedy line tracer, to make path straig... |
21,161,430 | Is any convinient way to dynamically render some page inside application and then retrieve its contents as `InputStream` or `String`?
For example, the simplest way is:
```
// generate url
Link link = linkSource.createPageRenderLink("SomePageLink");
String urlAsString = link.toAbsoluteURI() + "... | 2014/01/16 | [
"https://Stackoverflow.com/questions/21161430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1479414/"
] | You can optimize the problem by using a different algorithm, the following page illustrates and compares many different aglorihms and heuristics:
* A\*
* IDA\*
* Djikstra
* JumpPoint
* ...
<http://qiao.github.io/PathFinding.js/visual/>
 | 1. Find bottlenecks of your implementation using profiler . [ex. jprofiler is easy to use](http://java.dzone.com/articles/jprofiler-your-java-code-could)
2. Use threads in areas where algorithm can run simultaneously.
3. Profile your JavaVM to run faster.
[Allocate more RAM](http://www.wikihow.com/Allocate-More-RAM-to-... |
21,161,430 | Is any convinient way to dynamically render some page inside application and then retrieve its contents as `InputStream` or `String`?
For example, the simplest way is:
```
// generate url
Link link = linkSource.createPageRenderLink("SomePageLink");
String urlAsString = link.toAbsoluteURI() + "... | 2014/01/16 | [
"https://Stackoverflow.com/questions/21161430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1479414/"
] | From your implementation it seems that you are using naive A\* algorithm. Use following way:-
>
> 1. A\* is algorithm which is implemented using priority queue similar to BFS.
> 2. Heuristic function is evaluated at each node to define its fitness to be selected as next node to be visited.
> 3. As new node is visited... | a) As mentioned, you should use a heap in A\* - either a basic binary heap or a pairing heap which should be theoretically faster.
b) In larger maps, it always happens that you need some time for the algorithm to run (i.e., when you request a path, it will simply have to take some time). What can be done is to use som... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.