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 |
|---|---|---|---|---|---|
10,920,255 | I have a custom TextBox on a standard Windows Form. In OnLeave() of the TextBox, I am trying to find out the value of a particular custom string property added to the form in its constructor;
Form constructor;
```
public partial class FormName : Form
{
public string psTableName { get; set; }
```
TextBox OnLeave... | 2012/06/06 | [
"https://Stackoverflow.com/questions/10920255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1440549/"
] | You can do so like this:
```
FormName form = this.FindForm() as FormName;
if (form != null)
{
string psTableName = form.psTablename;
}
```
However, that's typically bad practice. Usually, you don't want a UserControl to assume that it's parent form is of a particular type. It would be better to make a public tab... | Does this achieve what you are looking for?
```
protected override void OnLeave(EventArgs e)
{
string x = this.psTableName;
}
``` |
10,920,255 | I have a custom TextBox on a standard Windows Form. In OnLeave() of the TextBox, I am trying to find out the value of a particular custom string property added to the form in its constructor;
Form constructor;
```
public partial class FormName : Form
{
public string psTableName { get; set; }
```
TextBox OnLeave... | 2012/06/06 | [
"https://Stackoverflow.com/questions/10920255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1440549/"
] | As suggested by Devin, this kind of code solves your problem:
```
(this.FindForm() as FormName).psTablename
```
But I think that this is not what you really want. In fact, this works only when your custom TextBox is used in FormName, or in a Form derived from FormName, since `this.FindForm() as FormName` would retur... | Does this achieve what you are looking for?
```
protected override void OnLeave(EventArgs e)
{
string x = this.psTableName;
}
``` |
19,916,170 | Hi I need to understand what is the time complexity of the following algorithm.
```
def complex(n):
l=[]
i=1
while i<n:
l=list(range(i))
i*=2
```
I've got to the point where I realized it runs int(log(n,2)) times over the loop but I'm having hard time incorporating the range(i) into the f... | 2013/11/11 | [
"https://Stackoverflow.com/questions/19916170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2980240/"
] | You've already worked out that it runs `int(log(n, 2))` iterations. (You can test that very easily by just adding a counter into the loop, and calling it with, e.g., 1, 2, 4, 8, 16, 32, 64, etc., and seeing that the counter goes up 1 every time `n` doubles.)
Now you want to know how long the inside of the loop takes. ... | This one is trickier than it looks, because `list(range(i))` is based on i, which grows geometrically. There is a simple way to look at the problem, however. How many elements are created, in total, relative to n? You can simplify the problem by assuming convenient values of n, i.e., powers of two.
If you're still stu... |
17,528,169 | I know there are many posts on centralizing a drop down menu. However, after trying all the various solutions, it seems that I'm still missing something. I got the code of a dropdownmenu from some free website as follows:
```
#nav {
margin: 0;
padding: 7px 6px 0;
line-height: 100%;
border-radius: 2em;
-webkit-border-r... | 2013/07/08 | [
"https://Stackoverflow.com/questions/17528169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2545233/"
] | Try:
```
#nav {
margin: 0;
}
#menu {
text-align: center;
}
```
Your updated **[fiddle](http://jsfiddle.net/ueVr8/1/)**. | not sure what the desired effect is, but using your #menu style, you can move that nav wherever you want:
```
#menu {
width:600px;
height:50px;
background-color:red;
padding-left:10px;
}
```
I just did a background color so you can see where your nav is in relation to the div. Post any other HTML you... |
35,099,366 | I have a question. There is any solution for reading from file list of tuples ? Depends on content ?
I know that if i need to read integers i do something like that:
```
toTuple :: [String] -> [(Int,Int)]
toTuple = map (\y -> read y ::(Int,Int))
```
But in file i can have tuples this kind (int,int) or (char, int). ... | 2016/01/30 | [
"https://Stackoverflow.com/questions/35099366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4494643/"
] | Just try both and choose the successful:
```
import Text.Read
import Control.Applicative
choose :: Maybe a -> Maybe b -> Maybe (Either a b)
choose x y = fmap Left x <|> fmap Right y
readListMaybe :: Read a => [String] -> Maybe [a]
readListMaybe = mapM readMaybe
toTuple :: [String] -> Maybe (Either [(Int, Int)] [(Ch... | As I said it may be a good idea to consider using a parsing library, if the task at hand gets a bit more complicated.
First of all you have the benefit of getting error messages and if you decide to switch to a self declared data Type it is still easily applicable (with slight modifications of course).
Also switching ... |
62,122,596 | I am having issues with this, i am trying to add a role called Simon Says Player, can anyone help??
```
bot.on('message', message => {
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]) {
case 'join':
let person = message.guild.member
if (!perso... | 2020/05/31 | [
"https://Stackoverflow.com/questions/62122596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13654915/"
] | One option is to take the margin-top from the `@page` (since you will not have an actual margin on page view, you want an html content to be there) and give the header fixed `height` of 2.5cm which will function as your top margin:
```
@page{
size: 21cm 29.7cm;
margin-right: 2.5cm;
margin-bottom: 2.5... | I solved it in this way:
```
@page {
size: 21cm 29.7cm;
margin-top: 0.5cm;
margin-right: 2.5cm;
margin-bottom: 2.5cm;
margin-left: 2.5cm;
}
header {
height: 2cm;
}
``` |
30,087,593 | I need to pull in data from a JSON facebook feed. I was able to do it like this:
```
$.getJSON( "https://graph.facebook.com/jessekiro7/posts?access_token=354581914738002|SlHvFFksutZP9kcYRFobNKjg7WI&limit=1", function(data){
$.each( data, function( index, value ) {
$( "<a href=" + value[0].link + " target='_blan... | 2015/05/06 | [
"https://Stackoverflow.com/questions/30087593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872329/"
] | You need to create the various elements separately with javascript and append to them into the DOM. Making sure that you do not concatenate the text from the JSON response into the jQuery call that creates the element.
```
$.getJSON( "https://graph.facebook.com/jessekiro7/posts?access_token=354581914738002|SlHvFFksut... | Try this. You create each element using the jQuery contruction function, and then build them up from lowest to highest in the hierarchy.
```
$.ajax({
url: 'https://graph.facebook.com/jessekiro7/posts?access_token=354581914738002|SlHvFFksutZP9kcYRFobNKjg7WI&limit=1',
}).done( function( data ){
$.each( data, fun... |
74,478,015 | I don't like passing multiple repeating arguments, it looks a bit ugly.
how can I refactor the following code?
```
prev_month_start = Date.today.prev_month.beginning_of_month
prev_month_end = Date.today.prev_month.end_of_month
contacts = contacts.where('
persons.actual_delivery_date >= ? AND persons.actual_d... | 2022/11/17 | [
"https://Stackoverflow.com/questions/74478015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1202194/"
] | You can use a date range ([`all_month`](https://api.rubyonrails.org/classes/DateAndTime/Calculations.html#method-i-all_month)) in cases like these combined with a [`or` condition](https://guides.rubyonrails.org/active_record_querying.html#or-conditions):
```
prev_month = Date.today.prev_month.all_month
contacts = cont... | You can try something like this with ActiveRecord 5 and above:
```
contacts.where(actual_delivery_date: prev_month_start..prev_month_end).or(expected_shipment_date: prev_month_start..prev_month_end)
```
<https://guides.rubyonrails.org/active_record_querying.html#range-conditions>
edited based on comments |
3,450,463 | Given the equivalence relation on N aRb $\leftrightarrow $ a and b are both even or odd, given a function $f: N\rightarrow\{x,y\}$ with $f(n)=x$ if n is even and $f(n)=y$ if n is odd exists an injective function from $N/R$ to $\{x,y\}$?
Can I use a homeomorphism theorem? | 2019/11/25 | [
"https://math.stackexchange.com/questions/3450463",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/178443/"
] | Your set of conditions doesn't upset me. It does make me expect there is an error in your set of conditions. Particularly, ...
The set of conditions you write is incorrect in the case $a = b$. When $a = b$ in the original set of conditions, we find the CDF is zero to the left, one to the right, and undefined at $x = a... | Referring to the Wikipedia [article](https://en.wikipedia.org/wiki/Uniform_distribution_(continuous)), the parameters are usually defined:
$$-\infty<a<b<\infty$$
and the interval can be closed, open or semi-open:
$$[a,b] \quad \text{or} \quad (a,b) \quad \text{or} \quad [a,b)$$
Hence, the CDF can be defined accordingl... |
7,164 | How can I compute the pmf of a random sum ($1$ to $N$) of iid bernoulli random variables, where $N$ is distributed geometrically? | 2010/10/19 | [
"https://math.stackexchange.com/questions/7164",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/2617/"
] | I suggest you modify your birthday party idea to include different types of people, such as friends from school, friends from soccer, etc. Then in general you need to add together the number of attendees from the various categories, and sometimes that will entail adding zero. | Assuming this is a two-student group.
Give student 1 three pieces. Give student 2 two pieces. Tell student 1 to take all of their pieces in the pot. Ask the students how much are in the pot. Now ask student 2 to put all their pieces in the pot. Ask the students how much are in the pot. Now ask student 1 to take all th... |
51,925,118 | How to toggle active class, i.e. if i clicked on the element, an active class should be added to this item and removed from another.
```
<th @click="sort('campaign')" class="initial" :class="{active: isActive}">Campaign</th> // here i am toggling class
<th @click="sort('time')" class="initial" :class="{active: isActi... | 2018/08/20 | [
"https://Stackoverflow.com/questions/51925118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8107104/"
] | You have to link your element with current sort property. From what I see you probably didn't provide whole component code (can't see `currentSort` anywhere except it being used), but it's doable considering `currentSort` holds sorting type's name:
`<th @click="sort('campaign')" class="initial" :class="{active: isActi... | Thanks! working for me . and for test you can add css :
```
.active {
color: rgb(150, 12, 12);
}
``` |
18,719,151 | I have an array like,
```
Array
(
[0] => controllers
[1] => event
[2] => add_new_file.php
)
```
I want to change it like
```
Array([controllers]=>[event]=>add_new_file.php)
```
Is there any idea about to change like this,Anyone have idea to change like this. | 2013/09/10 | [
"https://Stackoverflow.com/questions/18719151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1682826/"
] | Try with:
```
$input = array('controllers', 'event', 'add_new_file.php');
$output = null;
foreach (array_reverse($input) as $value) {
if (is_null($output)) {
$output = $value;
} else {
$output = array($value => $output);
}
}
```
Output:
```
array (size=1)
'controllers' =>
array (size=1)
... | While combination of `array_reverse()` and cycle will do the stuff, I was to late to post that (see good answer with that). So, this answer is just kind of joke (since I was curious - is it possible to resolve a matter with one-liner)
```
$rgData = ['foo', 'bar', 'baz'];
eval('$rgResult["'.join('"]["', array_slice($... |
66,428,459 | I'm trying to update af user's profile with [`updateProfile()`](https://firebase.google.com/docs/auth/web/manage-users?authuser=1#update_a_users_profile)
When I call the function exactly as the example from the [link above](https://firebase.google.com/docs/auth/web/manage-users?authuser=1#update_a_users_profile), it t... | 2021/03/01 | [
"https://Stackoverflow.com/questions/66428459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14674321/"
] | `Object.assign` copies all enumerable properties (<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign>). However, this doesn't include non-enumerable properties (like prototype methods).
I can think of a few different solutions:
### Use `firebase.auth().currentUser`
`fireb... | Make sure that your link to your js-file bellow ALL other firebase script imports.
Your error is quite common if you link them in the wrong order, also don't forget to defer the script tag if you link to your script in your header.
```
<script src="myJS.js" defer></script>
```
Defer makes sure that the js document i... |
28,162,322 | When handling a jQuery event with multiple selectors, can I get the value of the selector triggered the event?
I'm aware of [jQuery multiple selectors, get which selector triggered event](https://stackoverflow.com/questions/12941806/jquery-multiple-selectors-get-which-selector-triggered-event) and similar questions, b... | 2015/01/27 | [
"https://Stackoverflow.com/questions/28162322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1288371/"
] | Why not apply an ID to the button, and use that as your selector, instead of the class?
```
<button class='red stop danger' id="red">red</button>
<button class='green go safe' id="green">green</button>
```
Then:
`$('#red, #green').click(function() {
clickCounts[$(this).attr('id')] += 1;
});` | You may want to try this:
<http://jsfiddle.net/w3z3bfp4/1/>
```
<button name='red' class='red stop danger'>red</button>
<button class='amber floor-it caution'>amber</button>
<button name='green' class='green go safe'>green</button>
$('.red, .green').click(function(e) {
clickCounts[e.target.name] += 1;
alert('RED '+c... |
28,162,322 | When handling a jQuery event with multiple selectors, can I get the value of the selector triggered the event?
I'm aware of [jQuery multiple selectors, get which selector triggered event](https://stackoverflow.com/questions/12941806/jquery-multiple-selectors-get-which-selector-triggered-event) and similar questions, b... | 2015/01/27 | [
"https://Stackoverflow.com/questions/28162322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1288371/"
] | if you want **per button counts**,
i would personally stash it on a data attribute:
```
$('.red, .green').click(function() {
lastCount = $(this).data('clicks') || 0;
$(this).data('clicks', lastCount +1);
});
```
if you want **global red/green counts**,
i would do two separate handlers:
```
var clickCo... | You may want to try this:
<http://jsfiddle.net/w3z3bfp4/1/>
```
<button name='red' class='red stop danger'>red</button>
<button class='amber floor-it caution'>amber</button>
<button name='green' class='green go safe'>green</button>
$('.red, .green').click(function(e) {
clickCounts[e.target.name] += 1;
alert('RED '+c... |
28,162,322 | When handling a jQuery event with multiple selectors, can I get the value of the selector triggered the event?
I'm aware of [jQuery multiple selectors, get which selector triggered event](https://stackoverflow.com/questions/12941806/jquery-multiple-selectors-get-which-selector-triggered-event) and similar questions, b... | 2015/01/27 | [
"https://Stackoverflow.com/questions/28162322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1288371/"
] | You can use `Element.matches()` and (for older browsers) `Element. matchesSelector`. For example:
```
$('.red, .green').click(function (e) {
var sel;
if ( e.target.matches && e.target.matches('.red') ||
e.target. matchesSelector && e.target. matchesSelector('.red')) {
sel = 'red';
} else {... | You may want to try this:
<http://jsfiddle.net/w3z3bfp4/1/>
```
<button name='red' class='red stop danger'>red</button>
<button class='amber floor-it caution'>amber</button>
<button name='green' class='green go safe'>green</button>
$('.red, .green').click(function(e) {
clickCounts[e.target.name] += 1;
alert('RED '+c... |
84,450 | As it said in the title, is it possible that [Darth Sion](http://starwars.wikia.com/wiki/Darth_Sion) (Lord of Pain) is actually [Lucien Draay](http://starwars.wikia.com/wiki/Lucien_Draay) even though that is not said in wiki. It says that Sion fought on Exar Kun's side during the Great Sith war and so on, but there is ... | 2015/03/21 | [
"https://scifi.stackexchange.com/questions/84450",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/25943/"
] | No.
---
John Jackson Miller, writer of the *Knights of the Old Republic* comic books, confirmed this [on his website](http://www.farawaypress.com/comics/swknights/swkotor35.html):
>
> Lucien [in issue 35] tells us what he thinks about being forced into a role created for someone else. The galaxy may get its Darth Si... | Maybe Lucien goes back in time during the Exar Kun War and joins the Dark Lord. Self-fulfilling paradox. |
24,112,595 | I used the following command in the bash to remove the last two lines of bash.bashrc (I added some bad lines) : `sed '69,70d' /etc/bash.bashrc`
But it doesn't delete the lines permanently as I would like. | 2014/06/09 | [
"https://Stackoverflow.com/questions/24112595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3581976/"
] | Your guess of the meaning of `#define foo(...) bar` is correct. Your error is in thinking that `. . .` and `...` are the same; they are not. `...` must be written with no spaces between the dots. If I modify your program to read
```
#include <iostream>
#define foo(...) bar
using std::cout;
int foo()
{
cout << 54... | ```
#define FOO(...)
```
this means your macro can accept variable number of arguments. See [here](https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html) for details. |
38,048,103 | So I implemented code to let me pick images from my filesystem using the default image picker in Android, but for some reason every image is greyed out. It's not letting me choose an image at all. I tested it on Marshmallow 6.0.1 (from where screenshot is taken) and on Lollipop 5.1.1.
[ # Flask-Login Manager`
`ldap_manager = LDAP3LoginManager(app) # Setup a LDAP3 Login Manager` |
60,244,912 | When you write a constructor, you have the opportunity to test the values of the arguments from out of range or other unwanted situations in its body.
```
class a
{
int b;
public:
a(int c)
{
if(c < MIN_ALLOWED || c > MAX_ALLOWED)
{
// Take some measure
}
else
{
b = c;
}
}
}... | 2020/02/16 | [
"https://Stackoverflow.com/questions/60244912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9727450/"
] | Make a function:
```
class a {
int const b;
public:
a(int const c)
: b { initializeB(c) }
{
}
private:
static int initializeB(int const c)
{
if (c < MIN_ALLOWED || c > MAX_ALLOWED) {
// Take some mesure
return -1; // example
}
return c;
... | You can delegate the verification and modification of the variable to a function.
```
class a {
public:
a(int c) : b(ValidateAndTransformInputParameter(c)) {}
private:
const int b;
int ValidateAndTransformInputParameter(int d) const {
if (d < 100) {
d = 100;
}
return d;
}
};
``` |
60,244,912 | When you write a constructor, you have the opportunity to test the values of the arguments from out of range or other unwanted situations in its body.
```
class a
{
int b;
public:
a(int c)
{
if(c < MIN_ALLOWED || c > MAX_ALLOWED)
{
// Take some measure
}
else
{
b = c;
}
}
}... | 2020/02/16 | [
"https://Stackoverflow.com/questions/60244912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9727450/"
] | ```
class a
{
const int b;
public:
a(int c) : b((c < MIN_ALLOWED || c > MAX_ALLOWED) ? throw std::logic_error("bad") : c)
{
// How to control "c" value?!...
}
};
``` | You can delegate the verification and modification of the variable to a function.
```
class a {
public:
a(int c) : b(ValidateAndTransformInputParameter(c)) {}
private:
const int b;
int ValidateAndTransformInputParameter(int d) const {
if (d < 100) {
d = 100;
}
return d;
}
};
``` |
60,244,912 | When you write a constructor, you have the opportunity to test the values of the arguments from out of range or other unwanted situations in its body.
```
class a
{
int b;
public:
a(int c)
{
if(c < MIN_ALLOWED || c > MAX_ALLOWED)
{
// Take some measure
}
else
{
b = c;
}
}
}... | 2020/02/16 | [
"https://Stackoverflow.com/questions/60244912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9727450/"
] | You can delegate the verification and modification of the variable to a function.
```
class a {
public:
a(int c) : b(ValidateAndTransformInputParameter(c)) {}
private:
const int b;
int ValidateAndTransformInputParameter(int d) const {
if (d < 100) {
d = 100;
}
return d;
}
};
``` | There are three major ways:
1. Chain the validation with the comma-operator:
```
a(int c) : b(validate(c), c) {}
```
Remember that the initializers are executed strictly depth-first, in declaration order, ignoring virtual inheritance.
2. Using the ternary operator:
```
a(int c) : b(validate(c) ? c : throw 0) {}
`... |
60,244,912 | When you write a constructor, you have the opportunity to test the values of the arguments from out of range or other unwanted situations in its body.
```
class a
{
int b;
public:
a(int c)
{
if(c < MIN_ALLOWED || c > MAX_ALLOWED)
{
// Take some measure
}
else
{
b = c;
}
}
}... | 2020/02/16 | [
"https://Stackoverflow.com/questions/60244912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9727450/"
] | You can delegate the verification and modification of the variable to a function.
```
class a {
public:
a(int c) : b(ValidateAndTransformInputParameter(c)) {}
private:
const int b;
int ValidateAndTransformInputParameter(int d) const {
if (d < 100) {
d = 100;
}
return d;
}
};
``` | All of the above answers are good and work... but lest we forget, you can also do:
```
class a
{
public:
a(int c) : b([=]() -> int {
if (c < MIN_ALLOWED || c > MAX_ALLOWED)
throw std::logic_error("b");
return c;
}()) {}
private:
int b;
```
};
I... |
60,244,912 | When you write a constructor, you have the opportunity to test the values of the arguments from out of range or other unwanted situations in its body.
```
class a
{
int b;
public:
a(int c)
{
if(c < MIN_ALLOWED || c > MAX_ALLOWED)
{
// Take some measure
}
else
{
b = c;
}
}
}... | 2020/02/16 | [
"https://Stackoverflow.com/questions/60244912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9727450/"
] | Make a function:
```
class a {
int const b;
public:
a(int const c)
: b { initializeB(c) }
{
}
private:
static int initializeB(int const c)
{
if (c < MIN_ALLOWED || c > MAX_ALLOWED) {
// Take some mesure
return -1; // example
}
return c;
... | There are three major ways:
1. Chain the validation with the comma-operator:
```
a(int c) : b(validate(c), c) {}
```
Remember that the initializers are executed strictly depth-first, in declaration order, ignoring virtual inheritance.
2. Using the ternary operator:
```
a(int c) : b(validate(c) ? c : throw 0) {}
`... |
60,244,912 | When you write a constructor, you have the opportunity to test the values of the arguments from out of range or other unwanted situations in its body.
```
class a
{
int b;
public:
a(int c)
{
if(c < MIN_ALLOWED || c > MAX_ALLOWED)
{
// Take some measure
}
else
{
b = c;
}
}
}... | 2020/02/16 | [
"https://Stackoverflow.com/questions/60244912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9727450/"
] | Make a function:
```
class a {
int const b;
public:
a(int const c)
: b { initializeB(c) }
{
}
private:
static int initializeB(int const c)
{
if (c < MIN_ALLOWED || c > MAX_ALLOWED) {
// Take some mesure
return -1; // example
}
return c;
... | All of the above answers are good and work... but lest we forget, you can also do:
```
class a
{
public:
a(int c) : b([=]() -> int {
if (c < MIN_ALLOWED || c > MAX_ALLOWED)
throw std::logic_error("b");
return c;
}()) {}
private:
int b;
```
};
I... |
60,244,912 | When you write a constructor, you have the opportunity to test the values of the arguments from out of range or other unwanted situations in its body.
```
class a
{
int b;
public:
a(int c)
{
if(c < MIN_ALLOWED || c > MAX_ALLOWED)
{
// Take some measure
}
else
{
b = c;
}
}
}... | 2020/02/16 | [
"https://Stackoverflow.com/questions/60244912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9727450/"
] | ```
class a
{
const int b;
public:
a(int c) : b((c < MIN_ALLOWED || c > MAX_ALLOWED) ? throw std::logic_error("bad") : c)
{
// How to control "c" value?!...
}
};
``` | There are three major ways:
1. Chain the validation with the comma-operator:
```
a(int c) : b(validate(c), c) {}
```
Remember that the initializers are executed strictly depth-first, in declaration order, ignoring virtual inheritance.
2. Using the ternary operator:
```
a(int c) : b(validate(c) ? c : throw 0) {}
`... |
60,244,912 | When you write a constructor, you have the opportunity to test the values of the arguments from out of range or other unwanted situations in its body.
```
class a
{
int b;
public:
a(int c)
{
if(c < MIN_ALLOWED || c > MAX_ALLOWED)
{
// Take some measure
}
else
{
b = c;
}
}
}... | 2020/02/16 | [
"https://Stackoverflow.com/questions/60244912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9727450/"
] | ```
class a
{
const int b;
public:
a(int c) : b((c < MIN_ALLOWED || c > MAX_ALLOWED) ? throw std::logic_error("bad") : c)
{
// How to control "c" value?!...
}
};
``` | All of the above answers are good and work... but lest we forget, you can also do:
```
class a
{
public:
a(int c) : b([=]() -> int {
if (c < MIN_ALLOWED || c > MAX_ALLOWED)
throw std::logic_error("b");
return c;
}()) {}
private:
int b;
```
};
I... |
1,831,520 | >
> Let $B = \{x, x^3, x^5\}$ so that $B$ is a basis of $V\_1 = \{a\_1x + a\_2x^3 + a\_3x^5 \mid a\_1, a\_2, a\_3 \in \mathbb{R}\}$.
>
>
> Define a map $T: V\_1 \rightarrow \mathbb{R}$ by
>
>
> $T(f) = -f(3)$ for all $f \in V\_1$
>
>
> Show that $T$ is a linear map and finds its coordinates $[T]\_B\*$ with respe... | 2016/06/19 | [
"https://math.stackexchange.com/questions/1831520",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/240085/"
] | The index $k$ runs over $\{1,3,5\}$ in the following. We first have to identify the dual basis vectors $e\_k$. These vectors compute the coefficients of arbitrary elements $f\in V$ with respect to the basis $B:=(x,x^3,x^5)$ of $V$. It follows that $$e\_k(f)={f^{(k)}(0)\over k!}\ .$$
Since $$T(f)=-f(3)=-\sum\_k{f^{(k)}(... | In general, to find the coordinates of $T$ with respect to the dual basis, you first write it as a general sum of dual vectors
$$T=c\_1(x)^\*+c\_3(x^3)^\*+c\_5(x^5)^\*,$$
and then to isolate the coefficients, consider $c\_i=T(x^i)$. |
1,831,520 | >
> Let $B = \{x, x^3, x^5\}$ so that $B$ is a basis of $V\_1 = \{a\_1x + a\_2x^3 + a\_3x^5 \mid a\_1, a\_2, a\_3 \in \mathbb{R}\}$.
>
>
> Define a map $T: V\_1 \rightarrow \mathbb{R}$ by
>
>
> $T(f) = -f(3)$ for all $f \in V\_1$
>
>
> Show that $T$ is a linear map and finds its coordinates $[T]\_B\*$ with respe... | 2016/06/19 | [
"https://math.stackexchange.com/questions/1831520",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/240085/"
] | The index $k$ runs over $\{1,3,5\}$ in the following. We first have to identify the dual basis vectors $e\_k$. These vectors compute the coefficients of arbitrary elements $f\in V$ with respect to the basis $B:=(x,x^3,x^5)$ of $V$. It follows that $$e\_k(f)={f^{(k)}(0)\over k!}\ .$$
Since $$T(f)=-f(3)=-\sum\_k{f^{(k)}(... | I'm assuming when you say $x\*$ you mean the function that pulls out the coefficient of $x$. I'm going to call this $a\_1$, and the other two, I will call $a\_3$ and $a\_5$ respectively.
Now if $f=f\_1x+f\_3x^3+f\_5x^5$, then $T(f)=-f(3)=-f\_1\cdot3-f\_3\cdot 27-f\_5\cdot 243=-3a\_1(f)-27a\_3(f)-243a\_5(f)$. Therefore... |
8,991,520 | I'm getting a 'module object has no attribute ..." error when trying to use a package heirarchy I created. The error is reminiscant of the error you get when there is a circular import (i.e. module a imports b and module b imports a), but I can't see that issue here. I've gone through many posts with a similar error, b... | 2012/01/24 | [
"https://Stackoverflow.com/questions/8991520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1167413/"
] | Here's the why
==============
(This is, I believe, mostly supported by the explanation at <http://docs.python.org/faq/programming.html#how-can-i-have-modules-that-mutually-import-each-other>)
When the Python interpreter encounters a line of the form `import a.b.c`, it runs through the following steps. In pseudo-pytho... | Instead of using absolute imports, it might help to use relatives.
i.e.
**alpha/bravo/\_*init*\_.py**
```
import alpha.bravo.charlie
```
should be
```
import charlie
```
Otherwise, it probably is a circular import. i.e. if you import alpha.bravo.charlie from charlie, that means
```
alpha/__init__.py
bravo/__i... |
6,267,909 | Ttaking the following code, [(source)](http://nikojava.wordpress.com/2008/10/02/scjp-mock-exam-for-overriding-overloading/):
```
class Parent {
Integer a = 1;
static Integer b = 2;
}
class Child extends Parent {
static Integer a = 41;
Integer b = 42;
}
public class Test {
public static void m... | 2011/06/07 | [
"https://Stackoverflow.com/questions/6267909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195076/"
] | There is no dynamic binding for fields, all bindings for fields are done at compile time. That is why , it is printed fields of parent class not child. And also, static modifier does not change any thing, you can remove all static modifier and also you get the same result..
**You should keep in mind that, only instanc... | There is no instance variable `a` in class `Child` objects. Or, more precisely, the only instance variable `a` in `Child` objects is the one inherited from `Parent`; class `Child` does not define its own instance variable named `a`. |
6,267,909 | Ttaking the following code, [(source)](http://nikojava.wordpress.com/2008/10/02/scjp-mock-exam-for-overriding-overloading/):
```
class Parent {
Integer a = 1;
static Integer b = 2;
}
class Child extends Parent {
static Integer a = 41;
Integer b = 42;
}
public class Test {
public static void m... | 2011/06/07 | [
"https://Stackoverflow.com/questions/6267909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195076/"
] | Variables (fields) **are not overridden**, neither instance variables nor class variables.
An object always has all the instance variables from all the superclasses. A class has only the static variables it defines itself, though it also can access the superclasses' (and interfaces') variables (if not private).
If yo... | There is no instance variable `a` in class `Child` objects. Or, more precisely, the only instance variable `a` in `Child` objects is the one inherited from `Parent`; class `Child` does not define its own instance variable named `a`. |
6,267,909 | Ttaking the following code, [(source)](http://nikojava.wordpress.com/2008/10/02/scjp-mock-exam-for-overriding-overloading/):
```
class Parent {
Integer a = 1;
static Integer b = 2;
}
class Child extends Parent {
static Integer a = 41;
Integer b = 42;
}
public class Test {
public static void m... | 2011/06/07 | [
"https://Stackoverflow.com/questions/6267909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195076/"
] | Maybe this modified example helps to clarify the decision on which fields are seen or hidden, based on the compile-time type:
```
public static void main(String[] args) {
Parent parent = new Parent();
Child child = new Child();
Parent yo = new Child();
System.out.println(parent.a + " " + parent.b);
... | There is no instance variable `a` in class `Child` objects. Or, more precisely, the only instance variable `a` in `Child` objects is the one inherited from `Parent`; class `Child` does not define its own instance variable named `a`. |
6,267,909 | Ttaking the following code, [(source)](http://nikojava.wordpress.com/2008/10/02/scjp-mock-exam-for-overriding-overloading/):
```
class Parent {
Integer a = 1;
static Integer b = 2;
}
class Child extends Parent {
static Integer a = 41;
Integer b = 42;
}
public class Test {
public static void m... | 2011/06/07 | [
"https://Stackoverflow.com/questions/6267909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195076/"
] | Variables (fields) **are not overridden**, neither instance variables nor class variables.
An object always has all the instance variables from all the superclasses. A class has only the static variables it defines itself, though it also can access the superclasses' (and interfaces') variables (if not private).
If yo... | There is no dynamic binding for fields, all bindings for fields are done at compile time. That is why , it is printed fields of parent class not child. And also, static modifier does not change any thing, you can remove all static modifier and also you get the same result..
**You should keep in mind that, only instanc... |
6,267,909 | Ttaking the following code, [(source)](http://nikojava.wordpress.com/2008/10/02/scjp-mock-exam-for-overriding-overloading/):
```
class Parent {
Integer a = 1;
static Integer b = 2;
}
class Child extends Parent {
static Integer a = 41;
Integer b = 42;
}
public class Test {
public static void m... | 2011/06/07 | [
"https://Stackoverflow.com/questions/6267909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195076/"
] | There is no dynamic binding for fields, all bindings for fields are done at compile time. That is why , it is printed fields of parent class not child. And also, static modifier does not change any thing, you can remove all static modifier and also you get the same result..
**You should keep in mind that, only instanc... | Classes have fields. Instance fields cannot be overridden, only hidden in sub-classes. Local variables cannot be overridden or hidden. Static fields and method are bound to the class and attempting to use an instance variable is misleading because the instance variable is ignored.
e.g.
```
Parent yo = null;
System.ou... |
6,267,909 | Ttaking the following code, [(source)](http://nikojava.wordpress.com/2008/10/02/scjp-mock-exam-for-overriding-overloading/):
```
class Parent {
Integer a = 1;
static Integer b = 2;
}
class Child extends Parent {
static Integer a = 41;
Integer b = 42;
}
public class Test {
public static void m... | 2011/06/07 | [
"https://Stackoverflow.com/questions/6267909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195076/"
] | Variables (fields) **are not overridden**, neither instance variables nor class variables.
An object always has all the instance variables from all the superclasses. A class has only the static variables it defines itself, though it also can access the superclasses' (and interfaces') variables (if not private).
If yo... | Classes have fields. Instance fields cannot be overridden, only hidden in sub-classes. Local variables cannot be overridden or hidden. Static fields and method are bound to the class and attempting to use an instance variable is misleading because the instance variable is ignored.
e.g.
```
Parent yo = null;
System.ou... |
6,267,909 | Ttaking the following code, [(source)](http://nikojava.wordpress.com/2008/10/02/scjp-mock-exam-for-overriding-overloading/):
```
class Parent {
Integer a = 1;
static Integer b = 2;
}
class Child extends Parent {
static Integer a = 41;
Integer b = 42;
}
public class Test {
public static void m... | 2011/06/07 | [
"https://Stackoverflow.com/questions/6267909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195076/"
] | Variables (fields) **are not overridden**, neither instance variables nor class variables.
An object always has all the instance variables from all the superclasses. A class has only the static variables it defines itself, though it also can access the superclasses' (and interfaces') variables (if not private).
If yo... | Maybe this modified example helps to clarify the decision on which fields are seen or hidden, based on the compile-time type:
```
public static void main(String[] args) {
Parent parent = new Parent();
Child child = new Child();
Parent yo = new Child();
System.out.println(parent.a + " " + parent.b);
... |
6,267,909 | Ttaking the following code, [(source)](http://nikojava.wordpress.com/2008/10/02/scjp-mock-exam-for-overriding-overloading/):
```
class Parent {
Integer a = 1;
static Integer b = 2;
}
class Child extends Parent {
static Integer a = 41;
Integer b = 42;
}
public class Test {
public static void m... | 2011/06/07 | [
"https://Stackoverflow.com/questions/6267909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195076/"
] | Maybe this modified example helps to clarify the decision on which fields are seen or hidden, based on the compile-time type:
```
public static void main(String[] args) {
Parent parent = new Parent();
Child child = new Child();
Parent yo = new Child();
System.out.println(parent.a + " " + parent.b);
... | Classes have fields. Instance fields cannot be overridden, only hidden in sub-classes. Local variables cannot be overridden or hidden. Static fields and method are bound to the class and attempting to use an instance variable is misleading because the instance variable is ignored.
e.g.
```
Parent yo = null;
System.ou... |
46,738,112 | New to tcl and trying to understand the "trace add variable" command.
I understand the need to invoke a callback function when a variable is "written" to.
But what is the use of the "read" option? For debugging? | 2017/10/13 | [
"https://Stackoverflow.com/questions/46738112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6702511/"
] | One example use might be a global counter:
```
proc init { } {
set ::globalcounter 0
trace add variable ::globalcounter read ::gcountUpdate
}
proc gcountUpdate { } {
incr ::globalcounter
}
proc main { } {
init
puts $::globalcounter
puts $::globalcounter
}
main
```
I'm sure there are other uses. As you ... | One of the uses for read callbacks (which are indeed quite a bit less common than write callbacks) is in linking a Tcl variable to a C variable; the read callback is used to enforce the reading of the C variable and synchronizing the Tcl variable to it. (The write callback would ensure that the update of the Tcl variab... |
641,664 | I've tried aligning a linear system using this code:
```
\[\left\{
\begin{aligned}
&a_{11}x_1 & + & &a_{12}x_2 & + & &a_{13}x_3 & = & &b_1 \\
& & & &a_{22}x_2 & + & &a_{23}x_3 & = & &b_2 \\
& & & & & & &a_{33}x_3 & = & &b_3
\end{aligned}
\right.
... | 2022/04/22 | [
"https://tex.stackexchange.com/questions/641664",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/268952/"
] | Depending on your desired look, you can just align once at the `=` signs and let the natural math spacing of LaTeX take care of the rest:
[](https://i.stack.imgur.com/vrekm.png)
```
\[\left\{
\begin{aligned}
a_{11}x_1 + a_{12}x_2 + a_{13... | I have worked out a solution with the `array` package.
```
\documentclass{scrarticle}
\usepackage{amsmath}
\usepackage{array}
\begin{document}
\begin{equation*}
\left\{
\begin{array}{ccccccc}
a_{11}x_{1} & + & a_{12}x_{2} & + & a_{13}x_{3} & = & b_1 \\
& & a_{22}x_{2} & +... |
641,664 | I've tried aligning a linear system using this code:
```
\[\left\{
\begin{aligned}
&a_{11}x_1 & + & &a_{12}x_2 & + & &a_{13}x_3 & = & &b_1 \\
& & & &a_{22}x_2 & + & &a_{23}x_3 & = & &b_2 \\
& & & & & & &a_{33}x_3 & = & &b_3
\end{aligned}
\right.
... | 2022/04/22 | [
"https://tex.stackexchange.com/questions/641664",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/268952/"
] | No additional package is needed.
The root of the issue is the way the columns are align in the `aligned` structure: rlrlrlr ....
To synchronized the alignment two `&` are needed before the second `+` sign
[](https://i.stack.imgur.com/0QUQf.jpg)
```
\documentclass{article}
\... | I have worked out a solution with the `array` package.
```
\documentclass{scrarticle}
\usepackage{amsmath}
\usepackage{array}
\begin{document}
\begin{equation*}
\left\{
\begin{array}{ccccccc}
a_{11}x_{1} & + & a_{12}x_{2} & + & a_{13}x_{3} & = & b_1 \\
& & a_{22}x_{2} & +... |
641,664 | I've tried aligning a linear system using this code:
```
\[\left\{
\begin{aligned}
&a_{11}x_1 & + & &a_{12}x_2 & + & &a_{13}x_3 & = & &b_1 \\
& & & &a_{22}x_2 & + & &a_{23}x_3 & = & &b_2 \\
& & & & & & &a_{33}x_3 & = & &b_3
\end{aligned}
\right.
... | 2022/04/22 | [
"https://tex.stackexchange.com/questions/641664",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/268952/"
] | Depending on your desired look, you can just align once at the `=` signs and let the natural math spacing of LaTeX take care of the rest:
[](https://i.stack.imgur.com/vrekm.png)
```
\[\left\{
\begin{aligned}
a_{11}x_1 + a_{12}x_2 + a_{13... | You can use `alignedat` instead, or `\systeme`.
```
\documentclass{article}
\usepackage{amsmath}
\usepackage{systeme}% for the second solution
\begin{document}
\[
\left\{
\begin{alignedat}{3}
a_{11}x_1 & +{} & a_{12}x_2 & +{} & a_{13}x_3 & = b_1 \\
& & a_{22}x_2 & +{} & a_{23}x_3 & = b_2 \\
... |
641,664 | I've tried aligning a linear system using this code:
```
\[\left\{
\begin{aligned}
&a_{11}x_1 & + & &a_{12}x_2 & + & &a_{13}x_3 & = & &b_1 \\
& & & &a_{22}x_2 & + & &a_{23}x_3 & = & &b_2 \\
& & & & & & &a_{33}x_3 & = & &b_3
\end{aligned}
\right.
... | 2022/04/22 | [
"https://tex.stackexchange.com/questions/641664",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/268952/"
] | No additional package is needed.
The root of the issue is the way the columns are align in the `aligned` structure: rlrlrlr ....
To synchronized the alignment two `&` are needed before the second `+` sign
[](https://i.stack.imgur.com/0QUQf.jpg)
```
\documentclass{article}
\... | Depending on your desired look, you can just align once at the `=` signs and let the natural math spacing of LaTeX take care of the rest:
[](https://i.stack.imgur.com/vrekm.png)
```
\[\left\{
\begin{aligned}
a_{11}x_1 + a_{12}x_2 + a_{13... |
641,664 | I've tried aligning a linear system using this code:
```
\[\left\{
\begin{aligned}
&a_{11}x_1 & + & &a_{12}x_2 & + & &a_{13}x_3 & = & &b_1 \\
& & & &a_{22}x_2 & + & &a_{23}x_3 & = & &b_2 \\
& & & & & & &a_{33}x_3 & = & &b_3
\end{aligned}
\right.
... | 2022/04/22 | [
"https://tex.stackexchange.com/questions/641664",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/268952/"
] | Depending on your desired look, you can just align once at the `=` signs and let the natural math spacing of LaTeX take care of the rest:
[](https://i.stack.imgur.com/vrekm.png)
```
\[\left\{
\begin{aligned}
a_{11}x_1 + a_{12}x_2 + a_{13... | Here is a solution using the `IEEEeqnarraybox` environment from the [`IEEEtrantools`](https://www.ctan.org/pkg/ieeetrantools) (Appendix F of the documentation) package. [This tutorial](https://moser-isi.ethz.ch/docs/typeset_equations.pdf) on typesetting equations also demonstrates the usage of the `IEEEeqnarray` enviro... |
641,664 | I've tried aligning a linear system using this code:
```
\[\left\{
\begin{aligned}
&a_{11}x_1 & + & &a_{12}x_2 & + & &a_{13}x_3 & = & &b_1 \\
& & & &a_{22}x_2 & + & &a_{23}x_3 & = & &b_2 \\
& & & & & & &a_{33}x_3 & = & &b_3
\end{aligned}
\right.
... | 2022/04/22 | [
"https://tex.stackexchange.com/questions/641664",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/268952/"
] | Depending on your desired look, you can just align once at the `=` signs and let the natural math spacing of LaTeX take care of the rest:
[](https://i.stack.imgur.com/vrekm.png)
```
\[\left\{
\begin{aligned}
a_{11}x_1 + a_{12}x_2 + a_{13... | As @daleif comments, the problem could be solved easily by add a `{}` before `&` which could protect the space around symbols near `&`. By the way the codes could be simplified and rewritten as follows:
```
\[\left\{
\begin{aligned}
a_{11}x_1 + a_{12}x_2 + {}&a_{13}x_3 = b_1 \\
a_{22}x_2... |
641,664 | I've tried aligning a linear system using this code:
```
\[\left\{
\begin{aligned}
&a_{11}x_1 & + & &a_{12}x_2 & + & &a_{13}x_3 & = & &b_1 \\
& & & &a_{22}x_2 & + & &a_{23}x_3 & = & &b_2 \\
& & & & & & &a_{33}x_3 & = & &b_3
\end{aligned}
\right.
... | 2022/04/22 | [
"https://tex.stackexchange.com/questions/641664",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/268952/"
] | No additional package is needed.
The root of the issue is the way the columns are align in the `aligned` structure: rlrlrlr ....
To synchronized the alignment two `&` are needed before the second `+` sign
[](https://i.stack.imgur.com/0QUQf.jpg)
```
\documentclass{article}
\... | You can use `alignedat` instead, or `\systeme`.
```
\documentclass{article}
\usepackage{amsmath}
\usepackage{systeme}% for the second solution
\begin{document}
\[
\left\{
\begin{alignedat}{3}
a_{11}x_1 & +{} & a_{12}x_2 & +{} & a_{13}x_3 & = b_1 \\
& & a_{22}x_2 & +{} & a_{23}x_3 & = b_2 \\
... |
641,664 | I've tried aligning a linear system using this code:
```
\[\left\{
\begin{aligned}
&a_{11}x_1 & + & &a_{12}x_2 & + & &a_{13}x_3 & = & &b_1 \\
& & & &a_{22}x_2 & + & &a_{23}x_3 & = & &b_2 \\
& & & & & & &a_{33}x_3 & = & &b_3
\end{aligned}
\right.
... | 2022/04/22 | [
"https://tex.stackexchange.com/questions/641664",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/268952/"
] | No additional package is needed.
The root of the issue is the way the columns are align in the `aligned` structure: rlrlrlr ....
To synchronized the alignment two `&` are needed before the second `+` sign
[](https://i.stack.imgur.com/0QUQf.jpg)
```
\documentclass{article}
\... | Here is a solution using the `IEEEeqnarraybox` environment from the [`IEEEtrantools`](https://www.ctan.org/pkg/ieeetrantools) (Appendix F of the documentation) package. [This tutorial](https://moser-isi.ethz.ch/docs/typeset_equations.pdf) on typesetting equations also demonstrates the usage of the `IEEEeqnarray` enviro... |
641,664 | I've tried aligning a linear system using this code:
```
\[\left\{
\begin{aligned}
&a_{11}x_1 & + & &a_{12}x_2 & + & &a_{13}x_3 & = & &b_1 \\
& & & &a_{22}x_2 & + & &a_{23}x_3 & = & &b_2 \\
& & & & & & &a_{33}x_3 & = & &b_3
\end{aligned}
\right.
... | 2022/04/22 | [
"https://tex.stackexchange.com/questions/641664",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/268952/"
] | No additional package is needed.
The root of the issue is the way the columns are align in the `aligned` structure: rlrlrlr ....
To synchronized the alignment two `&` are needed before the second `+` sign
[](https://i.stack.imgur.com/0QUQf.jpg)
```
\documentclass{article}
\... | As @daleif comments, the problem could be solved easily by add a `{}` before `&` which could protect the space around symbols near `&`. By the way the codes could be simplified and rewritten as follows:
```
\[\left\{
\begin{aligned}
a_{11}x_1 + a_{12}x_2 + {}&a_{13}x_3 = b_1 \\
a_{22}x_2... |
45,470,195 | Given these two strings:
```
var a = "November 5, 1916";
var b = "October 5–10, 1592";
```
I am doing:
```
b.replace(' ', '').split(' ');
a.replace(' ', '').split(' ');
```
But I still get a comma and no white space. I need to be able to remove ALL commas from those strings and keep the white space in order to ha... | 2017/08/02 | [
"https://Stackoverflow.com/questions/45470195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1018804/"
] | The split() method is not needed since you are not trying to turn the string into an array.
Just to remove all commas straighforwardly:
```
a.replace(',', '');
b.replace(',', '');
``` | you can do this:
```
var stringWithoutCommas = stringWithComas.replace(/,/g, ' ');
``` |
45,470,195 | Given these two strings:
```
var a = "November 5, 1916";
var b = "October 5–10, 1592";
```
I am doing:
```
b.replace(' ', '').split(' ');
a.replace(' ', '').split(' ');
```
But I still get a comma and no white space. I need to be able to remove ALL commas from those strings and keep the white space in order to ha... | 2017/08/02 | [
"https://Stackoverflow.com/questions/45470195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1018804/"
] | To replace all occurrences of a string with another string, using the following function:
```js
str.replaceAll(',', '');
``` | If all you need to do is remove the commas, then you basically have a typo in your example. The first parameter to `replace()` should be the character(s) you want to remove. In your example, you are removing the spaces and keeping the commas. You need this:
```
b.replace('/,/g','');
a.replace('/,/g','');
``` |
45,470,195 | Given these two strings:
```
var a = "November 5, 1916";
var b = "October 5–10, 1592";
```
I am doing:
```
b.replace(' ', '').split(' ');
a.replace(' ', '').split(' ');
```
But I still get a comma and no white space. I need to be able to remove ALL commas from those strings and keep the white space in order to ha... | 2017/08/02 | [
"https://Stackoverflow.com/questions/45470195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1018804/"
] | The split() method is not needed since you are not trying to turn the string into an array.
Just to remove all commas straighforwardly:
```
a.replace(',', '');
b.replace(',', '');
``` | ```js
$(document).ready(function() {
var a = "November 5, 1916";
var b = "October 5-10, 1592";
$("#btn").click(function() {
a = a.replace(",", "");
b = b.replace(",", "");
var c = b.replace("-", " ");
$("#a").text(a);
$("#b").text(b);
$("#c").text(c);
});
});
```
```htm... |
45,470,195 | Given these two strings:
```
var a = "November 5, 1916";
var b = "October 5–10, 1592";
```
I am doing:
```
b.replace(' ', '').split(' ');
a.replace(' ', '').split(' ');
```
But I still get a comma and no white space. I need to be able to remove ALL commas from those strings and keep the white space in order to ha... | 2017/08/02 | [
"https://Stackoverflow.com/questions/45470195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1018804/"
] | If all you need to do is remove the commas, then you basically have a typo in your example. The first parameter to `replace()` should be the character(s) you want to remove. In your example, you are removing the spaces and keeping the commas. You need this:
```
b.replace('/,/g','');
a.replace('/,/g','');
``` | ```js
var a = "November 5, 1916";
var b = "October 5–10, 1592";
var r=/ |,/gi ;
$("#a").text(a.replace( r,""));
$("#b").text(b.replace( r,""));
```
```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id="a"></span>
<hr>
<span id="b"></span>
``` |
45,470,195 | Given these two strings:
```
var a = "November 5, 1916";
var b = "October 5–10, 1592";
```
I am doing:
```
b.replace(' ', '').split(' ');
a.replace(' ', '').split(' ');
```
But I still get a comma and no white space. I need to be able to remove ALL commas from those strings and keep the white space in order to ha... | 2017/08/02 | [
"https://Stackoverflow.com/questions/45470195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1018804/"
] | If all you need to do is remove the commas, then you basically have a typo in your example. The first parameter to `replace()` should be the character(s) you want to remove. In your example, you are removing the spaces and keeping the commas. You need this:
```
b.replace('/,/g','');
a.replace('/,/g','');
``` | ```js
$(document).ready(function() {
var a = "November 5, 1916";
var b = "October 5-10, 1592";
$("#btn").click(function() {
a = a.replace(",", "");
b = b.replace(",", "");
var c = b.replace("-", " ");
$("#a").text(a);
$("#b").text(b);
$("#c").text(c);
});
});
```
```htm... |
45,470,195 | Given these two strings:
```
var a = "November 5, 1916";
var b = "October 5–10, 1592";
```
I am doing:
```
b.replace(' ', '').split(' ');
a.replace(' ', '').split(' ');
```
But I still get a comma and no white space. I need to be able to remove ALL commas from those strings and keep the white space in order to ha... | 2017/08/02 | [
"https://Stackoverflow.com/questions/45470195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1018804/"
] | The split() method is not needed since you are not trying to turn the string into an array.
Just to remove all commas straighforwardly:
```
a.replace(',', '');
b.replace(',', '');
``` | To replace all occurrences of a string with another string, using the following function:
```js
str.replaceAll(',', '');
``` |
45,470,195 | Given these two strings:
```
var a = "November 5, 1916";
var b = "October 5–10, 1592";
```
I am doing:
```
b.replace(' ', '').split(' ');
a.replace(' ', '').split(' ');
```
But I still get a comma and no white space. I need to be able to remove ALL commas from those strings and keep the white space in order to ha... | 2017/08/02 | [
"https://Stackoverflow.com/questions/45470195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1018804/"
] | To replace all occurrences of a string with another string, using the following function:
```js
str.replaceAll(',', '');
``` | You can use this
```
var mystring = "this,is,a,test"
mystring.replace(/,/g , " ");
```
This will replace all the commas with space. |
45,470,195 | Given these two strings:
```
var a = "November 5, 1916";
var b = "October 5–10, 1592";
```
I am doing:
```
b.replace(' ', '').split(' ');
a.replace(' ', '').split(' ');
```
But I still get a comma and no white space. I need to be able to remove ALL commas from those strings and keep the white space in order to ha... | 2017/08/02 | [
"https://Stackoverflow.com/questions/45470195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1018804/"
] | If all you need to do is remove the commas, then you basically have a typo in your example. The first parameter to `replace()` should be the character(s) you want to remove. In your example, you are removing the spaces and keeping the commas. You need this:
```
b.replace('/,/g','');
a.replace('/,/g','');
``` | You can use this
```
var mystring = "this,is,a,test"
mystring.replace(/,/g , " ");
```
This will replace all the commas with space. |
45,470,195 | Given these two strings:
```
var a = "November 5, 1916";
var b = "October 5–10, 1592";
```
I am doing:
```
b.replace(' ', '').split(' ');
a.replace(' ', '').split(' ');
```
But I still get a comma and no white space. I need to be able to remove ALL commas from those strings and keep the white space in order to ha... | 2017/08/02 | [
"https://Stackoverflow.com/questions/45470195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1018804/"
] | The split() method is not needed since you are not trying to turn the string into an array.
Just to remove all commas straighforwardly:
```
a.replace(',', '');
b.replace(',', '');
``` | If all you need to do is remove the commas, then you basically have a typo in your example. The first parameter to `replace()` should be the character(s) you want to remove. In your example, you are removing the spaces and keeping the commas. You need this:
```
b.replace('/,/g','');
a.replace('/,/g','');
``` |
45,470,195 | Given these two strings:
```
var a = "November 5, 1916";
var b = "October 5–10, 1592";
```
I am doing:
```
b.replace(' ', '').split(' ');
a.replace(' ', '').split(' ');
```
But I still get a comma and no white space. I need to be able to remove ALL commas from those strings and keep the white space in order to ha... | 2017/08/02 | [
"https://Stackoverflow.com/questions/45470195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1018804/"
] | you can do this:
```
var stringWithoutCommas = stringWithComas.replace(/,/g, ' ');
``` | ```js
var a = "November 5, 1916";
var b = "October 5–10, 1592";
var r=/ |,/gi ;
$("#a").text(a.replace( r,""));
$("#b").text(b.replace( r,""));
```
```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id="a"></span>
<hr>
<span id="b"></span>
``` |
39,988,341 | I am trying to run a query on a table which returns two values (call it fstValue and lstValue). I am trying to get my query to return True in cases when the fstValue >=0 AND lstValue <=100, and false in all other cases.
Is there any way to do this in MySQL? | 2016/10/11 | [
"https://Stackoverflow.com/questions/39988341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5578257/"
] | Is it possible the images are very small? The limit you configured in URL-loader means that all images under 25000 bytes will be inlined (as data URI's) instead of served as a file. Files larger than 25000 bytes will be treated by url-loader the same way file-loader treats them. | I think you want to try <https://www.npmjs.com/package/copy-webpack-plugin>. This is a webpack plugin that copies individual files or entire directories to the build directory. |
39,988,341 | I am trying to run a query on a table which returns two values (call it fstValue and lstValue). I am trying to get my query to return True in cases when the fstValue >=0 AND lstValue <=100, and false in all other cases.
Is there any way to do this in MySQL? | 2016/10/11 | [
"https://Stackoverflow.com/questions/39988341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5578257/"
] | Is it possible the images are very small? The limit you configured in URL-loader means that all images under 25000 bytes will be inlined (as data URI's) instead of served as a file. Files larger than 25000 bytes will be treated by url-loader the same way file-loader treats them. | Switch to the file-loader instead of the url loader. The images may be under your limit of 25000 (25kb).
Without modifying your webpack configuration you could try this:
```
import logo from 'file-loader!./images/animus_logo_blacktext.png'
```
You should see the image in your assets. |
48,957,815 | I'm trying to get the value of the fractional part of a number. I need the number as an integer however.
```
float x = 12.345; // eventually not hard-coded
int whole = (int)x;
int frac = (x - (float)whole); // this gives 0.345 - expected
```
`x` may be/have any length of decimal places. I need (in my example) 345 st... | 2018/02/23 | [
"https://Stackoverflow.com/questions/48957815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/703176/"
] | >
> Q: How can I get the fractional value of a fractional number stored as int?
>
>
>
Use `modff()` to break a `float` into whole number and fractional parts. [@Michael Burr](https://stackoverflow.com/questions/48957815/c-get-fractional-value-as-int/48959341?noredirect=1#comment84922675_48957815)
>
> The `modf` ... | I made a quick routine that has what you are looking for. If you need to change the number of digits past the decimal then change the 3 in the .3f in the first printf to match the digits. otherwise you will either see the result multiplied by a multiple of 10 or stripped.
See: <http://www.cplusplus.com/reference/cstdi... |
72,893,187 | I'm a new comer in typescript, and I learnt that we can not assign Type 'string | undefined' to Type 'string' from internet tutorials like <https://linguinecode.com/post/how-to-solve-typescript-possibly-undefined-value>. But when I write a demo on WebStorm, I found it can be compiled, without any errors, and also can r... | 2022/07/07 | [
"https://Stackoverflow.com/questions/72893187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8793888/"
] | You need to activate [strictNullChecks](https://www.typescriptlang.org/tsconfig#strictNullChecks)
To test out how differnt typescript configs behave you can use [your sample in typescriptPlayground](https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABANwIYBsYBNVQKYAqcA1nmABRQlkBciAzlAE4xgDmAlIgN4BQiAxEzxQQTJFVJg... | Inside the compiler options you should set "strict": true. You can check the docs [here](https://www.typescriptlang.org/tsconfig/#strict). |
83,069 | What is the [maximum entropy distribution](http://en.wikipedia.org/wiki/Maximum_entropy_probability_distribution) for a positive continuous variable, given its first and second moments?
For example, a Gaussian distribution is the maximum entropy distribution for an unbounded variable, given its mean and standard devia... | 2014/01/22 | [
"https://stats.stackexchange.com/questions/83069",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/5536/"
] | One may simply use the theorem of Boltzmann's that is in [the very Wikipedia article you point to](http://en.wikipedia.org/wiki/Maximum_entropy_probability_distribution#Continuous_version).
Note that specifying the mean and variance is equivalent to specifying the first two raw moments - each determines the other (it'... | I want to make @Glen\_b's answer more explicit, here is an extra answer just because it wouldn't fit as a comment.
The formalism etc. is well explained in [Chapter 11 and 12 of Jaynes' book](https://books.google.de/books?id=tTN4HuUNXjgC&printsec=frontcover&dq=Jaynes+probability+theory&hl=en&sa=X&redir_esc=y#v=onepage&... |
2,699,180 | I'm generating your typical Web 2.0 HTML page with PHP: it contains a lot of `<script>` tags and javascript code that will substantially change the DOM after the load event.
Is there a way to get the final HTML code directly from PHP, without opening the page with any browser?
For example, let's say the HTML for the ... | 2010/04/23 | [
"https://Stackoverflow.com/questions/2699180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/95135/"
] | If I understand you right, you'd like to execute a JavaScript-function in PHP ... JavaScript is executed in the browser (client side), PHP is server-sided, so unless you write a JavaScript-parser in PHP, that won't work.
Why a JS-parser on the server would make sense at all (I can't think of a reason why it should) or... | ```
function visible() {
echo '<script type="text/javascript">
var o = document.getElementById("overlay");
o.style.visibility = "visible";
</script>';
}
```
This is a good way i used often for running JavaScript in PHP |
2,699,180 | I'm generating your typical Web 2.0 HTML page with PHP: it contains a lot of `<script>` tags and javascript code that will substantially change the DOM after the load event.
Is there a way to get the final HTML code directly from PHP, without opening the page with any browser?
For example, let's say the HTML for the ... | 2010/04/23 | [
"https://Stackoverflow.com/questions/2699180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/95135/"
] | To **evaluate JavaScript code using PHP**, have a look at the [V8 JavaScript engine extension](http://php.net/manual/en/book.v8js.php), which you may compile into your PHP binary:
* <http://php.net/manual/en/book.v8js.php>
V8 is [Google's open source JavaScript implementation](http://code.google.com/p/v8/). | The best solution that I could find is to use HtmlUnit <http://htmlunit.sourceforge.net/> on the server to execute your html with the javascript and get back the final html that the user would see on the browser.
The library has good support for JavaScript and is headless so you should be able to run it on the server.... |
2,699,180 | I'm generating your typical Web 2.0 HTML page with PHP: it contains a lot of `<script>` tags and javascript code that will substantially change the DOM after the load event.
Is there a way to get the final HTML code directly from PHP, without opening the page with any browser?
For example, let's say the HTML for the ... | 2010/04/23 | [
"https://Stackoverflow.com/questions/2699180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/95135/"
] | You have 2 problems:
1. Execute JavaScript.
2. Update DOM (the html after executing javascript).
To execute javascript you will need a javascript engine. There are currently 3 available for your use:
1. [V8](http://www.php.net/manual/en/book.v8js.php): By Google for Chrome. PHP extension.
2. [Rhino](https://develope... | It would be possible if you had a javascript interpreter built into PHP (or at least something on the server you could call to interpret the HTML with javascript embedded). There have been some attempts (eg <http://j4p5.sourceforge.net/index.php>), but I would steer clear of these and try to rethink what you're doing. ... |
2,699,180 | I'm generating your typical Web 2.0 HTML page with PHP: it contains a lot of `<script>` tags and javascript code that will substantially change the DOM after the load event.
Is there a way to get the final HTML code directly from PHP, without opening the page with any browser?
For example, let's say the HTML for the ... | 2010/04/23 | [
"https://Stackoverflow.com/questions/2699180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/95135/"
] | I faced the same issue while building a web crawler. You can get the final DOM by using a headless browser such as [PhantomJS](http://phantomjs.org/). You basically tell PhantomJS to load the data for you and dump the data you want.
If you are using PHP, there is a wrapper, [php-phantomjs](https://github.com/jonnnnyw/... | ```
function visible() {
echo '<script type="text/javascript">
var o = document.getElementById("overlay");
o.style.visibility = "visible";
</script>';
}
```
This is a good way i used often for running JavaScript in PHP |
2,699,180 | I'm generating your typical Web 2.0 HTML page with PHP: it contains a lot of `<script>` tags and javascript code that will substantially change the DOM after the load event.
Is there a way to get the final HTML code directly from PHP, without opening the page with any browser?
For example, let's say the HTML for the ... | 2010/04/23 | [
"https://Stackoverflow.com/questions/2699180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/95135/"
] | The best solution that I could find is to use HtmlUnit <http://htmlunit.sourceforge.net/> on the server to execute your html with the javascript and get back the final html that the user would see on the browser.
The library has good support for JavaScript and is headless so you should be able to run it on the server.... | There are new servers that run Javascript server-side and are able to manipulate the DOM but it has nothing to do with PHP .
<http://jaxer.org/> |
2,699,180 | I'm generating your typical Web 2.0 HTML page with PHP: it contains a lot of `<script>` tags and javascript code that will substantially change the DOM after the load event.
Is there a way to get the final HTML code directly from PHP, without opening the page with any browser?
For example, let's say the HTML for the ... | 2010/04/23 | [
"https://Stackoverflow.com/questions/2699180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/95135/"
] | To **evaluate JavaScript code using PHP**, have a look at the [V8 JavaScript engine extension](http://php.net/manual/en/book.v8js.php), which you may compile into your PHP binary:
* <http://php.net/manual/en/book.v8js.php>
V8 is [Google's open source JavaScript implementation](http://code.google.com/p/v8/). | It would be possible if you had a javascript interpreter built into PHP (or at least something on the server you could call to interpret the HTML with javascript embedded). There have been some attempts (eg <http://j4p5.sourceforge.net/index.php>), but I would steer clear of these and try to rethink what you're doing. ... |
2,699,180 | I'm generating your typical Web 2.0 HTML page with PHP: it contains a lot of `<script>` tags and javascript code that will substantially change the DOM after the load event.
Is there a way to get the final HTML code directly from PHP, without opening the page with any browser?
For example, let's say the HTML for the ... | 2010/04/23 | [
"https://Stackoverflow.com/questions/2699180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/95135/"
] | I faced the same issue while building a web crawler. You can get the final DOM by using a headless browser such as [PhantomJS](http://phantomjs.org/). You basically tell PhantomJS to load the data for you and dump the data you want.
If you are using PHP, there is a wrapper, [php-phantomjs](https://github.com/jonnnnyw/... | There are new servers that run Javascript server-side and are able to manipulate the DOM but it has nothing to do with PHP .
<http://jaxer.org/> |
2,699,180 | I'm generating your typical Web 2.0 HTML page with PHP: it contains a lot of `<script>` tags and javascript code that will substantially change the DOM after the load event.
Is there a way to get the final HTML code directly from PHP, without opening the page with any browser?
For example, let's say the HTML for the ... | 2010/04/23 | [
"https://Stackoverflow.com/questions/2699180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/95135/"
] | This question is very similar to how to execute javascript in javascript, or php in php, The answer is that you can eval it. If php could eval javascript and javascript could eval php, we would not have this discussion.
In order for JavaScript to eval PHP, it has to parse the PHP code into a structure that represents ... | ```
function visible() {
echo '<script type="text/javascript">
var o = document.getElementById("overlay");
o.style.visibility = "visible";
</script>';
}
```
This is a good way i used often for running JavaScript in PHP |
2,699,180 | I'm generating your typical Web 2.0 HTML page with PHP: it contains a lot of `<script>` tags and javascript code that will substantially change the DOM after the load event.
Is there a way to get the final HTML code directly from PHP, without opening the page with any browser?
For example, let's say the HTML for the ... | 2010/04/23 | [
"https://Stackoverflow.com/questions/2699180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/95135/"
] | You have 2 problems:
1. Execute JavaScript.
2. Update DOM (the html after executing javascript).
To execute javascript you will need a javascript engine. There are currently 3 available for your use:
1. [V8](http://www.php.net/manual/en/book.v8js.php): By Google for Chrome. PHP extension.
2. [Rhino](https://develope... | This question is very similar to how to execute javascript in javascript, or php in php, The answer is that you can eval it. If php could eval javascript and javascript could eval php, we would not have this discussion.
In order for JavaScript to eval PHP, it has to parse the PHP code into a structure that represents ... |
2,699,180 | I'm generating your typical Web 2.0 HTML page with PHP: it contains a lot of `<script>` tags and javascript code that will substantially change the DOM after the load event.
Is there a way to get the final HTML code directly from PHP, without opening the page with any browser?
For example, let's say the HTML for the ... | 2010/04/23 | [
"https://Stackoverflow.com/questions/2699180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/95135/"
] | The best solution that I could find is to use HtmlUnit <http://htmlunit.sourceforge.net/> on the server to execute your html with the javascript and get back the final html that the user would see on the browser.
The library has good support for JavaScript and is headless so you should be able to run it on the server.... | It would be possible if you had a javascript interpreter built into PHP (or at least something on the server you could call to interpret the HTML with javascript embedded). There have been some attempts (eg <http://j4p5.sourceforge.net/index.php>), but I would steer clear of these and try to rethink what you're doing. ... |
1,830,109 | My book states, without a proof, that
>
> If $q(X)$ is reducible in $\mathbb Z[X]$, then it's reducible in $\mathbb Z\_p[X]$ for every prime $p$.
>
>
>
The contrapositive of the above result is more useful: if one finds a prime $p$ such that $q(X)$ is irreducible in $\mathbb Z\_p[X]$, then it's irreducible in $\m... | 2016/06/17 | [
"https://math.stackexchange.com/questions/1830109",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/2582/"
] | The following implication is true (as you mention):
$$q(X) \in \Bbb Z[X] \text{ monic reducible } \implies \bar q(X) \in \Bbb Z/p\Bbb Z[X] \text{ reducible for all prime } p$$
The contrapositive of this implication is:
$$\bar q(X) \in \Bbb Z/p\Bbb Z[X] \text{ irreducible for some prime } p \implies q(X) \in \Bbb Z[X] \... | **The idea of the proof**
Suppose $q(X)$ reducible over $\mathbb Z[X]$. Then, $$q(X)=R(X)P(X)$$
where $\deg q,\deg R>0$. In particular, in $\mathbb Z\_p[X]$, $$\bar q(X)=\bar R(X)\bar P(X).$$
Now, you have to manage with primitive polynomials, since in $\mathbb Z\_p[X]$, some polynomial can be null (that is not possi... |
29,755,802 | I have the following code for creating a JTable
```
public void tableTeam()
{
rl.readRunners();
String[] sampleHeaders = {"Athlete ID", "Team"};
JTable myTable = new JTable(rl.teamTableData,sampleHeaders);
myTable.setAutoCreateRowSorter(true);
myTable.setRowHeight(20);
///////////////
sor... | 2015/04/20 | [
"https://Stackoverflow.com/questions/29755802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4601149/"
] | In order to update the table you can use the following:
```
myTable.setModel(new DefaultTableModel(rl.teamTableData,sampleHeaders));
``` | The refreshTeam method (note java methods should begin with lowercase) is not updating the JTable, it is creating a new table entirely, and then trying to add these Components to (what I presume is) an already visible UI. The UI is unaware of this, so after adding/removing Components you should call...
```
revalidate(... |
57,471,125 | I want to replace exact word in mysql.
For example, I want to replace 'u' with 'you' in a sentence.
sentence: are u sure.
output : are you sure.
I tried use replace but it is also changing 'u' in 'sure'. but i can't get the exact word to replace
Also i want change the cases where **u** like **"u, can"** , **"can u?... | 2019/08/13 | [
"https://Stackoverflow.com/questions/57471125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11920487/"
] | You have wrong parameter the replace format in this case is not `set columnname = replace(columnname,'you','u')` but `replace(columnname,'u','you')`
and you should also check for word boundaries .. ' u '
and you could use also like
```
update table
set columnname = replace(columnname,' u ',' you ')
where columnname... | If you want an exact word you should include the spaces around the word. so rather than `replace(columnname,'you','u')` you use `replace(columnname,' you ',' u ')` That should cover the situation you described
>
> I tried use replace but it is also changing 'u' in 'sure'. but i can't get the exact word to replace
> ... |
33,783,300 | I'm trying to implement encapsulation in a program as part of some coursework however I've run into an error which I just can't seem to be able to fix with my limited knowledge which isn't helped by my Teacher/Lecturer who is very good at what he does however doesn't do very well when it actually comes to communicating... | 2015/11/18 | [
"https://Stackoverflow.com/questions/33783300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4793393/"
] | When you call:
```
System.out.println("The perimeter is " + r.perimeter());
```
in r.perimeter you must pass two parameters (as your signature wants)
Your method in Rectangle class:
```
double perimeter(double h, double w){
getHeight();
getWidth();
return getHeight() * 2 + getWidth() * 2;
}
```
So fi... | The method `perimeter` in the class `Rectangle` expects two parameters, and you're not passing any. You could either call it like this:
```
r.perimeter(7.8,4.2);
```
Or redefine the method so it looks like this:
```
double perimeter(){
return getHeight() * 2 + getWidth() * 2;
}
``` |
33,783,300 | I'm trying to implement encapsulation in a program as part of some coursework however I've run into an error which I just can't seem to be able to fix with my limited knowledge which isn't helped by my Teacher/Lecturer who is very good at what he does however doesn't do very well when it actually comes to communicating... | 2015/11/18 | [
"https://Stackoverflow.com/questions/33783300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4793393/"
] | When you call:
```
System.out.println("The perimeter is " + r.perimeter());
```
in r.perimeter you must pass two parameters (as your signature wants)
Your method in Rectangle class:
```
double perimeter(double h, double w){
getHeight();
getWidth();
return getHeight() * 2 + getWidth() * 2;
}
```
So fi... | Thats because you are defining the `perimeter` function like this:
```
double perimeter(double h, double w){
getHeight();
getWidth();
return getHeight() * 2 + getWidth() * 2;
}
```
and calling `System.out.println("The perimeter is " + r.perimeter());` with no parameters.
Since you are not really using `... |
33,783,300 | I'm trying to implement encapsulation in a program as part of some coursework however I've run into an error which I just can't seem to be able to fix with my limited knowledge which isn't helped by my Teacher/Lecturer who is very good at what he does however doesn't do very well when it actually comes to communicating... | 2015/11/18 | [
"https://Stackoverflow.com/questions/33783300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4793393/"
] | When you call:
```
System.out.println("The perimeter is " + r.perimeter());
```
in r.perimeter you must pass two parameters (as your signature wants)
Your method in Rectangle class:
```
double perimeter(double h, double w){
getHeight();
getWidth();
return getHeight() * 2 + getWidth() * 2;
}
```
So fi... | Modify your signature to remove the arguments.
```
class Rectangle extends TwoDShapeEncap{
///...
double perimeter(double h, double w){
getHeight();
getWidth();
return getHeight() * 2 + getWidth() * 2;
}
```
should be
```
class Rectangle extends TwoDShapeEncap{
///...
... |
33,783,300 | I'm trying to implement encapsulation in a program as part of some coursework however I've run into an error which I just can't seem to be able to fix with my limited knowledge which isn't helped by my Teacher/Lecturer who is very good at what he does however doesn't do very well when it actually comes to communicating... | 2015/11/18 | [
"https://Stackoverflow.com/questions/33783300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4793393/"
] | When you call:
```
System.out.println("The perimeter is " + r.perimeter());
```
in r.perimeter you must pass two parameters (as your signature wants)
Your method in Rectangle class:
```
double perimeter(double h, double w){
getHeight();
getWidth();
return getHeight() * 2 + getWidth() * 2;
}
```
So fi... | Since everybody is just facing the problem with the parameters I will face this problem: Getters are used to get the values of private fields if you're "outside" your class! If you're in a method in your class you don't have to use the getters, you can just use the variables themselfs:
**Example:**
```
public class S... |
33,783,300 | I'm trying to implement encapsulation in a program as part of some coursework however I've run into an error which I just can't seem to be able to fix with my limited knowledge which isn't helped by my Teacher/Lecturer who is very good at what he does however doesn't do very well when it actually comes to communicating... | 2015/11/18 | [
"https://Stackoverflow.com/questions/33783300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4793393/"
] | The method `perimeter` in the class `Rectangle` expects two parameters, and you're not passing any. You could either call it like this:
```
r.perimeter(7.8,4.2);
```
Or redefine the method so it looks like this:
```
double perimeter(){
return getHeight() * 2 + getWidth() * 2;
}
``` | Modify your signature to remove the arguments.
```
class Rectangle extends TwoDShapeEncap{
///...
double perimeter(double h, double w){
getHeight();
getWidth();
return getHeight() * 2 + getWidth() * 2;
}
```
should be
```
class Rectangle extends TwoDShapeEncap{
///...
... |
33,783,300 | I'm trying to implement encapsulation in a program as part of some coursework however I've run into an error which I just can't seem to be able to fix with my limited knowledge which isn't helped by my Teacher/Lecturer who is very good at what he does however doesn't do very well when it actually comes to communicating... | 2015/11/18 | [
"https://Stackoverflow.com/questions/33783300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4793393/"
] | Thats because you are defining the `perimeter` function like this:
```
double perimeter(double h, double w){
getHeight();
getWidth();
return getHeight() * 2 + getWidth() * 2;
}
```
and calling `System.out.println("The perimeter is " + r.perimeter());` with no parameters.
Since you are not really using `... | Modify your signature to remove the arguments.
```
class Rectangle extends TwoDShapeEncap{
///...
double perimeter(double h, double w){
getHeight();
getWidth();
return getHeight() * 2 + getWidth() * 2;
}
```
should be
```
class Rectangle extends TwoDShapeEncap{
///...
... |
33,783,300 | I'm trying to implement encapsulation in a program as part of some coursework however I've run into an error which I just can't seem to be able to fix with my limited knowledge which isn't helped by my Teacher/Lecturer who is very good at what he does however doesn't do very well when it actually comes to communicating... | 2015/11/18 | [
"https://Stackoverflow.com/questions/33783300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4793393/"
] | Since everybody is just facing the problem with the parameters I will face this problem: Getters are used to get the values of private fields if you're "outside" your class! If you're in a method in your class you don't have to use the getters, you can just use the variables themselfs:
**Example:**
```
public class S... | Modify your signature to remove the arguments.
```
class Rectangle extends TwoDShapeEncap{
///...
double perimeter(double h, double w){
getHeight();
getWidth();
return getHeight() * 2 + getWidth() * 2;
}
```
should be
```
class Rectangle extends TwoDShapeEncap{
///...
... |
32,085,080 | I've written a custom validator for my schema field as shown in the documentation here:
<http://docs.plone.org/develop/plone/forms/z3c.form.html#form-widget-validators>
[](https://i.stack.imgur.com/lETqs.jpg)
My question is that if i want to use the ... | 2015/08/19 | [
"https://Stackoverflow.com/questions/32085080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/972336/"
] | As a workaround I have written two identical validators with different names which violates the DRY principle but not much i can for this one it seems... | It is possible to pass a field **type** as well for the `field` argument
(see: <https://docs.plone.org/develop/addons/schema-driven-forms/customising-form-behaviour/validation.html#field-widget-validators>): `validator.WidgetValidatorDiscriminators(MyListValidator, field=schema.List)`
In the above example the validato... |
32,085,080 | I've written a custom validator for my schema field as shown in the documentation here:
<http://docs.plone.org/develop/plone/forms/z3c.form.html#form-widget-validators>
[](https://i.stack.imgur.com/lETqs.jpg)
My question is that if i want to use the ... | 2015/08/19 | [
"https://Stackoverflow.com/questions/32085080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/972336/"
] | As a workaround I have written two identical validators with different names which violates the DRY principle but not much i can for this one it seems... | It's an old question but I just recently faced this problem and this is my approach:
1. Set a schema interface for the field to be validated.
```
class ICaptchaSchema(model.Schema):
captcha = schema.TextLine(
title=_('security_check', default="Security check"),
)
```
2. Use the field in form... |
41,110,871 | I'm trying to write a query that returns all the records when a certain column (value) is older than 1/1/1996. The data type of the column is `varchar`, so I'm converting it first to a `datetime` format.
Here is the query:
```
select *
from T1
where convert(varchar(20), convert(datetime, value), 113) > convert(varcha... | 2016/12/12 | [
"https://Stackoverflow.com/questions/41110871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/389884/"
] | Just compare dates:
```
where convert(datetime, value, 113) < '1996-01-01'
```
Only convert if you need to, for some reason.
And for constants, use ISO standard formats such as YYYY-MM-DD. | Try this
```
select *
from T1
where convert(datetime, value, 113) < convert(datetime, '1/1/1996', 113)
``` |
41,110,871 | I'm trying to write a query that returns all the records when a certain column (value) is older than 1/1/1996. The data type of the column is `varchar`, so I'm converting it first to a `datetime` format.
Here is the query:
```
select *
from T1
where convert(varchar(20), convert(datetime, value), 113) > convert(varcha... | 2016/12/12 | [
"https://Stackoverflow.com/questions/41110871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/389884/"
] | Just compare dates:
```
where convert(datetime, value, 113) < '1996-01-01'
```
Only convert if you need to, for some reason.
And for constants, use ISO standard formats such as YYYY-MM-DD. | SQL Server does intrinsic data conversions, so if your column were to be DATE, then this would be real easy.
However, since it is stored as a string (which is a very very bad idea), you have to convert it to a DATE first before using it.
First, test your column to make sure you can actually convert everything
```
Se... |
41,110,871 | I'm trying to write a query that returns all the records when a certain column (value) is older than 1/1/1996. The data type of the column is `varchar`, so I'm converting it first to a `datetime` format.
Here is the query:
```
select *
from T1
where convert(varchar(20), convert(datetime, value), 113) > convert(varcha... | 2016/12/12 | [
"https://Stackoverflow.com/questions/41110871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/389884/"
] | Just compare dates:
```
where convert(datetime, value, 113) < '1996-01-01'
```
Only convert if you need to, for some reason.
And for constants, use ISO standard formats such as YYYY-MM-DD. | There are many ways to CONVERT or CAST datetimes in SQL Server. Others have covered `CONVERT(datetime,value,113)` very well but I noticed your comment that `'10/9/2001 11:00:00 PM'` failes conversion and that would be because format `113` is `Europe default + mmilliseconds` or `don mon yyyy hh:mi:ss:mmm(24hr)`.
So you... |
41,110,871 | I'm trying to write a query that returns all the records when a certain column (value) is older than 1/1/1996. The data type of the column is `varchar`, so I'm converting it first to a `datetime` format.
Here is the query:
```
select *
from T1
where convert(varchar(20), convert(datetime, value), 113) > convert(varcha... | 2016/12/12 | [
"https://Stackoverflow.com/questions/41110871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/389884/"
] | There are many ways to CONVERT or CAST datetimes in SQL Server. Others have covered `CONVERT(datetime,value,113)` very well but I noticed your comment that `'10/9/2001 11:00:00 PM'` failes conversion and that would be because format `113` is `Europe default + mmilliseconds` or `don mon yyyy hh:mi:ss:mmm(24hr)`.
So you... | Try this
```
select *
from T1
where convert(datetime, value, 113) < convert(datetime, '1/1/1996', 113)
``` |
41,110,871 | I'm trying to write a query that returns all the records when a certain column (value) is older than 1/1/1996. The data type of the column is `varchar`, so I'm converting it first to a `datetime` format.
Here is the query:
```
select *
from T1
where convert(varchar(20), convert(datetime, value), 113) > convert(varcha... | 2016/12/12 | [
"https://Stackoverflow.com/questions/41110871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/389884/"
] | There are many ways to CONVERT or CAST datetimes in SQL Server. Others have covered `CONVERT(datetime,value,113)` very well but I noticed your comment that `'10/9/2001 11:00:00 PM'` failes conversion and that would be because format `113` is `Europe default + mmilliseconds` or `don mon yyyy hh:mi:ss:mmm(24hr)`.
So you... | SQL Server does intrinsic data conversions, so if your column were to be DATE, then this would be real easy.
However, since it is stored as a string (which is a very very bad idea), you have to convert it to a DATE first before using it.
First, test your column to make sure you can actually convert everything
```
Se... |
20,202,570 | I've created a database using MySQL and connected it to Catalyst framework in order to create a web interface.
I have to visualize my data using [d3.js](http://www.d3js.org) which gets data in JSON format.
I have created a php script which queries the database and exports the result of the query in JSON format.
Unfor... | 2013/11/25 | [
"https://Stackoverflow.com/questions/20202570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1563206/"
] | You can use Catalyst::View::JSON as recommended by Julien, but for the simple case:
```
=== SomeController.pm ===
package MyApp::Controllers::SomeController;
use strict;
use warnings;
use base 'Catalyst::Controller';
use JSON;
sub my_json_action :Local {
my ($self, $c, @args) = @_;
my $result = ... some pr... | You can render JSON through [Catalyst::View::JSON](http://search.cpan.org/perldoc?Catalyst%3a%3aView%3a%3aJSON).
```
sub my_json_action :Local {
my ($self, $c, @args) = @_;
my $result = ... some process or logic ...
$c->stash(
'foo' => 'bar',
'array' => [1,2],
);
$c->forwa... |
61,244,053 | and if not what are more things that we can do with spring boot?
i know that we can build a whole web app(frontend and backend) in one spring boot application in the folder resource/template and resource/static but in the real world does somebody uses this method to create web application with the resource/template an... | 2020/04/16 | [
"https://Stackoverflow.com/questions/61244053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11808013/"
] | No Spring Boot isn't just for REST APIs.
Spring Boot is "just" a mechanism for autoconfiguring a Spring Framework based application.
Therefore you can use and it does get used for all kinds of stuff.
* REST APIs for webservices
* Full web application using Spring MVC
* SOAP services (or are they called SOAP dispens... | This involves complete Spring history,
Actual motive of Spring was to enable loose coupling , so that unit tests can be easily performed . Spring MVC was for developing web applications with Model View Controller having their proper boundaries.
Then Spring Boot which enabled developer to focus on business logic then ... |
9,006,907 | I have iPhone 4 device and tested my app on it and it works perfectly fine, but when I sent app to my client having iPhone 3GS, its crashes at some particular view.
My question is that can I test my app on 3GS without real device like on simulator?,Also am I able to see the crash device logs of my client device. | 2012/01/25 | [
"https://Stackoverflow.com/questions/9006907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2450704/"
] | First you have to get the crashlog from your client, as it was probably you who compiled the build, your XCode will be able to symbolicate it. Then it should be easy to find the line wich crashs.
You can also try to reproduce the crash with the emulator, but keep it mind that it's not exactly the same as a real device... | Use <https://testflightapp.com/> for see logs from app. |
80,667 | For example usage, on asking a question.
The lack of response was expected/annoying...
Google gave me 'Indifferent' but I believe there must be something else. | 2012/09/05 | [
"https://english.stackexchange.com/questions/80667",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/589/"
] | "Inaction", "Inattention", or "Disregard" might be fitting. The first most fitting I think but maybe a little broad.
>
> The inaction was expected.
>
>
> | I suggest the slang office-speak term "crickets".
To *'get crickets'* during a conference call is to
have asked a question, waited for a response, and heard
only silence.
Example: *"when the district sales manager called a surprise meeting and asked for feedback, he got only 'crickets'..."* |
80,667 | For example usage, on asking a question.
The lack of response was expected/annoying...
Google gave me 'Indifferent' but I believe there must be something else. | 2012/09/05 | [
"https://english.stackexchange.com/questions/80667",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/589/"
] | Perhaps
>
> The silence was deafening.
>
>
> | Consider *[stodginess](http://en.wiktionary.org/wiki/stodginess)* (“state or quality of being stodgy”, *ie* of being dull, old-fashioned); as in “The stodginess of their response shocked me.” Also consider *[complacency](http://en.wiktionary.org/wiki/complacency#Noun)*, as in “The complacency of their response amazed m... |
80,667 | For example usage, on asking a question.
The lack of response was expected/annoying...
Google gave me 'Indifferent' but I believe there must be something else. | 2012/09/05 | [
"https://english.stackexchange.com/questions/80667",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/589/"
] | "Unresponsiveness" works if you really need it to be a single word. | If OP doesn't like **indifference**, how about
>
> [apathy](http://www.thefreedictionary.com/apathy) *- lack of interest or concern, especially regarding matters of general importance or appeal*
>
>
> |
80,667 | For example usage, on asking a question.
The lack of response was expected/annoying...
Google gave me 'Indifferent' but I believe there must be something else. | 2012/09/05 | [
"https://english.stackexchange.com/questions/80667",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/589/"
] | Perhaps
>
> The silence was deafening.
>
>
> | *The **stonewalling** was expected/annoying...*
Wikipedia says :
>
> Stonewalling is a refusal to communicate or cooperate. Such behaviour occurs in situations such as marriage guidance counseling, diplomatic negotiations, politics and legal cases
>
>
>
and *Dictionary.com Unabridged.
Based on the Random House D... |
80,667 | For example usage, on asking a question.
The lack of response was expected/annoying...
Google gave me 'Indifferent' but I believe there must be something else. | 2012/09/05 | [
"https://english.stackexchange.com/questions/80667",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/589/"
] | "Inaction", "Inattention", or "Disregard" might be fitting. The first most fitting I think but maybe a little broad.
>
> The inaction was expected.
>
>
> | Maybe
>
> They stayed away in droves.
>
>
> (attributed to Samuel Goldwyn)
>
>
> |
80,667 | For example usage, on asking a question.
The lack of response was expected/annoying...
Google gave me 'Indifferent' but I believe there must be something else. | 2012/09/05 | [
"https://english.stackexchange.com/questions/80667",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/589/"
] | *The **stonewalling** was expected/annoying...*
Wikipedia says :
>
> Stonewalling is a refusal to communicate or cooperate. Such behaviour occurs in situations such as marriage guidance counseling, diplomatic negotiations, politics and legal cases
>
>
>
and *Dictionary.com Unabridged.
Based on the Random House D... | Maybe
>
> They stayed away in droves.
>
>
> (attributed to Samuel Goldwyn)
>
>
> |
80,667 | For example usage, on asking a question.
The lack of response was expected/annoying...
Google gave me 'Indifferent' but I believe there must be something else. | 2012/09/05 | [
"https://english.stackexchange.com/questions/80667",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/589/"
] | Consider *[stodginess](http://en.wiktionary.org/wiki/stodginess)* (“state or quality of being stodgy”, *ie* of being dull, old-fashioned); as in “The stodginess of their response shocked me.” Also consider *[complacency](http://en.wiktionary.org/wiki/complacency#Noun)*, as in “The complacency of their response amazed m... | Maybe
>
> They stayed away in droves.
>
>
> (attributed to Samuel Goldwyn)
>
>
> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.