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 |
|---|---|---|---|---|---|
38,074,340 | The scipy integrators take two parameters when integrating: (1) `step` which tells the integrator to take only a single step, and (2) `relax` which tells the integrator that it is fine to step past the final time point.
I want to take steps (so that I can collect the entire solution), but also not step past the final ... | 2016/06/28 | [
"https://Stackoverflow.com/questions/38074340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1485877/"
] | This will give you an array of the values you want:
```
var r = window.location.href.split("?");
r.shift();
console.log(r);
```
If there are always exactly two values, you can use this to extract them:
```
var val1 = r.shift();
var val2 = r.shift();
```
Here's a version which gives the `.chicken` result:
```
var... | ```
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
// Do something with the name sParameterName[0]
// Do something with the... |
38,074,340 | The scipy integrators take two parameters when integrating: (1) `step` which tells the integrator to take only a single step, and (2) `relax` which tells the integrator that it is fine to step past the final time point.
I want to take steps (so that I can collect the entire solution), but also not step past the final ... | 2016/06/28 | [
"https://Stackoverflow.com/questions/38074340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1485877/"
] | I'd suggest:
```
// obviously, in production you should use document.location.href:
var url = "http://www.example.com/?chicken?toast",
// take a substring of the url variable, starting at the index of
// the (first) '?' character and running to the end of the string,
// giving "?chicken?toast", we then split that res... | ```
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
// Do something with the name sParameterName[0]
// Do something with the... |
45,181,430 | I am using `Bootstrap` and I want add a button at right of a bar that looks like `<input-group-addon>`. To be specific, full height and locates at right most.
I've tried `height: 100%` but the button styles super high.
this is part of my code: <https://plnkr.co/edit/lK8vt0wT1xDesuOZW8vU?p=preview>
this is what I m l... | 2017/07/19 | [
"https://Stackoverflow.com/questions/45181430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4809938/"
] | The parent needs `position:relative`.
Then you can position the button absolutely in the corner with `height:100%`
```css
.panel-heading{
position:relative;
}
button.btn{
float: none;
margin-right: 0;
position: absolute;
top: 0;
right: 0;
height: 100%;
}
```
```html
<link rel="stylesheet"... | **Using Position Property**
```css
.panel-heading{
position: relative;
}
button.btn{
position: absolute;
top:0;
bottom:0;
border-radius: 0;
right: 0;
}
```
```html
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://cdn... |
45,181,430 | I am using `Bootstrap` and I want add a button at right of a bar that looks like `<input-group-addon>`. To be specific, full height and locates at right most.
I've tried `height: 100%` but the button styles super high.
this is part of my code: <https://plnkr.co/edit/lK8vt0wT1xDesuOZW8vU?p=preview>
this is what I m l... | 2017/07/19 | [
"https://Stackoverflow.com/questions/45181430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4809938/"
] | Try absolutely positioning your button:
```css
.my-heading {
position: relative;
}
.btn.my-btn {
position:absolute;
right: 0;
top: 0;
height: 100%;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
```
```html
<head>
<link rel="stylesheet" href="s... | **Using Position Property**
```css
.panel-heading{
position: relative;
}
button.btn{
position: absolute;
top:0;
bottom:0;
border-radius: 0;
right: 0;
}
```
```html
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://cdn... |
45,181,430 | I am using `Bootstrap` and I want add a button at right of a bar that looks like `<input-group-addon>`. To be specific, full height and locates at right most.
I've tried `height: 100%` but the button styles super high.
this is part of my code: <https://plnkr.co/edit/lK8vt0wT1xDesuOZW8vU?p=preview>
this is what I m l... | 2017/07/19 | [
"https://Stackoverflow.com/questions/45181430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4809938/"
] | **Using Position Property**
```css
.panel-heading{
position: relative;
}
button.btn{
position: absolute;
top:0;
bottom:0;
border-radius: 0;
right: 0;
}
```
```html
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://cdn... | By using display flex on the parent panel you could set the panel heading and the button next to each other and then they will naturally have the same height. Then would just need to adjust to panel-heading width.
```css
.panel{
display: flex;
}
.panel-heading {
width: 100%;
}
```
```html
<!DOCTYPE html>
<html>
... |
45,181,430 | I am using `Bootstrap` and I want add a button at right of a bar that looks like `<input-group-addon>`. To be specific, full height and locates at right most.
I've tried `height: 100%` but the button styles super high.
this is part of my code: <https://plnkr.co/edit/lK8vt0wT1xDesuOZW8vU?p=preview>
this is what I m l... | 2017/07/19 | [
"https://Stackoverflow.com/questions/45181430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4809938/"
] | Try absolutely positioning your button:
```css
.my-heading {
position: relative;
}
.btn.my-btn {
position:absolute;
right: 0;
top: 0;
height: 100%;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
```
```html
<head>
<link rel="stylesheet" href="s... | The parent needs `position:relative`.
Then you can position the button absolutely in the corner with `height:100%`
```css
.panel-heading{
position:relative;
}
button.btn{
float: none;
margin-right: 0;
position: absolute;
top: 0;
right: 0;
height: 100%;
}
```
```html
<link rel="stylesheet"... |
45,181,430 | I am using `Bootstrap` and I want add a button at right of a bar that looks like `<input-group-addon>`. To be specific, full height and locates at right most.
I've tried `height: 100%` but the button styles super high.
this is part of my code: <https://plnkr.co/edit/lK8vt0wT1xDesuOZW8vU?p=preview>
this is what I m l... | 2017/07/19 | [
"https://Stackoverflow.com/questions/45181430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4809938/"
] | The parent needs `position:relative`.
Then you can position the button absolutely in the corner with `height:100%`
```css
.panel-heading{
position:relative;
}
button.btn{
float: none;
margin-right: 0;
position: absolute;
top: 0;
right: 0;
height: 100%;
}
```
```html
<link rel="stylesheet"... | By using display flex on the parent panel you could set the panel heading and the button next to each other and then they will naturally have the same height. Then would just need to adjust to panel-heading width.
```css
.panel{
display: flex;
}
.panel-heading {
width: 100%;
}
```
```html
<!DOCTYPE html>
<html>
... |
45,181,430 | I am using `Bootstrap` and I want add a button at right of a bar that looks like `<input-group-addon>`. To be specific, full height and locates at right most.
I've tried `height: 100%` but the button styles super high.
this is part of my code: <https://plnkr.co/edit/lK8vt0wT1xDesuOZW8vU?p=preview>
this is what I m l... | 2017/07/19 | [
"https://Stackoverflow.com/questions/45181430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4809938/"
] | Try absolutely positioning your button:
```css
.my-heading {
position: relative;
}
.btn.my-btn {
position:absolute;
right: 0;
top: 0;
height: 100%;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
```
```html
<head>
<link rel="stylesheet" href="s... | By using display flex on the parent panel you could set the panel heading and the button next to each other and then they will naturally have the same height. Then would just need to adjust to panel-heading width.
```css
.panel{
display: flex;
}
.panel-heading {
width: 100%;
}
```
```html
<!DOCTYPE html>
<html>
... |
66,534,369 | I am trying to create a website with my raspberry pi 1.0 with Nginx and gunicorn.
while configuring gunicorn i had to create the file myproject.service but when i try to execute this command:
```
systemctl enable myproject
```
is giving me an error (**Failed to enable unit: Invalid argument**)
that I couldn't resol... | 2021/03/08 | [
"https://Stackoverflow.com/questions/66534369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13549907/"
] | I have met this issue before, and the problem might be your deployment method. Not sure which one you use, but **the classic deployment center** below is being deprecated, try use the new deployment center.
[](https://i.stack.imgur.com/8FozR.png)
Check... | The possible reason for this question is that you don't have Django installed.
In the Microsoft-hosted agent `ubuntu-latest`, Django is not pre-installed. That is, you need to install it manually.
```
pip install Django==3.1.7
```
Click [this document](https://www.djangoproject.com/download/) for detailed informati... |
45,333,361 | Alexa just doesn't understand the word 'postpaid' and I've tried it a million times in my skill. I also tried "Alexa, Simon says postpaid" but it repeats something else other than postpaid, I don't know why. My sample utterance is like this "what is the {type} sales" and the type has custom slot values "postpaid",etc.
... | 2017/07/26 | [
"https://Stackoverflow.com/questions/45333361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1881473/"
] | As a general rule, Windows x64 requires *all* functions to provide unwind information. The only exception is for leaf functions which do not modify `rsp` and do not modify any nonvolatile registers. | Judging by the context of your question, what you really want to know is the practical consequences of not providing unwind information for your non-leaf assembly functions on x64 Windows. Since C++ exceptions are implemented based on SEH exceptions, when I talk about exceptions below, I mean both all "native" (access ... |
45,777,234 | I have a .txt textfile with a list formatted like
`[' ok ', ' test ', ' help ']`
How can I read/import this textfile list into a python list? | 2017/08/19 | [
"https://Stackoverflow.com/questions/45777234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3672953/"
] | color: yellow; does not overwrite the class (mat-tooltip) you have to add !important;
like this:
**XX.component.ts:**
```
import { Component, OnInit } from '@angular/core';
import { ViewEncapsulation } from '@angular/core';
@Component({
selector: 'app-tooltip-demo',
templateUrl: './XX.component.html',
styleUr... | Late at the party :-| Just in case somebody has as well the troubles. Angular Material won't apply the class if its encapsulated. The solution?
Put the style in the `styles.scss` file and using `!important`. This finally solved my problem. e.g.
```
.red-tooltip {
background-color: red !important;
font-size: l... |
45,777,234 | I have a .txt textfile with a list formatted like
`[' ok ', ' test ', ' help ']`
How can I read/import this textfile list into a python list? | 2017/08/19 | [
"https://Stackoverflow.com/questions/45777234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3672953/"
] | If you want to customize the css of the tooltip, then you can use `::ng-deep`. Add the following styles in your component's styles:
```css
::ng-deep .mat-tooltip {
/* your own custom styles here */
/* e.g. */
color: yellow;
}
```
Another option is to set the [View Encapsulation](https://angular.io/guide... | Always use the matTooltipClass and a custom class. Never use ::ng-deep directly on a material class and NEVER, NEVER set encapsulation: ViewEncapsulation.None. Angular components are made to be modular and have their own style. Both :ng-deep(or /deep/ or >>> or whatever they call it these days) and viewEncapsulation ar... |
45,777,234 | I have a .txt textfile with a list formatted like
`[' ok ', ' test ', ' help ']`
How can I read/import this textfile list into a python list? | 2017/08/19 | [
"https://Stackoverflow.com/questions/45777234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3672953/"
] | Simply add a `matTooltipClass="red-tooltip"` in your input tag may be.
And then in styles.css add the definition for this class
```
<input type="number" matTooltipClass='red-tooltip'/>
.red-tooltip{
background-color:red;
}
``` | Here's a solution without ::ng-deep / ViewEncapsulation.None. With it you can also use different tooltips in same / different components and each will have their own separate style.
>
> Firstly, in styles.scss define
>
>
>
> ```
> .mat-tooltip.my-tooltip
> {
> background-color: blue !important;
> }
>
> ```
>
> T... |
45,777,234 | I have a .txt textfile with a list formatted like
`[' ok ', ' test ', ' help ']`
How can I read/import this textfile list into a python list? | 2017/08/19 | [
"https://Stackoverflow.com/questions/45777234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3672953/"
] | color: yellow; does not overwrite the class (mat-tooltip) you have to add !important;
like this:
**XX.component.ts:**
```
import { Component, OnInit } from '@angular/core';
import { ViewEncapsulation } from '@angular/core';
@Component({
selector: 'app-tooltip-demo',
templateUrl: './XX.component.html',
styleUr... | Angular Material tooltip exposes input property 'matTooltipClass'
So in the HTML
```
`
<mat-icon color="primary" matTooltip="test"
[matTooltipClass]="{ 'tool-tip': true }"
>help</mat-icon>
`
```
In the CSS
```
.tool-tip {
color: white;
backgrou... |
45,777,234 | I have a .txt textfile with a list formatted like
`[' ok ', ' test ', ' help ']`
How can I read/import this textfile list into a python list? | 2017/08/19 | [
"https://Stackoverflow.com/questions/45777234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3672953/"
] | If you want to customize the css of the tooltip, then you can use `::ng-deep`. Add the following styles in your component's styles:
```css
::ng-deep .mat-tooltip {
/* your own custom styles here */
/* e.g. */
color: yellow;
}
```
Another option is to set the [View Encapsulation](https://angular.io/guide... | Angular Material tooltip exposes input property 'matTooltipClass'
So in the HTML
```
`
<mat-icon color="primary" matTooltip="test"
[matTooltipClass]="{ 'tool-tip': true }"
>help</mat-icon>
`
```
In the CSS
```
.tool-tip {
color: white;
backgrou... |
45,777,234 | I have a .txt textfile with a list formatted like
`[' ok ', ' test ', ' help ']`
How can I read/import this textfile list into a python list? | 2017/08/19 | [
"https://Stackoverflow.com/questions/45777234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3672953/"
] | Simply add a `matTooltipClass="red-tooltip"` in your input tag may be.
And then in styles.css add the definition for this class
```
<input type="number" matTooltipClass='red-tooltip'/>
.red-tooltip{
background-color:red;
}
``` | color: yellow; does not overwrite the class (mat-tooltip) you have to add !important;
like this:
**XX.component.ts:**
```
import { Component, OnInit } from '@angular/core';
import { ViewEncapsulation } from '@angular/core';
@Component({
selector: 'app-tooltip-demo',
templateUrl: './XX.component.html',
styleUr... |
45,777,234 | I have a .txt textfile with a list formatted like
`[' ok ', ' test ', ' help ']`
How can I read/import this textfile list into a python list? | 2017/08/19 | [
"https://Stackoverflow.com/questions/45777234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3672953/"
] | Always use the matTooltipClass and a custom class. Never use ::ng-deep directly on a material class and NEVER, NEVER set encapsulation: ViewEncapsulation.None. Angular components are made to be modular and have their own style. Both :ng-deep(or /deep/ or >>> or whatever they call it these days) and viewEncapsulation ar... | Angular Material tooltip exposes input property 'matTooltipClass'
So in the HTML
```
`
<mat-icon color="primary" matTooltip="test"
[matTooltipClass]="{ 'tool-tip': true }"
>help</mat-icon>
`
```
In the CSS
```
.tool-tip {
color: white;
backgrou... |
45,777,234 | I have a .txt textfile with a list formatted like
`[' ok ', ' test ', ' help ']`
How can I read/import this textfile list into a python list? | 2017/08/19 | [
"https://Stackoverflow.com/questions/45777234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3672953/"
] | If you want to customize the css of the tooltip, then you can use `::ng-deep`. Add the following styles in your component's styles:
```css
::ng-deep .mat-tooltip {
/* your own custom styles here */
/* e.g. */
color: yellow;
}
```
Another option is to set the [View Encapsulation](https://angular.io/guide... | Late at the party :-| Just in case somebody has as well the troubles. Angular Material won't apply the class if its encapsulated. The solution?
Put the style in the `styles.scss` file and using `!important`. This finally solved my problem. e.g.
```
.red-tooltip {
background-color: red !important;
font-size: l... |
45,777,234 | I have a .txt textfile with a list formatted like
`[' ok ', ' test ', ' help ']`
How can I read/import this textfile list into a python list? | 2017/08/19 | [
"https://Stackoverflow.com/questions/45777234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3672953/"
] | If you want to customize the css of the tooltip, then you can use `::ng-deep`. Add the following styles in your component's styles:
```css
::ng-deep .mat-tooltip {
/* your own custom styles here */
/* e.g. */
color: yellow;
}
```
Another option is to set the [View Encapsulation](https://angular.io/guide... | You could take a look into the following example [angular/material2 Tooltip Demo](https://github.com/angular/material2/blob/master/src/demo-app/tooltip/tooltip-demo.html)
Basically you could set up the tooltip as follows (you could define not only the css but also the position, the hide delay, the show delay and if it... |
45,777,234 | I have a .txt textfile with a list formatted like
`[' ok ', ' test ', ' help ']`
How can I read/import this textfile list into a python list? | 2017/08/19 | [
"https://Stackoverflow.com/questions/45777234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3672953/"
] | You could take a look into the following example [angular/material2 Tooltip Demo](https://github.com/angular/material2/blob/master/src/demo-app/tooltip/tooltip-demo.html)
Basically you could set up the tooltip as follows (you could define not only the css but also the position, the hide delay, the show delay and if it... | Here's a solution without ::ng-deep / ViewEncapsulation.None. With it you can also use different tooltips in same / different components and each will have their own separate style.
>
> Firstly, in styles.scss define
>
>
>
> ```
> .mat-tooltip.my-tooltip
> {
> background-color: blue !important;
> }
>
> ```
>
> T... |
30,126,329 | I am trying to use a regular expression in order to extract the part of a string before the first " / " occurrence. In the following example the initial string is "Atomic grouping / possessive qualifiers / conditional and recursive patterns" and i want to get "Atomic grouping"
```
library(stringr)
var.descr <- "Atomic... | 2015/05/08 | [
"https://Stackoverflow.com/questions/30126329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/299077/"
] | You can use lookahead regex like this:
```
str_extract(var.descr, perl("^.+?(?= / |$)"))
```
`(?= / |$)` will make sure either `/` is followed by the matched text or it matches till end of input.
[RegEx Demo](https://regex101.com/r/jF6fW9/3) | You can use the "lazy" `+` with `?` after it
```
str_extract(var.descr, perl("^[^/]+"))
``` |
4,931,193 | In CPP unit we run unit test as part of build as part of post build setup. We will be running multiple tests as part of this. In case if any test case fails post build should not stop, it should go ahead and run all the test cases and should report summary how many test cases passed and failed. how can we achieve this.... | 2011/02/08 | [
"https://Stackoverflow.com/questions/4931193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/519882/"
] | Your question is too vague for a precise answer. Usually, a unit test engine return a code to tell it has failed (like a non zero return code in the shell on linux) or generate some output file with results. The calling system handle this. If you have written it (some home made scripts) you have to give the option to g... | I would just write your tests this way. Instead of using the CPPUNIT\_ASSERT macros or whatever you would write them in regular C++ with some way of logging errors.
You could use a macro for this too of course. Something like:
`LOGASSERT( some_expression )`
could be defined to execute some\_expression and to log the... |
4,931,193 | In CPP unit we run unit test as part of build as part of post build setup. We will be running multiple tests as part of this. In case if any test case fails post build should not stop, it should go ahead and run all the test cases and should report summary how many test cases passed and failed. how can we achieve this.... | 2011/02/08 | [
"https://Stackoverflow.com/questions/4931193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/519882/"
] | His question is specific enough. You need a test runner. Encapsulate each test in its own behavior and class. The test project is contained separately from the tested code. Afterwards just configure your XMLOutputter. You can find an excellent example of how to do this in the linux website. <http://www.yolinux.com/TUTO... | I would just write your tests this way. Instead of using the CPPUNIT\_ASSERT macros or whatever you would write them in regular C++ with some way of logging errors.
You could use a macro for this too of course. Something like:
`LOGASSERT( some_expression )`
could be defined to execute some\_expression and to log the... |
8,614,134 | Here is some parts from a diff file generated using `git diff HEAD`.
```
@@ -261,6 +261,13 @@ public class JSONServiceAction extends JSONAction {
return new double[0][0];
}
}
+ /*
+ * Some changes made...
+ */
... | 2011/12/23 | [
"https://Stackoverflow.com/questions/8614134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/853599/"
] | 1. Git's putting those block names to make it easier for humans to determine which part of the file a given patch is affecting. In case of C it show a first line of a function definition, which is really useful. Apparently it's slightly less informative in case of Java. Why does it trouble you?
2. You have added or rem... | For your point 2, you had a file with no newline at the end committed. Your current version has a newline at the end (a lot of editors add one for you). That's what the diff is showing.
```
$ git init
Initialized empty Git repository in ...
$ echo -n hello > file
$ git add file ; git commit -m test
[master (root-commi... |
8,614,134 | Here is some parts from a diff file generated using `git diff HEAD`.
```
@@ -261,6 +261,13 @@ public class JSONServiceAction extends JSONAction {
return new double[0][0];
}
}
+ /*
+ * Some changes made...
+ */
... | 2011/12/23 | [
"https://Stackoverflow.com/questions/8614134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/853599/"
] | 1. Git's putting those block names to make it easier for humans to determine which part of the file a given patch is affecting. In case of C it show a first line of a function definition, which is really useful. Apparently it's slightly less informative in case of Java. Why does it trouble you?
2. You have added or rem... | 1. As mentioned, the hunk header is for convenience. If you want to change what it displays, see the [git attributes](http://schacon.github.com/git/gitattributes.html) manpage section on defining a custom hunk-header and see an example for python [here](https://stackoverflow.com/questions/2783086/how-does-git-diff-gene... |
100,866 | I am new to using Mac (Mac Pro, OS X 10.8.4) and I connect to many remote hosts using ssh. I have created aliases in .ssh/config file and would like to have the host alias as the name of the tab in terminal.
Can someone please advise on how it can be done?
Thanks much. | 2013/09/04 | [
"https://apple.stackexchange.com/questions/100866",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/56415/"
] | **EDIT**: On Yosemite (OS X 10.10) use this instead:
```
function ssh ()
{
servername=$(echo $@ | sed -E 's|([- a-zA-Z0-9:/]+)( *[^@ ]*@)([^@ ]*)|\3|')
echo -ne "\033]0;${servername}\007";
/usr/bin/ssh $@
}
```
Note that the function expects username and server name to be specified as `user@server` ... | You can use the LocalCommand argument in your ~/.ssh/config file to run a bash or Applescript file that sets the tab name.
Bash Script: ~/.ssh/settabname.sh
```
#!/bin/bash
osascript -e 'delay 2' -e "tell application \"Terminal\" to tell window 1 to set custom title to \"$1\""
```
Your ~/.ssh/config file:
```
Hos... |
98,928 | Is there a command working exactly like [Matlab's `find`](http://www.mathworks.com/help/matlab/ref/find.html)?
I know that `Pick` might work, but I just want to give a logic condition to select the elements of a list instead of a particular value.
For instance:
```
T={a, b, c, d, e}
Ctl={2.3, 0, 5, 0, 0}
```
I'd l... | 2015/11/08 | [
"https://mathematica.stackexchange.com/questions/98928",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/22893/"
] | You can find the position/index within an array of all values in a specified interval, (like Matlab's find) using `Position`. For instance:
```
pos = Position[a, _?((0.3 < # < 0.7) &)]
```
or
```
pos = Position[a, x_ /; (0.3 < x < 0.7)]
```
These find the indices of all elements in `a` with values between 0.3 an... | You use a `PositionIndex` with `KeySelect` for this, which is a good approach if you need to use multiple tests against the same array.
```
In[1]:= T = {a, b, c, d, e};
Ctl = {2.3, 0, 5, 0, 0};
In[2]:= index = PositionIndex[Ctl]
Out[2]= <|2.3 -> {1}, 0 -> {2, 4, 5}, 5 -> {3}|>
In[3]:= Extract[T, Values@Key... |
98,928 | Is there a command working exactly like [Matlab's `find`](http://www.mathworks.com/help/matlab/ref/find.html)?
I know that `Pick` might work, but I just want to give a logic condition to select the elements of a list instead of a particular value.
For instance:
```
T={a, b, c, d, e}
Ctl={2.3, 0, 5, 0, 0}
```
I'd l... | 2015/11/08 | [
"https://mathematica.stackexchange.com/questions/98928",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/22893/"
] | You can find the position/index within an array of all values in a specified interval, (like Matlab's find) using `Position`. For instance:
```
pos = Position[a, _?((0.3 < # < 0.7) &)]
```
or
```
pos = Position[a, x_ /; (0.3 < x < 0.7)]
```
These find the indices of all elements in `a` with values between 0.3 an... | Just for some ridiculousness (covering some of the give answers):
```
t = {a, b, c, d, e};
ctl = {2.3, 0, 5, 0, 0};
```
Various:
```
Pick[t, Positive@ctl] (* JM*)
Extract[t, Position[ctl, _?Positive]] (* bill s *)
Cases[Transpose[{t, ctl}], {x_, _?Positive} :> x]
First /@ Select[Transpose[{t, ctl}], #[[2]] > 0 &]
... |
98,928 | Is there a command working exactly like [Matlab's `find`](http://www.mathworks.com/help/matlab/ref/find.html)?
I know that `Pick` might work, but I just want to give a logic condition to select the elements of a list instead of a particular value.
For instance:
```
T={a, b, c, d, e}
Ctl={2.3, 0, 5, 0, 0}
```
I'd l... | 2015/11/08 | [
"https://mathematica.stackexchange.com/questions/98928",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/22893/"
] | You use a `PositionIndex` with `KeySelect` for this, which is a good approach if you need to use multiple tests against the same array.
```
In[1]:= T = {a, b, c, d, e};
Ctl = {2.3, 0, 5, 0, 0};
In[2]:= index = PositionIndex[Ctl]
Out[2]= <|2.3 -> {1}, 0 -> {2, 4, 5}, 5 -> {3}|>
In[3]:= Extract[T, Values@Key... | Just for some ridiculousness (covering some of the give answers):
```
t = {a, b, c, d, e};
ctl = {2.3, 0, 5, 0, 0};
```
Various:
```
Pick[t, Positive@ctl] (* JM*)
Extract[t, Position[ctl, _?Positive]] (* bill s *)
Cases[Transpose[{t, ctl}], {x_, _?Positive} :> x]
First /@ Select[Transpose[{t, ctl}], #[[2]] > 0 &]
... |
26,647,643 | I've got a base class with a few pure virtuals, and I want it to provide default implementations of several methods which can be overridden if needed. I've boiled my problem down to the following:
```
class A {};
class B {};
class Base {
public:
virtual void foo (const A&) {};
virtual void foo (const B&) = 0;
};
... | 2014/10/30 | [
"https://Stackoverflow.com/questions/26647643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1763982/"
] | Add this line to your `Derived` class definition:
```
using Base::foo;
```
This will solve the problem that your foo(B) definition in Derived hides both foo(A) and foo(B) functions in Base. | Within minutes, I find it.
I need `using Base::foo` in `Derived`.
<http://www.parashift.com/c++-faq-lite/hiding-rule.html>
Thank you StackOverflow once again for helping me answer my own question. Couldn't have done it without you. |
26,647,643 | I've got a base class with a few pure virtuals, and I want it to provide default implementations of several methods which can be overridden if needed. I've boiled my problem down to the following:
```
class A {};
class B {};
class Base {
public:
virtual void foo (const A&) {};
virtual void foo (const B&) = 0;
};
... | 2014/10/30 | [
"https://Stackoverflow.com/questions/26647643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1763982/"
] | Add this line to your `Derived` class definition:
```
using Base::foo;
```
This will solve the problem that your foo(B) definition in Derived hides both foo(A) and foo(B) functions in Base. | In case you cannot modify the base and/or derived class, and still want to call the (accessible) method, you may fully qualify the call:
```
Derived d;
d.Base::foo(A());
``` |
270,289 | One of my friends and I had an argument over this topic. He stressed the fact that in real life many forces exist, whereas in physics we deal only with ideal situations. He put the following arguments:-
>
> 1. Newton's First Law is invalid because friction exists in real life.
> 2. Newton's second law is invalid due ... | 2016/07/28 | [
"https://physics.stackexchange.com/questions/270289",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/107112/"
] | >
> Newton's First Law is invalid because friction exists in real life.
>
>
>
Let's review what Newton's first law says:
>
> When viewed in an inertial reference frame, an object either remains at rest or continues to move at a constant velocity, **unless acted upon by a net force**.
>
>
>
Your friend is rig... | Your friend actively misunderstands the Newton laws and the ideas behind it. He is about to argue that formula $E=mc^2$ is invalid because it states that Youngs modulus ($E$) is equal to mass ($m$) times hypotenuse squared ($c$). And he is supporting his arguments by several [argument fouls](https://www.reddit.com/r/re... |
270,289 | One of my friends and I had an argument over this topic. He stressed the fact that in real life many forces exist, whereas in physics we deal only with ideal situations. He put the following arguments:-
>
> 1. Newton's First Law is invalid because friction exists in real life.
> 2. Newton's second law is invalid due ... | 2016/07/28 | [
"https://physics.stackexchange.com/questions/270289",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/107112/"
] | >
> Newton's First Law is invalid because friction exists in real life.
>
>
>
Let's review what Newton's first law says:
>
> When viewed in an inertial reference frame, an object either remains at rest or continues to move at a constant velocity, **unless acted upon by a net force**.
>
>
>
Your friend is rig... | Newtons laws are a good approximation for how the world works when the velocity is less than 1% the speed of light, the gravity isn't too strong, when the number of elementary particles an object is composed of isn't too small as an object needs to be large enough for quantum uncertainty to be insignificant, and the am... |
270,289 | One of my friends and I had an argument over this topic. He stressed the fact that in real life many forces exist, whereas in physics we deal only with ideal situations. He put the following arguments:-
>
> 1. Newton's First Law is invalid because friction exists in real life.
> 2. Newton's second law is invalid due ... | 2016/07/28 | [
"https://physics.stackexchange.com/questions/270289",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/107112/"
] | Newtons laws are a good approximation for how the world works when the velocity is less than 1% the speed of light, the gravity isn't too strong, when the number of elementary particles an object is composed of isn't too small as an object needs to be large enough for quantum uncertainty to be insignificant, and the am... | **Short Answer:** Your friend is wrong because our models of friction (within certain parameters) are derived from Newton's laws. Tidal forces, for example, are are a form of friction.
The argument that Newton's "laws" are "invalid" in an pure philosophical sense, better rest on Newton simply pulling the concepts of g... |
270,289 | One of my friends and I had an argument over this topic. He stressed the fact that in real life many forces exist, whereas in physics we deal only with ideal situations. He put the following arguments:-
>
> 1. Newton's First Law is invalid because friction exists in real life.
> 2. Newton's second law is invalid due ... | 2016/07/28 | [
"https://physics.stackexchange.com/questions/270289",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/107112/"
] | Regardless of relativistic effects:
>
> 1. Newton's First Law is invalid because friction exists in real life.
>
>
>
False, the first law talks about the case when no forces are present, if forces are present go to the second law.
>
> 2. Newton's second law is invalid due to the same reasons.
>
>
>
False, y... | >
> Newton's First Law is invalid because friction exists in real life.
>
>
>
Let's review what Newton's first law says:
>
> When viewed in an inertial reference frame, an object either remains at rest or continues to move at a constant velocity, **unless acted upon by a net force**.
>
>
>
Your friend is rig... |
270,289 | One of my friends and I had an argument over this topic. He stressed the fact that in real life many forces exist, whereas in physics we deal only with ideal situations. He put the following arguments:-
>
> 1. Newton's First Law is invalid because friction exists in real life.
> 2. Newton's second law is invalid due ... | 2016/07/28 | [
"https://physics.stackexchange.com/questions/270289",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/107112/"
] | Newtons laws are a good approximation for how the world works when the velocity is less than 1% the speed of light, the gravity isn't too strong, when the number of elementary particles an object is composed of isn't too small as an object needs to be large enough for quantum uncertainty to be insignificant, and the am... | Newton's laws are valid for all situations where velocities are small (compared to the speed of light, ie relativity is not important) and where quantum effects are negligible (mostly where objects are much bigger than elementary particles). The problem with your argument is that you and your friend are using idealized... |
270,289 | One of my friends and I had an argument over this topic. He stressed the fact that in real life many forces exist, whereas in physics we deal only with ideal situations. He put the following arguments:-
>
> 1. Newton's First Law is invalid because friction exists in real life.
> 2. Newton's second law is invalid due ... | 2016/07/28 | [
"https://physics.stackexchange.com/questions/270289",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/107112/"
] | >
> Newton's First Law is invalid because friction exists in real life.
>
>
>
Let's review what Newton's first law says:
>
> When viewed in an inertial reference frame, an object either remains at rest or continues to move at a constant velocity, **unless acted upon by a net force**.
>
>
>
Your friend is rig... | As the saying goes: "All models are wrong, but some of them are useful."
For me, laws of physics are actually just models, i.e., simplifications of reality that give satisfactory answers to certain questions. Newton's laws are *useful* to build bridges, build skyscrapers, land rockets on the Moon, etc.
You could also... |
270,289 | One of my friends and I had an argument over this topic. He stressed the fact that in real life many forces exist, whereas in physics we deal only with ideal situations. He put the following arguments:-
>
> 1. Newton's First Law is invalid because friction exists in real life.
> 2. Newton's second law is invalid due ... | 2016/07/28 | [
"https://physics.stackexchange.com/questions/270289",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/107112/"
] | Wolphram johnny gave good explanation but for trampoline case there can be more explanation
Whenever you jump from earth, according to "third law", the force you give to the earth is equal to the force (reaction force) given by earth to you which makes you go off from the ground, the force you gave to earth actually m... | Your friend actively misunderstands the Newton laws and the ideas behind it. He is about to argue that formula $E=mc^2$ is invalid because it states that Youngs modulus ($E$) is equal to mass ($m$) times hypotenuse squared ($c$). And he is supporting his arguments by several [argument fouls](https://www.reddit.com/r/re... |
270,289 | One of my friends and I had an argument over this topic. He stressed the fact that in real life many forces exist, whereas in physics we deal only with ideal situations. He put the following arguments:-
>
> 1. Newton's First Law is invalid because friction exists in real life.
> 2. Newton's second law is invalid due ... | 2016/07/28 | [
"https://physics.stackexchange.com/questions/270289",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/107112/"
] | **Short Answer:** Your friend is wrong because our models of friction (within certain parameters) are derived from Newton's laws. Tidal forces, for example, are are a form of friction.
The argument that Newton's "laws" are "invalid" in an pure philosophical sense, better rest on Newton simply pulling the concepts of g... | Newton's laws are valid for all situations where velocities are small (compared to the speed of light, ie relativity is not important) and where quantum effects are negligible (mostly where objects are much bigger than elementary particles). The problem with your argument is that you and your friend are using idealized... |
270,289 | One of my friends and I had an argument over this topic. He stressed the fact that in real life many forces exist, whereas in physics we deal only with ideal situations. He put the following arguments:-
>
> 1. Newton's First Law is invalid because friction exists in real life.
> 2. Newton's second law is invalid due ... | 2016/07/28 | [
"https://physics.stackexchange.com/questions/270289",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/107112/"
] | As the saying goes: "All models are wrong, but some of them are useful."
For me, laws of physics are actually just models, i.e., simplifications of reality that give satisfactory answers to certain questions. Newton's laws are *useful* to build bridges, build skyscrapers, land rockets on the Moon, etc.
You could also... | Remember the **sum** $\sum$ symbol:
$$\sum \vec F=0$$
$$\sum \vec F=m\vec a$$
A very important detail.
It's not about "adjusting" anything to make the laws work, it's just about including *all* forces. Which might be tricky in real life, but that's another story.
And by the way, you can tell your friend that fricti... |
270,289 | One of my friends and I had an argument over this topic. He stressed the fact that in real life many forces exist, whereas in physics we deal only with ideal situations. He put the following arguments:-
>
> 1. Newton's First Law is invalid because friction exists in real life.
> 2. Newton's second law is invalid due ... | 2016/07/28 | [
"https://physics.stackexchange.com/questions/270289",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/107112/"
] | Newtons laws are a good approximation for how the world works when the velocity is less than 1% the speed of light, the gravity isn't too strong, when the number of elementary particles an object is composed of isn't too small as an object needs to be large enough for quantum uncertainty to be insignificant, and the am... | Your friend is wrong, and seems to suffer from a serious case of anti-intellectualism, not to mention arrogance and authority issues.
It's true that the models of physics we know are approximations, but the reason we're using them - after centuries of research - is that they're extremely good approximations.
To sugge... |
39,216,811 | I have an index match function that only needs 1 criteria, BUT there are potentially 5 different options for that single criteria. Is there a way to create the ability to go through the list of criteria iteratively until the match works outside of doing a series of nested if statements? I'm also hoping to avoid array f... | 2016/08/29 | [
"https://Stackoverflow.com/questions/39216811",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6720250/"
] | You formula works through a progression of possible [MATCH functions](https://support.office.com/en-us/article/match-function-0600e189-9f3c-4e4f-98c1-943a0eb427ca) and returns the first one in the series that does match. In this way, you will only ever get a single return or none at all.
If you were to put the a, b, c... | Please correct me if I misunderstood, I think you are looking to find the row number that matches 5 different criteria?
If so, you can do this:
```
=MATCH(A1 & B1 & C1 & D1 & E1, ArrayA & ArrayB & ArrayC & ArrayD & ArrayE, 0)
```
This will check for a match for all 5 values then return the row number. You can the... |
21,861,536 | The basic idea of what I want to achieve is to make a comparison between the current Android system date and an existing date in a SQlite database.
The idea is to 1.) If the database does not contain contain a entry with today's date, then allow new entry
2.) If the database already contains an entry from today's dat... | 2014/02/18 | [
"https://Stackoverflow.com/questions/21861536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3197786/"
] | When you call `map` on a `String` it is wrapped with `WrappedString` which extends `AbstractSeq[Char]`. Therefore, when you call `map` it is as if you are doing so on a `Seq` of `Char` not a `Seq` of `String`.
See the link below for the code <https://github.com/scala/scala/blob/v2.10.2/src/library/scala/collection/imm... | I found out that the code is perfect! Just because I was running it on Spark, the answer was kept in lazy RDD file that I needed to collect it somehow. Therefore, I saved it to a text file and problem solved! Here is the code:
file.flatMap(line=>line.split(" ")).map(w=>(w,1)).reduceByKey(*+*).saveAsTextFile("OUT.txt")... |
69,307,885 | There is an unexpected blue border when I type text. Please check the image. I tried editing `control` styles by setting `border` zero or none and even removed `boxShadow`. But nothing works. Please check the image.
```
control: (provided) => ({ ...provided, boxShadow: 'none', border: 0, }),
```
`.
2. If you want to keep this plugin. Add this into yo... | If you want to specifically modify **react-select** input style while keep using the tailwindcss-forms, you can use [classNamePrefix](https://react-select.com/styles#using-classnames) props.
```
<Select
classNamePrefix="select2-selection"
...
/>
```
Then in your **index.css** file, add this:
```
.select2-se... |
47,103,702 | My question is, if I have a function like this
```
function f(a) {
if (a == undefined) {
alert(1)
return f
} else {
alert(2)
}
```
}
and I call it like this, for example, `f()()()()('123')`, how can I keep track of how many times f was called?
Edit:
I had a play around and worked out a solution:
```... | 2017/11/03 | [
"https://Stackoverflow.com/questions/47103702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8746444/"
] | Rather than pollute the global space, attach the counter to the function itself.
```
function f(a)
{
++f.counter;
if (a) {
doAThing();
return f;
} else
doAnotherThing();
}
f.counter = 0;
```
Now you can access the number of calls by evaluating f.counter at any point. | Just create a count variable outside of the function scope and whenever you enter the function, you increase its value.
```
var count = 0;
function f(a) {
count++;
if (!a) {
alert(1);
return f;
} else {
alert(2);
}
}
``` |
47,103,702 | My question is, if I have a function like this
```
function f(a) {
if (a == undefined) {
alert(1)
return f
} else {
alert(2)
}
```
}
and I call it like this, for example, `f()()()()('123')`, how can I keep track of how many times f was called?
Edit:
I had a play around and worked out a solution:
```... | 2017/11/03 | [
"https://Stackoverflow.com/questions/47103702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8746444/"
] | Just create a count variable outside of the function scope and whenever you enter the function, you increase its value.
```
var count = 0;
function f(a) {
count++;
if (!a) {
alert(1);
return f;
} else {
alert(2);
}
}
``` | By "wrapper function) do you mean "closure"?
```
var f = (function (a) {
var count = 0;
return function () {
console.log(count);
count += 1;
if (!a) {
alert(1);
return f;
} else {
alert(2);
}
}
})();
``` |
47,103,702 | My question is, if I have a function like this
```
function f(a) {
if (a == undefined) {
alert(1)
return f
} else {
alert(2)
}
```
}
and I call it like this, for example, `f()()()()('123')`, how can I keep track of how many times f was called?
Edit:
I had a play around and worked out a solution:
```... | 2017/11/03 | [
"https://Stackoverflow.com/questions/47103702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8746444/"
] | Rather than pollute the global space, attach the counter to the function itself.
```
function f(a)
{
++f.counter;
if (a) {
doAThing();
return f;
} else
doAnotherThing();
}
f.counter = 0;
```
Now you can access the number of calls by evaluating f.counter at any point. | By "wrapper function) do you mean "closure"?
```
var f = (function (a) {
var count = 0;
return function () {
console.log(count);
count += 1;
if (!a) {
alert(1);
return f;
} else {
alert(2);
}
}
})();
``` |
52,428,076 | How come Intellij works well with JDK 10.0.2, while netbeans won't even open a new project? I tried to work with Netbeans, but it wouldn't open. However Intellij works very well. | 2018/09/20 | [
"https://Stackoverflow.com/questions/52428076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9512266/"
] | You could use `:after` pseudo element to create one square and then use `rotate` and `translate` transforms.
```css
.element {
display: inline-block;
background: lightgreen;
position: relative;
width: 200px;
height: 200px;
overflow: hidden;
}
.two {
margin-left: 30px;
width: 300px;
height:... | You can easily do this with gradient:
```css
.box {
width:200px;
height:200px;
background:
linear-gradient(red,red) right/30% 100%,
linear-gradient(to top left,red 49.8%,transparent 50%) top left/70% 50%,
linear-gradient(to bottom left,red 49.8%,transparent 50%) bottom left/70% 50%,
url(ht... |
6,832 | I'm looking for a storage solution for small files that would be moved into a small sensor running arduino-like processor.
Ideally the single memory unit would be cheap (in 1-10 cents range), but the memory can be very limited (several megabytes).
The closest I've got so far is small SD Memory card, but the smallest ... | 2015/01/03 | [
"https://arduino.stackexchange.com/questions/6832",
"https://arduino.stackexchange.com",
"https://arduino.stackexchange.com/users/6519/"
] | I assume that, if this is a cost sensitive item, you need a reliable supply of multiples (so looking for small SD cards on e-bay isn't a viable solution).
Does it need to be non-volatile storage? If it does't you may be able to find small 8-bit wide RAM chips at a pretty good price. If it needs to be non-volatile, you... | On ebay you can buy 2nd hand Nokia SD cards from old mobile phones which are 128MB or so and very cheap. |
618,919 | I am dynamically adding column to table in db through code using alter table query.
But i am facing problem wen i am trying to insert values in that column. it throws an exception column does not exists.
And wen i clean and rebuild my project through netbeans it works fine.
I am using java and mysql as databse .
Is t... | 2009/03/06 | [
"https://Stackoverflow.com/questions/618919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25778/"
] | You might also rethink your design. In general it is a poor practice for the user interface to add columns to tables. Perhaps you need a more normalized design. Database structural changes should not come from the user. You could create a real mess if different users were making changes at the same time. Additionally u... | I dont know about Java but in .net after performing a change on a table you need to call dataAdapter.AcceptChanges(); which essentially commits the change to the table.
In your codedo you need to make a similar call after you have added the column to the table,for the insert to be able to work. |
618,919 | I am dynamically adding column to table in db through code using alter table query.
But i am facing problem wen i am trying to insert values in that column. it throws an exception column does not exists.
And wen i clean and rebuild my project through netbeans it works fine.
I am using java and mysql as databse .
Is t... | 2009/03/06 | [
"https://Stackoverflow.com/questions/618919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25778/"
] | You might also rethink your design. In general it is a poor practice for the user interface to add columns to tables. Perhaps you need a more normalized design. Database structural changes should not come from the user. You could create a real mess if different users were making changes at the same time. Additionally u... | This may be because Data *Description* Language (DDL) is often executed outside of transactions. Perhaps a commit/rollback, or even reconnect would sort the problem. Just a guess. |
1,789 | I was trying to run test cases for CG and I need to generate:
* symmetric positive definite matrices
* of size > 10,000
* **FULL DENSE**
* Using only matrix indices and if necessary 1 vector
(Like $A(i,j) = \dfrac{x(i) - x(j)}{(i+j)}$)
* With condition number less than 1000.
I have tried:
1. Generating random matric... | 2012/03/28 | [
"https://scicomp.stackexchange.com/questions/1789",
"https://scicomp.stackexchange.com",
"https://scicomp.stackexchange.com/users/529/"
] | To get a dense positive definite matrix with condition number $c$ cheaply, pick a diagonal matrix $D$ whose diagonal consists of numbers from $[1,c]$ (which will be the eigenvalues), with $1$ and $c$ chosen at least once, and a vector $u$. Then apply a similarity transformation, via Householder transformations, to form... | I'm not sure how you would do it with just one vector, but with two random vectors $x$ and $\theta$ of size $N$, you can produce a positive semi-definite matrix via
$$
U=\prod\_i R\_i(\theta\_i)\\
A=U\mbox{diag}(\mbox{abs}(x)) U^\ast
$$
where $R\_i(\cdot)$ is a rotation in the plane of the axes $i$ and $i+1 \mbox{ m... |
1,789 | I was trying to run test cases for CG and I need to generate:
* symmetric positive definite matrices
* of size > 10,000
* **FULL DENSE**
* Using only matrix indices and if necessary 1 vector
(Like $A(i,j) = \dfrac{x(i) - x(j)}{(i+j)}$)
* With condition number less than 1000.
I have tried:
1. Generating random matric... | 2012/03/28 | [
"https://scicomp.stackexchange.com/questions/1789",
"https://scicomp.stackexchange.com",
"https://scicomp.stackexchange.com/users/529/"
] | To get a dense positive definite matrix with condition number $c$ cheaply, pick a diagonal matrix $D$ whose diagonal consists of numbers from $[1,c]$ (which will be the eigenvalues), with $1$ and $c$ chosen at least once, and a vector $u$. Then apply a similarity transformation, via Householder transformations, to form... | Try adding a large number $\alpha$ (on the order of the norm of the matrix) to the diagonal entries of your matrix. This is equivalent to adding $\alpha$ to each of your eigenvalues and should improve the condition number by reducing the gap between the largest and smallest eigenvalues. |
1,789 | I was trying to run test cases for CG and I need to generate:
* symmetric positive definite matrices
* of size > 10,000
* **FULL DENSE**
* Using only matrix indices and if necessary 1 vector
(Like $A(i,j) = \dfrac{x(i) - x(j)}{(i+j)}$)
* With condition number less than 1000.
I have tried:
1. Generating random matric... | 2012/03/28 | [
"https://scicomp.stackexchange.com/questions/1789",
"https://scicomp.stackexchange.com",
"https://scicomp.stackexchange.com/users/529/"
] | To get a dense positive definite matrix with condition number $c$ cheaply, pick a diagonal matrix $D$ whose diagonal consists of numbers from $[1,c]$ (which will be the eigenvalues), with $1$ and $c$ chosen at least once, and a vector $u$. Then apply a similarity transformation, via Householder transformations, to form... | An entirely different way to do it would be like this: consider a random vector $x$, then $A=xx^T$ is a rank-one matrix with $N-1$ eigenvalues equal to zero and one strictly positive eigenvalue equal to $\|x\|^2$ with eigenvector $x$. It's also symmetric.
To construct a dense SPD matrix, add together many such rank-1 ... |
33,680,174 | Latly I came upon a question where someone asked me, why I turn the output of `json_decode` into an assoc array.
For me it's easier to use assoc arrays than stdClasses and there are already many array\_\* functions which support data handling after I decode the json string.
After a short performance test it turns out... | 2015/11/12 | [
"https://Stackoverflow.com/questions/33680174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1043150/"
] | This might get closed as opinion based, but for me, I would typically decode to whatever data structure makes the most sense for the use case.
For example, say the JSON described a single item like a book and looked something like this:
```
{
"title": "Cool Book",
"author": "Amazing Author",
"publisher": ... | I think the reason is, that JSON is "JavaScript **Object** Notation" and therefore people *expect* an object. If you look at [json.org](http://json.org/) the an **object** is defined as an unordered set of name/value pairs and an array is for ordered collections of values, like people are used to it in javascript. This... |
123,336 | How can I see a video loaded in the background at any angle?
not only in the view of the camera or left right up down | 2018/11/23 | [
"https://blender.stackexchange.com/questions/123336",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/57088/"
] | Without using additional geometry or compositing, you can use the image as background for the world. Set the Texture coordinates to Window.
[](https://i.stack.imgur.com/blzHI.png) | The question isn't very clear, but if you are looking to view your object at different angles, press down on your scroll wheel and you should be able to see at all different angles. |
15,608,684 | Is there a better way to see if an object has one of several classes than
```
if ([item isKindOfClass:[NSArray class]] || [item isKindOfClass:[NSNumber class]] ||
[item isKindOfClass:[NSPredicate class]] || [item isKindOfClass:[NSMutableArray class]]
|| [item isKindOfClass:[NSString class]]) {
return YES;
};
```... | 2013/03/25 | [
"https://Stackoverflow.com/questions/15608684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/697190/"
] | Perhaps this?
```
NSArray *classes = @[ [NSArray class], [NSNumber class], [NSPredicate class], (etc.)];
for (Class cls in classes) {
if ([item isKindOfClass:cls]) {
return YES;
}
}
```
It's not significantly more succinct, but I think it's easier to read and maintain.
**Edit** : Naturally, you woul... | Here's what I ended up doing:
```
NSArray *classes = @[ [NSArray class], [NSDictionary class], [NSSet class] ];
NSUInteger *matches = [classes indexesOfObjectsPassingTest:^BOOL(id class, NSUInteger idx, BOOL *stop) {
return [item isKindOfClass:class]);
}].count;
``` |
70,701,193 | Have a look at the example:
```
unsigned char c = 64; /* 0100 0000 */
c = (c << 2 && 512); /* 512: 10 0000 0000 */
```
If I shift c two times to the left, I should get from 0100 0000 (64) to this 0001 0000 0000 (256). So my 8-bit char `c` has only zeroes. At the end, I am wondering why the expression `(c << 2 && 51... | 2022/01/13 | [
"https://Stackoverflow.com/questions/70701193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6366153/"
] | From the C Standard (6.5.7 Bitwise shift operators)
>
> 3 The integer promotions are performed on each of the operands. The
> type of the result is that of the promoted left operand.
>
>
>
So in this expression
```
c << 2
```
the object c is promoted to the type `int` and the result also has the type `int`.
A... | `&` is a bitwise AND. Each bit in its results is the AND of the two corresponding bits in its input. The bitwise AND of 01 0000 00002 and 10 0000 00002 would be 00 0000 00002.
`&&` is a logical AND. Its result is 1 if both of its operands are non-zero and 0 otherwise. The logical AND of 01 0000 00002 and 10 0000 00002... |
70,701,193 | Have a look at the example:
```
unsigned char c = 64; /* 0100 0000 */
c = (c << 2 && 512); /* 512: 10 0000 0000 */
```
If I shift c two times to the left, I should get from 0100 0000 (64) to this 0001 0000 0000 (256). So my 8-bit char `c` has only zeroes. At the end, I am wondering why the expression `(c << 2 && 51... | 2022/01/13 | [
"https://Stackoverflow.com/questions/70701193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6366153/"
] | From the C Standard (6.5.7 Bitwise shift operators)
>
> 3 The integer promotions are performed on each of the operands. The
> type of the result is that of the promoted left operand.
>
>
>
So in this expression
```
c << 2
```
the object c is promoted to the type `int` and the result also has the type `int`.
A... | The answer by Vlad is the explanation.
Here is a visualisation of how hard it is to get something into a special data type, in the presence of promotion:
```
#include <stdio.h>
int main()
{
printf("Hello, World!\n");
unsigned char c = 64;
if (c << 2 ) {printf("Yes 1.\n");}
if (c << '\2') {print... |
55,320,328 | When I'm copy/paste this code, trying use in another place of same Html file both javascript code stops working? Why?
**How I call js code to another form in my code below??**
```html
<form name="randform">
<input class="reload-but" type="button" value="↻ " onClick="randomString();">
<div class="u... | 2019/03/24 | [
"https://Stackoverflow.com/questions/55320328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The reason that it does not work when you put this code in multiple places in the same HTML file is because when you have one form with name `randform`, it returns that form. But since you have multiple form with the same name `randform`. The `document.randform` now returns an array of form.
---
This is quick fix (mi... | I'm having no problems with this. Remove the div closing that is unnecessary in this context and separate your html and javascript as this is generally good practice
```js
function randomString() {
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
var string_length = 8;
var randomst... |
55,320,328 | When I'm copy/paste this code, trying use in another place of same Html file both javascript code stops working? Why?
**How I call js code to another form in my code below??**
```html
<form name="randform">
<input class="reload-but" type="button" value="↻ " onClick="randomString();">
<div class="u... | 2019/03/24 | [
"https://Stackoverflow.com/questions/55320328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I solved myself, Just changed js `function` name and `form` name in Html to another not to same as before I used!
```
<form name="randformm">
<input class="reload-but" type="button" value="↻ " onClick="randomStr();">
<div class="unnec">
<input class="random-but" type="button" nam... | I'm having no problems with this. Remove the div closing that is unnecessary in this context and separate your html and javascript as this is generally good practice
```js
function randomString() {
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
var string_length = 8;
var randomst... |
70,293,037 | I am preparing a project documentation using `Sphinx` where to fetch `Doxygen XML output` I have used [breathe](https://breathe.readthedocs.io/en/latest/directives.html#doxygenclass). I am using the breathe directive in `.rst` files.
`sample.cpp`
```cpp
namespace X{
class A{
public:
int x;
};
}
```
in my ... | 2021/12/09 | [
"https://Stackoverflow.com/questions/70293037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10634362/"
] | Got the answer [here](https://github.com/executablebooks/MyST-Parser/issues/323#issuecomment-788897173).
Now markdown file is as like as follows
```
```{eval-rst}
.. doxygenclass:: X::A
``` | Could you try this?
```
```{doxygenclass} X::A
:members:
:protected-members:
:private-members:
```
```
And if it fails, report the error? |
1,792,610 | Im creating a nav that uses jquery to replace the image on rollover. Here is the code I am using:
<http://peps.ca/blog/easy-image-rollover-script-with-jquery/>
basically, you add a suffix (\_o) to the filename and when you rollover the src, jquery replaces it with the (\_o).png. I want to add fade so when there is a ... | 2009/11/24 | [
"https://Stackoverflow.com/questions/1792610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/121630/"
] | rather than replace, you'll have to overlay a new image and fade it in, waiting till the transition has completed.
something like...
```
$('.my_img').parent().append($('.my_img').clone().attr('src','my_img_o.jpg').fadeIn('slow'))
```
assuming the element is absolutely positioned | You could layer a second (hidden) element over the top of your default image, then see about fading that one in and out with a rollover. |
1,792,610 | Im creating a nav that uses jquery to replace the image on rollover. Here is the code I am using:
<http://peps.ca/blog/easy-image-rollover-script-with-jquery/>
basically, you add a suffix (\_o) to the filename and when you rollover the src, jquery replaces it with the (\_o).png. I want to add fade so when there is a ... | 2009/11/24 | [
"https://Stackoverflow.com/questions/1792610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/121630/"
] | ```
$('#the_image).hover(function() {
$(this).fadeOut(function() {
$(this).attr('src', $(this).attr('src').replace(".png", "_o.png")).fadeIn();
});
}, function {
$(this).fadeOut(function() {
$(this).attr('src', $(this).attr('src').replace("_o.png", ".png")).fadeIn();
});
});
``` | You could layer a second (hidden) element over the top of your default image, then see about fading that one in and out with a rollover. |
1,792,610 | Im creating a nav that uses jquery to replace the image on rollover. Here is the code I am using:
<http://peps.ca/blog/easy-image-rollover-script-with-jquery/>
basically, you add a suffix (\_o) to the filename and when you rollover the src, jquery replaces it with the (\_o).png. I want to add fade so when there is a ... | 2009/11/24 | [
"https://Stackoverflow.com/questions/1792610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/121630/"
] | ```
$('#the_image).hover(function() {
$(this).fadeOut(function() {
$(this).attr('src', $(this).attr('src').replace(".png", "_o.png")).fadeIn();
});
}, function {
$(this).fadeOut(function() {
$(this).attr('src', $(this).attr('src').replace("_o.png", ".png")).fadeIn();
});
});
``` | rather than replace, you'll have to overlay a new image and fade it in, waiting till the transition has completed.
something like...
```
$('.my_img').parent().append($('.my_img').clone().attr('src','my_img_o.jpg').fadeIn('slow'))
```
assuming the element is absolutely positioned |
41,262,029 | Basically I have data of multiple individuals, lets call them A, B and C, for which I have transaction information for each, which is updated regularly. For example, A has had 15 transactions since inceptions, B has had 10 and C has had 6.
I have created a sheet that using a drop down list to select A, B or C will us... | 2016/12/21 | [
"https://Stackoverflow.com/questions/41262029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7325434/"
] | Use `||` instead of `&&`. Something like: Is this not working ?
```
if(empty($_POST['name']) || empty($_POST['loc']) ||
empty($_POST['mob']) || empty($_POST['email'])) {
echo "pls enter all fleid ";
exit;
}
else {
//your remaining code to insert
}
```
Change the html too -
Use `mob`, `loc` instead of `mob... | If I understand your question, you want to apply a validation to not let null values in the database. You can use the php [`empty()`](http://php.net/manual/pt_BR/function.empty.php) function.
```
<?php
if(empty($_POST['name'])) {
die("Please enter with the name!");
}
?>
``` |
41,262,029 | Basically I have data of multiple individuals, lets call them A, B and C, for which I have transaction information for each, which is updated regularly. For example, A has had 15 transactions since inceptions, B has had 10 and C has had 6.
I have created a sheet that using a drop down list to select A, B or C will us... | 2016/12/21 | [
"https://Stackoverflow.com/questions/41262029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7325434/"
] | Use `||` instead of `&&`. Something like: Is this not working ?
```
if(empty($_POST['name']) || empty($_POST['loc']) ||
empty($_POST['mob']) || empty($_POST['email'])) {
echo "pls enter all fleid ";
exit;
}
else {
//your remaining code to insert
}
```
Change the html too -
Use `mob`, `loc` instead of `mob... | You can use like this
```
function check_post( $arr ) {
foreach( $arr as $value ) {
if( $value =='' ) return false;
}
return true;
}
$check = check_post( $_POST );
if($check == false){
die("Please enter all values");
}
```
Thanks |
41,262,029 | Basically I have data of multiple individuals, lets call them A, B and C, for which I have transaction information for each, which is updated regularly. For example, A has had 15 transactions since inceptions, B has had 10 and C has had 6.
I have created a sheet that using a drop down list to select A, B or C will us... | 2016/12/21 | [
"https://Stackoverflow.com/questions/41262029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7325434/"
] | Use `||` instead of `&&`. Something like: Is this not working ?
```
if(empty($_POST['name']) || empty($_POST['loc']) ||
empty($_POST['mob']) || empty($_POST['email'])) {
echo "pls enter all fleid ";
exit;
}
else {
//your remaining code to insert
}
```
Change the html too -
Use `mob`, `loc` instead of `mob... | Your Php and Javascript code is correct. it's working for me and store all value in DB.
I think problems in your DB structure. Please check it once. Please see below image for DB structure. it's working for me.
[](https://i.stack.imgur.com/WJcG5.png) |
41,262,029 | Basically I have data of multiple individuals, lets call them A, B and C, for which I have transaction information for each, which is updated regularly. For example, A has had 15 transactions since inceptions, B has had 10 and C has had 6.
I have created a sheet that using a drop down list to select A, B or C will us... | 2016/12/21 | [
"https://Stackoverflow.com/questions/41262029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7325434/"
] | Use `||` instead of `&&`. Something like: Is this not working ?
```
if(empty($_POST['name']) || empty($_POST['loc']) ||
empty($_POST['mob']) || empty($_POST['email'])) {
echo "pls enter all fleid ";
exit;
}
else {
//your remaining code to insert
}
```
Change the html too -
Use `mob`, `loc` instead of `mob... | correct answer found
PHP Code:
```
<?php
//var_dump($_REQUEST);die;
$con = mysql_connect("localhost","root","");
if (!$con){
die("Can not connect: " . mysql_error());
}
mysql_select_db("sll",$con);
echo "<table border='1'>
<tr><th>name</th>
<th>location</th>
<th>mobile</th>
<... |
41,262,029 | Basically I have data of multiple individuals, lets call them A, B and C, for which I have transaction information for each, which is updated regularly. For example, A has had 15 transactions since inceptions, B has had 10 and C has had 6.
I have created a sheet that using a drop down list to select A, B or C will us... | 2016/12/21 | [
"https://Stackoverflow.com/questions/41262029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7325434/"
] | Seems your field containing the spaces in field and your database column is checked with null value by default.
So here is solution if this is the case.
```
if($_POST['name'] == ' ' || $_POST['loc'] == ' ' || $_POST['mob'] == ' ' || $_POST['email'] == ' ') {
print 'Please input value for the blank field';
... | If I understand your question, you want to apply a validation to not let null values in the database. You can use the php [`empty()`](http://php.net/manual/pt_BR/function.empty.php) function.
```
<?php
if(empty($_POST['name'])) {
die("Please enter with the name!");
}
?>
``` |
41,262,029 | Basically I have data of multiple individuals, lets call them A, B and C, for which I have transaction information for each, which is updated regularly. For example, A has had 15 transactions since inceptions, B has had 10 and C has had 6.
I have created a sheet that using a drop down list to select A, B or C will us... | 2016/12/21 | [
"https://Stackoverflow.com/questions/41262029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7325434/"
] | Seems your field containing the spaces in field and your database column is checked with null value by default.
So here is solution if this is the case.
```
if($_POST['name'] == ' ' || $_POST['loc'] == ' ' || $_POST['mob'] == ' ' || $_POST['email'] == ' ') {
print 'Please input value for the blank field';
... | You can use like this
```
function check_post( $arr ) {
foreach( $arr as $value ) {
if( $value =='' ) return false;
}
return true;
}
$check = check_post( $_POST );
if($check == false){
die("Please enter all values");
}
```
Thanks |
41,262,029 | Basically I have data of multiple individuals, lets call them A, B and C, for which I have transaction information for each, which is updated regularly. For example, A has had 15 transactions since inceptions, B has had 10 and C has had 6.
I have created a sheet that using a drop down list to select A, B or C will us... | 2016/12/21 | [
"https://Stackoverflow.com/questions/41262029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7325434/"
] | Seems your field containing the spaces in field and your database column is checked with null value by default.
So here is solution if this is the case.
```
if($_POST['name'] == ' ' || $_POST['loc'] == ' ' || $_POST['mob'] == ' ' || $_POST['email'] == ' ') {
print 'Please input value for the blank field';
... | Your Php and Javascript code is correct. it's working for me and store all value in DB.
I think problems in your DB structure. Please check it once. Please see below image for DB structure. it's working for me.
[](https://i.stack.imgur.com/WJcG5.png) |
41,262,029 | Basically I have data of multiple individuals, lets call them A, B and C, for which I have transaction information for each, which is updated regularly. For example, A has had 15 transactions since inceptions, B has had 10 and C has had 6.
I have created a sheet that using a drop down list to select A, B or C will us... | 2016/12/21 | [
"https://Stackoverflow.com/questions/41262029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7325434/"
] | Seems your field containing the spaces in field and your database column is checked with null value by default.
So here is solution if this is the case.
```
if($_POST['name'] == ' ' || $_POST['loc'] == ' ' || $_POST['mob'] == ' ' || $_POST['email'] == ' ') {
print 'Please input value for the blank field';
... | correct answer found
PHP Code:
```
<?php
//var_dump($_REQUEST);die;
$con = mysql_connect("localhost","root","");
if (!$con){
die("Can not connect: " . mysql_error());
}
mysql_select_db("sll",$con);
echo "<table border='1'>
<tr><th>name</th>
<th>location</th>
<th>mobile</th>
<... |
71,883,376 | In my app, I have a button that enables users to calculate some data when it's clicked. To do the calculation, a service from the back-end is called. After the service finishes the calculation, I display a message that says 'Done'. But the message appears way before the service finishes calculation. Here's my code, how... | 2022/04/15 | [
"https://Stackoverflow.com/questions/71883376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16963547/"
] | ```
sendCalculateMaterialPlanDetail() {
this.confirmDialogRef = this._dialog.open(FuseConfirmDialogComponent, {
disableClose: false,
});
this.confirmDialogRef.componentInstance.confirmMessage =
"Will start to calculate.";
this.confirmDialogRef.afterClosed().subscribe((result) => {
i... | You can use the key words await and async
```
async sendCalculateMaterialPlanDetail() {
this.confirmDialogRef = this._dialog.open(FuseConfirmDialogComponent, {
disableClose: false,
});
this.confirmDialogRef.componentInstance.confirmMessage =
"Will start to calculate.";
this.confirmDialog... |
34,244,606 | I'm trying to install OpenCV for use with [Pastec](http://www.pastec.io) on an Amazon Linux instance. This is my first time using an Amazon service, and I don't have much experience using linux...
How would I install OpenCV and it's dependencies on Amazon Linux?
I have tried adding the EPEL repository using this comm... | 2015/12/12 | [
"https://Stackoverflow.com/questions/34244606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1008736/"
] | It seems that default `yum` repo for **Amazon AMI** doesn't contain **OpenCV** packages.
You can compile it from sources by yourself with the following simple steps:
* install necessary packages:
`sudo yum install git cmake gcc-c++`
* clone **OpenCV** from repository:
`git clone https://github.com/Itseez/opencv.gi... | cmake should be higher than 3.5 in latest linux versions for the purpose of installing opencv and other packages. To install in Fedora or similar flavour use
`sudo yum install cmake3` |
26,226,610 | I have 610 products with weights measured in Grams, in a database of over 2000 products.
I can find those products with this search
```
SELECT * FROM `jos_vm_product` WHERE `product_weight_uom` LIKE 'grams'
```
I would like to change the weight to Kg, which means dividing the product\_weight number by 1000.
I thi... | 2014/10/06 | [
"https://Stackoverflow.com/questions/26226610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3397762/"
] | Try This,
```sql
UPDATE jos_vm_product SET product_weight = product_weight/1000,
product_weight_uom='Kg' WHERE product_weight_uom LIKE 'grams';
``` | Based on your use of SELECT only and asking to join those two, I understand you're looking for retrieving the data in a different unit than stored, not actually changing the table.
So, if you meant to change the weight to Kg but only for display purposes, and you did not mean to actually alter the table contents, then... |
64,701,451 | Is there a Python Client-Side API for Discord?
I don't need much, just to listen to events like getting a call or a message.
Is it possible? | 2020/11/05 | [
"https://Stackoverflow.com/questions/64701451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14585001/"
] | The `char record[121]` variable is actually an *array* of characters, otherwise known as a *string*. It is used here so that, if an erroneous input is given (instead of a valid *integer* input), then the input stream is still cleared by the `fgets()` call, which takes in *all* characters up to (and including) the newli... | The program is reading lines from a file with fgets, which uses a string as storage buffer for the line. After that it processes the line to find a string that can be read as an int (%d), checks if that operation went OK, and returns the integer if so. |
64,701,451 | Is there a Python Client-Side API for Discord?
I don't need much, just to listen to events like getting a call or a message.
Is it possible? | 2020/11/05 | [
"https://Stackoverflow.com/questions/64701451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14585001/"
] | The `char record[121]` variable is actually an *array* of characters, otherwise known as a *string*. It is used here so that, if an erroneous input is given (instead of a valid *integer* input), then the input stream is still cleared by the `fgets()` call, which takes in *all* characters up to (and including) the newli... | The function is reading input as text, storing it to the character *array* `record`. It then converts that string into an equivalent integer value using `sscanf`.
This is a bit safer than just using `scanf` directly - it ensures that if the user types non-numeric input, it's still consumed from the input stream so tha... |
68,662,240 | I am reading about Kotlin coroutine in Google 's documentation. I'm adviced to use withContext(Dispacher.IO) to a different thread to main-safety. But I have a problem , fetchData() done before response from server so fetchData() return null result. Any help that I appreciate.
<https://developer.android.com/kotlin/cor... | 2021/08/05 | [
"https://Stackoverflow.com/questions/68662240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15989925/"
] | `withContext` is not helpful for converting an asynchronous function with callback into suspending code that can be used in a coroutine. It is more applicable to converting *synchronous* blocking code. Your non-working strategy of creating an empty variable and trying to fill it in the callback to synchronously return ... | You should use `suspendCancellableCoroutine` to convert asynchronous API into a coroutine flow, like this
```kotlin
suspend fun fetchData(): ListGameResponse = withTimeout(Duration.seconds(60)) {
suspendCancellableCoroutine<ListGameResponse> { cont ->
api.getAllGame(page = 1).enqueue(object : Callback<ListGameRe... |
55,196,194 | I have a 2-D tensor **A** with the shape of (?, *L*) which refers to the features obtained through the neural network (where '?' is the batch size), and a 3-D tensor **B** with the shape of (*N*, *K*, *L*). Obviously, there are *N* arrays with the shape of (*K*, *L*) in **B**, which are called **C** here.
Now, how can... | 2019/03/16 | [
"https://Stackoverflow.com/questions/55196194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9491512/"
] | Dividing by 2 is a simple bitwise right-shift. After @elgonzo's (now deleted) mention of the properties of C#'s rightshift, I decided to have a look how it works, and it *seems* to do exactly what you want:
```
var result = number >> 1;
```
This gives the following results:
11 -> 5
10 -> 5
2 -> 1
1 -> 0
... | If you want to divide `a` by `b`:
**The approach which won't fail because of overflow:**
```
int res = a / b;
return (a < 0 && a != b * res) ? res - 1 : res;
```
**The following approaches may possibly fail because of negative overflow.**
```
int mod = a % b;
if (mod < 0) {
mod += b;
}
return (a - mod) / b;
```... |
46,426,100 | I am trying to write a template class with multiple type parameters `T1` and `T2`. The class has a private member of type `std::promise<T2>`.
```
template <class T, class T2>
class Test
{
public:
void setValue(T2 value)
{
promise.set_value(value);
}
void setValue()
{
promise.set_v... | 2017/09/26 | [
"https://Stackoverflow.com/questions/46426100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1068959/"
] | helper template class specialisation:
```
#include <future>
template<typename T>
class TestHelper
{
public:
void setValue(T const& v)
{ promise.set_value(v); }
private:
std::promise<T> promise;
};
template<>
class TestHelper<void>
{
public:
void setValue()
{ promise.set_value(); }
private:
... | You can solve this problem with a conditional dependency on a base class:
```
#include <future>
#include <type_traits>
#include <iostream>
template<class T2>
struct Base {
protected:
std::promise<T2> promise;
};
template<class T2>
struct BaseWithVariable : public Base<T2> {
void setValue(T2 value)
{
... |
11,028,501 | I have a string which is something like `"c:\x\y\z"`
I want it in the form `"c://x//y//z"`
I tried using `stdString.replace("\","//");` but it doesn't work.
Any suggestions? | 2012/06/14 | [
"https://Stackoverflow.com/questions/11028501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1115889/"
] | If your string is `"c:\x\y\z"`, there are no `\` in your string. `\` denotes an escape character. Change your string to `"c:\\x\\y\\z"`.
Also, note how `replace` works - <http://www.cplusplus.com/reference/string/string/replace/>
I don't think you can replace one character `'\\'` with two `"//"` directly. (I might be... | ```
stdString.replace("\\","\/\/"); ?
``` |
11,028,501 | I have a string which is something like `"c:\x\y\z"`
I want it in the form `"c://x//y//z"`
I tried using `stdString.replace("\","//");` but it doesn't work.
Any suggestions? | 2012/06/14 | [
"https://Stackoverflow.com/questions/11028501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1115889/"
] | If your string is `"c:\x\y\z"`, there are no `\` in your string. `\` denotes an escape character. Change your string to `"c:\\x\\y\\z"`.
Also, note how `replace` works - <http://www.cplusplus.com/reference/string/string/replace/>
I don't think you can replace one character `'\\'` with two `"//"` directly. (I might be... | if you hard coded the filepath in your source code then you may change value to `"c:\\x\\y\\z"` |
46,984,424 | I have been spending forever on this and can not seem to work it out. I am self taught and not very familiar with this so forgive me if it is a remedial question. I am sending data from Android to .Net server. Data is getting corrupt on encoding, I know this I am just not sure how to fix. I am using the .Net Async serv... | 2017/10/27 | [
"https://Stackoverflow.com/questions/46984424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6811296/"
] | You don't have to encode it at all. Just write it directly as bytes using an `OutputStream`. Simpler, quicker, better. | I found the answer. It was so weird but makes sense now.
```
byte[] chunk = new byte[30000];
int chunkLen = 0;
while ((chunkLen = is.read(chunk)) != -1) {
String str = new String(Base64.encodeToString(chunk, Base64.NO_WRAP));
out.write(str);
... |
30,098,805 | I am working on a PHP page where I need a date picker. So I added the following files:
```
<script src="../J/jquery.js"></script>
<script src="../J/jquery.min.js"></script>
<script src="../J/jquery-1.5.2.min.js"></script>
<script src="../J/jquery.ui.core.js"></script>
<script src="../J/jquery.ui.datepicker.js"></scrip... | 2015/05/07 | [
"https://Stackoverflow.com/questions/30098805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2881402/"
] | The error message is quite clear. The number of input parameters which you are passing from the front end is greater than the expected number of parameters in your stored procedure.
Your stored procedure expects only these input parameters:
```
@Score INT=0,
@CorrectAnswer INT=0,
@WrongAnswer INT=0,
@TimeSpent INT=0,... | Update your stored procedure.You missed on the SessionId here
```
ALTER PROCEDURE [dbo].[spUpdateQuizScore]
-- Add the parameters for the stored procedure here
@Score INT=0,
@CorrectAnswer INT=0,
@WrongAnswer INT=0,
@TimeSpent INT=0,
@QuizId INT=0,
@UserId INT=0,
@UserName NVARCHAR(200)="No User",
@GroupId INT=0,
@G... |
29,315,493 | My table name is `tblEvent` and its columns are `EventID`, `Name`, `Description`, `EventTypeID`, `TotalBudget`, `CustomerID`, `EventStatus`, `EventDate`
I want to select the latest 3 records.
I have tried this:
```
public DataTable HomeEvents()
{
string query = "select TOP 3 tblEvent.*, tblCustomer.Name as 'Cus... | 2015/03/28 | [
"https://Stackoverflow.com/questions/29315493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4391039/"
] | The `order by` clause should be after the `where` clause:
```
select top 3
tblEvent.*,
tblCustomer.Name as 'CustomerName',
tblCustomer.Photo AS 'CustomerPhoto'
from
tblEvent
where
tblEvent.CustomerID = tblCustomer.CustomerID
order by
EventID desc,
tblCustomer
```
Note: If `EventID` is auto-incremented ... | Change your SQL statement to read
```
... ORDER DESC BY ...
```
This will sort in reverse order, the first three are now the last three. |
29,315,493 | My table name is `tblEvent` and its columns are `EventID`, `Name`, `Description`, `EventTypeID`, `TotalBudget`, `CustomerID`, `EventStatus`, `EventDate`
I want to select the latest 3 records.
I have tried this:
```
public DataTable HomeEvents()
{
string query = "select TOP 3 tblEvent.*, tblCustomer.Name as 'Cus... | 2015/03/28 | [
"https://Stackoverflow.com/questions/29315493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4391039/"
] | The `order by` clause should be after the `where` clause:
```
select top 3
tblEvent.*,
tblCustomer.Name as 'CustomerName',
tblCustomer.Photo AS 'CustomerPhoto'
from
tblEvent
where
tblEvent.CustomerID = tblCustomer.CustomerID
order by
EventID desc,
tblCustomer
```
Note: If `EventID` is auto-incremented ... | As Guffa said, Order By comes after where, and you need to
"Order By EventDate DESC" |
29,315,493 | My table name is `tblEvent` and its columns are `EventID`, `Name`, `Description`, `EventTypeID`, `TotalBudget`, `CustomerID`, `EventStatus`, `EventDate`
I want to select the latest 3 records.
I have tried this:
```
public DataTable HomeEvents()
{
string query = "select TOP 3 tblEvent.*, tblCustomer.Name as 'Cus... | 2015/03/28 | [
"https://Stackoverflow.com/questions/29315493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4391039/"
] | As Guffa said, Order By comes after where, and you need to
"Order By EventDate DESC" | Change your SQL statement to read
```
... ORDER DESC BY ...
```
This will sort in reverse order, the first three are now the last three. |
57,929,975 | I am using Selenium and I need to upload an image to instagram. But at the time the windows file selector opens I could not get it to search for the image and upload it automatically
[](https://i.stack.imgur.com/HNZuv.png)
Up to this point my applica... | 2019/09/13 | [
"https://Stackoverflow.com/questions/57929975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6943090/"
] | I've been playing around with a solution and posted a Gist to what I have working in terms of programmatically setting content offsets <https://gist.github.com/jfuellert/67e91df63394d7c9b713419ed8e2beb7> | With the regular SwiftUI ScrollView, as far as I can tell, you can get the position with GeometryReader with proxy.frame(in: .global).minY (see your modified example below), but you cannot set the "contentOffset".
Actually if you look at the Debug View Hierarchy you will notice that our content view is embedded in an... |
57,929,975 | I am using Selenium and I need to upload an image to instagram. But at the time the windows file selector opens I could not get it to search for the image and upload it automatically
[](https://i.stack.imgur.com/HNZuv.png)
Up to this point my applica... | 2019/09/13 | [
"https://Stackoverflow.com/questions/57929975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6943090/"
] | I've been playing around with a solution and posted a Gist to what I have working in terms of programmatically setting content offsets <https://gist.github.com/jfuellert/67e91df63394d7c9b713419ed8e2beb7> | I messed around with several solutions involving a `ScrollView` with one or more `GeometryReaders`, but ultimately I found everything easier if I just ignored `ScrollView` and rolled my own using `View.offset(x:y:)` and a `DragGesture`:
This allows the `LinearGradient` to be panned by either dragging it like a `Scroll... |
1 | What would it mean to say that mathematics was invented and how would this be different from saying mathematics was discovered?
Is this even a serious philosophical question or just a meaningless/tautological linguistic ambiguity? | 2011/06/07 | [
"https://philosophy.stackexchange.com/questions/1",
"https://philosophy.stackexchange.com",
"https://philosophy.stackexchange.com/users/7/"
] | There are things that are discovered, and things that are invented. The boundary is put at different places by different people. I put myself on the list and I believe that my position is objectively justifiable, and others are not.
### Definitely discovered: finite stuff
By probabilistic considerations, I am sure th... | I think the words "invention" and "discovery" are a bit poor to describe the birth of mathematic if there is one. It makes no sense to me to say mathematic has appeared as when Christophe Colomb discovered America or was invented as the boomerang.
The word mathematics might have been invented, the language in which t... |
1 | What would it mean to say that mathematics was invented and how would this be different from saying mathematics was discovered?
Is this even a serious philosophical question or just a meaningless/tautological linguistic ambiguity? | 2011/06/07 | [
"https://philosophy.stackexchange.com/questions/1",
"https://philosophy.stackexchange.com",
"https://philosophy.stackexchange.com/users/7/"
] | I'm going to posit, admittedly without any research whatsoever about those who've preceded these thoughts, that **an "invention" is a *kind* of "discovery,"** and that whether a thing qualifies as an invention is—yup, you saw it coming—*subjective*.
For example, we might say that the wheel was "invented" on grounds of... | My view on it is that Mathematics is a system invented by humans to represent things we otherwise can or cannot perceive. For example, we can perceive an object through vision and know it's a triangle, however, our vision alone does not tell us the length of the legs of the triangle. We need math to represent that for ... |
1 | What would it mean to say that mathematics was invented and how would this be different from saying mathematics was discovered?
Is this even a serious philosophical question or just a meaningless/tautological linguistic ambiguity? | 2011/06/07 | [
"https://philosophy.stackexchange.com/questions/1",
"https://philosophy.stackexchange.com",
"https://philosophy.stackexchange.com/users/7/"
] | My elementary math lecturer likes to say
>
> God created the number 0, and the [successor](http://en.wikipedia.org/wiki/Successor_function). The rest was invented by mankind.
>
>
>
I think there is some truth in this quote, even if you don't believe in God. So to answer your question: I'd say that the very basis ... | From a Neo-Intuitionist perspective, to the degree mathematics is invented, it is still discovered.
Did we invent, or discover the consonant 't'? We discovered that our mouths reasonably make that sound, across a wide swath of our species. But we decided that this was an important thing, and in so doing, we invented t... |
1 | What would it mean to say that mathematics was invented and how would this be different from saying mathematics was discovered?
Is this even a serious philosophical question or just a meaningless/tautological linguistic ambiguity? | 2011/06/07 | [
"https://philosophy.stackexchange.com/questions/1",
"https://philosophy.stackexchange.com",
"https://philosophy.stackexchange.com/users/7/"
] | My personal point of view is that mathematicians *invented* the axioms and the rules of operation, the rest are *discovered*. Mathematicians *invented* the notations for writing down the concepts which are *discovered* within the universe of an axiom.
The concept of numbers exists, but we invent the notation that the ... | Mathematics is normative. That is clear when one reads Euclid and Lobachevsky in juxtaposition, or Euclid and Descartes, or Euclid and Leibniz or Newton, or Leibniz and Newton and Dedekind, or Dedekind and Canton, or Canton and Godel, etc., etc.. Geometry is clearly normative, as we have different geometries (although ... |
1 | What would it mean to say that mathematics was invented and how would this be different from saying mathematics was discovered?
Is this even a serious philosophical question or just a meaningless/tautological linguistic ambiguity? | 2011/06/07 | [
"https://philosophy.stackexchange.com/questions/1",
"https://philosophy.stackexchange.com",
"https://philosophy.stackexchange.com/users/7/"
] | Mathematics is a lot of things: there are basic/complex entities/structures, proof strategies, algorithms, formal manipulations... in order to try to answer your question I think we should make some distinctions between different matematical entities/activities where the "creative" part of the thought is more or less r... | My view on it is that Mathematics is a system invented by humans to represent things we otherwise can or cannot perceive. For example, we can perceive an object through vision and know it's a triangle, however, our vision alone does not tell us the length of the legs of the triangle. We need math to represent that for ... |
1 | What would it mean to say that mathematics was invented and how would this be different from saying mathematics was discovered?
Is this even a serious philosophical question or just a meaningless/tautological linguistic ambiguity? | 2011/06/07 | [
"https://philosophy.stackexchange.com/questions/1",
"https://philosophy.stackexchange.com",
"https://philosophy.stackexchange.com/users/7/"
] | I'm going to posit, admittedly without any research whatsoever about those who've preceded these thoughts, that **an "invention" is a *kind* of "discovery,"** and that whether a thing qualifies as an invention is—yup, you saw it coming—*subjective*.
For example, we might say that the wheel was "invented" on grounds of... | I consider an answer too simple if it just affirms one of the alternatives and negates the other.
Naming just a few eminent contributions to mathematics: Complex numbers, set theory, theory of schemes. E.g., the concept of a set has been invented by Cantor, it did not exists before. After the basic concepts like set, ... |
1 | What would it mean to say that mathematics was invented and how would this be different from saying mathematics was discovered?
Is this even a serious philosophical question or just a meaningless/tautological linguistic ambiguity? | 2011/06/07 | [
"https://philosophy.stackexchange.com/questions/1",
"https://philosophy.stackexchange.com",
"https://philosophy.stackexchange.com/users/7/"
] | This is a serious question and it is the same as saying: is the knowledge in mathematics universal or a human construct?
Pi (the number, regardless of its base) and many other things are universals, mathematics are discovered to that extent. Then they can be used to formalise inventions that may prove to be wrong, rig... | Mathematics is normative. That is clear when one reads Euclid and Lobachevsky in juxtaposition, or Euclid and Descartes, or Euclid and Leibniz or Newton, or Leibniz and Newton and Dedekind, or Dedekind and Canton, or Canton and Godel, etc., etc.. Geometry is clearly normative, as we have different geometries (although ... |
1 | What would it mean to say that mathematics was invented and how would this be different from saying mathematics was discovered?
Is this even a serious philosophical question or just a meaningless/tautological linguistic ambiguity? | 2011/06/07 | [
"https://philosophy.stackexchange.com/questions/1",
"https://philosophy.stackexchange.com",
"https://philosophy.stackexchange.com/users/7/"
] | First, Quine:
"..[If externally true] the definitions [of mathematical laws] would generate all the concepts from clear and distinct ideas, and the proofs would generate all the theorems from self-evident truths."
"...the truths of logic are all obvious or at least potentially obvious..[but] mathematics reduces only to... | If only we would get the question right, we may be able to get the right answer. The problem is, is invention discovery or creation? As a seven times patented inventor, I will tell you that invention is, at least to a great extent, discovery. As my patent agent explained, what is invented is a "method", a way of gettin... |
1 | What would it mean to say that mathematics was invented and how would this be different from saying mathematics was discovered?
Is this even a serious philosophical question or just a meaningless/tautological linguistic ambiguity? | 2011/06/07 | [
"https://philosophy.stackexchange.com/questions/1",
"https://philosophy.stackexchange.com",
"https://philosophy.stackexchange.com/users/7/"
] | I consider an answer too simple if it just affirms one of the alternatives and negates the other.
Naming just a few eminent contributions to mathematics: Complex numbers, set theory, theory of schemes. E.g., the concept of a set has been invented by Cantor, it did not exists before. After the basic concepts like set, ... | Every mathematician can only discover mathematics.
Yet, mathematics is an invention.
And this is no contradiction.
Mathematics is fundamentally dependent on the human mind, and more particularly on human deductive logic and on the human perception of the real world, so it is a sort of invention of the homo sapiens s... |
1 | What would it mean to say that mathematics was invented and how would this be different from saying mathematics was discovered?
Is this even a serious philosophical question or just a meaningless/tautological linguistic ambiguity? | 2011/06/07 | [
"https://philosophy.stackexchange.com/questions/1",
"https://philosophy.stackexchange.com",
"https://philosophy.stackexchange.com/users/7/"
] | First, Quine:
"..[If externally true] the definitions [of mathematical laws] would generate all the concepts from clear and distinct ideas, and the proofs would generate all the theorems from self-evident truths."
"...the truths of logic are all obvious or at least potentially obvious..[but] mathematics reduces only to... | I think it's hard to say. If you believe that mathematics has been discovered, you must assume that "something" is out there, something we can interact with, of which we have been unable to prove existence so far.
However, even assuming that there are ideas out there, I believe that there is no reason to think that h... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.