qid int64 1 74.6M | question stringlengths 45 24.2k | date stringlengths 10 10 | metadata stringlengths 101 178 | response_j stringlengths 32 23.2k | response_k stringlengths 21 13.2k |
|---|---|---|---|---|---|
42,103,738 | I am really new to Swift and working on my first project (I have a bit of experience with Javascript and web development). I have run into trouble (going on 4 hours of trying different solutions).
I have an app where when a `UIButton` is pushed it logs a value to FireBase (ON). When it is pushed a second time it logs ... | 2017/02/08 | ['https://Stackoverflow.com/questions/42103738', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7532077/'] | `UIButton` inherits from `UIControl` which has an `isSelected` property. Use this to track state. Typically you'll use `button.isSelected == true` to correspond to your on state, and `false` is your off state.
To toggle state you can use `button.isSelected = !button.isSelected`.
For your specific example:
```
// Use... | Par's solution should work. However, I would suggest a different approach.
In general it's not good design to store state in a view object. It's fragile, and doesn't follow the MVC design pattern, where view objects display and collect state information, not store it.
Instead I would create an instance variable in yo... |
42,103,738 | I am really new to Swift and working on my first project (I have a bit of experience with Javascript and web development). I have run into trouble (going on 4 hours of trying different solutions).
I have an app where when a `UIButton` is pushed it logs a value to FireBase (ON). When it is pushed a second time it logs ... | 2017/02/08 | ['https://Stackoverflow.com/questions/42103738', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7532077/'] | `UIButton` inherits from `UIControl` which has an `isSelected` property. Use this to track state. Typically you'll use `button.isSelected == true` to correspond to your on state, and `false` is your off state.
To toggle state you can use `button.isSelected = !button.isSelected`.
For your specific example:
```
// Use... | Here’s a quick and dirty implementation of Duncan C’s suggestion to use a `buttonIsSelected` variable to store the button state:
```
import UIKit
class ViewController: UIViewController {
var buttonIsSelected = false
@IBOutlet weak var onOffButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad(... |
42,103,738 | I am really new to Swift and working on my first project (I have a bit of experience with Javascript and web development). I have run into trouble (going on 4 hours of trying different solutions).
I have an app where when a `UIButton` is pushed it logs a value to FireBase (ON). When it is pushed a second time it logs ... | 2017/02/08 | ['https://Stackoverflow.com/questions/42103738', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7532077/'] | Here’s a quick and dirty implementation of Duncan C’s suggestion to use a `buttonIsSelected` variable to store the button state:
```
import UIKit
class ViewController: UIViewController {
var buttonIsSelected = false
@IBOutlet weak var onOffButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad(... | Par's solution should work. However, I would suggest a different approach.
In general it's not good design to store state in a view object. It's fragile, and doesn't follow the MVC design pattern, where view objects display and collect state information, not store it.
Instead I would create an instance variable in yo... |
69,550,532 | I'm learning haskell, and I'm trying to rewrite a function using composition only
Here's the function I'm trying to refactor:
```hs
ceilingDiv a b = ceiling (a / b)
```
So far I managed to make it work using curry and uncurry but it feels dirty:
```hs
ceilingDiv = curry $ ceiling . uncurry (/)
```
Is there any w... | 2021/10/13 | ['https://Stackoverflow.com/questions/69550532', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2410957/'] | Compositions with multiple arguments are usually best just left in point-ful form. None of the alternatives is as clean and clear. Do make use of composition- and grouping operators, but don't golf away arguments just for the sake of it.
```
ceilingDiv a b = ceiling $ a/b
```
What you can certainly do is eta-reduce ... | There's a fun site called <https://pointfree.io> - it provides a solution to your problem like this: `ceilingDiv = (ceiling .) . (/)`. It looks ugly because point-free composition with multiple arguments is a pain. Sometimes it's achieved by using `.` [sections](https://wiki.haskell.org/Section_of_an_infix_operator) li... |
59,499,722 | The predicate function:
```
bool Schedule::predicateFunc(map<pair<string,int>,pair<string,Array> >::iterator it,string &a)
{
return (it->first).first == a;
}
```
Function which I have to use predicate func:
```
void Schedule::studentSchedule() {
string s,c;
cout<<"Enter the student and course name to... | 2019/12/27 | ['https://Stackoverflow.com/questions/59499722', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12543764/'] | Please execute query inside the loop as given below
```
...
$conn = mysqli_connect($servername, $username, $password, $dbname);
...
if (isset($_POST['array'])) {
foreach ($_POST['array'] as $loop) {
$sql = "insert into persons (Name, Email)
values ('" . $loop['name'] . "', '" . $loop['ema... | If you want to execute the query outside the loop
Try using as following
```
if (isset($_POST['array'])) {
$sql="";
foreach ($_POST['array'] as $loop) {
$sql .= "insert into persons (Name, Email)
values ('" . $loop['name'] . "', '" . $loop['email'] . "'... |
59,499,722 | The predicate function:
```
bool Schedule::predicateFunc(map<pair<string,int>,pair<string,Array> >::iterator it,string &a)
{
return (it->first).first == a;
}
```
Function which I have to use predicate func:
```
void Schedule::studentSchedule() {
string s,c;
cout<<"Enter the student and course name to... | 2019/12/27 | ['https://Stackoverflow.com/questions/59499722', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12543764/'] | Better way is only one time create `insert`
```
if (isset($_POST['array'])) {
$values = [];
$sql = "insert into persons (Name, Email) values ";
foreach ($_POST['array'] as $loop) {
$values[] = "('" . $conn->real_escape_string($loop['name']) . "', '" . $conn->real_escape_string($loop['email']) . "'... | Please execute query inside the loop as given below
```
...
$conn = mysqli_connect($servername, $username, $password, $dbname);
...
if (isset($_POST['array'])) {
foreach ($_POST['array'] as $loop) {
$sql = "insert into persons (Name, Email)
values ('" . $loop['name'] . "', '" . $loop['ema... |
59,499,722 | The predicate function:
```
bool Schedule::predicateFunc(map<pair<string,int>,pair<string,Array> >::iterator it,string &a)
{
return (it->first).first == a;
}
```
Function which I have to use predicate func:
```
void Schedule::studentSchedule() {
string s,c;
cout<<"Enter the student and course name to... | 2019/12/27 | ['https://Stackoverflow.com/questions/59499722', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12543764/'] | The reason why it doesn't work is because you never execute your SQL query anywhere.
To execute the query you should first prepare the statement and then bind the params and execute.
```
// Your connection to DB
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli('localhost', 'username', ... | Please execute query inside the loop as given below
```
...
$conn = mysqli_connect($servername, $username, $password, $dbname);
...
if (isset($_POST['array'])) {
foreach ($_POST['array'] as $loop) {
$sql = "insert into persons (Name, Email)
values ('" . $loop['name'] . "', '" . $loop['ema... |
59,499,722 | The predicate function:
```
bool Schedule::predicateFunc(map<pair<string,int>,pair<string,Array> >::iterator it,string &a)
{
return (it->first).first == a;
}
```
Function which I have to use predicate func:
```
void Schedule::studentSchedule() {
string s,c;
cout<<"Enter the student and course name to... | 2019/12/27 | ['https://Stackoverflow.com/questions/59499722', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12543764/'] | Please execute query inside the loop as given below
```
...
$conn = mysqli_connect($servername, $username, $password, $dbname);
...
if (isset($_POST['array'])) {
foreach ($_POST['array'] as $loop) {
$sql = "insert into persons (Name, Email)
values ('" . $loop['name'] . "', '" . $loop['ema... | I had the same issue inserting JSON arrays into MySQL and fixed it by putting the `mysqli_stmt->execute()` function inside the `foreach`
```
// loop through the array
foreach ($data as $row) {
echo "Data has been Uploaded successfully <br>";
// get the project details
$id = $row['id'];
$name = $row['na... |
59,499,722 | The predicate function:
```
bool Schedule::predicateFunc(map<pair<string,int>,pair<string,Array> >::iterator it,string &a)
{
return (it->first).first == a;
}
```
Function which I have to use predicate func:
```
void Schedule::studentSchedule() {
string s,c;
cout<<"Enter the student and course name to... | 2019/12/27 | ['https://Stackoverflow.com/questions/59499722', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12543764/'] | Better way is only one time create `insert`
```
if (isset($_POST['array'])) {
$values = [];
$sql = "insert into persons (Name, Email) values ";
foreach ($_POST['array'] as $loop) {
$values[] = "('" . $conn->real_escape_string($loop['name']) . "', '" . $conn->real_escape_string($loop['email']) . "'... | If you want to execute the query outside the loop
Try using as following
```
if (isset($_POST['array'])) {
$sql="";
foreach ($_POST['array'] as $loop) {
$sql .= "insert into persons (Name, Email)
values ('" . $loop['name'] . "', '" . $loop['email'] . "'... |
59,499,722 | The predicate function:
```
bool Schedule::predicateFunc(map<pair<string,int>,pair<string,Array> >::iterator it,string &a)
{
return (it->first).first == a;
}
```
Function which I have to use predicate func:
```
void Schedule::studentSchedule() {
string s,c;
cout<<"Enter the student and course name to... | 2019/12/27 | ['https://Stackoverflow.com/questions/59499722', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12543764/'] | The reason why it doesn't work is because you never execute your SQL query anywhere.
To execute the query you should first prepare the statement and then bind the params and execute.
```
// Your connection to DB
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli('localhost', 'username', ... | If you want to execute the query outside the loop
Try using as following
```
if (isset($_POST['array'])) {
$sql="";
foreach ($_POST['array'] as $loop) {
$sql .= "insert into persons (Name, Email)
values ('" . $loop['name'] . "', '" . $loop['email'] . "'... |
59,499,722 | The predicate function:
```
bool Schedule::predicateFunc(map<pair<string,int>,pair<string,Array> >::iterator it,string &a)
{
return (it->first).first == a;
}
```
Function which I have to use predicate func:
```
void Schedule::studentSchedule() {
string s,c;
cout<<"Enter the student and course name to... | 2019/12/27 | ['https://Stackoverflow.com/questions/59499722', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12543764/'] | I had the same issue inserting JSON arrays into MySQL and fixed it by putting the `mysqli_stmt->execute()` function inside the `foreach`
```
// loop through the array
foreach ($data as $row) {
echo "Data has been Uploaded successfully <br>";
// get the project details
$id = $row['id'];
$name = $row['na... | If you want to execute the query outside the loop
Try using as following
```
if (isset($_POST['array'])) {
$sql="";
foreach ($_POST['array'] as $loop) {
$sql .= "insert into persons (Name, Email)
values ('" . $loop['name'] . "', '" . $loop['email'] . "'... |
59,499,722 | The predicate function:
```
bool Schedule::predicateFunc(map<pair<string,int>,pair<string,Array> >::iterator it,string &a)
{
return (it->first).first == a;
}
```
Function which I have to use predicate func:
```
void Schedule::studentSchedule() {
string s,c;
cout<<"Enter the student and course name to... | 2019/12/27 | ['https://Stackoverflow.com/questions/59499722', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12543764/'] | The reason why it doesn't work is because you never execute your SQL query anywhere.
To execute the query you should first prepare the statement and then bind the params and execute.
```
// Your connection to DB
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli('localhost', 'username', ... | Better way is only one time create `insert`
```
if (isset($_POST['array'])) {
$values = [];
$sql = "insert into persons (Name, Email) values ";
foreach ($_POST['array'] as $loop) {
$values[] = "('" . $conn->real_escape_string($loop['name']) . "', '" . $conn->real_escape_string($loop['email']) . "'... |
59,499,722 | The predicate function:
```
bool Schedule::predicateFunc(map<pair<string,int>,pair<string,Array> >::iterator it,string &a)
{
return (it->first).first == a;
}
```
Function which I have to use predicate func:
```
void Schedule::studentSchedule() {
string s,c;
cout<<"Enter the student and course name to... | 2019/12/27 | ['https://Stackoverflow.com/questions/59499722', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12543764/'] | Better way is only one time create `insert`
```
if (isset($_POST['array'])) {
$values = [];
$sql = "insert into persons (Name, Email) values ";
foreach ($_POST['array'] as $loop) {
$values[] = "('" . $conn->real_escape_string($loop['name']) . "', '" . $conn->real_escape_string($loop['email']) . "'... | I had the same issue inserting JSON arrays into MySQL and fixed it by putting the `mysqli_stmt->execute()` function inside the `foreach`
```
// loop through the array
foreach ($data as $row) {
echo "Data has been Uploaded successfully <br>";
// get the project details
$id = $row['id'];
$name = $row['na... |
59,499,722 | The predicate function:
```
bool Schedule::predicateFunc(map<pair<string,int>,pair<string,Array> >::iterator it,string &a)
{
return (it->first).first == a;
}
```
Function which I have to use predicate func:
```
void Schedule::studentSchedule() {
string s,c;
cout<<"Enter the student and course name to... | 2019/12/27 | ['https://Stackoverflow.com/questions/59499722', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12543764/'] | The reason why it doesn't work is because you never execute your SQL query anywhere.
To execute the query you should first prepare the statement and then bind the params and execute.
```
// Your connection to DB
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli('localhost', 'username', ... | I had the same issue inserting JSON arrays into MySQL and fixed it by putting the `mysqli_stmt->execute()` function inside the `foreach`
```
// loop through the array
foreach ($data as $row) {
echo "Data has been Uploaded successfully <br>";
// get the project details
$id = $row['id'];
$name = $row['na... |
12,070,601 | The [NQueen problem](http://en.wikipedia.org/wiki/Eight_queens_puzzle) is a famous example of [backtracking](http://en.wikipedia.org/wiki/Backtracking). After reading from the [source](http://www.geeksforgeeks.org/archives/13387), I have tried the below code snippet.
```
int isSafe(int k,int i,int *x)
{
int j;
... | 2012/08/22 | ['https://Stackoverflow.com/questions/12070601', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1347366/'] | The `sol[k] = 0` is not the backtracking part. The backtracking is done in the recursive call: `if( Nqueen(k+1, sol, N) )`.
The idea of backtracking is an exhaustive search - you are trying to search all possibilities, until one is found. In here, you are trying all possible assignments of queens in the board, and "ke... | First, you really need to understand the algorithm (this will tell you that commenting that stuff out doesn't matter). This algorithm is recursive, as you have noticed. It is backtracking because you
* set the k-th queen to a position
* explore the possible placements for queens k+1,k+2,...
* then you go back to the k... |
12,070,601 | The [NQueen problem](http://en.wikipedia.org/wiki/Eight_queens_puzzle) is a famous example of [backtracking](http://en.wikipedia.org/wiki/Backtracking). After reading from the [source](http://www.geeksforgeeks.org/archives/13387), I have tried the below code snippet.
```
int isSafe(int k,int i,int *x)
{
int j;
... | 2012/08/22 | ['https://Stackoverflow.com/questions/12070601', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1347366/'] | The `sol[k] = 0` is not the backtracking part. The backtracking is done in the recursive call: `if( Nqueen(k+1, sol, N) )`.
The idea of backtracking is an exhaustive search - you are trying to search all possibilities, until one is found. In here, you are trying all possible assignments of queens in the board, and "ke... | Backtracking Problems are a programming paradigm in which you try each and every possible combination. Then for every combination you check if the combination so far is correct.
Below are few steps for N(or 8) queen problem.
1. Start from Row 0 and place 1st queen at Col 0.
2. Now place 2nd queen at Row 1 and col 0.
3... |
12,070,601 | The [NQueen problem](http://en.wikipedia.org/wiki/Eight_queens_puzzle) is a famous example of [backtracking](http://en.wikipedia.org/wiki/Backtracking). After reading from the [source](http://www.geeksforgeeks.org/archives/13387), I have tried the below code snippet.
```
int isSafe(int k,int i,int *x)
{
int j;
... | 2012/08/22 | ['https://Stackoverflow.com/questions/12070601', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1347366/'] | Backtracking Problems are a programming paradigm in which you try each and every possible combination. Then for every combination you check if the combination so far is correct.
Below are few steps for N(or 8) queen problem.
1. Start from Row 0 and place 1st queen at Col 0.
2. Now place 2nd queen at Row 1 and col 0.
3... | First, you really need to understand the algorithm (this will tell you that commenting that stuff out doesn't matter). This algorithm is recursive, as you have noticed. It is backtracking because you
* set the k-th queen to a position
* explore the possible placements for queens k+1,k+2,...
* then you go back to the k... |
9,776,878 | I'm looking for the best method of handling errors in a c# winforms class that I have. The gist of the application is that it has a data analyzer that analyzes the data for statistics and other such stuff. However, I'm looking for the proper way of handling an ABORT.
For example, I have the class called Analyzer
```
... | 2012/03/19 | ['https://Stackoverflow.com/questions/9776878', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/821484/'] | >
> I was really hoping for some sort of like "abort mechanism" that I
> could use. Is there any other ways of working around this? Any
> interesting work-arounds for this?
>
>
>
Yes, there is. It is called *exception handling*.
Let's rewrite your code:
```
namespace PHOEBE
{
public class Analyzer
{
... | You could just move `DoFurtherAnalysis();` into the the try block
And I would do this entire process somewhere other than the constructor.
Only thing I ever do in the constructor is initialize properties. |
9,776,878 | I'm looking for the best method of handling errors in a c# winforms class that I have. The gist of the application is that it has a data analyzer that analyzes the data for statistics and other such stuff. However, I'm looking for the proper way of handling an ABORT.
For example, I have the class called Analyzer
```
... | 2012/03/19 | ['https://Stackoverflow.com/questions/9776878', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/821484/'] | Just let the exception propagate up - you should only catch the exception if you can actually *handle* it. Exceptions *are* the "abort mechanism" in .NET. You're currently *swallowing* the signal that everything's gone wrong, and returning as if all were well.
Generally I find catching exceptions to be pretty rare - u... | >
> I was really hoping for some sort of like "abort mechanism" that I
> could use. Is there any other ways of working around this? Any
> interesting work-arounds for this?
>
>
>
Yes, there is. It is called *exception handling*.
Let's rewrite your code:
```
namespace PHOEBE
{
public class Analyzer
{
... |
9,776,878 | I'm looking for the best method of handling errors in a c# winforms class that I have. The gist of the application is that it has a data analyzer that analyzes the data for statistics and other such stuff. However, I'm looking for the proper way of handling an ABORT.
For example, I have the class called Analyzer
```
... | 2012/03/19 | ['https://Stackoverflow.com/questions/9776878', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/821484/'] | The easiest work-around is *don't catch the exception*. If that were to happen, it'd go straight past the `DoFurtherAnalysis()` function and out to the original caller. | use a try...catch in the constructor? |
9,776,878 | I'm looking for the best method of handling errors in a c# winforms class that I have. The gist of the application is that it has a data analyzer that analyzes the data for statistics and other such stuff. However, I'm looking for the proper way of handling an ABORT.
For example, I have the class called Analyzer
```
... | 2012/03/19 | ['https://Stackoverflow.com/questions/9776878', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/821484/'] | Just let the exception propagate up - you should only catch the exception if you can actually *handle* it. Exceptions *are* the "abort mechanism" in .NET. You're currently *swallowing* the signal that everything's gone wrong, and returning as if all were well.
Generally I find catching exceptions to be pretty rare - u... | Well, you've got several issues mixed up here. First, it looks like you do possibly-very expensive processing from your constructor. If that processing can throw, you really don't want to call it from your constructor becuase you don't even have the option of returning an error code.
Second, (and you'll read in many t... |
9,776,878 | I'm looking for the best method of handling errors in a c# winforms class that I have. The gist of the application is that it has a data analyzer that analyzes the data for statistics and other such stuff. However, I'm looking for the proper way of handling an ABORT.
For example, I have the class called Analyzer
```
... | 2012/03/19 | ['https://Stackoverflow.com/questions/9776878', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/821484/'] | Don't see anything anoying in returning and checking `bool` return value from the function. It's much much better solution then having some tricky internal state management, that you for sure will messed up after a couple of months when you return to your code.
Make code sumple and streghtforward. It's not anoying, it... | You could just move `DoFurtherAnalysis();` into the the try block
And I would do this entire process somewhere other than the constructor.
Only thing I ever do in the constructor is initialize properties. |
9,776,878 | I'm looking for the best method of handling errors in a c# winforms class that I have. The gist of the application is that it has a data analyzer that analyzes the data for statistics and other such stuff. However, I'm looking for the proper way of handling an ABORT.
For example, I have the class called Analyzer
```
... | 2012/03/19 | ['https://Stackoverflow.com/questions/9776878', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/821484/'] | >
> I was really hoping for some sort of like "abort mechanism" that I
> could use. Is there any other ways of working around this? Any
> interesting work-arounds for this?
>
>
>
Yes, there is. It is called *exception handling*.
Let's rewrite your code:
```
namespace PHOEBE
{
public class Analyzer
{
... | You are subverting the existing "abort" mechanism by catching an exception that you are not doing anything about and swallowing it.
You should not use a `try{}catch{}` block in this case and let the exception bubble up and cause the application to abort. |
9,776,878 | I'm looking for the best method of handling errors in a c# winforms class that I have. The gist of the application is that it has a data analyzer that analyzes the data for statistics and other such stuff. However, I'm looking for the proper way of handling an ABORT.
For example, I have the class called Analyzer
```
... | 2012/03/19 | ['https://Stackoverflow.com/questions/9776878', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/821484/'] | Don't see anything anoying in returning and checking `bool` return value from the function. It's much much better solution then having some tricky internal state management, that you for sure will messed up after a couple of months when you return to your code.
Make code sumple and streghtforward. It's not anoying, it... | use a try...catch in the constructor? |
9,776,878 | I'm looking for the best method of handling errors in a c# winforms class that I have. The gist of the application is that it has a data analyzer that analyzes the data for statistics and other such stuff. However, I'm looking for the proper way of handling an ABORT.
For example, I have the class called Analyzer
```
... | 2012/03/19 | ['https://Stackoverflow.com/questions/9776878', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/821484/'] | >
> I was really hoping for some sort of like "abort mechanism" that I
> could use. Is there any other ways of working around this? Any
> interesting work-arounds for this?
>
>
>
Yes, there is. It is called *exception handling*.
Let's rewrite your code:
```
namespace PHOEBE
{
public class Analyzer
{
... | Don't see anything anoying in returning and checking `bool` return value from the function. It's much much better solution then having some tricky internal state management, that you for sure will messed up after a couple of months when you return to your code.
Make code sumple and streghtforward. It's not anoying, it... |
9,776,878 | I'm looking for the best method of handling errors in a c# winforms class that I have. The gist of the application is that it has a data analyzer that analyzes the data for statistics and other such stuff. However, I'm looking for the proper way of handling an ABORT.
For example, I have the class called Analyzer
```
... | 2012/03/19 | ['https://Stackoverflow.com/questions/9776878', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/821484/'] | Just let the exception propagate up - you should only catch the exception if you can actually *handle* it. Exceptions *are* the "abort mechanism" in .NET. You're currently *swallowing* the signal that everything's gone wrong, and returning as if all were well.
Generally I find catching exceptions to be pretty rare - u... | You could just move `DoFurtherAnalysis();` into the the try block
And I would do this entire process somewhere other than the constructor.
Only thing I ever do in the constructor is initialize properties. |
9,776,878 | I'm looking for the best method of handling errors in a c# winforms class that I have. The gist of the application is that it has a data analyzer that analyzes the data for statistics and other such stuff. However, I'm looking for the proper way of handling an ABORT.
For example, I have the class called Analyzer
```
... | 2012/03/19 | ['https://Stackoverflow.com/questions/9776878', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/821484/'] | Just let the exception propagate up - you should only catch the exception if you can actually *handle* it. Exceptions *are* the "abort mechanism" in .NET. You're currently *swallowing* the signal that everything's gone wrong, and returning as if all were well.
Generally I find catching exceptions to be pretty rare - u... | Don't see anything anoying in returning and checking `bool` return value from the function. It's much much better solution then having some tricky internal state management, that you for sure will messed up after a couple of months when you return to your code.
Make code sumple and streghtforward. It's not anoying, it... |
42,317,542 | Yesterday I was making an HTML element and this problem hit me up.
The Background-image of the DIV is not showing, and I was curious, the link worked fine.
Here is my code
```html
<div id="floating-image-<?php echo $id; ?>" class="fl-<?php echo $id; ?>" style="
background-image: url(https://images.pexels.com/phot... | 2017/02/18 | ['https://Stackoverflow.com/questions/42317542', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/'] | I have checked, background image is properly working. Your image size is very big, approx 7 MB. Reduce it upto 300KB, too big to show. | Issue is in the image,
You have used very high quality image.
if you use a low quality image than you have currently used,
it will work fine. |
42,317,542 | Yesterday I was making an HTML element and this problem hit me up.
The Background-image of the DIV is not showing, and I was curious, the link worked fine.
Here is my code
```html
<div id="floating-image-<?php echo $id; ?>" class="fl-<?php echo $id; ?>" style="
background-image: url(https://images.pexels.com/phot... | 2017/02/18 | ['https://Stackoverflow.com/questions/42317542', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/'] | The solution is going to be solved only by me since it is included in a project.
Thanks for your help, and if I found the real solution, I will post it here.
**EDIT**
Well, I feel bad now, about the wasted hour in my life.
Anyway, I found the solution and it was about the animations.
I made this feature in my theme... | Issue is in the image,
You have used very high quality image.
if you use a low quality image than you have currently used,
it will work fine. |
130,194 | Would be possible to apply genetic changes (like splicing in a radiation hardening gene) to an adult human? With near future technology, like advanced forms of CRISPR? Or can things like that only be applied t unborn infants? | 2018/11/13 | ['https://worldbuilding.stackexchange.com/questions/130194', 'https://worldbuilding.stackexchange.com', 'https://worldbuilding.stackexchange.com/users/47304/'] | Yes but it's much harder and the effects can be limited and much slower.
**Genetic Surgery**
Enough engineered viruses can change the DNA but can be limited on changing physical structures.
Here's an [example](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4401361/) where viral surgery was used to repair genetic deafn... | [Gene Therapy](https://en.wikipedia.org/wiki/Gene_therapy)
==========================================================
With the gene therapy, is possible to modify the DNA of a born creature using Virus, Retrovirus, Adenovirus, Non-Virus or others as a Vector. (Surprisingly, the Spanish Wikipedia has more information a... |
130,194 | Would be possible to apply genetic changes (like splicing in a radiation hardening gene) to an adult human? With near future technology, like advanced forms of CRISPR? Or can things like that only be applied t unborn infants? | 2018/11/13 | ['https://worldbuilding.stackexchange.com/questions/130194', 'https://worldbuilding.stackexchange.com', 'https://worldbuilding.stackexchange.com/users/47304/'] | **Genetic engineering of adult subjects is currently not possible, especially with splicing**
But it might be theoretically possible, with some huge challenges to overcome:
A retrovirus is a virus capable of modifying a host cell's genome. I think the current scientific cliff is left at this: The virus can either mod... | Yes but it's much harder and the effects can be limited and much slower.
**Genetic Surgery**
Enough engineered viruses can change the DNA but can be limited on changing physical structures.
Here's an [example](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4401361/) where viral surgery was used to repair genetic deafn... |
130,194 | Would be possible to apply genetic changes (like splicing in a radiation hardening gene) to an adult human? With near future technology, like advanced forms of CRISPR? Or can things like that only be applied t unborn infants? | 2018/11/13 | ['https://worldbuilding.stackexchange.com/questions/130194', 'https://worldbuilding.stackexchange.com', 'https://worldbuilding.stackexchange.com/users/47304/'] | **Genetic engineering of adult subjects is currently not possible, especially with splicing**
But it might be theoretically possible, with some huge challenges to overcome:
A retrovirus is a virus capable of modifying a host cell's genome. I think the current scientific cliff is left at this: The virus can either mod... | [Gene Therapy](https://en.wikipedia.org/wiki/Gene_therapy)
==========================================================
With the gene therapy, is possible to modify the DNA of a born creature using Virus, Retrovirus, Adenovirus, Non-Virus or others as a Vector. (Surprisingly, the Spanish Wikipedia has more information a... |
58,764,751 | Got some problems with setting up drone with my gitea instance and because there are so much different guides with different configs over the past years for different environment variables for drone, i cannot setup this the way it works for me.
And yes, i do know, they explicitly stated *"We strongly recommend installi... | 2019/11/08 | ['https://Stackoverflow.com/questions/58764751', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9239809/'] | Try:
```
import matplotlib.pyplot as plt
ax = df.plot.bar(y='Profile_ID Count')
plt.show()
``` | ```
# Importing the requisite libraries
import pandas as pd
import matplotlib.pyplot as plt
# Creating the DataFrame
df = pd.DataFrame({'Creation Date':['2016-06-01','2016-06-03','2016-06-04'],'Profile_ID Count':[150,3,20]})
# Creating the bar chart below.
fig, ax = plt.subplots()
ax.bar(df['Creation Date'],df['Profi... |
11,106,110 | Does anyone know the standard size of a single listview item in android, in dpi or pixels?
Or maybe there isn't a standard? | 2012/06/19 | ['https://Stackoverflow.com/questions/11106110', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1301563/'] | Android defines a "preferred size" using,
```
android:minHeight="?android:attr/listPreferredItemHeight"
```
Documented [here](http://developer.android.com/reference/android/R.attr.html#listPreferredItemHeight) as well. | there is a strongly recommended list view item size, which you should use: [48dip](http://developer.android.com/design/style/metrics-grids.html#48dp-rhythm). This is recommended by the new Android Design Guidelines. |
2,996 | I recently upgraded to CiviCRM 4.6.3 from 4.4.XX. Since then, the WYSIWYG editor is missing when creating a new scheduled reminder or editing an existing one. To reproduce the error:
1. Click Manage Events
2. Click Configure an event, and choose Schedule Reminders.
3. Edit or create a new reminder
4. See the editor mis... | 2015/06/03 | ['https://civicrm.stackexchange.com/questions/2996', 'https://civicrm.stackexchange.com', 'https://civicrm.stackexchange.com/users/614/'] | Adding the contribution status itself is pretty easy. You can do that with Administer/System Settings/Option Groups, find the one for Contribution Status and click on 'options'. You will then get the possibility to add a value.
This is just adding a status, so I assume the settings of the status will be done manually.... | Normally, you can set new options in Administer > System Settings > Option Groups, but you'll notice that it says:
>
> This option group is reserved for system use. You cannot add or delete options in this list.
>
>
>
You could work around it by adding a new item in the civicrm\_option\_value table, but you'd be ... |
4,144 | I want to burn a .img file of Wheezy OS to my 8GB SD Card from Mac OS X but can't figure out how.
Any help would be appreciated. | 2012/12/27 | ['https://raspberrypi.stackexchange.com/questions/4144', 'https://raspberrypi.stackexchange.com', 'https://raspberrypi.stackexchange.com/users/-1/'] | First, verify the path to your SD card. You can do this by running the following command from terminal:
`diskutil list`
The output shows a list of disks currently mounted on the system. Here's the relevant line from my output:
```
/dev/disk3
#: TYPE NAME SIZE IDENTIFI... | Try this: [ApplePi-Baker](http://www.tweaking4all.com/hardware/raspberry-pi/macosx-apple-pi-baker/)
It's free, writes IMG files to SD-Card, can prepare a NOOBS card and can make a backup to IMG of your SD-Card. |
4,144 | I want to burn a .img file of Wheezy OS to my 8GB SD Card from Mac OS X but can't figure out how.
Any help would be appreciated. | 2012/12/27 | ['https://raspberrypi.stackexchange.com/questions/4144', 'https://raspberrypi.stackexchange.com', 'https://raspberrypi.stackexchange.com/users/-1/'] | I made a script to burn .img or .iso files to SD card or USB.
[Github > burn.sh](https://github.com/jmcerrejon/scripts/blob/master/burn.sh) | Use `df` to find the device path, in this case `/dev/disk2`.
```
$ df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk1 465Gi 414Gi 51Gi 90% 108573777 13263821 89% /
devfs 214Ki 214Ki 0Bi 100% 741 0 100% /dev
map -hosts 0Bi... |
4,144 | I want to burn a .img file of Wheezy OS to my 8GB SD Card from Mac OS X but can't figure out how.
Any help would be appreciated. | 2012/12/27 | ['https://raspberrypi.stackexchange.com/questions/4144', 'https://raspberrypi.stackexchange.com', 'https://raspberrypi.stackexchange.com/users/-1/'] | There is a faq/howto available that discusses all the various OS-es. For the Mac it is (nearly) the same as under the various other types of Unix versions. The use of dd.
In short you type:
```
sudo dd if=path_of_your_image.img of=/dev/rdiskn bs=1m
```
**N.B: the of=/rdev/diskn needs to be the SD card, if you do th... | Try this: [ApplePi-Baker](http://www.tweaking4all.com/hardware/raspberry-pi/macosx-apple-pi-baker/)
It's free, writes IMG files to SD-Card, can prepare a NOOBS card and can make a backup to IMG of your SD-Card. |
4,144 | I want to burn a .img file of Wheezy OS to my 8GB SD Card from Mac OS X but can't figure out how.
Any help would be appreciated. | 2012/12/27 | ['https://raspberrypi.stackexchange.com/questions/4144', 'https://raspberrypi.stackexchange.com', 'https://raspberrypi.stackexchange.com/users/-1/'] | In 2020, this accepted answer is obsolete: For *most* cases, people should follow the new [raspberrypi.org Installation Guide](https://www.raspberrypi.org/documentation/installation/installing-images/README.md).
Alternatively, the community-provided [Etcher](https://www.balena.io/etcher/) tool also provides a graphica... | You could also try: [dd Utility](https://www.thefanclub.co.za/how-to/dd-utility-write-and-backup-operating-system-img-files-memory-card-mac-os-x)
Features:
* Write IMG files to memory cards and hard drives.
* Backup and Restore IMG files to memory cards and hard drives.
* Install and Restore compressed disk image fil... |
4,144 | I want to burn a .img file of Wheezy OS to my 8GB SD Card from Mac OS X but can't figure out how.
Any help would be appreciated. | 2012/12/27 | ['https://raspberrypi.stackexchange.com/questions/4144', 'https://raspberrypi.stackexchange.com', 'https://raspberrypi.stackexchange.com/users/-1/'] | There is a faq/howto available that discusses all the various OS-es. For the Mac it is (nearly) the same as under the various other types of Unix versions. The use of dd.
In short you type:
```
sudo dd if=path_of_your_image.img of=/dev/rdiskn bs=1m
```
**N.B: the of=/rdev/diskn needs to be the SD card, if you do th... | Found a really good link: <http://www.tweaking4all.com/hardware/raspberry-pi/install-img-to-sd-card/#macosx> for installing file.img on SD card, very detailed steps! |
4,144 | I want to burn a .img file of Wheezy OS to my 8GB SD Card from Mac OS X but can't figure out how.
Any help would be appreciated. | 2012/12/27 | ['https://raspberrypi.stackexchange.com/questions/4144', 'https://raspberrypi.stackexchange.com', 'https://raspberrypi.stackexchange.com/users/-1/'] | First, verify the path to your SD card. You can do this by running the following command from terminal:
`diskutil list`
The output shows a list of disks currently mounted on the system. Here's the relevant line from my output:
```
/dev/disk3
#: TYPE NAME SIZE IDENTIFI... | Found a really good link: <http://www.tweaking4all.com/hardware/raspberry-pi/install-img-to-sd-card/#macosx> for installing file.img on SD card, very detailed steps! |
4,144 | I want to burn a .img file of Wheezy OS to my 8GB SD Card from Mac OS X but can't figure out how.
Any help would be appreciated. | 2012/12/27 | ['https://raspberrypi.stackexchange.com/questions/4144', 'https://raspberrypi.stackexchange.com', 'https://raspberrypi.stackexchange.com/users/-1/'] | Yes the simple answer is to just [dd](http://linux.die.net/man/1/dd) it, but there are some safety precautions you may want to enforce by wrapping your dd in a script;
```
#!/bin/bash
#
# copy_img_to_sd.sh
#
ME=$( id | grep root | wc -l | perl -p -e 's/[^0-9]+//g');
if [ "$ME" != "1" ] ;then
echo "must be root"
... | Use `df` to find the device path, in this case `/dev/disk2`.
```
$ df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk1 465Gi 414Gi 51Gi 90% 108573777 13263821 89% /
devfs 214Ki 214Ki 0Bi 100% 741 0 100% /dev
map -hosts 0Bi... |
4,144 | I want to burn a .img file of Wheezy OS to my 8GB SD Card from Mac OS X but can't figure out how.
Any help would be appreciated. | 2012/12/27 | ['https://raspberrypi.stackexchange.com/questions/4144', 'https://raspberrypi.stackexchange.com', 'https://raspberrypi.stackexchange.com/users/-1/'] | Found a really good link: <http://www.tweaking4all.com/hardware/raspberry-pi/install-img-to-sd-card/#macosx> for installing file.img on SD card, very detailed steps! | Use `df` to find the device path, in this case `/dev/disk2`.
```
$ df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk1 465Gi 414Gi 51Gi 90% 108573777 13263821 89% /
devfs 214Ki 214Ki 0Bi 100% 741 0 100% /dev
map -hosts 0Bi... |
4,144 | I want to burn a .img file of Wheezy OS to my 8GB SD Card from Mac OS X but can't figure out how.
Any help would be appreciated. | 2012/12/27 | ['https://raspberrypi.stackexchange.com/questions/4144', 'https://raspberrypi.stackexchange.com', 'https://raspberrypi.stackexchange.com/users/-1/'] | There is a faq/howto available that discusses all the various OS-es. For the Mac it is (nearly) the same as under the various other types of Unix versions. The use of dd.
In short you type:
```
sudo dd if=path_of_your_image.img of=/dev/rdiskn bs=1m
```
**N.B: the of=/rdev/diskn needs to be the SD card, if you do th... | Use `df` to find the device path, in this case `/dev/disk2`.
```
$ df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk1 465Gi 414Gi 51Gi 90% 108573777 13263821 89% /
devfs 214Ki 214Ki 0Bi 100% 741 0 100% /dev
map -hosts 0Bi... |
4,144 | I want to burn a .img file of Wheezy OS to my 8GB SD Card from Mac OS X but can't figure out how.
Any help would be appreciated. | 2012/12/27 | ['https://raspberrypi.stackexchange.com/questions/4144', 'https://raspberrypi.stackexchange.com', 'https://raspberrypi.stackexchange.com/users/-1/'] | First, verify the path to your SD card. You can do this by running the following command from terminal:
`diskutil list`
The output shows a list of disks currently mounted on the system. Here's the relevant line from my output:
```
/dev/disk3
#: TYPE NAME SIZE IDENTIFI... | I made a script to burn .img or .iso files to SD card or USB.
[Github > burn.sh](https://github.com/jmcerrejon/scripts/blob/master/burn.sh) |
47,550,227 | I'm trying to mount mongo `/data` directory on to a NFS volume in my kubernetes master machine for persisting mongo data. I see the volume is mounted successfully but I can see only `configdb` and `db` dirs but not their subdirectories. And I see the data is not even persisting in the volume. when I `kubectl describe <... | 2017/11/29 | ['https://Stackoverflow.com/questions/47550227', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4088785/'] | It's possible that pods don't have permission to create files and directories. You can `exec` to your pod and try to `touch` a file in NFS share if you get permission error you can ease up permission on file system and `exports` file to allow write access.
It's possible to specify `GID` in PV object to avoid permissio... | I see you did a `chown nobody:nogroup -R /mongodata`.
Make sure that the application on your pod runs as `nobody:nogroup` |
47,550,227 | I'm trying to mount mongo `/data` directory on to a NFS volume in my kubernetes master machine for persisting mongo data. I see the volume is mounted successfully but I can see only `configdb` and `db` dirs but not their subdirectories. And I see the data is not even persisting in the volume. when I `kubectl describe <... | 2017/11/29 | ['https://Stackoverflow.com/questions/47550227', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4088785/'] | It's possible that pods don't have permission to create files and directories. You can `exec` to your pod and try to `touch` a file in NFS share if you get permission error you can ease up permission on file system and `exports` file to allow write access.
It's possible to specify `GID` in PV object to avoid permissio... | Add the parameter `mountOptions: "vers=4.1"` to your StorageClass config, this should fix your issue.
See this Github comment for more info:
<https://github.com/kubernetes-incubator/external-storage/issues/223#issuecomment-344972640> |
66,288 | I recently upgraded to Oneiric and noticed that the calendar is no longer persistent like it was in Natty and Maverick. I could open the calendar to January 2007, then move to another window and still refer to the calendar. Now, as soon as I lose focus the calendar goes back into hiding. Is this a setting somewhere? | 2011/10/14 | ['https://askubuntu.com/questions/66288', 'https://askubuntu.com', 'https://askubuntu.com/users/23482/'] | Temporarily downloaded files
----------------------------
All Linux browsers (including Firefox and Chrome) store "Open for viewing" downloads in the `/tmp` directory. Old `/tmp` files are deleted the following situations:
1. When you close your browser
2. When you restart Ubuntu
3. When your disk space is low
If yo... | do you mean : "the browser cache
take a look at :
```
/home/$USER/.mozilla/firefox/SOMETHIN.default/Cache
``` |
66,288 | I recently upgraded to Oneiric and noticed that the calendar is no longer persistent like it was in Natty and Maverick. I could open the calendar to January 2007, then move to another window and still refer to the calendar. Now, as soon as I lose focus the calendar goes back into hiding. Is this a setting somewhere? | 2011/10/14 | ['https://askubuntu.com/questions/66288', 'https://askubuntu.com', 'https://askubuntu.com/users/23482/'] | Mozilla Firefox
---------------
`~/.mozilla/firefox/[something].default/Cache`
You can go to `about:cache` in your Browser to see information about this as well.

Chromium
--------
`~/.cache/chromium/[profile]/Cache/`
Google Chrome
-------------
`~/.cache/g... | do you mean : "the browser cache
take a look at :
```
/home/$USER/.mozilla/firefox/SOMETHIN.default/Cache
``` |
66,288 | I recently upgraded to Oneiric and noticed that the calendar is no longer persistent like it was in Natty and Maverick. I could open the calendar to January 2007, then move to another window and still refer to the calendar. Now, as soon as I lose focus the calendar goes back into hiding. Is this a setting somewhere? | 2011/10/14 | ['https://askubuntu.com/questions/66288', 'https://askubuntu.com', 'https://askubuntu.com/users/23482/'] | Mozilla Firefox
---------------
`~/.mozilla/firefox/[something].default/Cache`
You can go to `about:cache` in your Browser to see information about this as well.

Chromium
--------
`~/.cache/chromium/[profile]/Cache/`
Google Chrome
-------------
`~/.cache/g... | Temporarily downloaded files
----------------------------
All Linux browsers (including Firefox and Chrome) store "Open for viewing" downloads in the `/tmp` directory. Old `/tmp` files are deleted the following situations:
1. When you close your browser
2. When you restart Ubuntu
3. When your disk space is low
If yo... |
263,735 | Problem:
How can I tell if a selection of text in the CRichEditCtrl has multiple font sizes in it?
---
Goal:
I am sort of making my own RichEdit toolbar (bold, italic, font type, font size, etc). I want to emulate what MS Word does when a selection of text has more than a single font size spanning the selection.
Ex ... | 2008/11/04 | ['https://Stackoverflow.com/questions/263735', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/34460/'] | As the above answer notes, the easiest way I can think of to do this is to use the Text Object Model (TOM), which is accessed through the ITextDocument COM interface. To get at this from your rich edit control (note code not tested, but should work):
```
CComPtr<IRichEditOle> richOle;
richOle.Attach(edit.GetIRichEditO... | Been juggling a couple things, but I was finally able to work.
This is how I finally was able to get everything to compile and run:
```
HWND hwnd;
ITextDocument* pDoc;
IUnknown* pUnk = NULL;
float size = 0;
hwnd = GetSafeHwnd();
::SendMessage( hwnd, EM_GETOLEINTERFACE, 0, (LPARAM)&pUnk );
if ( pUnk && pUnk->QueryIn... |
56,659,834 | I want to get the text of a tag and span tag at the same time.
```
<td class="desc_autoHeight">
<a rel="nofollow" href="#" target="_blank">Silicon Power</a>
<br><span class="FreeGift">48 Hours Only</span>
</td>
<td class="desc_autoHeight">
... | 2019/06/19 | ['https://Stackoverflow.com/questions/56659834', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9730468/'] | I suggest you create an array to store all your `a` elements like so:
```
var arr = [10, 15, 20];
```
Which you can then loop over using a for loop. In the array the 0th index represents the `a1` and the n-1th index represents `a*n*`:
```js
var arr = [10, 15, 20];
for (var i = 0; i < arr.length; i++) {
console.lo... | ```
var a = [10, 15, 20];
for (var i=0; i<a.length; i++){
console.log("The value of a[i] is", a[i]);
}
``` |
20,939,193 | I am trying to wrap my head around network sockets. So far my understanding is that a server creates a new socket that is bound to the specific port. Then it listens to this socket to deal with client requests.
I've read this tutorial <http://docs.oracle.com/javase/tutorial/networking/sockets/definition.html> and it ... | 2014/01/05 | ['https://Stackoverflow.com/questions/20939193', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1745356/'] | 1. No. It means that an incoming connection arrived at the server.
2. No. It gets closed if the server closes it. Not otherwise.
3. No. It means that the incoming connection causes a connection to be fully formed and a socket created at the server to represent the server-end endpoint of it.
4. (a) No. A new socket is c... | 1) An incoming connection has arrived
2) Socket doesn't get closed
3) There is server socket and just socket. Server socket.accept returns a socket object when a client connects |
206,967 | This is my first Atmega project so I have following questions:
1. Do I have to connect all those gnds and vcc's?
2. In programming I used Vcc Reset Gnd Tx Rx SClk of USART0 is that okay?
3. I didn't used external clock generator (quarks) because I'm planning to use inside clock?
4. Is there any fundamental circuits or... | 2015/12/20 | ['https://electronics.stackexchange.com/questions/206967', 'https://electronics.stackexchange.com', 'https://electronics.stackexchange.com/users/89445/'] | 1. **Yes.**
2. Only if you've programmed it with a serial bootloader already. Otherwise use ISP or HVPP as normal.
3. Okay? This is not a question.
4. AVCC must be connected. You probably also want to connect nPEN to a switch.
5. No. They come unprogrammed from the factory other than the ATmega103 compatibility fuse. D... | @1: Yes, you have to connect all VCC and GND pins. This includes AVCC and AGND.
@2: Does the device run your program? Did the programmer return any error code?
@4: Connect a decoupling capacitor for every single VCC pin. Rule of thumb 100nF ceramic.
@5: Some devices may support JTAG testing or similar debug interfac... |
206,967 | This is my first Atmega project so I have following questions:
1. Do I have to connect all those gnds and vcc's?
2. In programming I used Vcc Reset Gnd Tx Rx SClk of USART0 is that okay?
3. I didn't used external clock generator (quarks) because I'm planning to use inside clock?
4. Is there any fundamental circuits or... | 2015/12/20 | ['https://electronics.stackexchange.com/questions/206967', 'https://electronics.stackexchange.com', 'https://electronics.stackexchange.com/users/89445/'] | 1. Yes. It is also recommended to place a 100nF capacitor as close to VCC and GND of every pair. On most modern devices you will see VCC/GND placed next to each other to make that easier.
2. Normally a microcontroller is programmed in-circuit via a specific port. On Atmega's this is usually some sort of SPI port (calle... | @1: Yes, you have to connect all VCC and GND pins. This includes AVCC and AGND.
@2: Does the device run your program? Did the programmer return any error code?
@4: Connect a decoupling capacitor for every single VCC pin. Rule of thumb 100nF ceramic.
@5: Some devices may support JTAG testing or similar debug interfac... |
19,112,318 | I want to be able to wrap text if there is a resizing of the window, I know this can be done as there have been other questions similar to mine in SO. (I guess this [one](https://stackoverflow.com/questions/18377376/how-to-get-textcolumns-to-auto-wrap-in-zurb-foundation-v3-2-5) would qualify )
I am using Foundation 4 ... | 2013/10/01 | ['https://Stackoverflow.com/questions/19112318', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1414710/'] | Use dynamic memory allocation.
```
Items **type;
type = malloc(sizeof (Items *) * typenum);
for (int i = 0; i < typenum; i++)
type[i] = malloc(sizeof Items) * typetotal);
```
You need to manually free the allocated memory after using the array.
```
for (int i = 0; i < typenum; i++)
free(types[i]);
free(ty... | If `typenum` and `typetotal` increase as your program runs be sure to use `realloc`, which will reallocate more memory and keep the contents. You'll need to allocate the first dimension of the array like this:
```
myArray = realloc(myArray, sizeof(Items*) * typenum);
```
and then allocate the second dimension for ea... |
53,963,876 | I am a new user to Laravel and have came from craft cms. On my homepage I want the navigation to be transparent and have a black background on all other pages.
To do this I have added a class to the homepage header called header-home. I craft to add this class to the homepage inside the layout file I wrote this:
```... | 2018/12/28 | ['https://Stackoverflow.com/questions/53963876', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3479267/'] | You can send the class from controller:
```
public function myAction
{
...
return view('home', ['layoutClass'=>'dark']);
}
<header class="{{ isset($layoutClass) ? $layoutClass:'') }} />
```
or you can match the route in the view:
```
<header class="{{ (\Request::route()->getName() == 'myRoute') ? 'dark':''... | I found the best way for me was to use an if statement in blade and check the route, below is how I done it:
```
@if (\Request::is('/'))
<img class="nav-logo" src="img/logo-light.svg">
@else
<img class="nav-logo" src="img/logo-dark.svg">
@endif
``` |
40,208,857 | I have a question about the following code.
```
public class test
{
public static void main (String[] args)
{
int a = 0;
int b = 0;
for (int i = 0; i < 5; i++); {
b = b + a;
a++;
}
System.out.println(b);
```
Why is the output of this 0? As you can see I'm a complete begi... | 2016/10/23 | ['https://Stackoverflow.com/questions/40208857', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7062013/'] | For loops iterate over the statement or block immediately following the for statement. In this case you have a stray semicolon causing the next statement to be empty. Remove it and your code will work as indended
Replace:
```
for (int i = 0; i < 5; i++); {
b = b + a;
a++;
}
```
-with-
```
for (int i = 0; ... | Just remove the semicolon after the for loop statement, otherwise the body surrounded by the curly braces will not be considered under the for loop.
Replace the following:
```
for (int i = 0; i < 5; i++); {
^ <--- remove it
b = b + a;
a++;
}
```
by
```
for (int i = 0; i < 5; i+... |
40,208,857 | I have a question about the following code.
```
public class test
{
public static void main (String[] args)
{
int a = 0;
int b = 0;
for (int i = 0; i < 5; i++); {
b = b + a;
a++;
}
System.out.println(b);
```
Why is the output of this 0? As you can see I'm a complete begi... | 2016/10/23 | ['https://Stackoverflow.com/questions/40208857', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7062013/'] | It does not return 0. In does not return anything as there are mistakes in your code.
After the for loop, there is no ;
```
public static void main(String[] args){
int a = 0;
int b = 0;
for (int i = 0; i < 5; i++) {
b = b + a;
a++;
}
System.out.println(b);
}
``` | Just remove the semicolon after the for loop statement, otherwise the body surrounded by the curly braces will not be considered under the for loop.
Replace the following:
```
for (int i = 0; i < 5; i++); {
^ <--- remove it
b = b + a;
a++;
}
```
by
```
for (int i = 0; i < 5; i+... |
61,629,887 | **Problem :**
Build a program that reads two strings from the keyboard and generates a third string which consists of combining two strings in such a way that the characters of the first string are placed in odd positions while the characters of the second string in even positions. The length of the new string will be... | 2020/05/06 | ['https://Stackoverflow.com/questions/61629887', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/'] | This can be done in using the popular requests library
```
import requests
url = 'https://www.google.com'
headers=requests.head(url).headers
downloadable = 'attachment' in headers.get('Content-Disposition', '')
```
[Content Disposition Header reference](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Conte... | On HTTP protocol level itself, there is no distinction between downloadable and non-downloadable URL. There is an HTTP request and there is a subsequent response. Response body can be a binary file, HTML, image etc..
You can just request the HTTP response header and look for `Content-Type:` and decide whether you want... |
61,629,887 | **Problem :**
Build a program that reads two strings from the keyboard and generates a third string which consists of combining two strings in such a way that the characters of the first string are placed in odd positions while the characters of the second string in even positions. The length of the new string will be... | 2020/05/06 | ['https://Stackoverflow.com/questions/61629887', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/'] | So I tried searching for a better way, the site link which I was checking was a bit tricky
most stackoverflow answers mentioned about using head request to get response header, but the site I was checking returned 404 error.When I use get request the whole file is downloaded before outputing the header.My friend sugges... | On HTTP protocol level itself, there is no distinction between downloadable and non-downloadable URL. There is an HTTP request and there is a subsequent response. Response body can be a binary file, HTML, image etc..
You can just request the HTTP response header and look for `Content-Type:` and decide whether you want... |
61,629,887 | **Problem :**
Build a program that reads two strings from the keyboard and generates a third string which consists of combining two strings in such a way that the characters of the first string are placed in odd positions while the characters of the second string in even positions. The length of the new string will be... | 2020/05/06 | ['https://Stackoverflow.com/questions/61629887', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/'] | On HTTP protocol level itself, there is no distinction between downloadable and non-downloadable URL. There is an HTTP request and there is a subsequent response. Response body can be a binary file, HTML, image etc..
You can just request the HTTP response header and look for `Content-Type:` and decide whether you want... | Downloadable files must have Content-Length in headers :
```
import requests
r = requests.get(url, stream=True)
try:
print(r.headers['content-length'])
except:
print("Not Downloadable")
``` |
61,629,887 | **Problem :**
Build a program that reads two strings from the keyboard and generates a third string which consists of combining two strings in such a way that the characters of the first string are placed in odd positions while the characters of the second string in even positions. The length of the new string will be... | 2020/05/06 | ['https://Stackoverflow.com/questions/61629887', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/'] | This can be done in using the popular requests library
```
import requests
url = 'https://www.google.com'
headers=requests.head(url).headers
downloadable = 'attachment' in headers.get('Content-Disposition', '')
```
[Content Disposition Header reference](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Conte... | So I tried searching for a better way, the site link which I was checking was a bit tricky
most stackoverflow answers mentioned about using head request to get response header, but the site I was checking returned 404 error.When I use get request the whole file is downloaded before outputing the header.My friend sugges... |
61,629,887 | **Problem :**
Build a program that reads two strings from the keyboard and generates a third string which consists of combining two strings in such a way that the characters of the first string are placed in odd positions while the characters of the second string in even positions. The length of the new string will be... | 2020/05/06 | ['https://Stackoverflow.com/questions/61629887', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/'] | This can be done in using the popular requests library
```
import requests
url = 'https://www.google.com'
headers=requests.head(url).headers
downloadable = 'attachment' in headers.get('Content-Disposition', '')
```
[Content Disposition Header reference](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Conte... | Downloadable files must have Content-Length in headers :
```
import requests
r = requests.get(url, stream=True)
try:
print(r.headers['content-length'])
except:
print("Not Downloadable")
``` |
61,629,887 | **Problem :**
Build a program that reads two strings from the keyboard and generates a third string which consists of combining two strings in such a way that the characters of the first string are placed in odd positions while the characters of the second string in even positions. The length of the new string will be... | 2020/05/06 | ['https://Stackoverflow.com/questions/61629887', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/'] | So I tried searching for a better way, the site link which I was checking was a bit tricky
most stackoverflow answers mentioned about using head request to get response header, but the site I was checking returned 404 error.When I use get request the whole file is downloaded before outputing the header.My friend sugges... | Downloadable files must have Content-Length in headers :
```
import requests
r = requests.get(url, stream=True)
try:
print(r.headers['content-length'])
except:
print("Not Downloadable")
``` |
85 | Neutron mass: 1.008664 u
Proton mass: 1.007276 u
Why the discrepancy?
On a related note, how does one go about measuring the mass of a neutron or proton, anyway? | 2010/11/02 | ['https://physics.stackexchange.com/questions/85', 'https://physics.stackexchange.com', 'https://physics.stackexchange.com/users/104/'] | Masses and coupling between quarks are free parameters in the standard model, so there is not real explanation to that fact.
About the measurment: you can have a look at this [wikipedia article about Penning traps](http://en.wikipedia.org/wiki/Penning_trap) which are devices used for precision measurements for nucleus... | A proton is made of two up quarks and a down quark, whereas a neutron is made of two down quarks and an up quark. The quark masses contribute very little of the actual mass of the proton and neutron, which mostly arises from energy associated with the strong interactions among the quarks. Still, they do contribute a sm... |
85 | Neutron mass: 1.008664 u
Proton mass: 1.007276 u
Why the discrepancy?
On a related note, how does one go about measuring the mass of a neutron or proton, anyway? | 2010/11/02 | ['https://physics.stackexchange.com/questions/85', 'https://physics.stackexchange.com', 'https://physics.stackexchange.com/users/104/'] | Masses and coupling between quarks are free parameters in the standard model, so there is not real explanation to that fact.
About the measurment: you can have a look at this [wikipedia article about Penning traps](http://en.wikipedia.org/wiki/Penning_trap) which are devices used for precision measurements for nucleus... | We can write approximately assuming strong energy $E\_s$ contribution inside proton and neutron is almost the same:
$m\_n c^2 = m\_d c^2 +m\_d c^2 +m\_u c^2 +E\_s $
$m\_p c^2 = m\_u c^2 +m\_u c^2 +m\_d c^2 +E\_s +E\_c $
in terms of quark u and d masses and $E\_c$ - electrostatic energy around and inside the proton, w... |
85 | Neutron mass: 1.008664 u
Proton mass: 1.007276 u
Why the discrepancy?
On a related note, how does one go about measuring the mass of a neutron or proton, anyway? | 2010/11/02 | ['https://physics.stackexchange.com/questions/85', 'https://physics.stackexchange.com', 'https://physics.stackexchange.com/users/104/'] | Masses and coupling between quarks are free parameters in the standard model, so there is not real explanation to that fact.
About the measurment: you can have a look at this [wikipedia article about Penning traps](http://en.wikipedia.org/wiki/Penning_trap) which are devices used for precision measurements for nucleus... | A recent paper [1] has computed the mass difference ab initio from the theory, using a technique know as lattice, where one writes the equations on a discretised spacetime (this is conceptually similar to what engineers do with finite elements method to study how a beam of metal flexes for example). They took into acco... |
85 | Neutron mass: 1.008664 u
Proton mass: 1.007276 u
Why the discrepancy?
On a related note, how does one go about measuring the mass of a neutron or proton, anyway? | 2010/11/02 | ['https://physics.stackexchange.com/questions/85', 'https://physics.stackexchange.com', 'https://physics.stackexchange.com/users/104/'] | A proton is made of two up quarks and a down quark, whereas a neutron is made of two down quarks and an up quark. The quark masses contribute very little of the actual mass of the proton and neutron, which mostly arises from energy associated with the strong interactions among the quarks. Still, they do contribute a sm... | We can write approximately assuming strong energy $E\_s$ contribution inside proton and neutron is almost the same:
$m\_n c^2 = m\_d c^2 +m\_d c^2 +m\_u c^2 +E\_s $
$m\_p c^2 = m\_u c^2 +m\_u c^2 +m\_d c^2 +E\_s +E\_c $
in terms of quark u and d masses and $E\_c$ - electrostatic energy around and inside the proton, w... |
85 | Neutron mass: 1.008664 u
Proton mass: 1.007276 u
Why the discrepancy?
On a related note, how does one go about measuring the mass of a neutron or proton, anyway? | 2010/11/02 | ['https://physics.stackexchange.com/questions/85', 'https://physics.stackexchange.com', 'https://physics.stackexchange.com/users/104/'] | A proton is made of two up quarks and a down quark, whereas a neutron is made of two down quarks and an up quark. The quark masses contribute very little of the actual mass of the proton and neutron, which mostly arises from energy associated with the strong interactions among the quarks. Still, they do contribute a sm... | A recent paper [1] has computed the mass difference ab initio from the theory, using a technique know as lattice, where one writes the equations on a discretised spacetime (this is conceptually similar to what engineers do with finite elements method to study how a beam of metal flexes for example). They took into acco... |
85 | Neutron mass: 1.008664 u
Proton mass: 1.007276 u
Why the discrepancy?
On a related note, how does one go about measuring the mass of a neutron or proton, anyway? | 2010/11/02 | ['https://physics.stackexchange.com/questions/85', 'https://physics.stackexchange.com', 'https://physics.stackexchange.com/users/104/'] | A recent paper [1] has computed the mass difference ab initio from the theory, using a technique know as lattice, where one writes the equations on a discretised spacetime (this is conceptually similar to what engineers do with finite elements method to study how a beam of metal flexes for example). They took into acco... | We can write approximately assuming strong energy $E\_s$ contribution inside proton and neutron is almost the same:
$m\_n c^2 = m\_d c^2 +m\_d c^2 +m\_u c^2 +E\_s $
$m\_p c^2 = m\_u c^2 +m\_u c^2 +m\_d c^2 +E\_s +E\_c $
in terms of quark u and d masses and $E\_c$ - electrostatic energy around and inside the proton, w... |
37,548,915 | I try to upload some videos to youtube. Somewhere in the stack it comes down to a `http.Client`. This part somehow behaves weird.
The request and everything is created inside the youtube package.
After doing my request in the end it fails with:
```
Error uploading video: Post https://www.googleapis.com/upload/youtu... | 2016/05/31 | ['https://Stackoverflow.com/questions/37548915', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/450598/'] | Ok, I figured it out. The problem was not the call to YouTube itself.
The library tried to refresh the token in the background but there was something wrong with the `TokenURL`.
Ensuring there is a valid URL fixed the problem.
A nicer error message would have helped a lot, but well... | This will probably apply to very, very few who arrive here: but my problem was that a [RoundTripper](https://pkg.go.dev/net/http#RoundTripper) was overriding the Host field with an empty string. |
340,403 | I have a validation Rule that I require assistance with , this validation rule should only allow fields to be updated by the two profile ids specified:
```
NOT(
OR(
$Profile.Id = "00e58000000yYlm",
$Profile.Id = "00e58000000E6lK",
AND(
ISPICKVAL((WorkOrder.Status ), 'WithTechnic... | 2021/04/14 | ['https://salesforce.stackexchange.com/questions/340403', 'https://salesforce.stackexchange.com', 'https://salesforce.stackexchange.com/users/94096/'] | The big thing to keep in mind with validation rules is that their purpose isn't really to tell you what data is valid, but rather to tell you what data is *invalid*. It's a small shift in how you mentally frame the problem, but one that I find very helpful.
Instead of stating the outcome as "these profiles should be a... | The issue is with OR operator on profile, AND operator on the status field, and NOT function. You haven't used/close them at appropriate places.
Below is the updated snippet.
```
AND(
ISPICKVAL(Status, "WithTechnician"),
NOT(OR(
$Profile.Id = "00e58000000yYlm",
$Profile.Id = "00e58000000E6lK")),
OR(
ISCHANGED(Propose... |
42,713,907 | I can fill my array,and found the two of biggest numbers.But,i can not delete it.May u guys could help me?
```
int n = sc.nextInt();
int [] myArray = new int[n];
int first = 0;
int second = 0;
for(int i = 0; i < myArray.length; i++) {
int num = sc.nextInt();`
if (num > first) {
secon... | 2017/03/10 | ['https://Stackoverflow.com/questions/42713907', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7513001/'] | You may create a new array (in this case, `filteredArray`) in which you store all the elements in `myArray` but the greatest two.
Also, it is better to save the indexes of the two biggest numbers rather than their values in order to be able to filter them out more easily.
This should work (you will find the array you ... | May be following code will useful for you
```
again :
for (int i = 0; i < n; i++)
{
if ((a[i] < a[i+1]) && (i+1)<n)
{
temp = a[i];
a[i] = a[i+1];
a[i+1] = temp;
continue again;
}
}
System.out.println("The largest " + a[0] + " & second large... |
42,713,907 | I can fill my array,and found the two of biggest numbers.But,i can not delete it.May u guys could help me?
```
int n = sc.nextInt();
int [] myArray = new int[n];
int first = 0;
int second = 0;
for(int i = 0; i < myArray.length; i++) {
int num = sc.nextInt();`
if (num > first) {
secon... | 2017/03/10 | ['https://Stackoverflow.com/questions/42713907', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7513001/'] | If you are using Java 8 you can sort your array then you can loop throw your array and set it values to the other one avoiding the last two Integer for example :
```
//Your array
Integer[] array = {8, 99, 6, 336, 2};
//sort your array this can give your [2, 6, 8, 99, 336]
Arrays.sort(array);
//create a new array wit... | You may create a new array (in this case, `filteredArray`) in which you store all the elements in `myArray` but the greatest two.
Also, it is better to save the indexes of the two biggest numbers rather than their values in order to be able to filter them out more easily.
This should work (you will find the array you ... |
42,713,907 | I can fill my array,and found the two of biggest numbers.But,i can not delete it.May u guys could help me?
```
int n = sc.nextInt();
int [] myArray = new int[n];
int first = 0;
int second = 0;
for(int i = 0; i < myArray.length; i++) {
int num = sc.nextInt();`
if (num > first) {
secon... | 2017/03/10 | ['https://Stackoverflow.com/questions/42713907', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7513001/'] | Sort your arrays (default sort is ascending, i.e. from smallest to largest) then make a new copy of the array without the last two elements.
```
if(myArray.length > 2) {
Arrays.sort(myArray);
myArray = Arrays.copyOf(myArray, myArray.length-2);
} else {
throw new IllegalArgumentException("Need moar elements... | You may create a new array (in this case, `filteredArray`) in which you store all the elements in `myArray` but the greatest two.
Also, it is better to save the indexes of the two biggest numbers rather than their values in order to be able to filter them out more easily.
This should work (you will find the array you ... |
42,713,907 | I can fill my array,and found the two of biggest numbers.But,i can not delete it.May u guys could help me?
```
int n = sc.nextInt();
int [] myArray = new int[n];
int first = 0;
int second = 0;
for(int i = 0; i < myArray.length; i++) {
int num = sc.nextInt();`
if (num > first) {
secon... | 2017/03/10 | ['https://Stackoverflow.com/questions/42713907', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7513001/'] | If you are using Java 8 you can sort your array then you can loop throw your array and set it values to the other one avoiding the last two Integer for example :
```
//Your array
Integer[] array = {8, 99, 6, 336, 2};
//sort your array this can give your [2, 6, 8, 99, 336]
Arrays.sort(array);
//create a new array wit... | May be following code will useful for you
```
again :
for (int i = 0; i < n; i++)
{
if ((a[i] < a[i+1]) && (i+1)<n)
{
temp = a[i];
a[i] = a[i+1];
a[i+1] = temp;
continue again;
}
}
System.out.println("The largest " + a[0] + " & second large... |
42,713,907 | I can fill my array,and found the two of biggest numbers.But,i can not delete it.May u guys could help me?
```
int n = sc.nextInt();
int [] myArray = new int[n];
int first = 0;
int second = 0;
for(int i = 0; i < myArray.length; i++) {
int num = sc.nextInt();`
if (num > first) {
secon... | 2017/03/10 | ['https://Stackoverflow.com/questions/42713907', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7513001/'] | Sort your arrays (default sort is ascending, i.e. from smallest to largest) then make a new copy of the array without the last two elements.
```
if(myArray.length > 2) {
Arrays.sort(myArray);
myArray = Arrays.copyOf(myArray, myArray.length-2);
} else {
throw new IllegalArgumentException("Need moar elements... | May be following code will useful for you
```
again :
for (int i = 0; i < n; i++)
{
if ((a[i] < a[i+1]) && (i+1)<n)
{
temp = a[i];
a[i] = a[i+1];
a[i+1] = temp;
continue again;
}
}
System.out.println("The largest " + a[0] + " & second large... |
42,713,907 | I can fill my array,and found the two of biggest numbers.But,i can not delete it.May u guys could help me?
```
int n = sc.nextInt();
int [] myArray = new int[n];
int first = 0;
int second = 0;
for(int i = 0; i < myArray.length; i++) {
int num = sc.nextInt();`
if (num > first) {
secon... | 2017/03/10 | ['https://Stackoverflow.com/questions/42713907', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7513001/'] | You can simply sort the array and find or remove the two biggest elements.
```
int [] myArray = new int[]{14,5,2,16,18,20};
System.out.println("The original array is "+ " " +Arrays.toString(myArray));
Arrays.sort(myArray);
System.out.println("The sorted array is "+ " " +Arrays.toString(myArray));;
int fisrtmax = myA... | May be following code will useful for you
```
again :
for (int i = 0; i < n; i++)
{
if ((a[i] < a[i+1]) && (i+1)<n)
{
temp = a[i];
a[i] = a[i+1];
a[i+1] = temp;
continue again;
}
}
System.out.println("The largest " + a[0] + " & second large... |
42,713,907 | I can fill my array,and found the two of biggest numbers.But,i can not delete it.May u guys could help me?
```
int n = sc.nextInt();
int [] myArray = new int[n];
int first = 0;
int second = 0;
for(int i = 0; i < myArray.length; i++) {
int num = sc.nextInt();`
if (num > first) {
secon... | 2017/03/10 | ['https://Stackoverflow.com/questions/42713907', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7513001/'] | If you are using Java 8 you can sort your array then you can loop throw your array and set it values to the other one avoiding the last two Integer for example :
```
//Your array
Integer[] array = {8, 99, 6, 336, 2};
//sort your array this can give your [2, 6, 8, 99, 336]
Arrays.sort(array);
//create a new array wit... | You can simply sort the array and find or remove the two biggest elements.
```
int [] myArray = new int[]{14,5,2,16,18,20};
System.out.println("The original array is "+ " " +Arrays.toString(myArray));
Arrays.sort(myArray);
System.out.println("The sorted array is "+ " " +Arrays.toString(myArray));;
int fisrtmax = myA... |
42,713,907 | I can fill my array,and found the two of biggest numbers.But,i can not delete it.May u guys could help me?
```
int n = sc.nextInt();
int [] myArray = new int[n];
int first = 0;
int second = 0;
for(int i = 0; i < myArray.length; i++) {
int num = sc.nextInt();`
if (num > first) {
secon... | 2017/03/10 | ['https://Stackoverflow.com/questions/42713907', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7513001/'] | Sort your arrays (default sort is ascending, i.e. from smallest to largest) then make a new copy of the array without the last two elements.
```
if(myArray.length > 2) {
Arrays.sort(myArray);
myArray = Arrays.copyOf(myArray, myArray.length-2);
} else {
throw new IllegalArgumentException("Need moar elements... | You can simply sort the array and find or remove the two biggest elements.
```
int [] myArray = new int[]{14,5,2,16,18,20};
System.out.println("The original array is "+ " " +Arrays.toString(myArray));
Arrays.sort(myArray);
System.out.println("The sorted array is "+ " " +Arrays.toString(myArray));;
int fisrtmax = myA... |
30,941,209 | I have a set of defined JS functions. I want users to pick a subset of these using a comma separated string. Then I want to randomly pick from their subset, and evaluate the function selected. I have this 99% working, except it is not evaluating for some reason. Why does console keep telling me 'undefined is not a func... | 2015/06/19 | ['https://Stackoverflow.com/questions/30941209', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/422203/'] | I could see two things wrong:
1. Your functions were not assigned to the `window`
2. Your `"effect"` variable contained leading whitespace
I have corrected the above points here: <http://jsfiddle.net/ftaq8q4m/1/>
This appears to have resolved the issue you described.
**Example:**
```
window.func1 = function() {
... | You approach is not working because you have a space between the function names
`var effectSubset = 'func4, func5, func6';` After split the variable effect has a space before the name of the functions.
So the functions being called are `func4`, `<space>func5`, `<space>func6` with a space which do not exist.
Firstly,... |
30,941,209 | I have a set of defined JS functions. I want users to pick a subset of these using a comma separated string. Then I want to randomly pick from their subset, and evaluate the function selected. I have this 99% working, except it is not evaluating for some reason. Why does console keep telling me 'undefined is not a func... | 2015/06/19 | ['https://Stackoverflow.com/questions/30941209', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/422203/'] | I could see two things wrong:
1. Your functions were not assigned to the `window`
2. Your `"effect"` variable contained leading whitespace
I have corrected the above points here: <http://jsfiddle.net/ftaq8q4m/1/>
This appears to have resolved the issue you described.
**Example:**
```
window.func1 = function() {
... | There are two issues: first there are leading whitespaces after you split the input and second, JSFiddle is wrapping your script in an IIFE. The first issue can be solved by either splitting with ' ,' or mapping the resulting array with a trim function. The second issue can be solved by creating an object to assign the... |
30,941,209 | I have a set of defined JS functions. I want users to pick a subset of these using a comma separated string. Then I want to randomly pick from their subset, and evaluate the function selected. I have this 99% working, except it is not evaluating for some reason. Why does console keep telling me 'undefined is not a func... | 2015/06/19 | ['https://Stackoverflow.com/questions/30941209', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/422203/'] | You approach is not working because you have a space between the function names
`var effectSubset = 'func4, func5, func6';` After split the variable effect has a space before the name of the functions.
So the functions being called are `func4`, `<space>func5`, `<space>func6` with a space which do not exist.
Firstly,... | There are two issues: first there are leading whitespaces after you split the input and second, JSFiddle is wrapping your script in an IIFE. The first issue can be solved by either splitting with ' ,' or mapping the resulting array with a trim function. The second issue can be solved by creating an object to assign the... |
341,338 | I have the following Perl scripts (though this applies to Python and other scripting languages): `script1.pl`, `script2.pl`, `script3.pl`
The way these scripts where written, users execute them with input flags, and the output is a file saved.
```
perl script1.pl --i input1.tsv ## this outputs the file `outputs1`
... | 2017/01/30 | ['https://unix.stackexchange.com/questions/341338', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/115891/'] | It seems that the path node\_exporter is not correct.
```
ExecStart=/usr/bin/node_exporter
```
I have another path to it on Ubuntu 16.04
```
~# cat /etc/issue
Ubuntu 16.04.3 LTS \n \l
~# which node_exporter
/usr/sbin/node_exporter
```
If it's not the root of the issue, check your `/var/log/syslog`. It must s... | Try to launch the command you're passing to `ExecStart` manually to verify whether it runs.
I got the 203 error as well and apparently it was due to downloading/using the binary for the wrong platform. I was using "Darwin" instead of "Linux".
```
Process: 20340 ExecStart=/usr/local/bin/node_exporter (code=exited, s... |
341,338 | I have the following Perl scripts (though this applies to Python and other scripting languages): `script1.pl`, `script2.pl`, `script3.pl`
The way these scripts where written, users execute them with input flags, and the output is a file saved.
```
perl script1.pl --i input1.tsv ## this outputs the file `outputs1`
... | 2017/01/30 | ['https://unix.stackexchange.com/questions/341338', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/115891/'] | It seems that the path node\_exporter is not correct.
```
ExecStart=/usr/bin/node_exporter
```
I have another path to it on Ubuntu 16.04
```
~# cat /etc/issue
Ubuntu 16.04.3 LTS \n \l
~# which node_exporter
/usr/sbin/node_exporter
```
If it's not the root of the issue, check your `/var/log/syslog`. It must s... | Here is the `/etc/systemd/system/node_exporter.service`
```
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter --collector.nfs --collector.nfsd
[Install]
WantedBy=multi-user.targe... |
341,338 | I have the following Perl scripts (though this applies to Python and other scripting languages): `script1.pl`, `script2.pl`, `script3.pl`
The way these scripts where written, users execute them with input flags, and the output is a file saved.
```
perl script1.pl --i input1.tsv ## this outputs the file `outputs1`
... | 2017/01/30 | ['https://unix.stackexchange.com/questions/341338', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/115891/'] | It seems that the path node\_exporter is not correct.
```
ExecStart=/usr/bin/node_exporter
```
I have another path to it on Ubuntu 16.04
```
~# cat /etc/issue
Ubuntu 16.04.3 LTS \n \l
~# which node_exporter
/usr/sbin/node_exporter
```
If it's not the root of the issue, check your `/var/log/syslog`. It must s... | I got this error. Solved as @Saex.
Reason for getting this error is that I have downloaded the wrong package `node_exporter-1.2.2.darwin-amd64.tar.gz` instead of `node_exporter-1.2.2.linux-amd64.tar.gz`
```
node_exporter.service - Node Exporter
Loaded: loaded (/etc/systemd/system/node_exporter.service; e... |
341,338 | I have the following Perl scripts (though this applies to Python and other scripting languages): `script1.pl`, `script2.pl`, `script3.pl`
The way these scripts where written, users execute them with input flags, and the output is a file saved.
```
perl script1.pl --i input1.tsv ## this outputs the file `outputs1`
... | 2017/01/30 | ['https://unix.stackexchange.com/questions/341338', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/115891/'] | I solved the problem like this...
**Node exporter:**
```none
ExecStart=/bin/sh -c '/usr/local/bin/node_exporter'
```
**Mysql\_exporter:**
```none
=/bin/sh -c '/usr/local/bin/mysqld_exporter \
--config.my-cnf /etc/.mysqld_exporter.cnf \
--collect.global_status \
--collect.info_schema.innodb_metrics \
--collect.... | It seems that the path node\_exporter is not correct.
```
ExecStart=/usr/bin/node_exporter
```
I have another path to it on Ubuntu 16.04
```
~# cat /etc/issue
Ubuntu 16.04.3 LTS \n \l
~# which node_exporter
/usr/sbin/node_exporter
```
If it's not the root of the issue, check your `/var/log/syslog`. It must s... |
341,338 | I have the following Perl scripts (though this applies to Python and other scripting languages): `script1.pl`, `script2.pl`, `script3.pl`
The way these scripts where written, users execute them with input flags, and the output is a file saved.
```
perl script1.pl --i input1.tsv ## this outputs the file `outputs1`
... | 2017/01/30 | ['https://unix.stackexchange.com/questions/341338', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/115891/'] | Try to launch the command you're passing to `ExecStart` manually to verify whether it runs.
I got the 203 error as well and apparently it was due to downloading/using the binary for the wrong platform. I was using "Darwin" instead of "Linux".
```
Process: 20340 ExecStart=/usr/local/bin/node_exporter (code=exited, s... | I got this error. Solved as @Saex.
Reason for getting this error is that I have downloaded the wrong package `node_exporter-1.2.2.darwin-amd64.tar.gz` instead of `node_exporter-1.2.2.linux-amd64.tar.gz`
```
node_exporter.service - Node Exporter
Loaded: loaded (/etc/systemd/system/node_exporter.service; e... |
341,338 | I have the following Perl scripts (though this applies to Python and other scripting languages): `script1.pl`, `script2.pl`, `script3.pl`
The way these scripts where written, users execute them with input flags, and the output is a file saved.
```
perl script1.pl --i input1.tsv ## this outputs the file `outputs1`
... | 2017/01/30 | ['https://unix.stackexchange.com/questions/341338', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/115891/'] | I solved the problem like this...
**Node exporter:**
```none
ExecStart=/bin/sh -c '/usr/local/bin/node_exporter'
```
**Mysql\_exporter:**
```none
=/bin/sh -c '/usr/local/bin/mysqld_exporter \
--config.my-cnf /etc/.mysqld_exporter.cnf \
--collect.global_status \
--collect.info_schema.innodb_metrics \
--collect.... | Try to launch the command you're passing to `ExecStart` manually to verify whether it runs.
I got the 203 error as well and apparently it was due to downloading/using the binary for the wrong platform. I was using "Darwin" instead of "Linux".
```
Process: 20340 ExecStart=/usr/local/bin/node_exporter (code=exited, s... |
341,338 | I have the following Perl scripts (though this applies to Python and other scripting languages): `script1.pl`, `script2.pl`, `script3.pl`
The way these scripts where written, users execute them with input flags, and the output is a file saved.
```
perl script1.pl --i input1.tsv ## this outputs the file `outputs1`
... | 2017/01/30 | ['https://unix.stackexchange.com/questions/341338', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/115891/'] | Here is the `/etc/systemd/system/node_exporter.service`
```
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter --collector.nfs --collector.nfsd
[Install]
WantedBy=multi-user.targe... | I got this error. Solved as @Saex.
Reason for getting this error is that I have downloaded the wrong package `node_exporter-1.2.2.darwin-amd64.tar.gz` instead of `node_exporter-1.2.2.linux-amd64.tar.gz`
```
node_exporter.service - Node Exporter
Loaded: loaded (/etc/systemd/system/node_exporter.service; e... |
341,338 | I have the following Perl scripts (though this applies to Python and other scripting languages): `script1.pl`, `script2.pl`, `script3.pl`
The way these scripts where written, users execute them with input flags, and the output is a file saved.
```
perl script1.pl --i input1.tsv ## this outputs the file `outputs1`
... | 2017/01/30 | ['https://unix.stackexchange.com/questions/341338', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/115891/'] | I solved the problem like this...
**Node exporter:**
```none
ExecStart=/bin/sh -c '/usr/local/bin/node_exporter'
```
**Mysql\_exporter:**
```none
=/bin/sh -c '/usr/local/bin/mysqld_exporter \
--config.my-cnf /etc/.mysqld_exporter.cnf \
--collect.global_status \
--collect.info_schema.innodb_metrics \
--collect.... | Here is the `/etc/systemd/system/node_exporter.service`
```
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter --collector.nfs --collector.nfsd
[Install]
WantedBy=multi-user.targe... |
341,338 | I have the following Perl scripts (though this applies to Python and other scripting languages): `script1.pl`, `script2.pl`, `script3.pl`
The way these scripts where written, users execute them with input flags, and the output is a file saved.
```
perl script1.pl --i input1.tsv ## this outputs the file `outputs1`
... | 2017/01/30 | ['https://unix.stackexchange.com/questions/341338', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/115891/'] | I solved the problem like this...
**Node exporter:**
```none
ExecStart=/bin/sh -c '/usr/local/bin/node_exporter'
```
**Mysql\_exporter:**
```none
=/bin/sh -c '/usr/local/bin/mysqld_exporter \
--config.my-cnf /etc/.mysqld_exporter.cnf \
--collect.global_status \
--collect.info_schema.innodb_metrics \
--collect.... | I got this error. Solved as @Saex.
Reason for getting this error is that I have downloaded the wrong package `node_exporter-1.2.2.darwin-amd64.tar.gz` instead of `node_exporter-1.2.2.linux-amd64.tar.gz`
```
node_exporter.service - Node Exporter
Loaded: loaded (/etc/systemd/system/node_exporter.service; e... |
1,589,095 | In Algebra (2) I was told that if a polynomial had an even multiplicity for some $x=a$, then the graph touches $y=0$ at $x=a$ but doesn't cross $y=0$. Odd multiplicities go through the $x$-intercept. For example:$$y=x^2\to y=(x-0)(x-0)\to x=0,0$$And you can clearly see the graph "touches without intersecting" at $x=0$.... | 2015/12/26 | ['https://math.stackexchange.com/questions/1589095', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/272831/'] | Let $P(x) = Q(x)(x-a)^{2n}$ such that $(x-a)\nmid Q(x)$. In a small enough neighbourhood of $a$ (for instance one that contains no roots of $Q(x)$), then $Q(x)$ preserves sign. And $(x-a)^{2n}\geq 0$, therefore, in said neighbourhood, $P(x)$ preserves sign, i.e., the function does not cross the line $y=0$.
You can fin... | Suppose you have $f(x) = (x+6)(x-4)(x-7)^2$. If $x$ is near $7$ then $(x+6)(x-4)$ is near $(7+6)(7-4) =39$, so $f(x)$ is approximately $39(x-7)^2$. Notice that if $x$ is either a little bit more than $7$ or a little bit less, then $(x-7)^2$ is positive, but if $x$ is exactly $7$, then $(x-7)^2$ is $0$. Being positive o... |
27,767,713 | As a part of an internal project, I have to parse through a dns zone file records. The file looks roughly like this.
```
$ORIGIN 0001.test.domain.com.
test-qa CNAME test-qa.0001.test.domain.com.
$ORIGIN test-qa.domain.com.
unit-test01 A 192.168.0.2
$TTL 60 ; 1 minute
integration-tes... | 2015/01/04 | ['https://Stackoverflow.com/questions/27767713', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3354434/'] | Before we look at the detail of the problem, there's a few things that could be cleaned up in this code that would make the error easier to find. Following code quality guidelines make code easier to maintain and understand, in particular - variable names should always be descriptive and tell the reader what the variab... | The line of error is
```
data_dict[primary_key][default_ttl] = value
```
Because `data_dict[primary_key]` is a list and not a dictionary object. You can fix this by doing
```
data_dict[primary_key] = {default_ttl: value}
``` |
15,369 | I'm putting together a gaming rig with an i5 11600k (liquid cooled) and GIGABYTE Z590 mobo... average RAM, GIGABYTE AORUS NVMe Gen4 SSD, beefy PSU... everything is coming along nicely... with the end goal being to be playing on 1440p with in-game settings pretty high.
But now i need to choose my GPU. I have access to ... | 2021/10/04 | ['https://hardwarerecs.stackexchange.com/questions/15369', 'https://hardwarerecs.stackexchange.com', 'https://hardwarerecs.stackexchange.com/users/20243/'] | >
> If I opt for Additional 2.5" 2 TB 5400RPM SATA Hard Drive, the battery 4 cells 64Whr battery should be selected.
>
>
>
This is probably because the larger battery takes up the space where a 2.5" HDD can be installed.
>
> Does Using both SSD & SATA Hard drive impacts Laptop Performance?
>
>
>
There is no ... | It doesnt affect performance, as long as nothing is on the hard drive. If you actively use the hard drive, the app that uses the hard drive slows down to hard drive speed. For some tasks (like rendering a video), you can write to the hard drive without performance issues because the bottleneck is somewhere else (cpu) |
7,518,255 | I wonder, if you open a text file in Python. And then you'd like to search of words containing a number of letters.
Say you type in 6 different letters (a,b,c,d,e,f) you want to search.
You'd like to find words matching at least 3 letters.
Each letter can only appear once in a word.
And the letter 'a' always has to b... | 2011/09/22 | ['https://Stackoverflow.com/questions/7518255', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/959397/'] | Here is what I would do if I had to write this:
I'd have a function that, given a word, would check whether it satisfies the criteria and would return a boolean flag.
Then I'd have some code that would iterate over all words in the file, present each of them to the function, and print out those for which the function... | ```
words = 'fubar cadre obsequious xray'
def find_words(src, required=[], letters=[], min_match=3):
required = set(required)
letters = set(letters)
words = ((word, set(word)) for word in src.split())
words = (word for word in words if word[1].issuperset(required))
words = (word for word in words ... |
7,518,255 | I wonder, if you open a text file in Python. And then you'd like to search of words containing a number of letters.
Say you type in 6 different letters (a,b,c,d,e,f) you want to search.
You'd like to find words matching at least 3 letters.
Each letter can only appear once in a word.
And the letter 'a' always has to b... | 2011/09/22 | ['https://Stackoverflow.com/questions/7518255', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/959397/'] | Here is what I would do if I had to write this:
I'd have a function that, given a word, would check whether it satisfies the criteria and would return a boolean flag.
Then I'd have some code that would iterate over all words in the file, present each of them to the function, and print out those for which the function... | I agree with aix's general plan, but it's perhaps even more general than a 'design pattern,' and I'm not sure how far it gets you, since it boils down to, "figure out a way to check for what you want to find and then check everything you need to check."
Advice about how to find what you want to find: You've entered i... |
7,518,255 | I wonder, if you open a text file in Python. And then you'd like to search of words containing a number of letters.
Say you type in 6 different letters (a,b,c,d,e,f) you want to search.
You'd like to find words matching at least 3 letters.
Each letter can only appear once in a word.
And the letter 'a' always has to b... | 2011/09/22 | ['https://Stackoverflow.com/questions/7518255', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/959397/'] | Let's see...
```
return [x for x in document.split()
if 'a' in x and sum((1 if y in 'abcdef' else 0 for y in x)) >= 3]
```
`split` with no parameters acts as a "words" function, splitting on any whitespace and removing words that contain no characters. Then you check if the letter 'a' is in the word. If 'a' ... | ```
words = 'fubar cadre obsequious xray'
def find_words(src, required=[], letters=[], min_match=3):
required = set(required)
letters = set(letters)
words = ((word, set(word)) for word in src.split())
words = (word for word in words if word[1].issuperset(required))
words = (word for word in words ... |
7,518,255 | I wonder, if you open a text file in Python. And then you'd like to search of words containing a number of letters.
Say you type in 6 different letters (a,b,c,d,e,f) you want to search.
You'd like to find words matching at least 3 letters.
Each letter can only appear once in a word.
And the letter 'a' always has to b... | 2011/09/22 | ['https://Stackoverflow.com/questions/7518255', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/959397/'] | Let's see...
```
return [x for x in document.split()
if 'a' in x and sum((1 if y in 'abcdef' else 0 for y in x)) >= 3]
```
`split` with no parameters acts as a "words" function, splitting on any whitespace and removing words that contain no characters. Then you check if the letter 'a' is in the word. If 'a' ... | I agree with aix's general plan, but it's perhaps even more general than a 'design pattern,' and I'm not sure how far it gets you, since it boils down to, "figure out a way to check for what you want to find and then check everything you need to check."
Advice about how to find what you want to find: You've entered i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.