qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
35,353,350 | I am trying to include an AlertDialog builder within a method that prompts for a pin code and when the positive button is pressed, checks it against a database value and returns a true or false value to the method caller.
For example: Adding/editing/deleting a user task requires a pin code. I don't want to generate a ... | 2016/02/12 | [
"https://Stackoverflow.com/questions/35353350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3113200/"
] | A dialog can't "return" a value in the way that it looks like you're expecting. A dialog can make changes to some other object, but you can't have a bit of code block on it and wait for the user to finish interacting with it.
Instead, you'll need to set up listeners for when the prompt dialog is [dismissed](http://dev... | this is how i'm doing :
```
public Boolean showAlert(String message)
{
action = false;
AlertDialog.Builder alertDialog = new AlertDialog.Builder(HAActivity.this);
// Setting Dialog Title
alertDialog.setTitle(getString(R.string.app_name));
// Setting Dialog Message
alertDialog.setMessage(me... |
35,353,350 | I am trying to include an AlertDialog builder within a method that prompts for a pin code and when the positive button is pressed, checks it against a database value and returns a true or false value to the method caller.
For example: Adding/editing/deleting a user task requires a pin code. I don't want to generate a ... | 2016/02/12 | [
"https://Stackoverflow.com/questions/35353350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3113200/"
] | You can create your own method to generate dialog with listener:
```
public void isCorrectPin(Context context, String title, String message, String btnPositive, final DialogSingleButtonListener dialogSingleButtonListener) {
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
dialogBuild... | this is how i'm doing :
```
public Boolean showAlert(String message)
{
action = false;
AlertDialog.Builder alertDialog = new AlertDialog.Builder(HAActivity.this);
// Setting Dialog Title
alertDialog.setTitle(getString(R.string.app_name));
// Setting Dialog Message
alertDialog.setMessage(me... |
174,542 | Why do games usually only allow some specific resolutions, instead of allowing arbitrary window resizing? Are there any technical difficulties for arbitrary window resizing? | 2019/08/11 | [
"https://gamedev.stackexchange.com/questions/174542",
"https://gamedev.stackexchange.com",
"https://gamedev.stackexchange.com/users/126344/"
] | There are plenty of games out there, some are from big studios, some use well established and battle tested tools, plenty don't. I can think of plenty of things that could go wrong when it comes to resolution.
*I am leaving aside the fact that on full-screen the monitor and driver combo will have a set of supported mo... | It’s already something of a chore to support multiple fixed window sizes and aspect ratios in terms of UI scaling, managing the visible play area (especially in some kinds competitive games), render target sizing and compositing, and so on. Just look around here at the number of questions focused on aspect ratio handli... |
576,737 | I recently moved over to `luaLaTeX` from `pdfLaTeX` which means I am no longer quite so font-constrained. I found [this answer](https://tex.stackexchange.com/a/431804/7880) which shows how to load this alphabet of upright Greek letters instead of the math alphabet. I *don't* want to load them in place of the math alpha... | 2020/12/29 | [
"https://tex.stackexchange.com/questions/576737",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/7880/"
] | You can hide the height of the heading and then adjust with a zero width rule:
[](https://i.stack.imgur.com/1h7dX.png)
```
\documentclass{report}
\usepackage{booktabs}
\begin{document}
1. booktabs example: Last column head fits on single line
\be... | Not sure if what I'm doing here is right, pls strike if not.
Both answers to my question work, and gave me what I needed, but it took me many hours over several days to understand them. Here is what I needed to learn.
The TeX Book C18 Fine Points of Mathematics Typing: \smash ``makes the height and depth zero.''
C11... |
576,737 | I recently moved over to `luaLaTeX` from `pdfLaTeX` which means I am no longer quite so font-constrained. I found [this answer](https://tex.stackexchange.com/a/431804/7880) which shows how to load this alphabet of upright Greek letters instead of the math alphabet. I *don't* want to load them in place of the math alpha... | 2020/12/29 | [
"https://tex.stackexchange.com/questions/576737",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/7880/"
] | I'd strive for making the header just two rows, smashing it so its depth is not seen.
```
\documentclass{report}
\usepackage{booktabs}
\newcommand{\smashedcell}[2]{%
\smash{\begin{tabular}[t]{@{}#1@{}}#2\end{tabular}}%
}
\begin{document}
1. booktabs example: Last column head fits on single line
\begin{center}
\... | Not sure if what I'm doing here is right, pls strike if not.
Both answers to my question work, and gave me what I needed, but it took me many hours over several days to understand them. Here is what I needed to learn.
The TeX Book C18 Fine Points of Mathematics Typing: \smash ``makes the height and depth zero.''
C11... |
60,736,648 | I Have defined an input field like below:
```html
<label>Enter more months</label>
<input #mname type='text' id="mname" >
<button (click)="addMonth(mname.value)" style="height: 30px;"></button>
```
on clicking on the button I want the value of the input field to be printed on the console ,for which i am ... | 2020/03/18 | [
"https://Stackoverflow.com/questions/60736648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12831046/"
] | I don't have an explanation of why your cube root call to `POWER` is not working. However, given that the input is a negative number (`-8`), the output should be equivalent to the negative of the cube root of the positive input:
```
SELECT -1.0*POWER(8.000, 1.000 / 3) AS output;
```
This outputs `-2.000` as expected... | The reason your calculation doesn't work is because:
```
(-8)^(1/3) --> an integer, -2
(-8)^(0.33333333333333) --> a complex number
```
That is, floating point values are inexact and cannot represent something like one-third. And the value has to be *exactly* 1/3 in order for the value to be a floating ... |
53,457,964 | I've seen there are a couple questions similar to this one but none of them seem to solve my problem.
I want a very simple design:
Two or more divs stacked on top of each other, each of them docked to the right. I'm practicing for a test on which using the float property is not allowed.
```css
body{
width:90... | 2018/11/24 | [
"https://Stackoverflow.com/questions/53457964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8873813/"
] | I can see two issues here.
The first is that you're trying to use `getElementById` with elements that don't appear to exist yet ("minutes", "hours", "days"). Elements with those IDs need to exist in the DOM before they can be accessed using the `getElementById` method.
One way to address this is to wrap your current ... | The issue is not with JS it seems.
Can not read property style of null means style property of the object you are trying to access is null.
Please check all the document.getElementById api you are using for the elements have correct id present in html elements(that you are using in code).
Also check in your browser co... |
1,001,198 | I have Blank screen disabled but my PC seems to be ignoring this. This issue also ignores the [Caffeine](https://extensions.gnome.org/extension/517/caffeine/) extension. This is pretty recent behavior as it's been working for a long while now.
[](https://i.stack.im... | 2018/01/30 | [
"https://askubuntu.com/questions/1001198",
"https://askubuntu.com",
"https://askubuntu.com/users/685801/"
] | This is from another [answer](https://askubuntu.com/questions/1000734/prevent-a-workstation-screen-from-dimming/1000745#1000745) I posted recently. You may not need the Login screen section.
Terminal CLI method
===================
To prevent screen from turning off you need two settings, one under battery power the o... | Nothing in the accepted answer has worked for me in 18.04. Instead I had to do the following:
```
gsettings set org.gnome.settings-daemon.plugins.power idle-brightness 100
```
Note that this doesn't set the idle to 100% of the max but 100% of the current setting (at least I think that's what it's doing). If you have... |
1,001,198 | I have Blank screen disabled but my PC seems to be ignoring this. This issue also ignores the [Caffeine](https://extensions.gnome.org/extension/517/caffeine/) extension. This is pretty recent behavior as it's been working for a long while now.
[](https://i.stack.im... | 2018/01/30 | [
"https://askubuntu.com/questions/1001198",
"https://askubuntu.com",
"https://askubuntu.com/users/685801/"
] | This is from another [answer](https://askubuntu.com/questions/1000734/prevent-a-workstation-screen-from-dimming/1000745#1000745) I posted recently. You may not need the Login screen section.
Terminal CLI method
===================
To prevent screen from turning off you need two settings, one under battery power the o... | I just want to add, that as a troubleshooting step w.r.t. my ...
Conspiratorially derived answer, that Ubuntu "Did Not Want" me logged into "Gnome on Xorg" ... as it sure seemed.
After a restart and the issue gone ... again, I specifically logged out of "Ubuntu" and logged back in via "Gnome on Xorg",
and No Problem... |
1,001,198 | I have Blank screen disabled but my PC seems to be ignoring this. This issue also ignores the [Caffeine](https://extensions.gnome.org/extension/517/caffeine/) extension. This is pretty recent behavior as it's been working for a long while now.
[](https://i.stack.im... | 2018/01/30 | [
"https://askubuntu.com/questions/1001198",
"https://askubuntu.com",
"https://askubuntu.com/users/685801/"
] | Nothing in the accepted answer has worked for me in 18.04. Instead I had to do the following:
```
gsettings set org.gnome.settings-daemon.plugins.power idle-brightness 100
```
Note that this doesn't set the idle to 100% of the max but 100% of the current setting (at least I think that's what it's doing). If you have... | I just want to add, that as a troubleshooting step w.r.t. my ...
Conspiratorially derived answer, that Ubuntu "Did Not Want" me logged into "Gnome on Xorg" ... as it sure seemed.
After a restart and the issue gone ... again, I specifically logged out of "Ubuntu" and logged back in via "Gnome on Xorg",
and No Problem... |
39,025,060 | I have the following code fragment. No problem with it:
```
while (++left < to && less(a[left], a[from]));
```
where left is some array index, less(a, b) is helper function that returns true iff a <= b; a - array[from <= array index < to]
I particularly don't understand difference of the upper code from this:
```... | 2016/08/18 | [
"https://Stackoverflow.com/questions/39025060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6546340/"
] | One difference between the placement comes from *not* executing `++` when `left` equal to `to-1`: this means that `++left` is equal to `to`, making `<` evaluate to `false`. This, in turn, leads to omitting the call to `less(...)` altogether due to short-circuiting of `&&`, thus preventing the exception.
When you move ... | In the second snippet, first condition will evaluate to true upto max value of `to - 1`; which will cause second condition to evaluate with `left` value equal to `to` due to pre-increment. This is what may cause the index-out-of-bounds exception. |
12,726,413 | I have a user that has a number of roles. The user is linked to the roles using a link entity table. I have set the configuration file to cascade delete the user role link entities when a user is deleted.
We are currently using soft delete to delete entities. We have added a soft delete event listener that is triggere... | 2012/10/04 | [
"https://Stackoverflow.com/questions/12726413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1223982/"
] | Found what the problem was.
Using soft delete will actually trigger update to set isDeleted flag. Because of this line in a mapping
```
cascade="all"
```
the cascade is applied for both **Update and Evict** actions. My postUpdate will be fired 2 times, but the same time Evict will try to evict on child entities.
... | I ran into the same problem, but since I'm using Fluent mappings there's no option to exclude `Evict` from the cascade. My solution was to avoid calling `Evict` and just remove the entity from the session cache:
```
public void OnPostUpdate(PostUpdateEvent @event)
{
var entity = @event.Entity as ISoftDeletable;
... |
12,726,413 | I have a user that has a number of roles. The user is linked to the roles using a link entity table. I have set the configuration file to cascade delete the user role link entities when a user is deleted.
We are currently using soft delete to delete entities. We have added a soft delete event listener that is triggere... | 2012/10/04 | [
"https://Stackoverflow.com/questions/12726413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1223982/"
] | According to <https://forum.hibernate.org/viewtopic.php?p=2424890> another way to avoid this is to basically call
```
session.save(s);
session.flush(); // allow evict to work
session.evict(s);
```
and that the root of the problem is that "if I've evicted the entity from cache the commit... | Found what the problem was.
Using soft delete will actually trigger update to set isDeleted flag. Because of this line in a mapping
```
cascade="all"
```
the cascade is applied for both **Update and Evict** actions. My postUpdate will be fired 2 times, but the same time Evict will try to evict on child entities.
... |
12,726,413 | I have a user that has a number of roles. The user is linked to the roles using a link entity table. I have set the configuration file to cascade delete the user role link entities when a user is deleted.
We are currently using soft delete to delete entities. We have added a soft delete event listener that is triggere... | 2012/10/04 | [
"https://Stackoverflow.com/questions/12726413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1223982/"
] | According to <https://forum.hibernate.org/viewtopic.php?p=2424890> another way to avoid this is to basically call
```
session.save(s);
session.flush(); // allow evict to work
session.evict(s);
```
and that the root of the problem is that "if I've evicted the entity from cache the commit... | I ran into the same problem, but since I'm using Fluent mappings there's no option to exclude `Evict` from the cascade. My solution was to avoid calling `Evict` and just remove the entity from the session cache:
```
public void OnPostUpdate(PostUpdateEvent @event)
{
var entity = @event.Entity as ISoftDeletable;
... |
39,396,908 | Am looking for something similar to [`scrollIntoView()`](https://developer.mozilla.org/en/docs/Web/API/Element/scrollIntoView) within Ionic2 to use when I click on a button, for example.
None of the methods detailed in [`ion-content`](http://ionicframework.com/docs/v2/api/components/content/Content/) help. | 2016/09/08 | [
"https://Stackoverflow.com/questions/39396908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275105/"
] | Please take a look at **[this working plunker](http://plnkr.co/edit/fOsyCC?p=preview)**
You can use the `scrollTo(x,y,duration)` method [(docs)](http://ionicframework.com/docs/v2/api/components/content/Content/#scrollTo).
The code is pretty simple, first we obtain the position of the target element (a `<p></p>` in thi... | The ion-content **should** have methods for scrolling to particular child elements, however deep. The current methods are okay, but one perspective of the purpose of ionic is to make laborious, boring code like `document.getElementById` obsolete.
The methods also lack control over the scroll animation.
Hence currentl... |
39,396,908 | Am looking for something similar to [`scrollIntoView()`](https://developer.mozilla.org/en/docs/Web/API/Element/scrollIntoView) within Ionic2 to use when I click on a button, for example.
None of the methods detailed in [`ion-content`](http://ionicframework.com/docs/v2/api/components/content/Content/) help. | 2016/09/08 | [
"https://Stackoverflow.com/questions/39396908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275105/"
] | For Ionic-4 there are multiple changes in the terms used
1. **Content** is changed to **IonContent**
2. **scrollTo** is changed to **scrollToPoint**
3. **ionic-angular** is changed to **@ionic/angular**
4. viewChild has to have **{ static: false }** // only if you are using angular >8.0
Here is the code modified of ... | Can I use scrollToPoint on div instead of content when I have fixed content and the scroll on div or form. |
39,396,908 | Am looking for something similar to [`scrollIntoView()`](https://developer.mozilla.org/en/docs/Web/API/Element/scrollIntoView) within Ionic2 to use when I click on a button, for example.
None of the methods detailed in [`ion-content`](http://ionicframework.com/docs/v2/api/components/content/Content/) help. | 2016/09/08 | [
"https://Stackoverflow.com/questions/39396908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275105/"
] | Please take a look at **[this working plunker](http://plnkr.co/edit/fOsyCC?p=preview)**
You can use the `scrollTo(x,y,duration)` method [(docs)](http://ionicframework.com/docs/v2/api/components/content/Content/#scrollTo).
The code is pretty simple, first we obtain the position of the target element (a `<p></p>` in thi... | In `Ionic 4` the scroll function is renamed to `scrollToPoint()`.
 |
39,396,908 | Am looking for something similar to [`scrollIntoView()`](https://developer.mozilla.org/en/docs/Web/API/Element/scrollIntoView) within Ionic2 to use when I click on a button, for example.
None of the methods detailed in [`ion-content`](http://ionicframework.com/docs/v2/api/components/content/Content/) help. | 2016/09/08 | [
"https://Stackoverflow.com/questions/39396908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275105/"
] | I was trying to do this in Ionic 3 and due to the fact that `<Element>.offsetTop` was returning`10` (the padding on the top of the element) instead of the distance to the top of the page (much larger unknown number) I ending up just using `<Element>.scrollIntoView()`, which worked well for me.
To get the `<Element>` o... | In `Ionic 4` the scroll function is renamed to `scrollToPoint()`.
 |
39,396,908 | Am looking for something similar to [`scrollIntoView()`](https://developer.mozilla.org/en/docs/Web/API/Element/scrollIntoView) within Ionic2 to use when I click on a button, for example.
None of the methods detailed in [`ion-content`](http://ionicframework.com/docs/v2/api/components/content/Content/) help. | 2016/09/08 | [
"https://Stackoverflow.com/questions/39396908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275105/"
] | The ion-content **should** have methods for scrolling to particular child elements, however deep. The current methods are okay, but one perspective of the purpose of ionic is to make laborious, boring code like `document.getElementById` obsolete.
The methods also lack control over the scroll animation.
Hence currentl... | I was trying to do this in Ionic 3 and due to the fact that `<Element>.offsetTop` was returning`10` (the padding on the top of the element) instead of the distance to the top of the page (much larger unknown number) I ending up just using `<Element>.scrollIntoView()`, which worked well for me.
To get the `<Element>` o... |
39,396,908 | Am looking for something similar to [`scrollIntoView()`](https://developer.mozilla.org/en/docs/Web/API/Element/scrollIntoView) within Ionic2 to use when I click on a button, for example.
None of the methods detailed in [`ion-content`](http://ionicframework.com/docs/v2/api/components/content/Content/) help. | 2016/09/08 | [
"https://Stackoverflow.com/questions/39396908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275105/"
] | I was trying to do this in Ionic 3 and due to the fact that `<Element>.offsetTop` was returning`10` (the padding on the top of the element) instead of the distance to the top of the page (much larger unknown number) I ending up just using `<Element>.scrollIntoView()`, which worked well for me.
To get the `<Element>` o... | Can I use scrollToPoint on div instead of content when I have fixed content and the scroll on div or form. |
39,396,908 | Am looking for something similar to [`scrollIntoView()`](https://developer.mozilla.org/en/docs/Web/API/Element/scrollIntoView) within Ionic2 to use when I click on a button, for example.
None of the methods detailed in [`ion-content`](http://ionicframework.com/docs/v2/api/components/content/Content/) help. | 2016/09/08 | [
"https://Stackoverflow.com/questions/39396908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275105/"
] | The ion-content **should** have methods for scrolling to particular child elements, however deep. The current methods are okay, but one perspective of the purpose of ionic is to make laborious, boring code like `document.getElementById` obsolete.
The methods also lack control over the scroll animation.
Hence currentl... | In `Ionic 4` the scroll function is renamed to `scrollToPoint()`.
 |
39,396,908 | Am looking for something similar to [`scrollIntoView()`](https://developer.mozilla.org/en/docs/Web/API/Element/scrollIntoView) within Ionic2 to use when I click on a button, for example.
None of the methods detailed in [`ion-content`](http://ionicframework.com/docs/v2/api/components/content/Content/) help. | 2016/09/08 | [
"https://Stackoverflow.com/questions/39396908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275105/"
] | The ion-content **should** have methods for scrolling to particular child elements, however deep. The current methods are okay, but one perspective of the purpose of ionic is to make laborious, boring code like `document.getElementById` obsolete.
The methods also lack control over the scroll animation.
Hence currentl... | I noticed the above solution don't work well with Angular Universal server-side rendering (SSR) due to `document` not being available server-side.
Hence I wrote a convenient plugin to achieve scrolling to elements in Angular 4+ that work with `AoT` and `SSR`
NPM
[ngx-scroll-to](https://www.npmjs.com/package/@nicky... |
39,396,908 | Am looking for something similar to [`scrollIntoView()`](https://developer.mozilla.org/en/docs/Web/API/Element/scrollIntoView) within Ionic2 to use when I click on a button, for example.
None of the methods detailed in [`ion-content`](http://ionicframework.com/docs/v2/api/components/content/Content/) help. | 2016/09/08 | [
"https://Stackoverflow.com/questions/39396908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275105/"
] | For Ionic-4 there are multiple changes in the terms used
1. **Content** is changed to **IonContent**
2. **scrollTo** is changed to **scrollToPoint**
3. **ionic-angular** is changed to **@ionic/angular**
4. viewChild has to have **{ static: false }** // only if you are using angular >8.0
Here is the code modified of ... | I was trying to do this in Ionic 3 and due to the fact that `<Element>.offsetTop` was returning`10` (the padding on the top of the element) instead of the distance to the top of the page (much larger unknown number) I ending up just using `<Element>.scrollIntoView()`, which worked well for me.
To get the `<Element>` o... |
39,396,908 | Am looking for something similar to [`scrollIntoView()`](https://developer.mozilla.org/en/docs/Web/API/Element/scrollIntoView) within Ionic2 to use when I click on a button, for example.
None of the methods detailed in [`ion-content`](http://ionicframework.com/docs/v2/api/components/content/Content/) help. | 2016/09/08 | [
"https://Stackoverflow.com/questions/39396908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275105/"
] | For Ionic-4 there are multiple changes in the terms used
1. **Content** is changed to **IonContent**
2. **scrollTo** is changed to **scrollToPoint**
3. **ionic-angular** is changed to **@ionic/angular**
4. viewChild has to have **{ static: false }** // only if you are using angular >8.0
Here is the code modified of ... | In `Ionic 4` the scroll function is renamed to `scrollToPoint()`.
 |
55,004,686 | I'm trying to implement the [`update`-method for nested representations](https://www.django-rest-framework.org/api-guide/serializers/#writing-update-methods-for-nested-representations) in Django Rest Framework.
```py
from django.db import models
from django.utils import timezone
from rest_framework import serializers... | 2019/03/05 | [
"https://Stackoverflow.com/questions/55004686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1523238/"
] | From [docs](https://www.django-rest-framework.org/api-guide/fields/#core-arguments):
>
> The `default` is not applied during partial update operations. In the partial update case only fields that are provided in the incoming data will have a validated value returned.
>
>
>
So, you are going to have to add the val... | You receive that error because in your Bar model the create\_date attribute has null=False, if you want a default value prefer use [auto\_now or auto\_now\_add](https://docs.djangoproject.com/en/2.1/ref/models/fields/#datefield) arguments in the created\_date attr on your Bar model like this:
```
class Bar(models.Mode... |
2,677,330 | Forgive my clumsy explanation, but I have a class that contains a List:
```
public class Document
{
public int OwnerId { get; set; }
public List<User> Users { get; set; }
public Document() { }
}
public class User
{
public string UserName { get; set; }
public st... | 2010/04/20 | [
"https://Stackoverflow.com/questions/2677330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799/"
] | The university's job is not to teach you a programming language, it's to teach you programming concepts. The language they use is only relevant in terms of the teaching material they have already generated or use from other sources.
I imagine that redoing a curriculum is something like rewriting a large application - ... | I realise this question is rather old and there are many good answers. Nevertheless, I'd like to chime in.
Most of the answers are variations of the "Modula-2 is simpler, thus easier to teach/learn" theme. Although this is correct, it isn't the this-disqualifies-all-else rationale why a university should choose to tea... |
2,677,330 | Forgive my clumsy explanation, but I have a class that contains a List:
```
public class Document
{
public int OwnerId { get; set; }
public List<User> Users { get; set; }
public Document() { }
}
public class User
{
public string UserName { get; set; }
public st... | 2010/04/20 | [
"https://Stackoverflow.com/questions/2677330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799/"
] | I realise this question is rather old and there are many good answers. Nevertheless, I'd like to chime in.
Most of the answers are variations of the "Modula-2 is simpler, thus easier to teach/learn" theme. Although this is correct, it isn't the this-disqualifies-all-else rationale why a university should choose to tea... | The matter of Lisp/ADA vs C/Java is the same as Informatics vs programming. One is a science, the other is a craft. |
2,677,330 | Forgive my clumsy explanation, but I have a class that contains a List:
```
public class Document
{
public int OwnerId { get; set; }
public List<User> Users { get; set; }
public Document() { }
}
public class User
{
public string UserName { get; set; }
public st... | 2010/04/20 | [
"https://Stackoverflow.com/questions/2677330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799/"
] | Although this question seems to have been handled some time ago i wanted to add something (since i am the asker of the mentioned Question :) )
Why we learn Modula2 in our first year:
Apart from all the already mentioned reasons, it is for getting a grip on how basic things (e.g. pointers) work before getting involved w... | I realise this question is rather old and there are many good answers. Nevertheless, I'd like to chime in.
Most of the answers are variations of the "Modula-2 is simpler, thus easier to teach/learn" theme. Although this is correct, it isn't the this-disqualifies-all-else rationale why a university should choose to tea... |
2,677,330 | Forgive my clumsy explanation, but I have a class that contains a List:
```
public class Document
{
public int OwnerId { get; set; }
public List<User> Users { get; set; }
public Document() { }
}
public class User
{
public string UserName { get; set; }
public st... | 2010/04/20 | [
"https://Stackoverflow.com/questions/2677330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799/"
] | Although this question seems to have been handled some time ago i wanted to add something (since i am the asker of the mentioned Question :) )
Why we learn Modula2 in our first year:
Apart from all the already mentioned reasons, it is for getting a grip on how basic things (e.g. pointers) work before getting involved w... | The matter of Lisp/ADA vs C/Java is the same as Informatics vs programming. One is a science, the other is a craft. |
2,677,330 | Forgive my clumsy explanation, but I have a class that contains a List:
```
public class Document
{
public int OwnerId { get; set; }
public List<User> Users { get; set; }
public Document() { }
}
public class User
{
public string UserName { get; set; }
public st... | 2010/04/20 | [
"https://Stackoverflow.com/questions/2677330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799/"
] | >
> Improved modern languages (Java, C#, Haskell) are available for free?
>
>
>
So by "improved" you mean powerful, loaded with external libraries and frameworks, and insanely complicated? With a maze of twisty little features in which beginning students can easily get lost? And when they are lost, they get error ... | I realise this question is rather old and there are many good answers. Nevertheless, I'd like to chime in.
Most of the answers are variations of the "Modula-2 is simpler, thus easier to teach/learn" theme. Although this is correct, it isn't the this-disqualifies-all-else rationale why a university should choose to tea... |
2,677,330 | Forgive my clumsy explanation, but I have a class that contains a List:
```
public class Document
{
public int OwnerId { get; set; }
public List<User> Users { get; set; }
public Document() { }
}
public class User
{
public string UserName { get; set; }
public st... | 2010/04/20 | [
"https://Stackoverflow.com/questions/2677330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799/"
] | Two reasons I can think of, one good, one not. (And I was a prof.)
The good reason: to simplify teaching. Teaching intro students is like herding chicks on a diving board. If there's a way for them to fall off, they will. If I had to teach C, I'd be tearing my hair out, what with `char`, `unsigned char`, `char*`, `cha... | The matter of Lisp/ADA vs C/Java is the same as Informatics vs programming. One is a science, the other is a craft. |
2,677,330 | Forgive my clumsy explanation, but I have a class that contains a List:
```
public class Document
{
public int OwnerId { get; set; }
public List<User> Users { get; set; }
public Document() { }
}
public class User
{
public string UserName { get; set; }
public st... | 2010/04/20 | [
"https://Stackoverflow.com/questions/2677330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799/"
] | >
> Improved modern languages (Java, C#, Haskell) are available for free?
>
>
>
So by "improved" you mean powerful, loaded with external libraries and frameworks, and insanely complicated? With a maze of twisty little features in which beginning students can easily get lost? And when they are lost, they get error ... | Two reasons I can think of, one good, one not. (And I was a prof.)
The good reason: to simplify teaching. Teaching intro students is like herding chicks on a diving board. If there's a way for them to fall off, they will. If I had to teach C, I'd be tearing my hair out, what with `char`, `unsigned char`, `char*`, `cha... |
2,677,330 | Forgive my clumsy explanation, but I have a class that contains a List:
```
public class Document
{
public int OwnerId { get; set; }
public List<User> Users { get; set; }
public Document() { }
}
public class User
{
public string UserName { get; set; }
public st... | 2010/04/20 | [
"https://Stackoverflow.com/questions/2677330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799/"
] | The university's job is not to teach you a programming language, it's to teach you programming concepts. The language they use is only relevant in terms of the teaching material they have already generated or use from other sources.
I imagine that redoing a curriculum is something like rewriting a large application - ... | >
> Improved modern languages (Java, C#, Haskell) are available for free?
>
>
>
So by "improved" you mean powerful, loaded with external libraries and frameworks, and insanely complicated? With a maze of twisty little features in which beginning students can easily get lost? And when they are lost, they get error ... |
2,677,330 | Forgive my clumsy explanation, but I have a class that contains a List:
```
public class Document
{
public int OwnerId { get; set; }
public List<User> Users { get; set; }
public Document() { }
}
public class User
{
public string UserName { get; set; }
public st... | 2010/04/20 | [
"https://Stackoverflow.com/questions/2677330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799/"
] | The university's job is not to teach you a programming language, it's to teach you programming concepts. The language they use is only relevant in terms of the teaching material they have already generated or use from other sources.
I imagine that redoing a curriculum is something like rewriting a large application - ... | The matter of Lisp/ADA vs C/Java is the same as Informatics vs programming. One is a science, the other is a craft. |
2,677,330 | Forgive my clumsy explanation, but I have a class that contains a List:
```
public class Document
{
public int OwnerId { get; set; }
public List<User> Users { get; set; }
public Document() { }
}
public class User
{
public string UserName { get; set; }
public st... | 2010/04/20 | [
"https://Stackoverflow.com/questions/2677330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799/"
] | >
> Improved modern languages (Java, C#, Haskell) are available for free?
>
>
>
So by "improved" you mean powerful, loaded with external libraries and frameworks, and insanely complicated? With a maze of twisty little features in which beginning students can easily get lost? And when they are lost, they get error ... | The matter of Lisp/ADA vs C/Java is the same as Informatics vs programming. One is a science, the other is a craft. |
24,602,155 | The external API that my application is using, sometimes returns no values for one of the float64 fields. When that happens, I cannot unmarshal the rest of the document.
Here is the sample code in Go playground:
<http://play.golang.org/p/Twv8b6KCtw>
```
package main
import (
"encoding/xml"
"fmt"
)
func ma... | 2014/07/07 | [
"https://Stackoverflow.com/questions/24602155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/393109/"
] | Is this what you are looking for?
```
SELECT DATEDIFF(`pro_masastr`, NOW()) as DiffDate
FROM `i2n_profiler_users`
WHERE `userid` = 725;
```
This is no need for the additional subquery. Note thate `datediff()` is `expr1 - expr2`, so you might want the arguments in the other order:
```
SELECT DATEDIFF(now(), `pro_mas... | ```
SELECT DATEDIFF(NOW(), 'pro_masastr') as DiffDate
FROM i2n_profiler_users
WHERE userid = SOME_ID_HERE;
``` |
38,273,174 | Say I'm implementing a generic stack structure for a library. Here's a sample chunk:
```
typedef struct stack
{
void* key;
struct stack* next;
void*(*alloc_fn)(void*);
} stack;
static stack* make_stack_node(void* val, stack* next,
void*(*f)(void*))
{
stack* node = malloc(... | 2016/07/08 | [
"https://Stackoverflow.com/questions/38273174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5212827/"
] | You are not allocating memory for `int*`, you're allocating memory for `int`. And no, there is no memory leak provided you release the memory.
When you allocate memory for the `stack` the `key` doesn't point anywhere in specific. It's an undefined pointer that you must not dereference. You are required to allocate mem... | >
> *Is there a memory leak when I make `node->key = f(val);`?*
>
>
>
When you assign to `node->key` in `make_stack_node`, `node->key` doesn't point to anything yet, so no memory is leaked.
If you were to assign to `node->key` later in your program, you would need to call `free(node->key)` first to avoid leaking ... |
39,723,617 | Is it possible to log to a file on the iPhone (or get at the console output somehow) to read it later, or perhaps directly from the phone?
I need to debug an app that is using a cable-connected accessory device, so it cannot be connected to XCode at the same time. | 2016/09/27 | [
"https://Stackoverflow.com/questions/39723617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/417150/"
] | Kevin Xi's approach is OK. You can also redirect NSLog output to the file using following code in AppDelegate's didFinishLaunchingWithOptions method:
```
NSArray *allPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [allPaths objectAtIndex:0];
NSStr... | It is really a pity that Apple doesn't provide WiFi debugging for Xcode, but for your question, the answer is YES, you can definitely redirect NSLog to a log file, you can try this approach:
```
// this will redirect all NSLog in your project, add it to PCH file.
#define NSLog(args...) writeLog(__PRETTY_FUNCTION__, __... |
39,723,617 | Is it possible to log to a file on the iPhone (or get at the console output somehow) to read it later, or perhaps directly from the phone?
I need to debug an app that is using a cable-connected accessory device, so it cannot be connected to XCode at the same time. | 2016/09/27 | [
"https://Stackoverflow.com/questions/39723617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/417150/"
] | You can make use of [PonyDebugger](https://github.com/square/PonyDebugger).
I've been using it a lot to debug networking and CoreData resources, but it also allows logging to the console with PDLog.
>
> PonyDebugger is a remote debugging toolset. It is a client library and gateway server combination that uses Chrom... | It is really a pity that Apple doesn't provide WiFi debugging for Xcode, but for your question, the answer is YES, you can definitely redirect NSLog to a log file, you can try this approach:
```
// this will redirect all NSLog in your project, add it to PCH file.
#define NSLog(args...) writeLog(__PRETTY_FUNCTION__, __... |
39,723,617 | Is it possible to log to a file on the iPhone (or get at the console output somehow) to read it later, or perhaps directly from the phone?
I need to debug an app that is using a cable-connected accessory device, so it cannot be connected to XCode at the same time. | 2016/09/27 | [
"https://Stackoverflow.com/questions/39723617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/417150/"
] | Kevin Xi's approach is OK. You can also redirect NSLog output to the file using following code in AppDelegate's didFinishLaunchingWithOptions method:
```
NSArray *allPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [allPaths objectAtIndex:0];
NSStr... | As far as I know, this is not possible.
You can eventually use a free and excellent solution like [bugfender](http://www.bugfender.com) which will allow you to get the data logged by NSLog remotely. This could help you. |
39,723,617 | Is it possible to log to a file on the iPhone (or get at the console output somehow) to read it later, or perhaps directly from the phone?
I need to debug an app that is using a cable-connected accessory device, so it cannot be connected to XCode at the same time. | 2016/09/27 | [
"https://Stackoverflow.com/questions/39723617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/417150/"
] | You can make use of [PonyDebugger](https://github.com/square/PonyDebugger).
I've been using it a lot to debug networking and CoreData resources, but it also allows logging to the console with PDLog.
>
> PonyDebugger is a remote debugging toolset. It is a client library and gateway server combination that uses Chrom... | As far as I know, this is not possible.
You can eventually use a free and excellent solution like [bugfender](http://www.bugfender.com) which will allow you to get the data logged by NSLog remotely. This could help you. |
72,501,353 | `volatile` modifier is required when a variable is read/written by several concurrent Threads.
Are there tools that can detect missing `volatile` modifiers automatically, e.g. in Android Studio?
Algorithm:
```
for (Class c:allClasses) {
for (Field f:allFields) {
List<Method> allMethods = getCallHierarchy... | 2022/06/04 | [
"https://Stackoverflow.com/questions/72501353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2401879/"
] | No, not possible.
>
> `volatile` modifier is required when a variable is read/written by several concurrent Threads.
>
>
>
This is flat out incorrect.
Any field that is accessed by multiple threads, at least one which is also writing, needs 'Happens-Before' guarding.
`volatile` is just *one* way to get it. `syn... | You should find a tool that gives an inspection for necessity of volatile modifier, for example IntelliJ IDEA has a plugin:
[Mike's IDEA Extensions](https://plugins.jetbrains.com/plugin/12690-mike-s-idea-extensions) has a (Java + Kotlin) inspection *Atomic can be replaced with volatile*
Then you can run a named inspe... |
37,388,805 | So I would like to only view certain pages in one explorer in google analytics how do i do so?
For example:
example.com/contact < (exact match and not anything beyond contact/example)
example.com/blog
example.com/how-to
I tried using segments with the conditions "exact matches" but what happen is that it still sho... | 2016/05/23 | [
"https://Stackoverflow.com/questions/37388805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6370567/"
] | Try to conclude your regex with $ (/how-to$), meaning "ends with the preceding character. GA regex is a bit overeager and assumes you want to match anything that contains your string, so you have to specifically terminate with the [ends-with metacharacter](http://regexone.com/lesson/line_beginning_end). | You need to learn about Analytics Regular Expressions (or Regex).
'$' means 'ends here'
'^' means 'begins here'
'|' means 'or'
So ^/page1$ will search for exactly that page, and ^/page1$|^/page2$ will search for one of the two pages.
Now Google Analytics will cut out the hostname, so you'll want to search or filter ... |
37,388,805 | So I would like to only view certain pages in one explorer in google analytics how do i do so?
For example:
example.com/contact < (exact match and not anything beyond contact/example)
example.com/blog
example.com/how-to
I tried using segments with the conditions "exact matches" but what happen is that it still sho... | 2016/05/23 | [
"https://Stackoverflow.com/questions/37388805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6370567/"
] | Try to conclude your regex with $ (/how-to$), meaning "ends with the preceding character. GA regex is a bit overeager and assumes you want to match anything that contains your string, so you have to specifically terminate with the [ends-with metacharacter](http://regexone.com/lesson/line_beginning_end). | Not that the end result in this particular case would yield anything different but I just think it is best practice escaping slashes also in regexes in Google Analytics too just in case the regex is copied and used somewhere else like Perl e.g.
Here is a shorter version:
>
> ^\/(contact|blog|how-to)$
>
>
> |
66,059,939 | Can anyone tell me how to solve these things?
1.if the list is pressed, I'd like to change the background color of the list
beige(#FFF5E7) to white(#FBFBFB)
2.Also, I'd like to change the read value of the Object fales to true with useState
Problem is that if I pressed the list, whole background color of the list ... | 2021/02/05 | [
"https://Stackoverflow.com/questions/66059939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15150365/"
] | One way using `heapq.nlargest`:
```
from heapq import nlargest
df["col2"] = df["col2"].apply(lambda x: nlargest(2, x, key=d.get))
print(df)
```
Output:
```
col1 col2
0 A [x, y]
1 B [z]
2 C [q, p]
3 D [q, t]
``` | Use:
```
df = (df.explode('col2')
.assign(new = lambda x: x['col2'].map(d))
.dropna(subset=['new'])
.sort_values(['col1','new'], ascending=[True, False])
.groupby('col1')['col2']
.agg(lambda x: list(x.head(2)))
.reset_index()
)
print (df)
col1 col2
0 A [x, y]
1 B ... |
66,059,939 | Can anyone tell me how to solve these things?
1.if the list is pressed, I'd like to change the background color of the list
beige(#FFF5E7) to white(#FBFBFB)
2.Also, I'd like to change the read value of the Object fales to true with useState
Problem is that if I pressed the list, whole background color of the list ... | 2021/02/05 | [
"https://Stackoverflow.com/questions/66059939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15150365/"
] | Use:
```
df = (df.explode('col2')
.assign(new = lambda x: x['col2'].map(d))
.dropna(subset=['new'])
.sort_values(['col1','new'], ascending=[True, False])
.groupby('col1')['col2']
.agg(lambda x: list(x.head(2)))
.reset_index()
)
print (df)
col1 col2
0 A [x, y]
1 B ... | Try this pure pandas method. -
```
d_inv = {v:k for k,v in d.items()}
df.explode('col2')\ #Explode the list to separate rows
.replace(d)\ #Replace the alphabets by numbers from d
.groupby('col1')['col2']\ #groupby on col1
.nlargest(2)\ #get top 2 largest numbers
.replace(d... |
66,059,939 | Can anyone tell me how to solve these things?
1.if the list is pressed, I'd like to change the background color of the list
beige(#FFF5E7) to white(#FBFBFB)
2.Also, I'd like to change the read value of the Object fales to true with useState
Problem is that if I pressed the list, whole background color of the list ... | 2021/02/05 | [
"https://Stackoverflow.com/questions/66059939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15150365/"
] | One way using `heapq.nlargest`:
```
from heapq import nlargest
df["col2"] = df["col2"].apply(lambda x: nlargest(2, x, key=d.get))
print(df)
```
Output:
```
col1 col2
0 A [x, y]
1 B [z]
2 C [q, p]
3 D [q, t]
``` | Try this pure pandas method. -
```
d_inv = {v:k for k,v in d.items()}
df.explode('col2')\ #Explode the list to separate rows
.replace(d)\ #Replace the alphabets by numbers from d
.groupby('col1')['col2']\ #groupby on col1
.nlargest(2)\ #get top 2 largest numbers
.replace(d... |
740 | The [travel](https://pets.stackexchange.com/questions/tagged/travel "show questions tagged 'travel'") [tag wiki description](https://pets.stackexchange.com/tags/travel/info) says it's for travelling *with* pets, but there are a few questions where the owner is travelling and wants to arrange holiday care for the pet.
... | 2014/04/09 | [
"https://pets.meta.stackexchange.com/questions/740",
"https://pets.meta.stackexchange.com",
"https://pets.meta.stackexchange.com/users/628/"
] | I think the wiki page for [travel](https://pets.stackexchange.com/questions/tagged/travel "show questions tagged 'travel'") should be updated. I think lumping those questions in with care is too generalized. It is a question about travelling and how to take care of your pet while travelling, only in these instances the... | Okay, an answer is better than a comment, so that also downvoting is possible. This is for the question asked in question title alone.
Yes. The [care](https://pets.stackexchange.com/questions/tagged/care "show questions tagged 'care'") tag should be fit enough for use with such questions. |
740 | The [travel](https://pets.stackexchange.com/questions/tagged/travel "show questions tagged 'travel'") [tag wiki description](https://pets.stackexchange.com/tags/travel/info) says it's for travelling *with* pets, but there are a few questions where the owner is travelling and wants to arrange holiday care for the pet.
... | 2014/04/09 | [
"https://pets.meta.stackexchange.com/questions/740",
"https://pets.meta.stackexchange.com",
"https://pets.meta.stackexchange.com/users/628/"
] | **Situation one: pet is travelling.**
Questions will be about things like:
* how to subdue/calm the pet whilst in transit
* any veterinary or legal requirements regarding taking the pet to other countries (border control etc.)
* what containers or restraints to use
* dealing with motion sickness in pets
**Situation... | Okay, an answer is better than a comment, so that also downvoting is possible. This is for the question asked in question title alone.
Yes. The [care](https://pets.stackexchange.com/questions/tagged/care "show questions tagged 'care'") tag should be fit enough for use with such questions. |
740 | The [travel](https://pets.stackexchange.com/questions/tagged/travel "show questions tagged 'travel'") [tag wiki description](https://pets.stackexchange.com/tags/travel/info) says it's for travelling *with* pets, but there are a few questions where the owner is travelling and wants to arrange holiday care for the pet.
... | 2014/04/09 | [
"https://pets.meta.stackexchange.com/questions/740",
"https://pets.meta.stackexchange.com",
"https://pets.meta.stackexchange.com/users/628/"
] | I mostly agree with expanding the scope of the [travel](https://pets.stackexchange.com/questions/tagged/travel "show questions tagged 'travel'") tag as [suggested](https://pets.meta.stackexchange.com/a/742/101) by [Matt S.](https://pets.meta.stackexchange.com/users/481/matt-s), but I've also thought a couple of new tag... | Okay, an answer is better than a comment, so that also downvoting is possible. This is for the question asked in question title alone.
Yes. The [care](https://pets.stackexchange.com/questions/tagged/care "show questions tagged 'care'") tag should be fit enough for use with such questions. |
740 | The [travel](https://pets.stackexchange.com/questions/tagged/travel "show questions tagged 'travel'") [tag wiki description](https://pets.stackexchange.com/tags/travel/info) says it's for travelling *with* pets, but there are a few questions where the owner is travelling and wants to arrange holiday care for the pet.
... | 2014/04/09 | [
"https://pets.meta.stackexchange.com/questions/740",
"https://pets.meta.stackexchange.com",
"https://pets.meta.stackexchange.com/users/628/"
] | I think the wiki page for [travel](https://pets.stackexchange.com/questions/tagged/travel "show questions tagged 'travel'") should be updated. I think lumping those questions in with care is too generalized. It is a question about travelling and how to take care of your pet while travelling, only in these instances the... | **Situation one: pet is travelling.**
Questions will be about things like:
* how to subdue/calm the pet whilst in transit
* any veterinary or legal requirements regarding taking the pet to other countries (border control etc.)
* what containers or restraints to use
* dealing with motion sickness in pets
**Situation... |
740 | The [travel](https://pets.stackexchange.com/questions/tagged/travel "show questions tagged 'travel'") [tag wiki description](https://pets.stackexchange.com/tags/travel/info) says it's for travelling *with* pets, but there are a few questions where the owner is travelling and wants to arrange holiday care for the pet.
... | 2014/04/09 | [
"https://pets.meta.stackexchange.com/questions/740",
"https://pets.meta.stackexchange.com",
"https://pets.meta.stackexchange.com/users/628/"
] | I think the wiki page for [travel](https://pets.stackexchange.com/questions/tagged/travel "show questions tagged 'travel'") should be updated. I think lumping those questions in with care is too generalized. It is a question about travelling and how to take care of your pet while travelling, only in these instances the... | How about a new tag [unsupervised](https://pets.stackexchange.com/questions/tagged/unsupervised "show questions tagged 'unsupervised'") ? |
740 | The [travel](https://pets.stackexchange.com/questions/tagged/travel "show questions tagged 'travel'") [tag wiki description](https://pets.stackexchange.com/tags/travel/info) says it's for travelling *with* pets, but there are a few questions where the owner is travelling and wants to arrange holiday care for the pet.
... | 2014/04/09 | [
"https://pets.meta.stackexchange.com/questions/740",
"https://pets.meta.stackexchange.com",
"https://pets.meta.stackexchange.com/users/628/"
] | **Situation one: pet is travelling.**
Questions will be about things like:
* how to subdue/calm the pet whilst in transit
* any veterinary or legal requirements regarding taking the pet to other countries (border control etc.)
* what containers or restraints to use
* dealing with motion sickness in pets
**Situation... | How about a new tag [unsupervised](https://pets.stackexchange.com/questions/tagged/unsupervised "show questions tagged 'unsupervised'") ? |
740 | The [travel](https://pets.stackexchange.com/questions/tagged/travel "show questions tagged 'travel'") [tag wiki description](https://pets.stackexchange.com/tags/travel/info) says it's for travelling *with* pets, but there are a few questions where the owner is travelling and wants to arrange holiday care for the pet.
... | 2014/04/09 | [
"https://pets.meta.stackexchange.com/questions/740",
"https://pets.meta.stackexchange.com",
"https://pets.meta.stackexchange.com/users/628/"
] | I mostly agree with expanding the scope of the [travel](https://pets.stackexchange.com/questions/tagged/travel "show questions tagged 'travel'") tag as [suggested](https://pets.meta.stackexchange.com/a/742/101) by [Matt S.](https://pets.meta.stackexchange.com/users/481/matt-s), but I've also thought a couple of new tag... | **Situation one: pet is travelling.**
Questions will be about things like:
* how to subdue/calm the pet whilst in transit
* any veterinary or legal requirements regarding taking the pet to other countries (border control etc.)
* what containers or restraints to use
* dealing with motion sickness in pets
**Situation... |
740 | The [travel](https://pets.stackexchange.com/questions/tagged/travel "show questions tagged 'travel'") [tag wiki description](https://pets.stackexchange.com/tags/travel/info) says it's for travelling *with* pets, but there are a few questions where the owner is travelling and wants to arrange holiday care for the pet.
... | 2014/04/09 | [
"https://pets.meta.stackexchange.com/questions/740",
"https://pets.meta.stackexchange.com",
"https://pets.meta.stackexchange.com/users/628/"
] | I mostly agree with expanding the scope of the [travel](https://pets.stackexchange.com/questions/tagged/travel "show questions tagged 'travel'") tag as [suggested](https://pets.meta.stackexchange.com/a/742/101) by [Matt S.](https://pets.meta.stackexchange.com/users/481/matt-s), but I've also thought a couple of new tag... | How about a new tag [unsupervised](https://pets.stackexchange.com/questions/tagged/unsupervised "show questions tagged 'unsupervised'") ? |
64,440,400 | I use react-hook-form with yup to validate my forms.
I want to know all required fields of a schema to display some information in form (like '\*' for required fields).
We could achieve this with this line of code :
`schema.describe().fields[field].tests.findIndex(({ name }) => name === 'required'`
However, this cod... | 2020/10/20 | [
"https://Stackoverflow.com/questions/64440400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14483349/"
] | There is actually no "nice" way to do it but this works:
```
function isRequired(field){
return schema.fields[field]._exclusive.required || false
}
```
Notice: `schema.fields[field]._exclusive.required` returns true if required or undefined. | Testing exclusiveTests instead of \_exclusive worked for me.
```
const isRequired =
validationSchema?.fields[aField.name]?.exclusiveTests?.required || false;
``` |
33,309,508 | I have string regex
`"product_default_shipping_cost:\['(.*)'"`
and string
`"product_sale_price:['19.99'], product_default_shipping_cost:['1.99'], product_type:['Newegg']"`
and i want get only `1.99`.
My code :
```
Pattern pattern = Pattern.compile(regex_string);
Matcher m = pattern.matcher(html);
while (m.fin... | 2015/10/23 | [
"https://Stackoverflow.com/questions/33309508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4750323/"
] | Try changing it to this:
```
product_default_shipping_cost:\['(.*?)'
```
`.*?` is lazy and will only try to match up to the first `'` | `.*` will match as many characters as possible (is "greedy").
You can either use non-gready `.*?`, or limit what can be matched: `[^']*`. |
33,309,508 | I have string regex
`"product_default_shipping_cost:\['(.*)'"`
and string
`"product_sale_price:['19.99'], product_default_shipping_cost:['1.99'], product_type:['Newegg']"`
and i want get only `1.99`.
My code :
```
Pattern pattern = Pattern.compile(regex_string);
Matcher m = pattern.matcher(html);
while (m.fin... | 2015/10/23 | [
"https://Stackoverflow.com/questions/33309508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4750323/"
] | Try changing it to this:
```
product_default_shipping_cost:\['(.*?)'
```
`.*?` is lazy and will only try to match up to the first `'` | You're using a `greedy` regex `.*`, try using a *non greedy*, also know as `lazy`, by appending a `?`, i.e.:
```
product_default_shipping_cost:\['(.*?)'\]
```
---
```
Pattern pattern = Pattern.compile("product_default_shipping_cost:\['(.*?)'\]");
Matcher m = pattern.matcher(html);
while (m.find()) {
for (int i ... |
33,309,508 | I have string regex
`"product_default_shipping_cost:\['(.*)'"`
and string
`"product_sale_price:['19.99'], product_default_shipping_cost:['1.99'], product_type:['Newegg']"`
and i want get only `1.99`.
My code :
```
Pattern pattern = Pattern.compile(regex_string);
Matcher m = pattern.matcher(html);
while (m.fin... | 2015/10/23 | [
"https://Stackoverflow.com/questions/33309508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4750323/"
] | `.*` will match as many characters as possible (is "greedy").
You can either use non-gready `.*?`, or limit what can be matched: `[^']*`. | You're using a `greedy` regex `.*`, try using a *non greedy*, also know as `lazy`, by appending a `?`, i.e.:
```
product_default_shipping_cost:\['(.*?)'\]
```
---
```
Pattern pattern = Pattern.compile("product_default_shipping_cost:\['(.*?)'\]");
Matcher m = pattern.matcher(html);
while (m.find()) {
for (int i ... |
56,649,847 | I want to do parser, which will print out expressions into steps of their calculation. And when I compile my code, I cannot solve these problem. I always get error
```
code.l:13:1: error: expected expression before '=' token
yylval.name = strdup(yytext);
^
code.l:18:1: error: expected expression before '=' token
... | 2019/06/18 | [
"https://Stackoverflow.com/questions/56649847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8095821/"
] | The action in a lex rule must start on the same line as the pattern. So you need to write, for example
```
[a-zA-Z]+ {
yylval.name = strdup(yytext);
return(ID);
}
```
For what it's worth, this requirement is clearly stated in the [flex manual section on the format of an input file](http://westes.github.... | If you look at the generated `lex.yy.c` file, you eventually find code like:
```
case 4:
YY_RULE_SETUP
#line 13 "code.l"
= strdup(yytext);
YY_BREAK
```
This is clearly not what you had in mind. As noted by [Rici](https://stackoverflow.com/users/1566221/rici) in their [answer](https://stackoverflow.com/a/5665... |
9,800,982 | How would I go about writing a Makefile that would call, say, gedit hashtable.cpp main.cpp& ?
I know how to use them to compile and make tar files but I'm not sure about this one. | 2012/03/21 | [
"https://Stackoverflow.com/questions/9800982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1855247/"
] | What's the difference exactly? Instead of `gcc` write `gedit` and you're done. `Make` just executes the command in certain order. It is tailored for compilations, for "general" scripting there are much more suitable tools, but you can do it if you wish. | Something like this would work:
```
.PHONY : all
all: hashtable.cpp main.cpp
gedit hashtable.cpp main.cpp &
```
Gedit is not really ideal for Make though. |
1,190,870 | >
> **Possible Duplicates:**
>
> [How to generate a random number in C?](https://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c)
>
> [implementation of rand()](https://stackoverflow.com/questions/1167253/implementation-of-rand)
>
> [Generating random terrain in Blender3D](https://stac... | 2009/07/27 | [
"https://Stackoverflow.com/questions/1190870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/110276/"
] | You can try something like this:
```
main()
{
srand(time(0));
for(int i=0;i<1000;++i)
printf("%f ", ((float)rand())/RAND_MAX*99+1);
return 0;
}
```
It's as uniform a distribution as the standard rand() can give. | The other posts have good advice. If you really want to dive into the guts of random number generation, take a look at [Numerical Recipes in C](http://www.nrbook.com/a/bookcpdf.php). Start with [Chapter 7](http://www.nrbook.com/a/bookcpdf/c7-0.pdf). |
1,190,870 | >
> **Possible Duplicates:**
>
> [How to generate a random number in C?](https://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c)
>
> [implementation of rand()](https://stackoverflow.com/questions/1167253/implementation-of-rand)
>
> [Generating random terrain in Blender3D](https://stac... | 2009/07/27 | [
"https://Stackoverflow.com/questions/1190870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/110276/"
] | This is the simplest method of producing uniformly distributed random numbers in C:
**Step 1.** Be sure to include the standard library header to get the necessary function prototypes
```
#include <stdlib.h>
```
**Step 2.** Seed the random number generator using `srand()`. The seed determines where the random numbe... | The other posts have good advice. If you really want to dive into the guts of random number generation, take a look at [Numerical Recipes in C](http://www.nrbook.com/a/bookcpdf.php). Start with [Chapter 7](http://www.nrbook.com/a/bookcpdf/c7-0.pdf). |
1,190,870 | >
> **Possible Duplicates:**
>
> [How to generate a random number in C?](https://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c)
>
> [implementation of rand()](https://stackoverflow.com/questions/1167253/implementation-of-rand)
>
> [Generating random terrain in Blender3D](https://stac... | 2009/07/27 | [
"https://Stackoverflow.com/questions/1190870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/110276/"
] | This is the simplest method of producing uniformly distributed random numbers in C:
**Step 1.** Be sure to include the standard library header to get the necessary function prototypes
```
#include <stdlib.h>
```
**Step 2.** Seed the random number generator using `srand()`. The seed determines where the random numbe... | You can try something like this:
```
main()
{
srand(time(0));
for(int i=0;i<1000;++i)
printf("%f ", ((float)rand())/RAND_MAX*99+1);
return 0;
}
```
It's as uniform a distribution as the standard rand() can give. |
1,190,870 | >
> **Possible Duplicates:**
>
> [How to generate a random number in C?](https://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c)
>
> [implementation of rand()](https://stackoverflow.com/questions/1167253/implementation-of-rand)
>
> [Generating random terrain in Blender3D](https://stac... | 2009/07/27 | [
"https://Stackoverflow.com/questions/1190870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/110276/"
] | <http://mathworld.wolfram.com/RandomNumber.html>
This article explains the basics to creating your own random number generator that will outperform the standard C library function if you find it lacking in distribution. It produces a better spread and hence a more random number.
This is critical if you hope to produc... | If you really need lottery-quality random numbers, I don't think you want a digital algorithm at all.
[You want an actual physical process. See Random.org.](http://www.random.org/) Are you willing to pay?
Beware programmatic random number generators if you *really* need random numbers. As we've seen in the answers so... |
1,190,870 | >
> **Possible Duplicates:**
>
> [How to generate a random number in C?](https://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c)
>
> [implementation of rand()](https://stackoverflow.com/questions/1167253/implementation-of-rand)
>
> [Generating random terrain in Blender3D](https://stac... | 2009/07/27 | [
"https://Stackoverflow.com/questions/1190870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/110276/"
] | This is the simplest method of producing uniformly distributed random numbers in C:
**Step 1.** Be sure to include the standard library header to get the necessary function prototypes
```
#include <stdlib.h>
```
**Step 2.** Seed the random number generator using `srand()`. The seed determines where the random numbe... | If you really need lottery-quality random numbers, I don't think you want a digital algorithm at all.
[You want an actual physical process. See Random.org.](http://www.random.org/) Are you willing to pay?
Beware programmatic random number generators if you *really* need random numbers. As we've seen in the answers so... |
1,190,870 | >
> **Possible Duplicates:**
>
> [How to generate a random number in C?](https://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c)
>
> [implementation of rand()](https://stackoverflow.com/questions/1167253/implementation-of-rand)
>
> [Generating random terrain in Blender3D](https://stac... | 2009/07/27 | [
"https://Stackoverflow.com/questions/1190870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/110276/"
] | This is the simplest method of producing uniformly distributed random numbers in C:
**Step 1.** Be sure to include the standard library header to get the necessary function prototypes
```
#include <stdlib.h>
```
**Step 2.** Seed the random number generator using `srand()`. The seed determines where the random numbe... | <http://mathworld.wolfram.com/RandomNumber.html>
This article explains the basics to creating your own random number generator that will outperform the standard C library function if you find it lacking in distribution. It produces a better spread and hence a more random number.
This is critical if you hope to produc... |
1,190,870 | >
> **Possible Duplicates:**
>
> [How to generate a random number in C?](https://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c)
>
> [implementation of rand()](https://stackoverflow.com/questions/1167253/implementation-of-rand)
>
> [Generating random terrain in Blender3D](https://stac... | 2009/07/27 | [
"https://Stackoverflow.com/questions/1190870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/110276/"
] | By "fair distribution", I assume you mean that you're not generally satisfied by `rand()`. In this case, you should probably use OS-specific methods that produce cryptographically secure random numbers - `/dev/random` or `/dev/urandom` (depending on your needs) on Unix, and `CryptGenRandom` or `RtlGetRandom` on Win32. ... | The standard C library has [rand](http://www.rocketaware.com/man/man3/rand.3.htm) which will probably be sufficient, unless you have a need for a prng with a particular statistical distribution.. |
1,190,870 | >
> **Possible Duplicates:**
>
> [How to generate a random number in C?](https://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c)
>
> [implementation of rand()](https://stackoverflow.com/questions/1167253/implementation-of-rand)
>
> [Generating random terrain in Blender3D](https://stac... | 2009/07/27 | [
"https://Stackoverflow.com/questions/1190870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/110276/"
] | By "fair distribution", I assume you mean that you're not generally satisfied by `rand()`. In this case, you should probably use OS-specific methods that produce cryptographically secure random numbers - `/dev/random` or `/dev/urandom` (depending on your needs) on Unix, and `CryptGenRandom` or `RtlGetRandom` on Win32. ... | You can try something like this:
```
main()
{
srand(time(0));
for(int i=0;i<1000;++i)
printf("%f ", ((float)rand())/RAND_MAX*99+1);
return 0;
}
```
It's as uniform a distribution as the standard rand() can give. |
1,190,870 | >
> **Possible Duplicates:**
>
> [How to generate a random number in C?](https://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c)
>
> [implementation of rand()](https://stackoverflow.com/questions/1167253/implementation-of-rand)
>
> [Generating random terrain in Blender3D](https://stac... | 2009/07/27 | [
"https://Stackoverflow.com/questions/1190870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/110276/"
] | By "fair distribution", I assume you mean that you're not generally satisfied by `rand()`. In this case, you should probably use OS-specific methods that produce cryptographically secure random numbers - `/dev/random` or `/dev/urandom` (depending on your needs) on Unix, and `CryptGenRandom` or `RtlGetRandom` on Win32. ... | The other posts have good advice. If you really want to dive into the guts of random number generation, take a look at [Numerical Recipes in C](http://www.nrbook.com/a/bookcpdf.php). Start with [Chapter 7](http://www.nrbook.com/a/bookcpdf/c7-0.pdf). |
1,190,870 | >
> **Possible Duplicates:**
>
> [How to generate a random number in C?](https://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c)
>
> [implementation of rand()](https://stackoverflow.com/questions/1167253/implementation-of-rand)
>
> [Generating random terrain in Blender3D](https://stac... | 2009/07/27 | [
"https://Stackoverflow.com/questions/1190870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/110276/"
] | This is the simplest method of producing uniformly distributed random numbers in C:
**Step 1.** Be sure to include the standard library header to get the necessary function prototypes
```
#include <stdlib.h>
```
**Step 2.** Seed the random number generator using `srand()`. The seed determines where the random numbe... | By "fair distribution", I assume you mean that you're not generally satisfied by `rand()`. In this case, you should probably use OS-specific methods that produce cryptographically secure random numbers - `/dev/random` or `/dev/urandom` (depending on your needs) on Unix, and `CryptGenRandom` or `RtlGetRandom` on Win32. ... |
8,185,776 | I'm used to seeing `if obj is None:` in Python, and I've recently come across `if obj is ():`. Since tuples are not mutable, it sounds like a reasonable internal optimization in the Python interpreter to have the empty tuple be a singleton, therefore allowing the use of `is` rather than requiring `==`. But is this guar... | 2011/11/18 | [
"https://Stackoverflow.com/questions/8185776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/281368/"
] | From the Python 2 [docs](http://docs.python.org/reference/expressions.html#parenthesized-forms) and Python 3 [docs](http://docs.python.org/release/3.1.3/reference/expressions.html#parenthesized-forms):
>
> ... two occurrences of the empty tuple may or may not yield the same object.
>
>
>
In other words, you can't... | Let's use the [id()](http://docs.python.org/library/functions.html#id) method to get the internal id of the () :
```
>>> id(())
140180995895376
>>> empty_tuple = ()
>>> id(empty_tuple)
140180995895376 # same as the id of ()
>>> from copy import copy
>>> id(copy(empty_tuple))
140180995895376 # still the s... |
8,185,776 | I'm used to seeing `if obj is None:` in Python, and I've recently come across `if obj is ():`. Since tuples are not mutable, it sounds like a reasonable internal optimization in the Python interpreter to have the empty tuple be a singleton, therefore allowing the use of `is` rather than requiring `==`. But is this guar... | 2011/11/18 | [
"https://Stackoverflow.com/questions/8185776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/281368/"
] | Let's use the [id()](http://docs.python.org/library/functions.html#id) method to get the internal id of the () :
```
>>> id(())
140180995895376
>>> empty_tuple = ()
>>> id(empty_tuple)
140180995895376 # same as the id of ()
>>> from copy import copy
>>> id(copy(empty_tuple))
140180995895376 # still the s... | It's not about optimization. It's about objects comparisons. Python "is" is used to test object identity, then compare empty tuple "()" is not required to use "==" operator. In fact, anything in python can be compared with "is".
```
>>> obj = ()
>>> obj is ()
True
>>> isinstance(obj, tuple)
True
>>> obj is tuple
False... |
8,185,776 | I'm used to seeing `if obj is None:` in Python, and I've recently come across `if obj is ():`. Since tuples are not mutable, it sounds like a reasonable internal optimization in the Python interpreter to have the empty tuple be a singleton, therefore allowing the use of `is` rather than requiring `==`. But is this guar... | 2011/11/18 | [
"https://Stackoverflow.com/questions/8185776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/281368/"
] | From the Python 2 [docs](http://docs.python.org/reference/expressions.html#parenthesized-forms) and Python 3 [docs](http://docs.python.org/release/3.1.3/reference/expressions.html#parenthesized-forms):
>
> ... two occurrences of the empty tuple may or may not yield the same object.
>
>
>
In other words, you can't... | This is a non-guaranteed implementation detail of current versions of CPython, so you won't necessarily be able to rely on it in other Python implementations, including Jython, IronPython, PyPy, and potentially future versions of CPython.
Using `is` appears to be about 0.04 μs faster on my system when comparing agains... |
8,185,776 | I'm used to seeing `if obj is None:` in Python, and I've recently come across `if obj is ():`. Since tuples are not mutable, it sounds like a reasonable internal optimization in the Python interpreter to have the empty tuple be a singleton, therefore allowing the use of `is` rather than requiring `==`. But is this guar... | 2011/11/18 | [
"https://Stackoverflow.com/questions/8185776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/281368/"
] | From the Python 2 [docs](http://docs.python.org/reference/expressions.html#parenthesized-forms) and Python 3 [docs](http://docs.python.org/release/3.1.3/reference/expressions.html#parenthesized-forms):
>
> ... two occurrences of the empty tuple may or may not yield the same object.
>
>
>
In other words, you can't... | It's not about optimization. It's about objects comparisons. Python "is" is used to test object identity, then compare empty tuple "()" is not required to use "==" operator. In fact, anything in python can be compared with "is".
```
>>> obj = ()
>>> obj is ()
True
>>> isinstance(obj, tuple)
True
>>> obj is tuple
False... |
8,185,776 | I'm used to seeing `if obj is None:` in Python, and I've recently come across `if obj is ():`. Since tuples are not mutable, it sounds like a reasonable internal optimization in the Python interpreter to have the empty tuple be a singleton, therefore allowing the use of `is` rather than requiring `==`. But is this guar... | 2011/11/18 | [
"https://Stackoverflow.com/questions/8185776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/281368/"
] | This is a non-guaranteed implementation detail of current versions of CPython, so you won't necessarily be able to rely on it in other Python implementations, including Jython, IronPython, PyPy, and potentially future versions of CPython.
Using `is` appears to be about 0.04 μs faster on my system when comparing agains... | It's not about optimization. It's about objects comparisons. Python "is" is used to test object identity, then compare empty tuple "()" is not required to use "==" operator. In fact, anything in python can be compared with "is".
```
>>> obj = ()
>>> obj is ()
True
>>> isinstance(obj, tuple)
True
>>> obj is tuple
False... |
60,458,721 | I have two tables, one for all the foods which contains food id, default name and other foods values.
Another table is for the food name translations which contains food id, language id, translation.
What i want to do is join between these tables by the food id to get the translation for food id = 5 for example and l... | 2020/02/28 | [
"https://Stackoverflow.com/questions/60458721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12691708/"
] | You would do a LEFT JOIN and put the language ID into the join condition.
```
SELECT
COALESCE(t.TranslatedName, f.DefaultName) FoodName
FROM
Foods f
LEFT JOIN FoodNameTranslations t ON t.Food_ID = f.Food_ID AND t.Language_ID = 1
WHERE
f.Food_ID = 5
``` | You cando do this by changing the JOIN condition:
INNER JOIN gets all records that are common between both tables based on the supplied ON clause.
LEFT JOIN gets all records from the LEFT linked and the related record from the right table ,but if you have selected some columns from the RIGHT table, if there is no rel... |
563,579 | I got a job to do a household appliances with wireless remote control. I’m working as embedded developer in current company, but we haven't had to certificate our solutions and I'm looking for advice.
The first level of this job is to make a prototype of the machine. However I want this prototype not to demand too man... | 2021/05/05 | [
"https://electronics.stackexchange.com/questions/563579",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/284772/"
] | The detailed technical information on your product would be needed to advise on exactly what standards may or may not be applicable. But I can talk in general terms.
>
> I know that the necessery things to do are: certification EMC, RED,
> LVD...
>
>
>
This is not anywhere near as simple, you also need to declare... | >
> Has anyone of you designed or made a household device controled by MCU?
>
>
>
Not as such, but industrial applications with very similar requirements. IEC 60730 is one of the "functional safety" ("SIL") standards, there exist different ones but all of them are pretty much the offspring of the industrial IEC 61... |
1,817,909 | I have two questions about a specific system of differential equations. First, if a complex number can be an equilibrium point. Second, and related with the first question, how can I verify that $(0,0)$ is the only solution that satisfy $X'=0$ and $Y'=0.$ The system is as follows:
$X'=xy^3-xy^2$
$Y'=-y^3-3x^4$
Thanks ... | 2016/06/08 | [
"https://math.stackexchange.com/questions/1817909",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/346372/"
] | Normally, you only consider real equilibrium points in a first course on differential equations.
$X′=xy^3−xy^2=0$ gives $xy^3=xy^2$ so either (a) $x=0$ (b) $y=0$ or (c) $y=1$
$Y′=−y^3−3x^4=0$ gives $−y^3=3x^4$. So now all we have to do is to plug (a-c) above in to this equation to see what equilibrium points we get.
... | We have two coupled polynomial ODEs
$$\dot x = xy^3 - xy^2 \qquad \qquad \dot y = -y^3 - 3x^4$$
To find the equilibria, solve the system of polynomial equations
$$0 = xy^3 - xy^2 \qquad \qquad 0 = -y^3 - 3x^4$$
Using [SymPy](http://live.sympy.org/),
```
>>> from sympy import roots, solve_poly_system
>>> x, y = sym... |
60,763,025 | When i try to use the math.log function in the objective expression, this error pops out. Can someone help me understand how can a add the formula that i need to optimize?
model\_MPL += samples \* (math.log(beta\_var) - beta\_var \* math.log(alfa\_var)) + suma
I am trying to reproduce Excel's solver in order to opti... | 2020/03/19 | [
"https://Stackoverflow.com/questions/60763025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11637325/"
] | I am afraid it's not possible to efficiently solve this task using Stream API. But you can still do it using iterators.
```
public static void addCars(Stream<Person> clients, Stream<Car> cars) {
Iterator<Person> clientsIt = clients.iterator();
Iterator<Car> carsIt = cars.iterator();
Person client = null;
... | A precompute can help. Something like
```
Map<String, List<Car>> cars = Stream.of(
new Car("Johnny", "Mazda"),
new Car("Johnny", "Fiat"),
new Car("Mary", "Volvo"))
.collect(Collectors.groupingBy(Car::getOwner));
Stream.of(new Person("Anne", 500),
new Person("Johnny", 340))
... |
8,379,277 | My conection string was
```
string connStr = @"Data Source=(local)\SQLEXPRESS
Initial Catalog=University11;
Integrated Security=True";
```
But then I copied my database to
```
C:\Users\Чак\Desktop\ботанизм\ООП\coursework.start\CourseWorkFinal\CourseWorkFinal\
```
An... | 2011/12/04 | [
"https://Stackoverflow.com/questions/8379277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/964645/"
] | The connection string (`Data Source=(local)\SQLEXPRESS`...) is intended for hiding the physical location of the database files when you decide to move files. No matter where your files are, the programs that use your database should not care, because logically it's the same database. When you move your DB files, you ne... | I think you shouldn't change your connention string, you can't access SQL SERVER database directly you must always pass through the SQL SERVER DBMS. The only thing you can do is import/export your data or manage your SQL SERVER to read your database from the new destination folder (but this must be done within SQL SERV... |
8,379,277 | My conection string was
```
string connStr = @"Data Source=(local)\SQLEXPRESS
Initial Catalog=University11;
Integrated Security=True";
```
But then I copied my database to
```
C:\Users\Чак\Desktop\ботанизм\ООП\coursework.start\CourseWorkFinal\CourseWorkFinal\
```
An... | 2011/12/04 | [
"https://Stackoverflow.com/questions/8379277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/964645/"
] | If that is intended to be a "user instance" access to a file, then the connection string is more like:
```
Data Source=.\SQLEXPRESS;AttachDBFilename=YourPath.mdf;Integrated Security=True;
```
Otherwise, use the Initial Catalog to supply a database name registered on the instance. | I think you shouldn't change your connention string, you can't access SQL SERVER database directly you must always pass through the SQL SERVER DBMS. The only thing you can do is import/export your data or manage your SQL SERVER to read your database from the new destination folder (but this must be done within SQL SERV... |
11,278,474 | I've a normal Java class (neither a JSP nor a Servlet) that performs some processing on files like reading, writing, and executing some executable files. How to know the relative path of each file?
I know about `getClass().getResourceStream()`, but this is useful only for reading files. And I know about `getServletCon... | 2012/06/30 | [
"https://Stackoverflow.com/questions/11278474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/446991/"
] | >
> *And I know about `getServletContext().getRealPath()` but my code is in ordinary Java class not a servlet*
>
>
>
Just pass its result to the Java class.
```
String desiredPath = calculateItSomehowBasedOn(getServletContext().getRealPath("/"));
yourJavaClass.executeExe(desiredPath);
```
Note that the `getReal... | Your questions seems to address Java SE and not Java EE. I assume your "exe" file is located relative to your java project? To get the absolute path, you could use:
```
File f = new File("path/to/exe");
String exePath = f.getAbsolutePath();
```
Then you could use the absolute path to issue your command. See also: [J... |
2,038,431 | >
> The vector space $P\_2(\mathbb{R})$ has a basis of $(P\_1(x),P\_2(x),P\_3(x))$ and the polynomials $Q\_1(x)=3+2x+7x^2, Q\_2(x)=2+x+4x^2, Q\_3(x)=5+2x^2$ with respect to this basis have the coordinates $(1,-2,0), \, (1,-1,0)$ and $(0,1,1)$.
>
>
> Determine the three basis vectors $P\_1(x), P\_2(x)$ and $P\_3(x)$.... | 2016/12/01 | [
"https://math.stackexchange.com/questions/2038431",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/319082/"
] | Solve the system
$$\begin{bmatrix} \mid &\mid & \mid \\ P\_1 &P\_2 & P\_3\\\mid&\mid&\mid\end{bmatrix} \begin{bmatrix}1&1&0\\-2&-1&1\\0&0&1\end{bmatrix} = \begin{bmatrix}
3&2&5\\2&1&0\\7&4&2
\end{bmatrix}$$ | With respect to a standard basis $\{1,x,x^2\}$, you can write:
$P\left[\begin{matrix} 1 & 1 & 0 \\ -2 & -1 & 1 \\ 0 & 0 & 1 \end{matrix}\right]=\left[\begin{matrix} 3 & 2 & 5 \\ 2 & 1 & 0 \\ 7 & 4 & 2 \end{matrix}\right]$
Can you solve that for $P$? |
2,038,431 | >
> The vector space $P\_2(\mathbb{R})$ has a basis of $(P\_1(x),P\_2(x),P\_3(x))$ and the polynomials $Q\_1(x)=3+2x+7x^2, Q\_2(x)=2+x+4x^2, Q\_3(x)=5+2x^2$ with respect to this basis have the coordinates $(1,-2,0), \, (1,-1,0)$ and $(0,1,1)$.
>
>
> Determine the three basis vectors $P\_1(x), P\_2(x)$ and $P\_3(x)$.... | 2016/12/01 | [
"https://math.stackexchange.com/questions/2038431",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/319082/"
] | Solve the system
$$\begin{bmatrix} \mid &\mid & \mid \\ P\_1 &P\_2 & P\_3\\\mid&\mid&\mid\end{bmatrix} \begin{bmatrix}1&1&0\\-2&-1&1\\0&0&1\end{bmatrix} = \begin{bmatrix}
3&2&5\\2&1&0\\7&4&2
\end{bmatrix}$$ | You have $$\begin{pmatrix}1&-2&0 \\ 1&-1&0 \\0&1&1 \end{pmatrix}\begin{pmatrix}P\_1\\P\_2\\P\_3\end{pmatrix}=\begin{pmatrix}Q\_1\\Q\_2\\Q\_3\end{pmatrix}$$
Now just invert the square matrix. |
55,752,938 | I don't have power to impact the incoming JSON schema so i need find solution.
Say i have some simple DTO classes:
```
public class ClassA { prop1, prop2, ... }
public class ClassB { prop3, prop4, ... }
```
And the incoming JSON is like:
```
{
"type": "determinant",
"data": { ... }
}
```
Of course i created ... | 2019/04/18 | [
"https://Stackoverflow.com/questions/55752938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3752919/"
] | You can do the conditional deserialization by creating a Json converter but on `CallbackEvent` instead on your `Data` property. It's a little bit more complex as you need to move on the json reader manually.
The drawback is that json properties of root object must be in the exact same order. And you need to handle man... | you can try use Object, or Dynamic |
29,168 | I recently updated MiKTeX and I can't compile anymore xelatex through Texmaker simple multilingual tex e.g.
```
\documentclass{article}
\usepackage{xltxtra}
\usepackage{xgreek}
\setmainfont[Mapping=tex-text]{Times New Roman}
\begin{document}
Hello world Χαίρε κόσμε
\end{document}
```
obtaining errors concerning e... | 2011/09/22 | [
"https://tex.stackexchange.com/questions/29168",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/8019/"
] | The answer lies in the log line
```
(./expl3.sty
```
This indicates that `expl3` is being loaded from the *current* folder, not the TeX Live folder (and thus explains why the problem was common to MiKTeX and TeX Live). Delete the file `expl3` from the folder containing your `.tex` file, and the issue should go away... | What solved the issue for me was running a MiKTeX/Maintenance/Update ***as user*** (not as Admin). I found out there was an obsolete l3kernel to be removed (even though that package had already been removed in the Admin interface).
Explanation is here: <http://sourceforge.net/p/miktex/bugs/2111/> |
21,332,887 | I want to upload images on click of img tag.When user Click on image, file input tag will call and user chose any image and set this image to clicked img tag.
How i will achive.Can anyone tell me. | 2014/01/24 | [
"https://Stackoverflow.com/questions/21332887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3232027/"
] | You can achieve this by triggering a click event with jquery. First thing to do is.
1. Create An image tag (I'm assuming you want to put a no picture image on this tag)
2. Create a file input tag somewhere on the page, preferable under the above image tag.
3. Hide the file input (Set display to none with css);
4. use ... | try this
```
<img url="#Your image url" alt="click here to add file upload" />
<div id="fileUpload" />
```
and script
```
$('img').click(function () {
AddFileUpload();
});
function AddFileUpload() {
$('#fileUpload').append('<input type="file"/>');
}
```
[Demo](http://jsfiddle.net/carunchandran/25xGQ/1/) |
21,332,887 | I want to upload images on click of img tag.When user Click on image, file input tag will call and user chose any image and set this image to clicked img tag.
How i will achive.Can anyone tell me. | 2014/01/24 | [
"https://Stackoverflow.com/questions/21332887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3232027/"
] | You can achieve this by triggering a click event with jquery. First thing to do is.
1. Create An image tag (I'm assuming you want to put a no picture image on this tag)
2. Create a file input tag somewhere on the page, preferable under the above image tag.
3. Hide the file input (Set display to none with css);
4. use ... | You can try ng-file-upload <https://github.com/danialfarid/ng-file-upload>
1. Create img tag
2. Use directive straight in img tag |
21,332,887 | I want to upload images on click of img tag.When user Click on image, file input tag will call and user chose any image and set this image to clicked img tag.
How i will achive.Can anyone tell me. | 2014/01/24 | [
"https://Stackoverflow.com/questions/21332887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3232027/"
] | You can achieve this by triggering a click event with jquery. First thing to do is.
1. Create An image tag (I'm assuming you want to put a no picture image on this tag)
2. Create a file input tag somewhere on the page, preferable under the above image tag.
3. Hide the file input (Set display to none with css);
4. use ... | @shanks solution doesn't address setting the image to the clicked image. I have modified the code to address the same.
**HTML**
```
<input type="file" ng-file-select="uploadImage($files)" id="file-input" name="filedata"/>
<img src="no_image.png" ng-click="triggerUpload()" id="imageId"/>
```
**JAVASCRIPT**
In brow... |
21,332,887 | I want to upload images on click of img tag.When user Click on image, file input tag will call and user chose any image and set this image to clicked img tag.
How i will achive.Can anyone tell me. | 2014/01/24 | [
"https://Stackoverflow.com/questions/21332887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3232027/"
] | You can try ng-file-upload <https://github.com/danialfarid/ng-file-upload>
1. Create img tag
2. Use directive straight in img tag | try this
```
<img url="#Your image url" alt="click here to add file upload" />
<div id="fileUpload" />
```
and script
```
$('img').click(function () {
AddFileUpload();
});
function AddFileUpload() {
$('#fileUpload').append('<input type="file"/>');
}
```
[Demo](http://jsfiddle.net/carunchandran/25xGQ/1/) |
21,332,887 | I want to upload images on click of img tag.When user Click on image, file input tag will call and user chose any image and set this image to clicked img tag.
How i will achive.Can anyone tell me. | 2014/01/24 | [
"https://Stackoverflow.com/questions/21332887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3232027/"
] | @shanks solution doesn't address setting the image to the clicked image. I have modified the code to address the same.
**HTML**
```
<input type="file" ng-file-select="uploadImage($files)" id="file-input" name="filedata"/>
<img src="no_image.png" ng-click="triggerUpload()" id="imageId"/>
```
**JAVASCRIPT**
In brow... | try this
```
<img url="#Your image url" alt="click here to add file upload" />
<div id="fileUpload" />
```
and script
```
$('img').click(function () {
AddFileUpload();
});
function AddFileUpload() {
$('#fileUpload').append('<input type="file"/>');
}
```
[Demo](http://jsfiddle.net/carunchandran/25xGQ/1/) |
110,870 | In chapter 80, *The Primary*, Neal Stephenson has one of his character describe how the drives of a computer carried through a door (by the police, who where raiding the facility) will have been erased.
Basically, there's an enormous electromagnet around the door frame:
>
> Cantrell is now drawing an elaborate dia... | 2014/05/01 | [
"https://physics.stackexchange.com/questions/110870",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/45702/"
] | There's really two parts to your question, which I'm going to answer separately. First of all, the explicit question:
Could a huge electromagnetic coil erase a hard drive carried through it?
------------------------------------------------------------------------
Sure it could. That's pretty much what a [degausser](h... | **Possibly**.
[Degaussing](http://www.dataerasure.com/degauss.php) is the process of destroying data on a hard drive using an electromagnetic field, so there's some scientific basis to the idea. Assuming the electromagnet was sufficiently strong and there was no or very little shielding around the hard drive - which, ... |
110,870 | In chapter 80, *The Primary*, Neal Stephenson has one of his character describe how the drives of a computer carried through a door (by the police, who where raiding the facility) will have been erased.
Basically, there's an enormous electromagnet around the door frame:
>
> Cantrell is now drawing an elaborate dia... | 2014/05/01 | [
"https://physics.stackexchange.com/questions/110870",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/45702/"
] | **Possibly**.
[Degaussing](http://www.dataerasure.com/degauss.php) is the process of destroying data on a hard drive using an electromagnetic field, so there's some scientific basis to the idea. Assuming the electromagnet was sufficiently strong and there was no or very little shielding around the hard drive - which, ... | I agree that **some** hard drives could be "erased" with the described electromagnet. However, if the hard drive is "magnetically shielded," then it is highly unlikely. If a "high enough" (> 50,000 hertz) frequency is used, the presence of the electromagnet should not be "humanly" detectable. |
110,870 | In chapter 80, *The Primary*, Neal Stephenson has one of his character describe how the drives of a computer carried through a door (by the police, who where raiding the facility) will have been erased.
Basically, there's an enormous electromagnet around the door frame:
>
> Cantrell is now drawing an elaborate dia... | 2014/05/01 | [
"https://physics.stackexchange.com/questions/110870",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/45702/"
] | Yes.
It is definitely possible to erase a hard drive with a strong enough magnetic field. Machines called "degaussers" exist only to erase hard drives in this manner, specifically without removing the drive platters (disks) from an enclosure.
Most degaussers appear to be rated at 8000-10000 Gauss. At the top end, the... | I agree that **some** hard drives could be "erased" with the described electromagnet. However, if the hard drive is "magnetically shielded," then it is highly unlikely. If a "high enough" (> 50,000 hertz) frequency is used, the presence of the electromagnet should not be "humanly" detectable. |
110,870 | In chapter 80, *The Primary*, Neal Stephenson has one of his character describe how the drives of a computer carried through a door (by the police, who where raiding the facility) will have been erased.
Basically, there's an enormous electromagnet around the door frame:
>
> Cantrell is now drawing an elaborate dia... | 2014/05/01 | [
"https://physics.stackexchange.com/questions/110870",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/45702/"
] | There's really two parts to your question, which I'm going to answer separately. First of all, the explicit question:
Could a huge electromagnetic coil erase a hard drive carried through it?
------------------------------------------------------------------------
Sure it could. That's pretty much what a [degausser](h... | Yes.
It is definitely possible to erase a hard drive with a strong enough magnetic field. Machines called "degaussers" exist only to erase hard drives in this manner, specifically without removing the drive platters (disks) from an enclosure.
Most degaussers appear to be rated at 8000-10000 Gauss. At the top end, the... |
110,870 | In chapter 80, *The Primary*, Neal Stephenson has one of his character describe how the drives of a computer carried through a door (by the police, who where raiding the facility) will have been erased.
Basically, there's an enormous electromagnet around the door frame:
>
> Cantrell is now drawing an elaborate dia... | 2014/05/01 | [
"https://physics.stackexchange.com/questions/110870",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/45702/"
] | **In Theory...but Not In Reality**
It's one of those ideas that is possible in theory but impractical in practice.
Hard drives in computers are surrounded by a metal case of the drive, then the metal case of the computer. Even if you specifically got a non-metal case there is still some shielding there.
To generate ... | Yes.
It is definitely possible to erase a hard drive with a strong enough magnetic field. Machines called "degaussers" exist only to erase hard drives in this manner, specifically without removing the drive platters (disks) from an enclosure.
Most degaussers appear to be rated at 8000-10000 Gauss. At the top end, the... |
110,870 | In chapter 80, *The Primary*, Neal Stephenson has one of his character describe how the drives of a computer carried through a door (by the police, who where raiding the facility) will have been erased.
Basically, there's an enormous electromagnet around the door frame:
>
> Cantrell is now drawing an elaborate dia... | 2014/05/01 | [
"https://physics.stackexchange.com/questions/110870",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/45702/"
] | **Possibly**.
[Degaussing](http://www.dataerasure.com/degauss.php) is the process of destroying data on a hard drive using an electromagnetic field, so there's some scientific basis to the idea. Assuming the electromagnet was sufficiently strong and there was no or very little shielding around the hard drive - which, ... | Agree with all comments above about the required strength, and the likely side effects if it were a DC degausser. But I got to thinking - if it were an AC degausser instead, you'd have lots of erasure events per second. Plus, you'd get metal objects wiggling back and forth instead of being yanked around. Do it at a pre... |
110,870 | In chapter 80, *The Primary*, Neal Stephenson has one of his character describe how the drives of a computer carried through a door (by the police, who where raiding the facility) will have been erased.
Basically, there's an enormous electromagnet around the door frame:
>
> Cantrell is now drawing an elaborate dia... | 2014/05/01 | [
"https://physics.stackexchange.com/questions/110870",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/45702/"
] | **In Theory...but Not In Reality**
It's one of those ideas that is possible in theory but impractical in practice.
Hard drives in computers are surrounded by a metal case of the drive, then the metal case of the computer. Even if you specifically got a non-metal case there is still some shielding there.
To generate ... | I agree that **some** hard drives could be "erased" with the described electromagnet. However, if the hard drive is "magnetically shielded," then it is highly unlikely. If a "high enough" (> 50,000 hertz) frequency is used, the presence of the electromagnet should not be "humanly" detectable. |
110,870 | In chapter 80, *The Primary*, Neal Stephenson has one of his character describe how the drives of a computer carried through a door (by the police, who where raiding the facility) will have been erased.
Basically, there's an enormous electromagnet around the door frame:
>
> Cantrell is now drawing an elaborate dia... | 2014/05/01 | [
"https://physics.stackexchange.com/questions/110870",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/45702/"
] | Agree with all comments above about the required strength, and the likely side effects if it were a DC degausser. But I got to thinking - if it were an AC degausser instead, you'd have lots of erasure events per second. Plus, you'd get metal objects wiggling back and forth instead of being yanked around. Do it at a pre... | I agree that **some** hard drives could be "erased" with the described electromagnet. However, if the hard drive is "magnetically shielded," then it is highly unlikely. If a "high enough" (> 50,000 hertz) frequency is used, the presence of the electromagnet should not be "humanly" detectable. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.