qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
59,763,708 | I'm having overflowed text and I want to display the number of words that are hidden by overflow.
For example: I'm having the string: `I want to see the overflowed words that are hidden in here`. And my div can only contain 3 words. So I want to see: `I want to +9`.
This is what I have:
```js
let items = [
"item ... | 2020/01/16 | [
"https://Stackoverflow.com/questions/59763708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3729184/"
] | ### UPDATE after comment:
Okay, after the clarification I think I have a better handle on what you are trying to achieve. The code below almost exactly does what you want - but this is not an elegant solution, for sure. The fixed width, the character-limit still being there as a constant are both liabilities (e.g. whe... | I think you can do it by using `el.offsetLeft - el.scrollLeft` and then `getBoundingClientRect()` to get the width and see if the element is inside the `<div my class="a">`:
<https://codepen.io/Alexander9111/pen/OJPaNBP>
So far I have only looped through to see which elements (spans) are inside, half-inside and outsi... |
27,512 | I noticed a few piles of soil near plants in the garden. Not sure which critter is doing it.
[](https://i.stack.imgur.com/m4POz.jpg)
[](https://i.stack.imgur.com/FBbSB.jpg)
So far I... | 2016/07/29 | [
"https://gardening.stackexchange.com/questions/27512",
"https://gardening.stackexchange.com",
"https://gardening.stackexchange.com/users/11971/"
] | Your location would be helpful here, but it appears that whatever it was is after insects, etc, that are living in the decomposing mulch layer (not plants). If it's not rodents, it could be possums, coons, etc rooting through. It looks to me more like something rooting, rather than a rodent tunneling. The best way to s... | This all depends on location of course. This looks like squirrel gopher. Larger than vole and shrews. Usually the preferred food are grubs. Occasionally they will eat roots, bulbs and tender plants as well. If you don't have a big community of grubs. Echnerwal's opinion to 'wait and see' is wise.
J. Musser's live tra... |
19,987,755 | basically my app has 2 activities.Say "A" and "B" . A launches B.
Activity B plays music(in a service) and also has a notification.
when the view is on activity B and i press back button ,and then i click on the the notification, activity B is opened with the state of activity completely lost and music also stops(not... | 2013/11/14 | [
"https://Stackoverflow.com/questions/19987755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2993677/"
] | To expand on the answers by Hendrik and Alasdair, I suggest looking into using the Decorator plugin.
<http://swiftmailer.org/docs/plugins.html#using-the-decorator-plugin>
Instead of manipulating the individual message parts, the plugin will replace the desired placeholders of the entire message for each recipient.
Fo... | According to the [Swift Mailer Docs](http://swiftmailer.org/docs/messages.html#setting-the-body-content), there is no such method as a `getBody()` really.
I would suggest you to store the actual message *template* containing your placeholders in a variable and use `setBody()` on every iteration to replace the complete... |
19,987,755 | basically my app has 2 activities.Say "A" and "B" . A launches B.
Activity B plays music(in a service) and also has a notification.
when the view is on activity B and i press back button ,and then i click on the the notification, activity B is opened with the state of activity completely lost and music also stops(not... | 2013/11/14 | [
"https://Stackoverflow.com/questions/19987755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2993677/"
] | To expand on the answers by Hendrik and Alasdair, I suggest looking into using the Decorator plugin.
<http://swiftmailer.org/docs/plugins.html#using-the-decorator-plugin>
Instead of manipulating the individual message parts, the plugin will replace the desired placeholders of the entire message for each recipient.
Fo... | @tetranz As @Hendrik outlines you can use `$message->getBody()` and `$message->setBody($body)` for the main body part.
You can access the parts (of the multipart `addPart()` you mention) via the same methods of the children. i.e. something similar to:
```
$children = $message->getChildren();
foreach($children as &$ch... |
15,344,451 | I have an interface that looks like this:
```
public interface IOpportunity
{
string Name { get; }
string Description { get; }
ILocation Location { get; }
}
public interface ILocation : IHierarchicalEntity
{
int OpptyCount { get; }
}
public interface IHierarchicalEntity
{
string SID { get; }
... | 2013/03/11 | [
"https://Stackoverflow.com/questions/15344451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1429064/"
] | You can't. You either explicitly implement an interface, or you don't. What you're describing is effectively "either method A *or* method B will exist," but that's not a concept that exists in C# (or any other language that I'm aware of!).
The closest you'll be able to get would be to throw an exception in the code th... | I am not aware of any way to enforce this at compile time. I think you would have to make this a runtime check by using a base class that throws an exception if both interfaces are implemented.
However, that won't stop someone from bypassing your base class and implementing the interfaces themselves, and I know of no ... |
15,344,451 | I have an interface that looks like this:
```
public interface IOpportunity
{
string Name { get; }
string Description { get; }
ILocation Location { get; }
}
public interface ILocation : IHierarchicalEntity
{
int OpptyCount { get; }
}
public interface IHierarchicalEntity
{
string SID { get; }
... | 2013/03/11 | [
"https://Stackoverflow.com/questions/15344451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1429064/"
] | I believe you are over-constraining the true problem. This is very similar to an issue I encountered in my game engine, where coordinates on a hex grid can be either in the canonical reference frame (axes at 120 degress, convenient for most internal game functions) or in the rectangular (user) reference frame with axes... | I am not aware of any way to enforce this at compile time. I think you would have to make this a runtime check by using a base class that throws an exception if both interfaces are implemented.
However, that won't stop someone from bypassing your base class and implementing the interfaces themselves, and I know of no ... |
15,344,451 | I have an interface that looks like this:
```
public interface IOpportunity
{
string Name { get; }
string Description { get; }
ILocation Location { get; }
}
public interface ILocation : IHierarchicalEntity
{
int OpptyCount { get; }
}
public interface IHierarchicalEntity
{
string SID { get; }
... | 2013/03/11 | [
"https://Stackoverflow.com/questions/15344451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1429064/"
] | You can't. You either explicitly implement an interface, or you don't. What you're describing is effectively "either method A *or* method B will exist," but that's not a concept that exists in C# (or any other language that I'm aware of!).
The closest you'll be able to get would be to throw an exception in the code th... | You can try Code Contracts. Post-condition. Smth like this
```
[ContractClassFor(typeof(IOpportunity))]
public abstract class OpportunityContract : IOpportunity
{
public ILocation Location
{
get { Contract.Ensures(Contract.Result<ILocation>() is IHierarchicalEntityWithParentNames || Contract.Result<IL... |
15,344,451 | I have an interface that looks like this:
```
public interface IOpportunity
{
string Name { get; }
string Description { get; }
ILocation Location { get; }
}
public interface ILocation : IHierarchicalEntity
{
int OpptyCount { get; }
}
public interface IHierarchicalEntity
{
string SID { get; }
... | 2013/03/11 | [
"https://Stackoverflow.com/questions/15344451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1429064/"
] | I believe you are over-constraining the true problem. This is very similar to an issue I encountered in my game engine, where coordinates on a hex grid can be either in the canonical reference frame (axes at 120 degress, convenient for most internal game functions) or in the rectangular (user) reference frame with axes... | You can try Code Contracts. Post-condition. Smth like this
```
[ContractClassFor(typeof(IOpportunity))]
public abstract class OpportunityContract : IOpportunity
{
public ILocation Location
{
get { Contract.Ensures(Contract.Result<ILocation>() is IHierarchicalEntityWithParentNames || Contract.Result<IL... |
72,878,449 | I want something like this:
[](https://i.stack.imgur.com/J9cBB.png)
```
Time 33000CE 33100CE
15:00:00 3.85 5.09
15:00:03 0.10 1.45
15:00:06 (0.35) 1.26
15:00:09 (1.04)... | 2022/07/06 | [
"https://Stackoverflow.com/questions/72878449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14349940/"
] | We can use a calendar table approach here:
```sql
SELECT t1.Type,
COALESCE(t3.Qty, 0) AS Qty,
COALESCE(t3.total, 0) AS total,
t2.time
FROM (SELECT DISTINCT Type FROM yourTable) t1
CROSS JOIN (SELECT DISTINCT time FROM yourTable) t2
LEFT JOIN yourTable t3
ON t3.Type = t1.Type AND
t3.time... | The most common method to fetch previous row value in SQL is by using the LAG function. The LAG function returns the previous row value. Depending on the order by clause the previous row is determined and the column value is returned.
```
SELECT value - lag(value) OVER (ORDER BY Id) FROM table
``` |
72,878,449 | I want something like this:
[](https://i.stack.imgur.com/J9cBB.png)
```
Time 33000CE 33100CE
15:00:00 3.85 5.09
15:00:03 0.10 1.45
15:00:06 (0.35) 1.26
15:00:09 (1.04)... | 2022/07/06 | [
"https://Stackoverflow.com/questions/72878449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14349940/"
] | We can use a calendar table approach here:
```sql
SELECT t1.Type,
COALESCE(t3.Qty, 0) AS Qty,
COALESCE(t3.total, 0) AS total,
t2.time
FROM (SELECT DISTINCT Type FROM yourTable) t1
CROSS JOIN (SELECT DISTINCT time FROM yourTable) t2
LEFT JOIN yourTable t3
ON t3.Type = t1.Type AND
t3.time... | Mysql 8.0
```sql
WITH a AS (SELECT COALESCE(Type, 'orange') AS Type, Qty, total, time
FROM tcbi_test.demo1
UNION
SELECT COALESCE(Type, 'apple') AS Type, Qty, total, time
FROM tcbi_test.demo1)
SELECT Type
, COALESCE(Qty, LAG(Qty) OVER (PARTITION BY Type ORDER BY time), 0... |
72,878,449 | I want something like this:
[](https://i.stack.imgur.com/J9cBB.png)
```
Time 33000CE 33100CE
15:00:00 3.85 5.09
15:00:03 0.10 1.45
15:00:06 (0.35) 1.26
15:00:09 (1.04)... | 2022/07/06 | [
"https://Stackoverflow.com/questions/72878449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14349940/"
] | We can use a calendar table approach here:
```sql
SELECT t1.Type,
COALESCE(t3.Qty, 0) AS Qty,
COALESCE(t3.total, 0) AS total,
t2.time
FROM (SELECT DISTINCT Type FROM yourTable) t1
CROSS JOIN (SELECT DISTINCT time FROM yourTable) t2
LEFT JOIN yourTable t3
ON t3.Type = t1.Type AND
t3.time... | MySql does not support the `IGNORE NULLS` clause after `ORDER BY` in window functions, which would be very useful in this case, so I use correlated subqueries to fetch the last non-null value for `Qty` and `total`:
```
WITH types AS (SELECT DISTINCT Type FROM tablename WHERE type IS NOT NULL),
times AS (SELECT DI... |
17,773,516 | I had to implement the QuickSort algorithm for a homework in a language of my choice and I chose Python.
During the lectures, we've been told that QuickSort is memory efficient because it works in-place; i.e., it has no additional copies of parts of the input array for recursions.
With this in mind, I tried to implem... | 2013/07/21 | [
"https://Stackoverflow.com/questions/17773516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2570695/"
] | Sure not the best way, plus this famous algorithm will have dozens of perfect implementations.. this is mine, quite easy to understand
```
def sub_partition(array, start, end, idx_pivot):
'returns the position where the pivot winds up'
if not (start <= idx_pivot <= end):
raise ValueError('idx pivot m... | I have started learning python lately and the following is my attempt at implementing quicksort using python. Hope it is helpful. Feedback is welcomed :)
```
#!/usr/bin/python
Array = [ 3,7,2,8,1,6,8,9,6,9]
def partition(a, left, right):
pivot = left + (right - left)/2
a[left],a[pivot] = a[pivot], a[left] ... |
17,773,516 | I had to implement the QuickSort algorithm for a homework in a language of my choice and I chose Python.
During the lectures, we've been told that QuickSort is memory efficient because it works in-place; i.e., it has no additional copies of parts of the input array for recursions.
With this in mind, I tried to implem... | 2013/07/21 | [
"https://Stackoverflow.com/questions/17773516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2570695/"
] | Here is another implementation:
```
def quicksort(alist):
if len(alist) <= 1:
return alist
return part(alist,0,len(alist)-1)
def part(alist,start,end):
pivot = alist[end]
border = start
if start < end:
for i in range(start,end+1):
if alist[i] <= pivot:
... | Here's what I came up with. The algorithm is in-place, looks nice and is recursive.
```
# `a` is the subarray we're working on
# `p` is the start point in the subarray we're working on
# `r` is the index of the last element of the subarray we're working on
def part(a,p,r):
k=a[r] #pivot
j,q=p,p
if p<r: # i... |
17,773,516 | I had to implement the QuickSort algorithm for a homework in a language of my choice and I chose Python.
During the lectures, we've been told that QuickSort is memory efficient because it works in-place; i.e., it has no additional copies of parts of the input array for recursions.
With this in mind, I tried to implem... | 2013/07/21 | [
"https://Stackoverflow.com/questions/17773516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2570695/"
] | Here's what I came up with. The algorithm is in-place, looks nice and is recursive.
```
# `a` is the subarray we're working on
# `p` is the start point in the subarray we're working on
# `r` is the index of the last element of the subarray we're working on
def part(a,p,r):
k=a[r] #pivot
j,q=p,p
if p<r: # i... | ```
def quicksort(arr):
lesser = []
equal = []
greater = []
if len(arr)>1:
pivot = arr[len(arr)-1]
start = 0
while start<len(arr):
if arr[start] > pivot:
greater.append(arr.pop(start))
elif arr[start] < pivot:
lesser.append... |
17,773,516 | I had to implement the QuickSort algorithm for a homework in a language of my choice and I chose Python.
During the lectures, we've been told that QuickSort is memory efficient because it works in-place; i.e., it has no additional copies of parts of the input array for recursions.
With this in mind, I tried to implem... | 2013/07/21 | [
"https://Stackoverflow.com/questions/17773516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2570695/"
] | I have started learning python lately and the following is my attempt at implementing quicksort using python. Hope it is helpful. Feedback is welcomed :)
```
#!/usr/bin/python
Array = [ 3,7,2,8,1,6,8,9,6,9]
def partition(a, left, right):
pivot = left + (right - left)/2
a[left],a[pivot] = a[pivot], a[left] ... | An in place implementation with pivot as the right most element
```
def partition(array, begin, end):
pivot = end
while begin < pivot:
if array[begin] > array[pivot]:
if begin != pivot - 1:
array[pivot], array[pivot - 1] = array[pivot - 1], array[pivot]
array[beg... |
17,773,516 | I had to implement the QuickSort algorithm for a homework in a language of my choice and I chose Python.
During the lectures, we've been told that QuickSort is memory efficient because it works in-place; i.e., it has no additional copies of parts of the input array for recursions.
With this in mind, I tried to implem... | 2013/07/21 | [
"https://Stackoverflow.com/questions/17773516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2570695/"
] | Sure not the best way, plus this famous algorithm will have dozens of perfect implementations.. this is mine, quite easy to understand
```
def sub_partition(array, start, end, idx_pivot):
'returns the position where the pivot winds up'
if not (start <= idx_pivot <= end):
raise ValueError('idx pivot m... | An in place implementation with pivot as the right most element
```
def partition(array, begin, end):
pivot = end
while begin < pivot:
if array[begin] > array[pivot]:
if begin != pivot - 1:
array[pivot], array[pivot - 1] = array[pivot - 1], array[pivot]
array[beg... |
17,773,516 | I had to implement the QuickSort algorithm for a homework in a language of my choice and I chose Python.
During the lectures, we've been told that QuickSort is memory efficient because it works in-place; i.e., it has no additional copies of parts of the input array for recursions.
With this in mind, I tried to implem... | 2013/07/21 | [
"https://Stackoverflow.com/questions/17773516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2570695/"
] | Here is another implementation:
```
def quicksort(alist):
if len(alist) <= 1:
return alist
return part(alist,0,len(alist)-1)
def part(alist,start,end):
pivot = alist[end]
border = start
if start < end:
for i in range(start,end+1):
if alist[i] <= pivot:
... | ```
def quicksort(arr):
lesser = []
equal = []
greater = []
if len(arr)>1:
pivot = arr[len(arr)-1]
start = 0
while start<len(arr):
if arr[start] > pivot:
greater.append(arr.pop(start))
elif arr[start] < pivot:
lesser.append... |
17,773,516 | I had to implement the QuickSort algorithm for a homework in a language of my choice and I chose Python.
During the lectures, we've been told that QuickSort is memory efficient because it works in-place; i.e., it has no additional copies of parts of the input array for recursions.
With this in mind, I tried to implem... | 2013/07/21 | [
"https://Stackoverflow.com/questions/17773516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2570695/"
] | Sure not the best way, plus this famous algorithm will have dozens of perfect implementations.. this is mine, quite easy to understand
```
def sub_partition(array, start, end, idx_pivot):
'returns the position where the pivot winds up'
if not (start <= idx_pivot <= end):
raise ValueError('idx pivot m... | Here is another implementation:
```
def quicksort(alist):
if len(alist) <= 1:
return alist
return part(alist,0,len(alist)-1)
def part(alist,start,end):
pivot = alist[end]
border = start
if start < end:
for i in range(start,end+1):
if alist[i] <= pivot:
... |
17,773,516 | I had to implement the QuickSort algorithm for a homework in a language of my choice and I chose Python.
During the lectures, we've been told that QuickSort is memory efficient because it works in-place; i.e., it has no additional copies of parts of the input array for recursions.
With this in mind, I tried to implem... | 2013/07/21 | [
"https://Stackoverflow.com/questions/17773516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2570695/"
] | I have started learning python lately and the following is my attempt at implementing quicksort using python. Hope it is helpful. Feedback is welcomed :)
```
#!/usr/bin/python
Array = [ 3,7,2,8,1,6,8,9,6,9]
def partition(a, left, right):
pivot = left + (right - left)/2
a[left],a[pivot] = a[pivot], a[left] ... | ```
def quicksort(arr):
lesser = []
equal = []
greater = []
if len(arr)>1:
pivot = arr[len(arr)-1]
start = 0
while start<len(arr):
if arr[start] > pivot:
greater.append(arr.pop(start))
elif arr[start] < pivot:
lesser.append... |
17,773,516 | I had to implement the QuickSort algorithm for a homework in a language of my choice and I chose Python.
During the lectures, we've been told that QuickSort is memory efficient because it works in-place; i.e., it has no additional copies of parts of the input array for recursions.
With this in mind, I tried to implem... | 2013/07/21 | [
"https://Stackoverflow.com/questions/17773516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2570695/"
] | I have started learning python lately and the following is my attempt at implementing quicksort using python. Hope it is helpful. Feedback is welcomed :)
```
#!/usr/bin/python
Array = [ 3,7,2,8,1,6,8,9,6,9]
def partition(a, left, right):
pivot = left + (right - left)/2
a[left],a[pivot] = a[pivot], a[left] ... | Explanation:
Pivot is always the last element in given array.
In my approach I keep track of the 'border' between numbers smaller and bigger than pivot. Border is an index of first number in 'bigger' group.
At the end of each iteration we swap number under 'border' with the pivot number.
And the code:
```
def qs(ar, ... |
17,773,516 | I had to implement the QuickSort algorithm for a homework in a language of my choice and I chose Python.
During the lectures, we've been told that QuickSort is memory efficient because it works in-place; i.e., it has no additional copies of parts of the input array for recursions.
With this in mind, I tried to implem... | 2013/07/21 | [
"https://Stackoverflow.com/questions/17773516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2570695/"
] | Sure not the best way, plus this famous algorithm will have dozens of perfect implementations.. this is mine, quite easy to understand
```
def sub_partition(array, start, end, idx_pivot):
'returns the position where the pivot winds up'
if not (start <= idx_pivot <= end):
raise ValueError('idx pivot m... | ```
def quicksort(arr):
lesser = []
equal = []
greater = []
if len(arr)>1:
pivot = arr[len(arr)-1]
start = 0
while start<len(arr):
if arr[start] > pivot:
greater.append(arr.pop(start))
elif arr[start] < pivot:
lesser.append... |
8,698,013 | what logic i can use to generate 6 digit random number based on current date and time. suppose i want to generate a 6 digit random number which will be valid up to 5 second. after 5 second if anyone input that random number into system then system will say it is expire. one thing i need to mention that there will be no... | 2012/01/02 | [
"https://Stackoverflow.com/questions/8698013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/750398/"
] | If it is the same process which stays during these five seconds, you could just store the key inside an hashtable, and to validate it check that it is inside the hashtable. Also keep in the hashtable the creation time of the key, and periodically clean that hashtable (removing obsolete keys and associated data).
Of co... | You can't reverse the process of random number generation to determine *when* the number were generated, particularly if you're seeding `Random` with milliseconds.
Getting a 6-digit random number:
```
int randomNumber = random.Next(0, 1000000);
``` |
34,936,450 | I am using a 64bit Windows 10 machine.
I am trying to install the [fancy impute module](https://github.com/hammerlab/fancyimpute) to do K-Nearest Neighbors Imputation of null values in a data set.
I have had to separately install `cvxopt` with
```
conda install -c https://conda.binstar.org/eswears cvxopt
```
and ... | 2016/01/21 | [
"https://Stackoverflow.com/questions/34936450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4975446/"
] | Just looking at your code (and not giving you another, out of many neat ways, to calculate this): your function expects return type `Int`, but you return `Double`.
Below follows your code with commented corrections:
```
func averageOf(numbers: Int...) -> Double {
var sum = 0 // ^ note the return... | Your function is declared as returning an Int:
```
func averageOf(numbers: Int...) -> ***Int*** {
```
You can't return a Double because it doesn't match this signature. You could either convert back to an Int before returning, or change the function signature. |
34,936,450 | I am using a 64bit Windows 10 machine.
I am trying to install the [fancy impute module](https://github.com/hammerlab/fancyimpute) to do K-Nearest Neighbors Imputation of null values in a data set.
I have had to separately install `cvxopt` with
```
conda install -c https://conda.binstar.org/eswears cvxopt
```
and ... | 2016/01/21 | [
"https://Stackoverflow.com/questions/34936450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4975446/"
] | Just looking at your code (and not giving you another, out of many neat ways, to calculate this): your function expects return type `Int`, but you return `Double`.
Below follows your code with commented corrections:
```
func averageOf(numbers: Int...) -> Double {
var sum = 0 // ^ note the return... | If you look at your function definition, it is return an `Int` (the return parameter is after the `->`.
```
func averageOf(numbers: Int...) -> Int
```
Change it to `Double` if you want to return the `Double` or cast your result to an `Int` before returning |
34,936,450 | I am using a 64bit Windows 10 machine.
I am trying to install the [fancy impute module](https://github.com/hammerlab/fancyimpute) to do K-Nearest Neighbors Imputation of null values in a data set.
I have had to separately install `cvxopt` with
```
conda install -c https://conda.binstar.org/eswears cvxopt
```
and ... | 2016/01/21 | [
"https://Stackoverflow.com/questions/34936450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4975446/"
] | Just looking at your code (and not giving you another, out of many neat ways, to calculate this): your function expects return type `Int`, but you return `Double`.
Below follows your code with commented corrections:
```
func averageOf(numbers: Int...) -> Double {
var sum = 0 // ^ note the return... | In Swift 3...
Using variadic parameter:
```
func averageOf(_ n: Int...) -> Double {
return Double(n.reduce(0, +)) / Double(n.count)
}
averageOf() // nan
averageOf(0) // 0
averageOf(1, 2, 3, 4) // 2.5
```
Using array parameter (`guard`ing for empty array):
```
func averageOf(_ n: [Int]) -> Double {
guard n... |
34,936,450 | I am using a 64bit Windows 10 machine.
I am trying to install the [fancy impute module](https://github.com/hammerlab/fancyimpute) to do K-Nearest Neighbors Imputation of null values in a data set.
I have had to separately install `cvxopt` with
```
conda install -c https://conda.binstar.org/eswears cvxopt
```
and ... | 2016/01/21 | [
"https://Stackoverflow.com/questions/34936450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4975446/"
] | If you look at your function definition, it is return an `Int` (the return parameter is after the `->`.
```
func averageOf(numbers: Int...) -> Int
```
Change it to `Double` if you want to return the `Double` or cast your result to an `Int` before returning | Your function is declared as returning an Int:
```
func averageOf(numbers: Int...) -> ***Int*** {
```
You can't return a Double because it doesn't match this signature. You could either convert back to an Int before returning, or change the function signature. |
34,936,450 | I am using a 64bit Windows 10 machine.
I am trying to install the [fancy impute module](https://github.com/hammerlab/fancyimpute) to do K-Nearest Neighbors Imputation of null values in a data set.
I have had to separately install `cvxopt` with
```
conda install -c https://conda.binstar.org/eswears cvxopt
```
and ... | 2016/01/21 | [
"https://Stackoverflow.com/questions/34936450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4975446/"
] | In Swift 3...
Using variadic parameter:
```
func averageOf(_ n: Int...) -> Double {
return Double(n.reduce(0, +)) / Double(n.count)
}
averageOf() // nan
averageOf(0) // 0
averageOf(1, 2, 3, 4) // 2.5
```
Using array parameter (`guard`ing for empty array):
```
func averageOf(_ n: [Int]) -> Double {
guard n... | Your function is declared as returning an Int:
```
func averageOf(numbers: Int...) -> ***Int*** {
```
You can't return a Double because it doesn't match this signature. You could either convert back to an Int before returning, or change the function signature. |
29,408,809 | I'm parsing some file into my Java-program. Due to its non-csv/tsv nature, I wanted to format it beforehand, so I can read it in easily. For this I tried regular expressions, which work fine for me with one exception: Start of line.
My files still have a tab at each line's start, which I want to get rid of, so that th... | 2015/04/02 | [
"https://Stackoverflow.com/questions/29408809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4558359/"
] | To remove whitespace (space/tab) from **start of each line** use `MULTILINE` flag:
```
content = content.replaceAll("(?m)^\\s+","");`
``` | Use `^\t` with `multiline` modifier.
```
str.replace("(?m)^\t", "");
```
[DEMO](https://regex101.com/r/gQ9aT6/1) |
29,408,809 | I'm parsing some file into my Java-program. Due to its non-csv/tsv nature, I wanted to format it beforehand, so I can read it in easily. For this I tried regular expressions, which work fine for me with one exception: Start of line.
My files still have a tab at each line's start, which I want to get rid of, so that th... | 2015/04/02 | [
"https://Stackoverflow.com/questions/29408809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4558359/"
] | To remove whitespace (space/tab) from **start of each line** use `MULTILINE` flag:
```
content = content.replaceAll("(?m)^\\s+","");`
``` | You do not need regexes for this kind of thing, you can leverage `String.Trim()` method.
Read the lines in, and use the following code:
```
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
String line;
while ((line = br.readLine()) != null) {
line = lines.trim();
// Then, write t... |
23,522,166 | I don't really understand the concept of a [software testing oracle](http://en.wikipedia.org/wiki/Oracle_%28software_testing%29). It says:
>
> An oracle is a mechanism for determining whether the program has passed or failed a test.
>
>
>
Consider the following code:
```
// class that should be tested
public in... | 2014/05/07 | [
"https://Stackoverflow.com/questions/23522166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/982865/"
] | A test oracle is a source of information about whether the output of a program (or function or method) is correct or not.
A test oracle might specify correct output for all possible input or only for specific input. It might not specify actual output values but only constraints on them.
The oracle might be
* a progr... | Let me pose the oracle question this way: how can we check that the program returns the right answer?
For this function, we can easily check the answer with the following pseudocode (Sorry, it's not C++.):
```
repeat many times {
int a = randomNumber();
int b = randomNumber();
int result = sum(a, b);
... |
22,685,378 | hi i am trying to make java desktop application where i am trying to make jbutton bottom left i did following code i dont know where i am wrong my code is note working
here is my code
```
import java.awt.*;
import java.awt.event.*;
import javax.imageio.ImageIO;
import javax.swing.*;
new complete code
public cl... | 2014/03/27 | [
"https://Stackoverflow.com/questions/22685378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3456343/"
] | I'm going to assume the null pointer exception is something to do with your buttons array. Check that you have initialised it properly.
```
private JButton[] buttons = new JButton[8];
```
I copied your code into a test project and ran it after some modifications:
```
public static void main(String[] args) {
f... | There is an elegant solution that I'll give you but maybe it serves. Use WindowsBuilder and adds several buttons and then you look like is placing code. So make yourself an idea of the pattern that follows a setLayout with Flow. |
27,426,668 | In matplotlib, Is it possible to set a a separate title for each row of subplots in addition to the title set for the entire figure and the title set for each individual plot? This would correspond to the orange text in the figure below.

If not, how ... | 2014/12/11 | [
"https://Stackoverflow.com/questions/27426668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2166823/"
] | An idea is to create three "big subplots", to give each of them a title, and make them invisible. On the top of that you can create your matrix of smaller subplots.
This solution is entirely based on [this post](https://stackoverflow.com/questions/6963035/pyplot-axes-labels-for-subplots), except that more attention ha... | Another easy cheat is to give the title of the middle column as `subplot row XX\n\nPlot title No.YY` |
27,426,668 | In matplotlib, Is it possible to set a a separate title for each row of subplots in addition to the title set for the entire figure and the title set for each individual plot? This would correspond to the orange text in the figure below.

If not, how ... | 2014/12/11 | [
"https://Stackoverflow.com/questions/27426668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2166823/"
] | An idea is to create three "big subplots", to give each of them a title, and make them invisible. On the top of that you can create your matrix of smaller subplots.
This solution is entirely based on [this post](https://stackoverflow.com/questions/6963035/pyplot-axes-labels-for-subplots), except that more attention ha... | It is better to firstly plot your real subplots and then plot empty subplots above them, thus you will have a more precise title align. And to do it precisely we need `plt.GridSpec()` ([link](https://jakevdp.github.io/PythonDataScienceHandbook/04.08-multiple-subplots.html#plt.GridSpec:-More-Complicated-Arrangements)).
... |
27,426,668 | In matplotlib, Is it possible to set a a separate title for each row of subplots in addition to the title set for the entire figure and the title set for each individual plot? This would correspond to the orange text in the figure below.

If not, how ... | 2014/12/11 | [
"https://Stackoverflow.com/questions/27426668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2166823/"
] | New in matplotlib 3.4.0
-----------------------
Row titles can now be implemented as **subfigure suptitles**:
>
> The new subfigure feature allows creating virtual figures within figures with localized artists (e.g., colorbars and **suptitles**) that **only pertain to each subfigure**.
>
>
> See [how to plot subfi... | An idea is to create three "big subplots", to give each of them a title, and make them invisible. On the top of that you can create your matrix of smaller subplots.
This solution is entirely based on [this post](https://stackoverflow.com/questions/6963035/pyplot-axes-labels-for-subplots), except that more attention ha... |
27,426,668 | In matplotlib, Is it possible to set a a separate title for each row of subplots in addition to the title set for the entire figure and the title set for each individual plot? This would correspond to the orange text in the figure below.

If not, how ... | 2014/12/11 | [
"https://Stackoverflow.com/questions/27426668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2166823/"
] | New in matplotlib 3.4.0
-----------------------
Row titles can now be implemented as **subfigure suptitles**:
>
> The new subfigure feature allows creating virtual figures within figures with localized artists (e.g., colorbars and **suptitles**) that **only pertain to each subfigure**.
>
>
> See [how to plot subfi... | Another easy cheat is to give the title of the middle column as `subplot row XX\n\nPlot title No.YY` |
27,426,668 | In matplotlib, Is it possible to set a a separate title for each row of subplots in addition to the title set for the entire figure and the title set for each individual plot? This would correspond to the orange text in the figure below.

If not, how ... | 2014/12/11 | [
"https://Stackoverflow.com/questions/27426668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2166823/"
] | New in matplotlib 3.4.0
-----------------------
Row titles can now be implemented as **subfigure suptitles**:
>
> The new subfigure feature allows creating virtual figures within figures with localized artists (e.g., colorbars and **suptitles**) that **only pertain to each subfigure**.
>
>
> See [how to plot subfi... | It is better to firstly plot your real subplots and then plot empty subplots above them, thus you will have a more precise title align. And to do it precisely we need `plt.GridSpec()` ([link](https://jakevdp.github.io/PythonDataScienceHandbook/04.08-multiple-subplots.html#plt.GridSpec:-More-Complicated-Arrangements)).
... |
42,527,013 | Is there a shorthand which would allow to get the value of the Promise and push it forward the promise chain without explicitly returning it?
In other words, is there a shorthand syntax for the following in bluebird:
```
.then(result => { callSomething(result); return result })
``` | 2017/03/01 | [
"https://Stackoverflow.com/questions/42527013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2230249/"
] | Hope this will work fine
Regex: `(?<!\()\bAPPLE\b(?![\w\s]*[\)])`
`\b` a word boundary
`(?![\w\s]*[\)])` Negatively lookahead for `) followed by words or spaces`
`(?<!\()` Negatively lookbehind for `(`
[RegexDemo](https://regex101.com/r/e2dw0k/6) | Try this Regex (if you don't need javascript regex):
```
(?<!\()\b\w+\b(?![\)])
```
[See Explanation and try Demos](https://regex101.com/r/tbqcfi/1)
---
You may have some complex texts between `(..\n..)`. So I suggest:
1- Add `)` in beginning and `(` to end of string! wait!
2- split your text with this regex `/\... |
117,904 | I am building an intranet site. I have the site set up with single sign on via the server authentication module meaning there are no anonymous users. This means large parts of the cache are worthless.
The site is now set up how I want, however it's running extremely slowly for the first couple of page loads if the sit... | 2014/06/11 | [
"https://drupal.stackexchange.com/questions/117904",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/24926/"
] | I created a presentation that covers some of the basics of of performance <https://docs.google.com/presentation/d/1AgnurTWsWdMAFjfFmSU7mk2zfJu8jG_KmVdZ7-o6Pok/edit#slide=id>. In your case I would make sure poormans cron in core is disabled, use an IP for your database connection (very important on IIS), make sure you h... | Also check out mySQL optimisation. Here's a couple links to get you started.
* [Tuning MySQL](https://drupal.org/node/51263)
* [Building a Drupal 7 Optimized my.conf File](https://groups.drupal.org/node/289613) |
23,720,880 | I am working with Express and mongoose . Don't know why `array.push` is not working . Maybe I am calling it in asynchronous function .
```
function x(){
var a = [] ;
database.auth.distinct('tag',function(err , tagname){
console.log(tagname); // printing tag names perfectly
a.push(tagname);
... | 2014/05/18 | [
"https://Stackoverflow.com/questions/23720880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2566671/"
] | please don't try with the old cv module, use cv2:
```
import cv2
cv2.rectangle(img, (x1, y1), (x2, y2), (255,0,0), 2)
x1,y1 ------
| |
| |
| |
--------x2,y2
```
[edit] to append the follow-up questions below:
```
cv2.imwrite("my.png",img)
cv2.imshow("lalala", img)
k = cv2.waitKey(0) # ... | You can use [`cv2.rectangle()`](https://docs.opencv.org/3.1.0/d6/d6e/group__imgproc__draw.html#ga07d2f74cadcf8e305e810ce8eed13bc9):
```
cv2.rectangle(img, pt1, pt2, color, thickness, lineType, shift)
Draws a simple, thick, or filled up-right rectangle.
The function rectangle draws a rectangle outline or a filled rec... |
23,720,880 | I am working with Express and mongoose . Don't know why `array.push` is not working . Maybe I am calling it in asynchronous function .
```
function x(){
var a = [] ;
database.auth.distinct('tag',function(err , tagname){
console.log(tagname); // printing tag names perfectly
a.push(tagname);
... | 2014/05/18 | [
"https://Stackoverflow.com/questions/23720880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2566671/"
] | please don't try with the old cv module, use cv2:
```
import cv2
cv2.rectangle(img, (x1, y1), (x2, y2), (255,0,0), 2)
x1,y1 ------
| |
| |
| |
--------x2,y2
```
[edit] to append the follow-up questions below:
```
cv2.imwrite("my.png",img)
cv2.imshow("lalala", img)
k = cv2.waitKey(0) # ... | As the other answers said, the function you need is `cv2.rectangle()`, but keep in mind that the coordinates for the bounding box vertices need to be integers if they are in a tuple, and they need to be in the order of `(left, top)` and `(right, bottom)`. Or, equivalently, `(xmin, ymin)` and `(xmax, ymax)`. |
23,720,880 | I am working with Express and mongoose . Don't know why `array.push` is not working . Maybe I am calling it in asynchronous function .
```
function x(){
var a = [] ;
database.auth.distinct('tag',function(err , tagname){
console.log(tagname); // printing tag names perfectly
a.push(tagname);
... | 2014/05/18 | [
"https://Stackoverflow.com/questions/23720880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2566671/"
] | please don't try with the old cv module, use cv2:
```
import cv2
cv2.rectangle(img, (x1, y1), (x2, y2), (255,0,0), 2)
x1,y1 ------
| |
| |
| |
--------x2,y2
```
[edit] to append the follow-up questions below:
```
cv2.imwrite("my.png",img)
cv2.imshow("lalala", img)
k = cv2.waitKey(0) # ... | The code for drawing a rectangle on an image is:
```
cv2.rectangle(image, pt1, pt2, color, thickness)
```
where `pt1` is starting point-->(x,y) and `pt2` is end point-->(x+w,y+h). |
23,720,880 | I am working with Express and mongoose . Don't know why `array.push` is not working . Maybe I am calling it in asynchronous function .
```
function x(){
var a = [] ;
database.auth.distinct('tag',function(err , tagname){
console.log(tagname); // printing tag names perfectly
a.push(tagname);
... | 2014/05/18 | [
"https://Stackoverflow.com/questions/23720880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2566671/"
] | You can use [`cv2.rectangle()`](https://docs.opencv.org/3.1.0/d6/d6e/group__imgproc__draw.html#ga07d2f74cadcf8e305e810ce8eed13bc9):
```
cv2.rectangle(img, pt1, pt2, color, thickness, lineType, shift)
Draws a simple, thick, or filled up-right rectangle.
The function rectangle draws a rectangle outline or a filled rec... | The code for drawing a rectangle on an image is:
```
cv2.rectangle(image, pt1, pt2, color, thickness)
```
where `pt1` is starting point-->(x,y) and `pt2` is end point-->(x+w,y+h). |
23,720,880 | I am working with Express and mongoose . Don't know why `array.push` is not working . Maybe I am calling it in asynchronous function .
```
function x(){
var a = [] ;
database.auth.distinct('tag',function(err , tagname){
console.log(tagname); // printing tag names perfectly
a.push(tagname);
... | 2014/05/18 | [
"https://Stackoverflow.com/questions/23720880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2566671/"
] | As the other answers said, the function you need is `cv2.rectangle()`, but keep in mind that the coordinates for the bounding box vertices need to be integers if they are in a tuple, and they need to be in the order of `(left, top)` and `(right, bottom)`. Or, equivalently, `(xmin, ymin)` and `(xmax, ymax)`. | The code for drawing a rectangle on an image is:
```
cv2.rectangle(image, pt1, pt2, color, thickness)
```
where `pt1` is starting point-->(x,y) and `pt2` is end point-->(x+w,y+h). |
195,149 | Prove that if $\lim\limits\_{x\to a} f(x)$ exists, and $\lim\limits\_{x\to a} [f(x)+g(x)]$ does not exists, then $\lim\limits\_{x\to a} g(x)$ does not exists.
I understand that I have to suppose a certain limit exists, then prove by contradication.
But which should I suppose to exists, and which should I aim towards?... | 2012/09/13 | [
"https://math.stackexchange.com/questions/195149",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/40217/"
] | Hint: Assume by negation that the limit of $g(x)$ when x approaches $a$ exist and equals $b$. Denote the limit of $f(x)$ when x approaches $a$ as $c$ and prove that the limit of $f(x)+g(x)$ when x approaches is $c+b$ | Just think again for a moment how proof by contradiction works.
Say, you want to prove that statement A implies statement B.
To do so, you can equivalently start with the negation of statement B and conclude that statement A is not true.
So in your case, statement B is "lim g(x) does not exist", so this should get y... |
195,149 | Prove that if $\lim\limits\_{x\to a} f(x)$ exists, and $\lim\limits\_{x\to a} [f(x)+g(x)]$ does not exists, then $\lim\limits\_{x\to a} g(x)$ does not exists.
I understand that I have to suppose a certain limit exists, then prove by contradication.
But which should I suppose to exists, and which should I aim towards?... | 2012/09/13 | [
"https://math.stackexchange.com/questions/195149",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/40217/"
] | Hint: Assume by negation that the limit of $g(x)$ when x approaches $a$ exist and equals $b$. Denote the limit of $f(x)$ when x approaches $a$ as $c$ and prove that the limit of $f(x)+g(x)$ when x approaches is $c+b$ | Alex, I see where you're going but your outline to the solution is missing some important information. I suppose my answer is similar to Belgi's.
If you want to prove " A and B implies C", then you can prove the contrapositive, which is "C implies not (A and B)".
Not(A and B) means they cannot both be true at the sam... |
195,149 | Prove that if $\lim\limits\_{x\to a} f(x)$ exists, and $\lim\limits\_{x\to a} [f(x)+g(x)]$ does not exists, then $\lim\limits\_{x\to a} g(x)$ does not exists.
I understand that I have to suppose a certain limit exists, then prove by contradication.
But which should I suppose to exists, and which should I aim towards?... | 2012/09/13 | [
"https://math.stackexchange.com/questions/195149",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/40217/"
] | Alex, I see where you're going but your outline to the solution is missing some important information. I suppose my answer is similar to Belgi's.
If you want to prove " A and B implies C", then you can prove the contrapositive, which is "C implies not (A and B)".
Not(A and B) means they cannot both be true at the sam... | Just think again for a moment how proof by contradiction works.
Say, you want to prove that statement A implies statement B.
To do so, you can equivalently start with the negation of statement B and conclude that statement A is not true.
So in your case, statement B is "lim g(x) does not exist", so this should get y... |
44,386,399 | I have a commit where a file is renamed. Is there any possibility to get the new file name from the old file name and the commit key?
Example: `file.php` is renamed to `filex.php` at commit `5119afae52e5ae08ca8e378e00895d824a179f03`.
I'm searching for something that returns `filex.php` from the information about `511... | 2017/06/06 | [
"https://Stackoverflow.com/questions/44386399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2612484/"
] | The following bash script will do the job:
**Usage**:
```
new_name_of_renamed_file <oldname> <commitid>
```
**new\_name\_of\_renamed\_file**:
```
#!/usr/bin/env bash
if [ $# -ne 2 ]
then
echo "Usage: new_name_of_renamed_file <oldname> <commitid>"
exit 1
fi
pattern="^rename from ${1/./\\.}\$"
git diff -M1... | If you run :
```
git log --oneline -- file.php
```
you will see a list of all the commits that modified this `file.php`.
The most recent of these commits (the one on top) will be the one when `file.php` has been renamed to `filex.php`.
You can confirm this by running `git diff <hash>`, where `<hash>` is the commit... |
9,850,732 | I am trying to input a telephone number in an input box like this (ex. 111-222-3333)
so I use this code:
```
<script type="text/javascript">
function validate(evt) {
var theEvent = evt || window.event;
var key = theEvent.keyCode || theEvent.which;
key = String.fromCharCode( key );
var rege... | 2012/03/24 | [
"https://Stackoverflow.com/questions/9850732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1289733/"
] | You could use an alternate framework such as <http://alexgorbatchev.com/SyntaxHighlighter/>
Or take a look here and find something that suites.
<http://www.1stwebdesigner.com/css/16-free-javascript-code-syntax-highlighters-for-better-programming/> | The basic steps would be:
1. Take the HTML inside the element.
2. Split by newline characters (`\n`).
3. For each string, add a number and a dot in front of it.
4. Combine the strings again with newline characters.
5. Set the string as the HTML of the element.
However, this would mess up the syntax highlighting of th... |
9,850,732 | I am trying to input a telephone number in an input box like this (ex. 111-222-3333)
so I use this code:
```
<script type="text/javascript">
function validate(evt) {
var theEvent = evt || window.event;
var key = theEvent.keyCode || theEvent.which;
key = String.fromCharCode( key );
var rege... | 2012/03/24 | [
"https://Stackoverflow.com/questions/9850732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1289733/"
] | You could use an alternate framework such as <http://alexgorbatchev.com/SyntaxHighlighter/>
Or take a look here and find something that suites.
<http://www.1stwebdesigner.com/css/16-free-javascript-code-syntax-highlighters-for-better-programming/> | Adding a new answer to an old question.
I wanted to display line numbers in the left margin the way ace.js does.
My solution has some hacky details, but I wanted to share it anyway, because it turns out that absolute-positioned spans within relative-positioned spans work pretty well for this.
Encouraged by the abov... |
61,854 | This is the numerical question.
>
> *A particle having a mass of 0.05 mg carries a charge of $5\times10^{-6}C$. The particle is given an initial horizontal velocity of 5000 m/s, what is the magnitude and direction of the magnetic field that will keep the particle moving in a horizontal direction?*
>
>
>
Well I d... | 2013/04/22 | [
"https://physics.stackexchange.com/questions/61854",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/21068/"
] | I would guess the question is asking you to calculate the magnetic field that produces a force exactly equal to the gravitational force. That is, without the magnetic field the particle will accelerate downwards due to gravity. You need the field that exactly balances this to the particle carries on in a straight line. | mass (m)= 0.05 mg
= 0.05\*10^-6 kg
charge(q)=5\*10^-5 C
velocity(v)=5000 m/s
for the charge move to constant horizontal direction;
F=Bqvsin0 and
mg=F
Also, the velocity must be perpendiculars to B.
So, mg=Bqv
B=0.5\*10^-6\*9.8/5\*10^-6\*5000
Therefore, B= 1.96\*10^-5 T |
29,812,143 | I have been recently trying to get back into LibGDX's version of Box2D, and I looked back at a demo I created a few months back, and my code looks fine, and from my Google search results, my code is fine, but for the life of me, I cannot get the `Fixture` to render.
Here is my (Minimalist example) code, and for the li... | 2015/04/23 | [
"https://Stackoverflow.com/questions/29812143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3019891/"
] | The solution was simple. The 'secure' field should be 'secureConnection'. The MEANjs scaffold that generated the configs created mailer options with the 'secure' field. The rest of the options are fine. For anyone that needs a working Office365 SMTP nodemailer options block, the following should work:
```
{
host:... | This nodemailer documentation <https://nodemailer.com/2-0-0-beta/setup-smtp/> indeed states options.secure and not options.secureConnection. It also suggests, in an example, that options.secure is expecting a boolean value true or false and not a string value `'true'` or `'false'`. Removing the `''` from around `'false... |
29,812,143 | I have been recently trying to get back into LibGDX's version of Box2D, and I looked back at a demo I created a few months back, and my code looks fine, and from my Google search results, my code is fine, but for the life of me, I cannot get the `Fixture` to render.
Here is my (Minimalist example) code, and for the li... | 2015/04/23 | [
"https://Stackoverflow.com/questions/29812143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3019891/"
] | The solution was simple. The 'secure' field should be 'secureConnection'. The MEANjs scaffold that generated the configs created mailer options with the 'secure' field. The rest of the options are fine. For anyone that needs a working Office365 SMTP nodemailer options block, the following should work:
```
{
host:... | I know this is old but if anyone looks this up in 2019, you can just add
`service: "Outlook365"`
and you won't have to specify connection options.
[Node Mailer Docs](https://nodemailer.com/smtp/well-known/)
```
let transporter = nodemailer.createTransport({
service: "Outlook365",
auth: {
user: 'FROMU... |
29,812,143 | I have been recently trying to get back into LibGDX's version of Box2D, and I looked back at a demo I created a few months back, and my code looks fine, and from my Google search results, my code is fine, but for the life of me, I cannot get the `Fixture` to render.
Here is my (Minimalist example) code, and for the li... | 2015/04/23 | [
"https://Stackoverflow.com/questions/29812143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3019891/"
] | The solution was simple. The 'secure' field should be 'secureConnection'. The MEANjs scaffold that generated the configs created mailer options with the 'secure' field. The rest of the options are fine. For anyone that needs a working Office365 SMTP nodemailer options block, the following should work:
```
{
host:... | My problem was that the username and password were spelled correctly but I did not login in the Account after creation. So I used a mail program (Thunderbird) to login once and had to change my password and then I had access over Nodemailer. |
29,812,143 | I have been recently trying to get back into LibGDX's version of Box2D, and I looked back at a demo I created a few months back, and my code looks fine, and from my Google search results, my code is fine, but for the life of me, I cannot get the `Fixture` to render.
Here is my (Minimalist example) code, and for the li... | 2015/04/23 | [
"https://Stackoverflow.com/questions/29812143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3019891/"
] | I know this is old but if anyone looks this up in 2019, you can just add
`service: "Outlook365"`
and you won't have to specify connection options.
[Node Mailer Docs](https://nodemailer.com/smtp/well-known/)
```
let transporter = nodemailer.createTransport({
service: "Outlook365",
auth: {
user: 'FROMU... | This nodemailer documentation <https://nodemailer.com/2-0-0-beta/setup-smtp/> indeed states options.secure and not options.secureConnection. It also suggests, in an example, that options.secure is expecting a boolean value true or false and not a string value `'true'` or `'false'`. Removing the `''` from around `'false... |
29,812,143 | I have been recently trying to get back into LibGDX's version of Box2D, and I looked back at a demo I created a few months back, and my code looks fine, and from my Google search results, my code is fine, but for the life of me, I cannot get the `Fixture` to render.
Here is my (Minimalist example) code, and for the li... | 2015/04/23 | [
"https://Stackoverflow.com/questions/29812143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3019891/"
] | This nodemailer documentation <https://nodemailer.com/2-0-0-beta/setup-smtp/> indeed states options.secure and not options.secureConnection. It also suggests, in an example, that options.secure is expecting a boolean value true or false and not a string value `'true'` or `'false'`. Removing the `''` from around `'false... | My problem was that the username and password were spelled correctly but I did not login in the Account after creation. So I used a mail program (Thunderbird) to login once and had to change my password and then I had access over Nodemailer. |
29,812,143 | I have been recently trying to get back into LibGDX's version of Box2D, and I looked back at a demo I created a few months back, and my code looks fine, and from my Google search results, my code is fine, but for the life of me, I cannot get the `Fixture` to render.
Here is my (Minimalist example) code, and for the li... | 2015/04/23 | [
"https://Stackoverflow.com/questions/29812143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3019891/"
] | I know this is old but if anyone looks this up in 2019, you can just add
`service: "Outlook365"`
and you won't have to specify connection options.
[Node Mailer Docs](https://nodemailer.com/smtp/well-known/)
```
let transporter = nodemailer.createTransport({
service: "Outlook365",
auth: {
user: 'FROMU... | My problem was that the username and password were spelled correctly but I did not login in the Account after creation. So I used a mail program (Thunderbird) to login once and had to change my password and then I had access over Nodemailer. |
45,695,427 | After defining `FLAG_ACTIVITY_NO_ANIMATION` for the back arrow in the action bar to correct to animation when the toolbar back arrow is clicked, a warning is then returned. What is the best way to get rid of this warning?
>
> Method invocation 'addFlags' may produce 'java.lang.NullPointerException'
>
>
>
```
@Ove... | 2017/08/15 | [
"https://Stackoverflow.com/questions/45695427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3293579/"
] | Wrap it into an if intent != null.
```
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
final Intent intent = getParentActivityIntent();
if(intent != null){
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
}else{
... | From the doc of the `getParentActivityIntent`:
>
> @return: a new Intent targeting the defined parent of this activity or null if
> there is no valid parent.
>
>
>
This method returns null only if there is no parent `Activity` and so they marked the `@Nullable` annotation for the return value. That's why you are... |
61,481,025 | I have to display the records based on the integer value in an array. For instance, if I have an array i.e.
```
2, 3, 5, 3, 6, 8, 10, 1, 9, 7
```
I would need to display 3 and 5 based on the integer 2. Then it should display 6,8 and 10 based on integer 3 and then 9 based on 1. So my display array would be:
```
3,5
... | 2020/04/28 | [
"https://Stackoverflow.com/questions/61481025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11334430/"
] | tested it with your given array...
```
void display_records(std::vector<int> vi) {
int tmp = 0;
int index = 0;
for(int i=0;i<vi.size(); i++){
for(int j=1;j<=vi[i];j++){
index = i + j;
tmp = vi[index];
if((i+j) < vi.size()) { //to prevent it going out of ran... | Try something like this: (i am not sure if i understood your question) (not tested)
```
void displayRecords(int* vect, int size, int val)
{
for(int i=0; i<size; i++)
{
if(vect[i]==val)
{
int tmp = val;
int j = i + 1;
w... |
9,741,389 | I have written the following query in Entity Framework and the values are different.
```
var query = from p in db.Parents
let children = p.Children
let grandchildren = children.SelectMany(c => c.Grandchildren)
select new
{
Count1 = children.Count(c => !c... | 2012/03/16 | [
"https://Stackoverflow.com/questions/9741389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/143919/"
] | ```
grandchildren.Any()
```
is simply returning if there are any objects in your `grandchildren` collection. So it will always return true unless your `SelectMany` returns zero results.
So, you will never get anything but `Count2 = 0` because if there are any results `!grandChildren.Any()` will equal 0. | The problem is with your `grandchildren` range variable. It contains *all* grandchildren (*not* filtered to a specific child), so Count2 is always considering if there are *any* grandchildren in the entire tree. |
25,605,088 | I have a combobox that is bind with a datasource and I am inserting a blank value to the 0 index like below.
```
Private Sub BuildCustomerList()
Dim ID As String = CStr(Session("M3_CustomerID"))
Dim fCustID As Guid = Guid.Parse(ID)
Dim dt As DataTable = dbAccess.GetCustomerRecord(fCustID)
... | 2014/09/01 | [
"https://Stackoverflow.com/questions/25605088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3797248/"
] | Just check it:
```
Dim customer = cmbSelectCustomer.SelectedValue
Dim guid As Guid
If String.IsNullOrEmpty(customer) Then
guid = Guid.Empty
Else
guid = Guid.Parse(customer)
End If
PopulateManageMessageGridView(guid)
```
You could also use `Guid.TryParse`:
```
Dim customer = cmbSelectCustomer.SelectedValue... | I'm always a fan on less code.
```
Dim cb As New ComboBox
Dim guid As Guid = If(cb.SelectedIndex > 0, guid.Parse(cb.SelectedValue), guid.NewGuid())
```
We check the `SelectedIndex` property of the ComboBox and confirm it is greater than 0, which will also handle the case that nothing is selected (index is -1).
Whil... |
22,841,608 | I am writing a foreach loop where I am outputting some HTML. I need to change the name of an input element each time it goes through the loop. I know in PHP it is super easy to combine text with a PHP variable. I cannot figure out how to do this in C#. I am using MVC3 Razor.
```
<img src="@Url.Content("~/Content/img/s... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22841608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/571723/"
] | You could try using parentheses around the variable you're trying to output.
```
<img src="@Url.Content("~/Content/img/subtract.png")" alt="Subtract" class="qtyminus" field="qtyValue@(i)" />
``` | you will not have the expected output as it's considered as a string
try this
```
<img src="@Url.Content("~/Content/img/subtract.png")" alt="Subtract" class="qtyminus" field="qtyValue"+ @i />
``` |
22,841,608 | I am writing a foreach loop where I am outputting some HTML. I need to change the name of an input element each time it goes through the loop. I know in PHP it is super easy to combine text with a PHP variable. I cannot figure out how to do this in C#. I am using MVC3 Razor.
```
<img src="@Url.Content("~/Content/img/s... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22841608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/571723/"
] | ```
<img src="@Url.Content("~/Content/img/subtract.png")" alt="Subtract" class="qtyminus" field="qtyValue@(i)" />
``` | you will not have the expected output as it's considered as a string
try this
```
<img src="@Url.Content("~/Content/img/subtract.png")" alt="Subtract" class="qtyminus" field="qtyValue"+ @i />
``` |
22,841,608 | I am writing a foreach loop where I am outputting some HTML. I need to change the name of an input element each time it goes through the loop. I know in PHP it is super easy to combine text with a PHP variable. I cannot figure out how to do this in C#. I am using MVC3 Razor.
```
<img src="@Url.Content("~/Content/img/s... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22841608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/571723/"
] | You could try using parentheses around the variable you're trying to output.
```
<img src="@Url.Content("~/Content/img/subtract.png")" alt="Subtract" class="qtyminus" field="qtyValue@(i)" />
``` | ```
<img src="@Url.Content("~/Content/img/subtract.png")" alt="Subtract" class="qtyminus" field="qtyValue@(i)" />
``` |
22,841,608 | I am writing a foreach loop where I am outputting some HTML. I need to change the name of an input element each time it goes through the loop. I know in PHP it is super easy to combine text with a PHP variable. I cannot figure out how to do this in C#. I am using MVC3 Razor.
```
<img src="@Url.Content("~/Content/img/s... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22841608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/571723/"
] | You could try using parentheses around the variable you're trying to output.
```
<img src="@Url.Content("~/Content/img/subtract.png")" alt="Subtract" class="qtyminus" field="qtyValue@(i)" />
``` | You are looking for:
```
<img src="@Url.Content("~/Content/img/subtract.png")" alt="Subtract"
class="qtyminus"
field=@string.Format(@"""qtyValue{0}""",i) />
``` |
22,841,608 | I am writing a foreach loop where I am outputting some HTML. I need to change the name of an input element each time it goes through the loop. I know in PHP it is super easy to combine text with a PHP variable. I cannot figure out how to do this in C#. I am using MVC3 Razor.
```
<img src="@Url.Content("~/Content/img/s... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22841608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/571723/"
] | ```
<img src="@Url.Content("~/Content/img/subtract.png")" alt="Subtract" class="qtyminus" field="qtyValue@(i)" />
``` | You are looking for:
```
<img src="@Url.Content("~/Content/img/subtract.png")" alt="Subtract"
class="qtyminus"
field=@string.Format(@"""qtyValue{0}""",i) />
``` |
56,131,448 | I'm playing with React Hooks for more than a few hours, I'm probably ran into an intriguing problem: using setInterval just doesn’t work as I'd expect with react-native
```
function Counter() {
const [time, setTime] = useState(0);
const r = useRef(null);
r.current = { time, setTime };
useEffect(() => {
con... | 2019/05/14 | [
"https://Stackoverflow.com/questions/56131448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11490372/"
] | Because you are mutating the DOM via a DOM node refs and the DOM mutation will change the appearance of the DOM node between the time that's rendered and your effects mutates it. then you don't need to use `useEffect` you will want to use `useLayoutEffect`
`useLayoutEffect` this runs synchronously immediately after Re... | You should be able to still use the state hook variables in the effect hook as they are in scope.
[useRef](https://reactjs.org/docs/hooks-reference.html#useref): mutations here aren't tracked, so they don't trigger re-renders.
[CodeSandbox Counter Example](https://codesandbox.io/s/9l42k273qr)
I feel that using refs ... |
37,254,348 | What am I doing wrong? If the button is clicked, variable s will have a value of 10, if not, it's 0. It's not working though.
```
$('button').observe('click', function () {
var clicked = true;
window.clicked = clicked;
});
if (clicked)
{
var s = 10;
}
else
{
var s = 0;
}
``` | 2016/05/16 | [
"https://Stackoverflow.com/questions/37254348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5757070/"
] | This might help you-
```
<button>
click
</button>
<script>
var clickCounter=0;
var s=0;
alert(s);
$('button').on('click',function(){
var s=10;
alert(s);
});
</script>
```
Initially the variable will store value of 0, after the vutton is cl... | You are creating a variable S inside the if and else scope.
Create a var s outside of the if and else and assign afterwards
Or you can do it like this:
```
var s = 0;
$('button').observe('click', function () {
s = 10;
});
```
This way you assign 10 to s only after click. The code you had before w... |
37,254,348 | What am I doing wrong? If the button is clicked, variable s will have a value of 10, if not, it's 0. It's not working though.
```
$('button').observe('click', function () {
var clicked = true;
window.clicked = clicked;
});
if (clicked)
{
var s = 10;
}
else
{
var s = 0;
}
``` | 2016/05/16 | [
"https://Stackoverflow.com/questions/37254348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5757070/"
] | This might help you-
```
<button>
click
</button>
<script>
var clickCounter=0;
var s=0;
alert(s);
$('button').on('click',function(){
var s=10;
alert(s);
});
</script>
```
Initially the variable will store value of 0, after the vutton is cl... | What exactly are you trying to achieve? Why don't you just set `s = 10` on click event? Like this:
```
var s = 0;
$('button').click(function () {
s = 10;
console.log(s);
});
console.log(s);
```
Or, if you're trying to observe the value that changes, try something like this:
```
$('button').click(function () {... |
5,859,702 | I don't find any solution to show a loading animation (or just an imageView) before a VideoView start to play : during the video is buffering.
Does anyone have a clue ?
Thanks. | 2011/05/02 | [
"https://Stackoverflow.com/questions/5859702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/424106/"
] | Or you can just use Progress Dialog;
```
public class VideoEkrani extends Activity {
VideoView ekran;
String kaynakYolu = "http://commonsware.com/misc/test2.3gp";
ProgressDialog progDailog;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
... | Finally I found the method `setOnPreparedListener()` on VideoView.
I added a ProgressBar inside my layout, and hide it with the OnPreparedListener |
5,859,702 | I don't find any solution to show a loading animation (or just an imageView) before a VideoView start to play : during the video is buffering.
Does anyone have a clue ?
Thanks. | 2011/05/02 | [
"https://Stackoverflow.com/questions/5859702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/424106/"
] | Or you can just use Progress Dialog;
```
public class VideoEkrani extends Activity {
VideoView ekran;
String kaynakYolu = "http://commonsware.com/misc/test2.3gp";
ProgressDialog progDailog;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
... | You cant detect the video buffer using `OnBufferingUpdateListener` on `MediaPlayer`. If you use `VideView` set that listener inside `OnPreparedListener`.
```
videoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
mp.setOnBufferingUpdateListener(new Media... |
241,540 | I have a relatively fresh instance of Ubuntu 16.04 running a Drupal 7 site, with php5.6 installed instead of php7. The drupal site runs well. I am trying to get drush installed so that I can easily do updates.
I have done the global install per <http://docs.drush.org/en/8.x/install/>
Specifically, as the ubuntu user ... | 2017/07/12 | [
"https://drupal.stackexchange.com/questions/241540",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/77491/"
] | To use namespaced classes in Drupal 7, you can use one of these modules:
* <https://drupal.org/project/xautoload>
* <https://drupal.org/project/registry_autoload>
One reason for choosing one or the other may be if you have other modules that also depend on one of those modules.
Otherwise I guess it is largely a matt... | I believe the reason is that Drupal 7's class loader doesn't account for namespaces, so it would find \TestClass but \Drupal\testmodule\TestClass is not found.
There are two ways around this: don't use namespaces (may not be possible), or include your own class loader as one of the files mentioned in your .info file.
... |
33,605,657 | I'm quite new to using Phaser and the Tiled map editor and I'm currently making a platformer game using a Tiled map I made. I haven't been able to find any information in the Tiled or Phaser documentation, or in tutorials or forums on how to select a layer in my Tiled map to be a collision layer. In some tutorials I've... | 2015/11/09 | [
"https://Stackoverflow.com/questions/33605657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5541661/"
] | ```
$(document).on("load", ".load-next-page", function(){
myApp.activities.myFunction1();
});
```
Each time document element is loaded the function is triggered.
If IE8 is not a constraint, use the DOMSubtreeModified event for this. | try `Promises` like [Q](https://github.com/kriskowal/q/)
and then using `.then()`
or [jquery `.promise()`](https://api.jquery.com/promise/)
like `$( "div" ).promise().done(function() {...`
you can read more about it [hare](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise) and [h... |
71,356,160 | This is my Form
```
<?php
namespace Admin\Form;
use Admin\Filter\ArticleAddInputFilter;
use Doctrine\Persistence\ObjectManager;
use Laminas\Form\Element\Checkbox;
use Laminas\Form\Element\Submit;
use Laminas\Form\Element\Text;
use Laminas\Form\Element\Textarea;
use Laminas\Form\Form;
use DoctrineModule;
class Ar... | 2022/03/04 | [
"https://Stackoverflow.com/questions/71356160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17509710/"
] | Success. Return property - good .
```
public function getObjectManager()
{
return $this->objectManager;
}
```
Error. Return method - error and infinite loop
```
public function getObjectManager()
{
return $this->getObjectManager();
}
``` | There is an infinite loop in your code. I think that’s what Aleksey Blossom is trying to say.
This part
```
public function getObjectManager()
{
return $this->getObjectManager();
}
```
This method is calling itself again, over and over.
I am not sure about the syntax but you'll need to return a value or call a... |
69,014,895 | I see following implementation in List.scala from Scala library:
```
override final def forall(p: A => Boolean): Boolean = {
var these: List[A] = this
while (!these.isEmpty) {
if (!p(these.head)) return false
these = these.tail
}
true
}
```
This method can be implemented recursively to ... | 2021/09/01 | [
"https://Stackoverflow.com/questions/69014895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2444661/"
] | The mutability of `var these` is not visible outside `forall` method and likely helps with performance
```
override final def forall(p: A => Boolean): Boolean = {
var these: List[A] = this
...
true
} // var is out-of-scope at this point
```
so technically `forall` is still pure from perspective of callers. *Ta... | The recursive approach is considered more declarative and readable that's why it's a good approach. From the other side functional approach implies immutibilty in particular which can lead to perfornace degradation so using such approach in Scala library is understandable. I assume that the authors of the Scala library... |
62,240,168 | What I really want to do is , if a user click on "ADD more" button then a same form repeat itself and the values should store in database, if he/she doesn't click of that button then only the values from first form should be stored.
I am not able to get this, I just created a form , and a table in database for those d... | 2020/06/07 | [
"https://Stackoverflow.com/questions/62240168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12308084/"
] | Change your buildToolsVersion to '29.0.2' in build.gradle file. | As on version Android 4.1.2 it says remove buildToolsVersion "28.0.2" from your build.gradle file since it has its own default build tools now and just Sync it. It worked for me. |
14,953,001 | How can I use at-exp to include blew raw string:
```
package foo
}
import (
```
I write like this, but it cannot include the "}" character:
```
#lang at-exp racket/base
(define code @S{
package foo
}
import (
}
```
How to include special character like "{}" in the raw part. | 2013/02/19 | [
"https://Stackoverflow.com/questions/14953001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1543634/"
] | Use `@S|{...}|` for that: since the closing part is `}|`, plain `}`s would not be special. Also, remember to use `|@` instead of just `@` for nested forms. And if you need another different quotation since you want to use `}|`s too, you can add more things between, as in `@S|==={...}===|`. See the [documentation page](... | oh, sorry, I find use @|"{"| is ok. |
2,046,096 | How to convert a number to $10^n$?
For example, $9.3\times10^{-6}=10^{-5.03}$.
How do you do this conversion to calculate the exponent of $10$?
How does one calculate the $-5.03$ exponent? | 2016/12/06 | [
"https://math.stackexchange.com/questions/2046096",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/396463/"
] | What you are basically saying is that you have a number $a$ and you want to find some number $x$ such that
$$10^x = a.$$
You can solve the equation above by applying the $\log\_{10}$ function on both sides to get
$$\log\_{10}(10^x) = \log\_{10}(a).$$
Now, remember what the $\log$ function is, and you are done. | If it is in form of $a\times 10^b$, then it is $10^x$ where $x=\log\_{10}(a)+b$. |
2,046,096 | How to convert a number to $10^n$?
For example, $9.3\times10^{-6}=10^{-5.03}$.
How do you do this conversion to calculate the exponent of $10$?
How does one calculate the $-5.03$ exponent? | 2016/12/06 | [
"https://math.stackexchange.com/questions/2046096",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/396463/"
] | What you are basically saying is that you have a number $a$ and you want to find some number $x$ such that
$$10^x = a.$$
You can solve the equation above by applying the $\log\_{10}$ function on both sides to get
$$\log\_{10}(10^x) = \log\_{10}(a).$$
Now, remember what the $\log$ function is, and you are done. | Just put it in logarithmic form, since expression is $a^n$.
$\log \_{10}(x) = n$
$x = 10^n$
where
$n = \log\_{10}(9,3 \times 10^{-6}) = x$ |
2,046,096 | How to convert a number to $10^n$?
For example, $9.3\times10^{-6}=10^{-5.03}$.
How do you do this conversion to calculate the exponent of $10$?
How does one calculate the $-5.03$ exponent? | 2016/12/06 | [
"https://math.stackexchange.com/questions/2046096",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/396463/"
] | Given the equation:
$10^{n}=9.3\times10^{-6}$
Take $\log\_{10}$ on each side:
$n=\log\_{10}(9.3\times10^{-6})$
Simplify the right-hand side:
$n=\log\_{10}(9.3)+\log\_{10}(10^{-6})$
Simplify the right-hand side again:
$n=\log\_{10}(9.3)+(-6)$
Solve the right-hand side in a calculator:
$n\approx-5.03$ | If it is in form of $a\times 10^b$, then it is $10^x$ where $x=\log\_{10}(a)+b$. |
2,046,096 | How to convert a number to $10^n$?
For example, $9.3\times10^{-6}=10^{-5.03}$.
How do you do this conversion to calculate the exponent of $10$?
How does one calculate the $-5.03$ exponent? | 2016/12/06 | [
"https://math.stackexchange.com/questions/2046096",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/396463/"
] | Well... logarithm values are not easy to hand-calculate, if that's what you're asking. Because $x = 10^{\log\_{10} x}$ is the simple definition of logarithm values.
Which is why, once upon a time, kids like me were taught how to look up the relevant values (for $9.3$, in your case) in a table of logarithms: $0.9685$, ... | If it is in form of $a\times 10^b$, then it is $10^x$ where $x=\log\_{10}(a)+b$. |
2,046,096 | How to convert a number to $10^n$?
For example, $9.3\times10^{-6}=10^{-5.03}$.
How do you do this conversion to calculate the exponent of $10$?
How does one calculate the $-5.03$ exponent? | 2016/12/06 | [
"https://math.stackexchange.com/questions/2046096",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/396463/"
] | Given the equation:
$10^{n}=9.3\times10^{-6}$
Take $\log\_{10}$ on each side:
$n=\log\_{10}(9.3\times10^{-6})$
Simplify the right-hand side:
$n=\log\_{10}(9.3)+\log\_{10}(10^{-6})$
Simplify the right-hand side again:
$n=\log\_{10}(9.3)+(-6)$
Solve the right-hand side in a calculator:
$n\approx-5.03$ | Just put it in logarithmic form, since expression is $a^n$.
$\log \_{10}(x) = n$
$x = 10^n$
where
$n = \log\_{10}(9,3 \times 10^{-6}) = x$ |
2,046,096 | How to convert a number to $10^n$?
For example, $9.3\times10^{-6}=10^{-5.03}$.
How do you do this conversion to calculate the exponent of $10$?
How does one calculate the $-5.03$ exponent? | 2016/12/06 | [
"https://math.stackexchange.com/questions/2046096",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/396463/"
] | Well... logarithm values are not easy to hand-calculate, if that's what you're asking. Because $x = 10^{\log\_{10} x}$ is the simple definition of logarithm values.
Which is why, once upon a time, kids like me were taught how to look up the relevant values (for $9.3$, in your case) in a table of logarithms: $0.9685$, ... | Just put it in logarithmic form, since expression is $a^n$.
$\log \_{10}(x) = n$
$x = 10^n$
where
$n = \log\_{10}(9,3 \times 10^{-6}) = x$ |
22,116,192 | I have date in without "/" in text field and it is in `mm/dd/yy` format. We received input in this format 03292014. I want to get month,date and year from this number like 03/29/2014
```
var m = new Date(3292014*1000)
console.log(m.toGMTString())
``` | 2014/03/01 | [
"https://Stackoverflow.com/questions/22116192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2917268/"
] | You could do this :
```
var m = '03292014'.match(/(\d\d)(\d\d)(\d\d\d\d)/);
var d = new Date(m[3], m[1] - 1, m[2]);
```
Or convert the input into a standard "YYYY-MM-DD" format :
```
var d = new Date('03292014'.replace(
/(\d\d)(\d\d)(\d\d\d\d)/, '$3-$1-$2'
));
```
Specs : <http://es5.github.io/#x15.9.1.15>.
... | Get the components from the input, then you can create a `Date` object from them. Example:
```
var input = '03292014';
var year = parseInt(input.substr(4), 10);
var day = parseInt(input.substr(2, 2), 10);
var month = parseInt(input.substr(0, 2), 10);
var date = new Date(year, month - 1, day);
``` |
267,027 | I have a group:
```
group = PermutationGroup[{Cycles[{{1, 3, 6}, {2, 4}}], Cycles[{{6, 7}}]}];
```
And I have s subgroup
```
subgroup = PermutationGroup[{Cycles[{{6,7}}],Cycles[{{2,4}}],Cycles[{{1,7}}]}];
```
We can check it:
```
ResourceFunction["SubgroupQ"][subgroup, group]
```
>
> True
>
>
>
So how to ... | 2022/04/19 | [
"https://mathematica.stackexchange.com/questions/267027",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/21532/"
] | Since two left cosets $g\cdot H$ and $h \cdot H$ satisfies $g\cdot H= h \cdot H$ is equavalent to $ h^{-1}\cdot g\in H$,we set it as the equivalence relationships and use `Gather`.
```
Gather[GroupElements[group],
GroupElementQ[subgroup, PermutationProduct[InversePermutation[#1], #2]] &]
```
There are 4 cosets.
... | First edit
==========
Since $b\in aH$, if and only if $aH=bH$:
```
Union[Sort[#, Less] &/@ Table[Table[
PermutationProduct[e, i], {i, GroupElements[subgroup]}], {e,
GroupElements[group]}]]
```
[](https://i.stack.imgur.com/qERpN.png)
The r... |
267,027 | I have a group:
```
group = PermutationGroup[{Cycles[{{1, 3, 6}, {2, 4}}], Cycles[{{6, 7}}]}];
```
And I have s subgroup
```
subgroup = PermutationGroup[{Cycles[{{6,7}}],Cycles[{{2,4}}],Cycles[{{1,7}}]}];
```
We can check it:
```
ResourceFunction["SubgroupQ"][subgroup, group]
```
>
> True
>
>
>
So how to ... | 2022/04/19 | [
"https://mathematica.stackexchange.com/questions/267027",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/21532/"
] | Since two left cosets $g\cdot H$ and $h \cdot H$ satisfies $g\cdot H= h \cdot H$ is equavalent to $ h^{-1}\cdot g\in H$,we set it as the equivalence relationships and use `Gather`.
```
Gather[GroupElements[group],
GroupElementQ[subgroup, PermutationProduct[InversePermutation[#1], #2]] &]
```
There are 4 cosets.
... | Share another elegant method to **list all right cosets**. The only regret is that it cannot be used to find left cosets. Because The inverse of the right coset canonical representative about $p$ is not in the same left coset with $p$:
```
GatherBy[GroupElements[group], RightCosetRepresentative[subgroup, #] &]
``` |
267,027 | I have a group:
```
group = PermutationGroup[{Cycles[{{1, 3, 6}, {2, 4}}], Cycles[{{6, 7}}]}];
```
And I have s subgroup
```
subgroup = PermutationGroup[{Cycles[{{6,7}}],Cycles[{{2,4}}],Cycles[{{1,7}}]}];
```
We can check it:
```
ResourceFunction["SubgroupQ"][subgroup, group]
```
>
> True
>
>
>
So how to ... | 2022/04/19 | [
"https://mathematica.stackexchange.com/questions/267027",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/21532/"
] | First edit
==========
Since $b\in aH$, if and only if $aH=bH$:
```
Union[Sort[#, Less] &/@ Table[Table[
PermutationProduct[e, i], {i, GroupElements[subgroup]}], {e,
GroupElements[group]}]]
```
[](https://i.stack.imgur.com/qERpN.png)
The r... | Share another elegant method to **list all right cosets**. The only regret is that it cannot be used to find left cosets. Because The inverse of the right coset canonical representative about $p$ is not in the same left coset with $p$:
```
GatherBy[GroupElements[group], RightCosetRepresentative[subgroup, #] &]
``` |
15,724,955 | Say I have user input these variables: ID name age
And I'm using a while loop to get user input like below
```
while(cin){
cin >> ID >> name >> age;
do_stuff(ID, name, age);
}
```
but if at some moment the user only input some of those variables, say only ID and name, the while loop should end immediately witho... | 2013/03/31 | [
"https://Stackoverflow.com/questions/15724955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1468639/"
] | ```
#include <iostream>
#include <string>
int main() {
int ID, age;
std::string name;
while(std::cin.good()){
if (std::cin >> ID && std::cin >> name && std::cin >> age) {
std::cout << ID << name << age << std::endl;
}
}
ret... | You can achieve this by using stringstream and getline, something like the following:
```
#include <sstream>
#include <string>
int age = -1; //assume you init age as -1 and age is integer type
stringstream ss;
while (getline(cin,line))
{
age = -1;
ss.clear();
ss << line;
ss >> ID >> n... |
2,696,229 | I've been a CF developer for 15 years and I've never run into anything this strange or frustrating. I've pulled my hair out for hours, googled, abstracted, simplified, prayed and done it all in reverse. Can you help me?
A cffunction takes one string argument and from that string I build an array of "phrases" to run a ... | 2010/04/23 | [
"https://Stackoverflow.com/questions/2696229",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/182544/"
] | It seems to me that your function generates a slightly different query than what you are expecting, try to put a breakpoint in your function after generating the query, copy the generated query and run it in sql server. I expect no results will be found also.
May be some spaces or something resulting in no records fo... | Are you using CF 8 or CF 8.01? Upgrade to CF 8.01 if you're not on it already.
You can also try loading a different JDBC driver for SQL Server 2005 than the built-in one. See <http://kb2.adobe.com/cps/421/ded4216b.html> I suggest this because the connection between CF/JRUN and the database seems to be the layer where ... |
244,926 | I'm using a the TreeView control and it scrolls automatically to left-align TreeViewItem when one of them is clicked. I've gone looking at my Styles and ControlTemplates, but I haven't found anything. Is there a default ControlTemplate that causes this? I want to disable it. | 2008/10/28 | [
"https://Stackoverflow.com/questions/244926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3279/"
] | The items scroll because the ScrollViewer calls BringIntoView() on them. So one way to avoid scrolling is to suppress the handling of the RequestBringIntoView event. You can try that out quickly by subclassing TreeView and instantiating this control instead:
```
public class NoScrollTreeView : TreeView
{
public cl... | It looks like I found a good clue on [MSDN](http://social.msdn.microsoft.com/forums/en-US/wpf/thread/9abff78f-481d-4db1-a545-c461f7d19200/):
>
> Sounds like this is an interaction
> with the scrollviewer and the focus
> system.
>
>
> When an element is focused within a
> ScrollViewer (which is part of the
> Tre... |
244,926 | I'm using a the TreeView control and it scrolls automatically to left-align TreeViewItem when one of them is clicked. I've gone looking at my Styles and ControlTemplates, but I haven't found anything. Is there a default ControlTemplate that causes this? I want to disable it. | 2008/10/28 | [
"https://Stackoverflow.com/questions/244926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3279/"
] | after spending some hours on this problem i found a solution that works for me.
brians solution to prevent the RequestBringIntoView event on a TreeViewItem from bubbling was the first step. unfortunately this also stops a treeviewitem to be shown if you change the selected item programmatically by
```
yourtreeview.Se... | It looks like I found a good clue on [MSDN](http://social.msdn.microsoft.com/forums/en-US/wpf/thread/9abff78f-481d-4db1-a545-c461f7d19200/):
>
> Sounds like this is an interaction
> with the scrollviewer and the focus
> system.
>
>
> When an element is focused within a
> ScrollViewer (which is part of the
> Tre... |
244,926 | I'm using a the TreeView control and it scrolls automatically to left-align TreeViewItem when one of them is clicked. I've gone looking at my Styles and ControlTemplates, but I haven't found anything. Is there a default ControlTemplate that causes this? I want to disable it. | 2008/10/28 | [
"https://Stackoverflow.com/questions/244926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3279/"
] | The items scroll because the ScrollViewer calls BringIntoView() on them. So one way to avoid scrolling is to suppress the handling of the RequestBringIntoView event. You can try that out quickly by subclassing TreeView and instantiating this control instead:
```
public class NoScrollTreeView : TreeView
{
public cl... | Ok, I was finally able to get the default style like this:
```
using (Stream sw = File.Open(@"C:\TreeViewDefaults.xaml", FileMode.Truncate, FileAccess.Write))
{
Style ts = Application.Current.FindResource(typeof(TreeView)) as Style;
if (ts != null)
XamlWriter.Sav... |
244,926 | I'm using a the TreeView control and it scrolls automatically to left-align TreeViewItem when one of them is clicked. I've gone looking at my Styles and ControlTemplates, but I haven't found anything. Is there a default ControlTemplate that causes this? I want to disable it. | 2008/10/28 | [
"https://Stackoverflow.com/questions/244926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3279/"
] | after spending some hours on this problem i found a solution that works for me.
brians solution to prevent the RequestBringIntoView event on a TreeViewItem from bubbling was the first step. unfortunately this also stops a treeviewitem to be shown if you change the selected item programmatically by
```
yourtreeview.Se... | Ok, I was finally able to get the default style like this:
```
using (Stream sw = File.Open(@"C:\TreeViewDefaults.xaml", FileMode.Truncate, FileAccess.Write))
{
Style ts = Application.Current.FindResource(typeof(TreeView)) as Style;
if (ts != null)
XamlWriter.Sav... |
244,926 | I'm using a the TreeView control and it scrolls automatically to left-align TreeViewItem when one of them is clicked. I've gone looking at my Styles and ControlTemplates, but I haven't found anything. Is there a default ControlTemplate that causes this? I want to disable it. | 2008/10/28 | [
"https://Stackoverflow.com/questions/244926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3279/"
] | The items scroll because the ScrollViewer calls BringIntoView() on them. So one way to avoid scrolling is to suppress the handling of the RequestBringIntoView event. You can try that out quickly by subclassing TreeView and instantiating this control instead:
```
public class NoScrollTreeView : TreeView
{
public cl... | Another fun tidbit: there is a overridable boolean value called HandlesScrolling that always returns true. After decompiling the source, it looks like this property is NEVER used (or it's being used in some deep, dark, secret place in XAML). I tried making my own TreeView control to set this value to false and it didn'... |
244,926 | I'm using a the TreeView control and it scrolls automatically to left-align TreeViewItem when one of them is clicked. I've gone looking at my Styles and ControlTemplates, but I haven't found anything. Is there a default ControlTemplate that causes this? I want to disable it. | 2008/10/28 | [
"https://Stackoverflow.com/questions/244926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3279/"
] | after spending some hours on this problem i found a solution that works for me.
brians solution to prevent the RequestBringIntoView event on a TreeViewItem from bubbling was the first step. unfortunately this also stops a treeviewitem to be shown if you change the selected item programmatically by
```
yourtreeview.Se... | Another fun tidbit: there is a overridable boolean value called HandlesScrolling that always returns true. After decompiling the source, it looks like this property is NEVER used (or it's being used in some deep, dark, secret place in XAML). I tried making my own TreeView control to set this value to false and it didn'... |
244,926 | I'm using a the TreeView control and it scrolls automatically to left-align TreeViewItem when one of them is clicked. I've gone looking at my Styles and ControlTemplates, but I haven't found anything. Is there a default ControlTemplate that causes this? I want to disable it. | 2008/10/28 | [
"https://Stackoverflow.com/questions/244926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3279/"
] | The items scroll because the ScrollViewer calls BringIntoView() on them. So one way to avoid scrolling is to suppress the handling of the RequestBringIntoView event. You can try that out quickly by subclassing TreeView and instantiating this control instead:
```
public class NoScrollTreeView : TreeView
{
public cl... | after spending some hours on this problem i found a solution that works for me.
brians solution to prevent the RequestBringIntoView event on a TreeViewItem from bubbling was the first step. unfortunately this also stops a treeviewitem to be shown if you change the selected item programmatically by
```
yourtreeview.Se... |
520,985 | Some physical theories such as special theory of relativity are based on the invariance of the speed of light.
However, is the invariance of the speed of light, in the first place, logically possible?
I'm talking about this version or its equivalence: the speed of light in vacuum is always measured to be the same v... | 2019/12/23 | [
"https://physics.stackexchange.com/questions/520985",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/250120/"
] | You're correct that you've reached a contradiction but it is because you have used the non-relativistic velocity addition formula. The relativistic version is needed to keep the speed of light invariant.
Also, how can the speed of light be different but always be measured to be the same? The value of a number can only... | >
> Also consider the velocity of L with respect to each observers
>
>
>
What seems obvious to us now wasn't as obvious to people at the time of Galileo. Although we are used to [Galilean transformation](https://en.wikipedia.org/wiki/Galilean_transformation) so much that we consider it trivial and obvious, it is n... |
520,985 | Some physical theories such as special theory of relativity are based on the invariance of the speed of light.
However, is the invariance of the speed of light, in the first place, logically possible?
I'm talking about this version or its equivalence: the speed of light in vacuum is always measured to be the same v... | 2019/12/23 | [
"https://physics.stackexchange.com/questions/520985",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/250120/"
] | You're correct that you've reached a contradiction but it is because you have used the non-relativistic velocity addition formula. The relativistic version is needed to keep the speed of light invariant.
Also, how can the speed of light be different but always be measured to be the same? The value of a number can only... | There are two related but distinct assumptions in your argument that are culprits:
1. An object moving at the speed of light can be an observer.
2. If the velocity of an object is $\vec{u}$ w.r.t. an observer $O$ who itself moves at velocity $-\vec{v}$ w.r.t. another observer $O'$ then the velocity of the object w.r.... |
520,985 | Some physical theories such as special theory of relativity are based on the invariance of the speed of light.
However, is the invariance of the speed of light, in the first place, logically possible?
I'm talking about this version or its equivalence: the speed of light in vacuum is always measured to be the same v... | 2019/12/23 | [
"https://physics.stackexchange.com/questions/520985",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/250120/"
] | Your argument is faulty. You set out to prove that the speed of light cannot be invariant, and you do so by assuming it is not invariant. Specifically, you say that the velocity of L with respect to O is c-v, which means that the velocity of L is not invariant. If L is light in a vacuum then its velocity is c with resp... | >
> Also consider the velocity of L with respect to each observers
>
>
>
What seems obvious to us now wasn't as obvious to people at the time of Galileo. Although we are used to [Galilean transformation](https://en.wikipedia.org/wiki/Galilean_transformation) so much that we consider it trivial and obvious, it is n... |
520,985 | Some physical theories such as special theory of relativity are based on the invariance of the speed of light.
However, is the invariance of the speed of light, in the first place, logically possible?
I'm talking about this version or its equivalence: the speed of light in vacuum is always measured to be the same v... | 2019/12/23 | [
"https://physics.stackexchange.com/questions/520985",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/250120/"
] | >
> Also consider the velocity of L with respect to each observers
>
>
>
What seems obvious to us now wasn't as obvious to people at the time of Galileo. Although we are used to [Galilean transformation](https://en.wikipedia.org/wiki/Galilean_transformation) so much that we consider it trivial and obvious, it is n... | There are two related but distinct assumptions in your argument that are culprits:
1. An object moving at the speed of light can be an observer.
2. If the velocity of an object is $\vec{u}$ w.r.t. an observer $O$ who itself moves at velocity $-\vec{v}$ w.r.t. another observer $O'$ then the velocity of the object w.r.... |
520,985 | Some physical theories such as special theory of relativity are based on the invariance of the speed of light.
However, is the invariance of the speed of light, in the first place, logically possible?
I'm talking about this version or its equivalence: the speed of light in vacuum is always measured to be the same v... | 2019/12/23 | [
"https://physics.stackexchange.com/questions/520985",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/250120/"
] | Your argument is faulty. You set out to prove that the speed of light cannot be invariant, and you do so by assuming it is not invariant. Specifically, you say that the velocity of L with respect to O is c-v, which means that the velocity of L is not invariant. If L is light in a vacuum then its velocity is c with resp... | There are two related but distinct assumptions in your argument that are culprits:
1. An object moving at the speed of light can be an observer.
2. If the velocity of an object is $\vec{u}$ w.r.t. an observer $O$ who itself moves at velocity $-\vec{v}$ w.r.t. another observer $O'$ then the velocity of the object w.r.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.