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 |
|---|---|---|---|---|---|
34,548,039 | i am using [Gorilla Mux](http://www.gorillatoolkit.org/pkg/mux) for writing a REST API and i am having trouble organizing my routes, currently all of my routes are defined in the `main.go` file like this
```
//main.go
package main
import (
"NovAPI/routes"
"fmt"
"github.com/gorilla/mux"
"net/http"
)
f... | 2015/12/31 | [
"https://Stackoverflow.com/questions/34548039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5288071/"
] | You can modularize your routers independently into different packages, and mount them on the main router
Elaborating just a little on the following [issue](https://github.com/gorilla/mux/issues/136), you can come up with this approach, that makes it quite scalable (and easier to test, to some degree)
/api/router.go
... | I like checking out other projects in github to grab ideas on how to do stuff, and for these cases I usually take a look first at the [Docker repo](https://github.com/docker/docker). This is the way they do it:
For the [system](https://github.com/docker/docker/tree/master/api/server/router/system)'s routes, define all... |
34,548,039 | i am using [Gorilla Mux](http://www.gorillatoolkit.org/pkg/mux) for writing a REST API and i am having trouble organizing my routes, currently all of my routes are defined in the `main.go` file like this
```
//main.go
package main
import (
"NovAPI/routes"
"fmt"
"github.com/gorilla/mux"
"net/http"
)
f... | 2015/12/31 | [
"https://Stackoverflow.com/questions/34548039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5288071/"
] | I like checking out other projects in github to grab ideas on how to do stuff, and for these cases I usually take a look first at the [Docker repo](https://github.com/docker/docker). This is the way they do it:
For the [system](https://github.com/docker/docker/tree/master/api/server/router/system)'s routes, define all... | Since I am new to Go, I prefer a less verbose solution. In each module, we can create a Route function that expects a main route pointer and creates sub-routes to it. Our main.go file would be as follows
```
package main
import (
"net/http"
"github.com/user-name/repo-name/auth"
"github.com/gorilla/mux"
)
... |
34,548,039 | i am using [Gorilla Mux](http://www.gorillatoolkit.org/pkg/mux) for writing a REST API and i am having trouble organizing my routes, currently all of my routes are defined in the `main.go` file like this
```
//main.go
package main
import (
"NovAPI/routes"
"fmt"
"github.com/gorilla/mux"
"net/http"
)
f... | 2015/12/31 | [
"https://Stackoverflow.com/questions/34548039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5288071/"
] | You can modularize your routers independently into different packages, and mount them on the main router
Elaborating just a little on the following [issue](https://github.com/gorilla/mux/issues/136), you can come up with this approach, that makes it quite scalable (and easier to test, to some degree)
/api/router.go
... | Since I am new to Go, I prefer a less verbose solution. In each module, we can create a Route function that expects a main route pointer and creates sub-routes to it. Our main.go file would be as follows
```
package main
import (
"net/http"
"github.com/user-name/repo-name/auth"
"github.com/gorilla/mux"
)
... |
33,102,918 | In a Symfony2 application, I use Twig's [attribute](http://twig.sensiolabs.org/doc/functions/attribute.html) function to display properties of a product on a generic manner : I have an array of names of properties, and cycling through it I display properties :
```
{% for property in arrayProperties %}
{{ attribute... | 2015/10/13 | [
"https://Stackoverflow.com/questions/33102918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3448249/"
] | In your case, `objectID` is just the id itself, the selector requires `#` aswell.
So change
```
console.log($(objectID).width()); // --> NULL
```
to
```
console.log($('#' + objectID).width()); // --> MAGIC
```
Futhermore, this is invalid syntax:
```
$(objectID > "span")
```
Correct that to
```
$('#' + objectI... | Your current code doesn't give you the value because the `objectID` variable doesn't contain the preceding `#` for the id selector to work:
```
params = {
w: $('#' + objectID).width($('#' + objectID + " > span").width() * 1.25),
h: $('#' + objectID).height($('#' + objectID + " > span").width() * 1.25)
};
```
... |
17,811,730 | I am working with Matlab and i have the following problem. I have a matrix let's say `A`
```
A =
1 0 0 1 0 0
1 0 1 0 0 0
```
I want to be able to delete the columns that have only zeros but only after the last column with at least one 1 i.e column 5 and column 6 but not col... | 2013/07/23 | [
"https://Stackoverflow.com/questions/17811730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/730047/"
] | Or, with fewer lines
```
b = A(:,1:find(any(A),1,'last'))
``` | try this
```
zerocols=sum(A,1)
b=A(:,1:find(zerocols~=0,1,'last'))
``` |
26,114,345 | I am writing my own background location updates for interval of every 5 minutes in android. I would like to know the difference between setInterval and setFastestInterval
When I setInterval to 5 mins and setFastestInterval to 2 mins. The location update is called every 2 mins.
I would like to know the difference. I ... | 2014/09/30 | [
"https://Stackoverflow.com/questions/26114345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1443051/"
] | Based on the relevant [Android documentation](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest):
* `setInterval(long)` means - set the interval in which you want to get locations.
* `setFastestInterval(long)` means - if a location is available sooner you can get it (i.e. ... | >
> I am writing my own background location updates for interval of every *5 minutes* in android. I would like to know the difference between `setInterval`and `setFastestInterval`
>
>
>
Assume that the `setFastestInterval();` has higher priority for requesting a `Location`. To whatever app you set the `setFastest... |
26,114,345 | I am writing my own background location updates for interval of every 5 minutes in android. I would like to know the difference between setInterval and setFastestInterval
When I setInterval to 5 mins and setFastestInterval to 2 mins. The location update is called every 2 mins.
I would like to know the difference. I ... | 2014/09/30 | [
"https://Stackoverflow.com/questions/26114345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1443051/"
] | Based on the relevant [Android documentation](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest):
* `setInterval(long)` means - set the interval in which you want to get locations.
* `setFastestInterval(long)` means - if a location is available sooner you can get it (i.e. ... | >
> Also: Is there an inbuilt function to check the location updates only if the distances of the first update are more than 20meters with the second update?
>
>
>
LocationRequest has a method you can use to set the minimum distance between updates.
```
int minimumDistanceBetweenUpdates = 20;
LocationRequest req... |
26,114,345 | I am writing my own background location updates for interval of every 5 minutes in android. I would like to know the difference between setInterval and setFastestInterval
When I setInterval to 5 mins and setFastestInterval to 2 mins. The location update is called every 2 mins.
I would like to know the difference. I ... | 2014/09/30 | [
"https://Stackoverflow.com/questions/26114345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1443051/"
] | Based on the relevant [Android documentation](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest):
* `setInterval(long)` means - set the interval in which you want to get locations.
* `setFastestInterval(long)` means - if a location is available sooner you can get it (i.e. ... | setInterval (long millis)
This interval is inexact. You may not receive updates at all (if no location sources are available), or you may receive them slower than requested. You may also receive them faster than requested (if other applications are requesting location at a faster interval). The fastest rate that that y... |
26,114,345 | I am writing my own background location updates for interval of every 5 minutes in android. I would like to know the difference between setInterval and setFastestInterval
When I setInterval to 5 mins and setFastestInterval to 2 mins. The location update is called every 2 mins.
I would like to know the difference. I ... | 2014/09/30 | [
"https://Stackoverflow.com/questions/26114345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1443051/"
] | >
> I am writing my own background location updates for interval of every *5 minutes* in android. I would like to know the difference between `setInterval`and `setFastestInterval`
>
>
>
Assume that the `setFastestInterval();` has higher priority for requesting a `Location`. To whatever app you set the `setFastest... | setInterval (long millis)
This interval is inexact. You may not receive updates at all (if no location sources are available), or you may receive them slower than requested. You may also receive them faster than requested (if other applications are requesting location at a faster interval). The fastest rate that that y... |
26,114,345 | I am writing my own background location updates for interval of every 5 minutes in android. I would like to know the difference between setInterval and setFastestInterval
When I setInterval to 5 mins and setFastestInterval to 2 mins. The location update is called every 2 mins.
I would like to know the difference. I ... | 2014/09/30 | [
"https://Stackoverflow.com/questions/26114345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1443051/"
] | >
> Also: Is there an inbuilt function to check the location updates only if the distances of the first update are more than 20meters with the second update?
>
>
>
LocationRequest has a method you can use to set the minimum distance between updates.
```
int minimumDistanceBetweenUpdates = 20;
LocationRequest req... | setInterval (long millis)
This interval is inexact. You may not receive updates at all (if no location sources are available), or you may receive them slower than requested. You may also receive them faster than requested (if other applications are requesting location at a faster interval). The fastest rate that that y... |
209,790 | I would like to have the same editor available on all of the platforms I frequent.
Emacs and Vi are not desired solutions. | 2008/10/16 | [
"https://Stackoverflow.com/questions/209790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] | From <http://help.eclipse.org/help21/topic/org.eclipse.platform.doc.user/tasks/running_eclipse.htm>:
Use the following command-line argument:
```
-data your_workspace_location
```
For example,
```
-data c:\users\robert\myworkspace
```
you can also use UNIX-style relative path names such as
```
-data ../workspa... | note that you can use UNIX-style relative path names such as
```
-data ../workspace
```
even under Windows, in case something doesn't like colons or backslashes in parameters, like Jumplist Launcher |
209,790 | I would like to have the same editor available on all of the platforms I frequent.
Emacs and Vi are not desired solutions. | 2008/10/16 | [
"https://Stackoverflow.com/questions/209790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] | From <http://help.eclipse.org/help21/topic/org.eclipse.platform.doc.user/tasks/running_eclipse.htm>:
Use the following command-line argument:
```
-data your_workspace_location
```
For example,
```
-data c:\users\robert\myworkspace
```
you can also use UNIX-style relative path names such as
```
-data ../workspa... | With the -data switch
Setting a specific location for the workspace with -data
To use the -data command line argument, simply add -data your\_workspace\_location (for example, -data c:\users\robert\myworkspace) to the Target field in the shortcut properties, or include it explicitly on your command line.
From: <http... |
209,790 | I would like to have the same editor available on all of the platforms I frequent.
Emacs and Vi are not desired solutions. | 2008/10/16 | [
"https://Stackoverflow.com/questions/209790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] | We set the default workspace for students at a high school by modifying the shortcut properties. In this case, we operate a Windows 7 environment. The default workspace is on a student's network share mapped as the H: drive so we added **-data h:\workspace**. The screenshot shows exactly where.
![enter image descripti... | **Creating a shortcut file with target :**
Create a shortcut of your eclipse.
Open the properties of the shortcut file and set the target as follows,
```
E\STS.exe -data "WORKSPACE_LOCATION"
```
**For launching from .bat file :**
```
cd ECLIPSE_LOCATION
start STS.exe -data "WORKSPACE_LOCATION"
```
Example:
`... |
209,790 | I would like to have the same editor available on all of the platforms I frequent.
Emacs and Vi are not desired solutions. | 2008/10/16 | [
"https://Stackoverflow.com/questions/209790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] | From <http://help.eclipse.org/help21/topic/org.eclipse.platform.doc.user/tasks/running_eclipse.htm>:
Use the following command-line argument:
```
-data your_workspace_location
```
For example,
```
-data c:\users\robert\myworkspace
```
you can also use UNIX-style relative path names such as
```
-data ../workspa... | **Creating a shortcut file with target :**
Create a shortcut of your eclipse.
Open the properties of the shortcut file and set the target as follows,
```
E\STS.exe -data "WORKSPACE_LOCATION"
```
**For launching from .bat file :**
```
cd ECLIPSE_LOCATION
start STS.exe -data "WORKSPACE_LOCATION"
```
Example:
`... |
209,790 | I would like to have the same editor available on all of the platforms I frequent.
Emacs and Vi are not desired solutions. | 2008/10/16 | [
"https://Stackoverflow.com/questions/209790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] | Old question, I know, but just wanted to point out that you may need to add quotes around the target workspace path. For example; I tried `C:\Eclipse\eclipse.exe -data E:\Eclipse Projects2` and it would open a blank, default, workspace while doing `C:\Eclipse\eclipse.exe -data "E:\Eclipse Projects2"` allowed it to use ... | I wish people would give an actual example, i learn better with examples rather than syntax.
so here it goes...
```
"C:\MyEclipse Blue Edition\MyEclipse Blue Edition 10\myeclipse-blue.exe" -showlocation -data "C:\EclipseWork\WorkSpace"
```
this command will open eclipse with the specified workspace. this is a workin... |
209,790 | I would like to have the same editor available on all of the platforms I frequent.
Emacs and Vi are not desired solutions. | 2008/10/16 | [
"https://Stackoverflow.com/questions/209790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] | **Creating a shortcut file with target :**
Create a shortcut of your eclipse.
Open the properties of the shortcut file and set the target as follows,
```
E\STS.exe -data "WORKSPACE_LOCATION"
```
**For launching from .bat file :**
```
cd ECLIPSE_LOCATION
start STS.exe -data "WORKSPACE_LOCATION"
```
Example:
`... | From <https://help.eclipse.org/topic/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html>
It is also possible to specify the workspace location using the `osgi.instance.area` JVM arg as `-Dosgi.instance.area=../workspace`
This can be specified in the eclipse.ini file along with existing/other JVM args su... |
209,790 | I would like to have the same editor available on all of the platforms I frequent.
Emacs and Vi are not desired solutions. | 2008/10/16 | [
"https://Stackoverflow.com/questions/209790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] | note that you can use UNIX-style relative path names such as
```
-data ../workspace
```
even under Windows, in case something doesn't like colons or backslashes in parameters, like Jumplist Launcher | From <https://help.eclipse.org/topic/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html>
It is also possible to specify the workspace location using the `osgi.instance.area` JVM arg as `-Dosgi.instance.area=../workspace`
This can be specified in the eclipse.ini file along with existing/other JVM args su... |
209,790 | I would like to have the same editor available on all of the platforms I frequent.
Emacs and Vi are not desired solutions. | 2008/10/16 | [
"https://Stackoverflow.com/questions/209790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] | We set the default workspace for students at a high school by modifying the shortcut properties. In this case, we operate a Windows 7 environment. The default workspace is on a student's network share mapped as the H: drive so we added **-data h:\workspace**. The screenshot shows exactly where.
![enter image descripti... | I wish people would give an actual example, i learn better with examples rather than syntax.
so here it goes...
```
"C:\MyEclipse Blue Edition\MyEclipse Blue Edition 10\myeclipse-blue.exe" -showlocation -data "C:\EclipseWork\WorkSpace"
```
this command will open eclipse with the specified workspace. this is a workin... |
209,790 | I would like to have the same editor available on all of the platforms I frequent.
Emacs and Vi are not desired solutions. | 2008/10/16 | [
"https://Stackoverflow.com/questions/209790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] | We set the default workspace for students at a high school by modifying the shortcut properties. In this case, we operate a Windows 7 environment. The default workspace is on a student's network share mapped as the H: drive so we added **-data h:\workspace**. The screenshot shows exactly where.
![enter image descripti... | Old question, I know, but just wanted to point out that you may need to add quotes around the target workspace path. For example; I tried `C:\Eclipse\eclipse.exe -data E:\Eclipse Projects2` and it would open a blank, default, workspace while doing `C:\Eclipse\eclipse.exe -data "E:\Eclipse Projects2"` allowed it to use ... |
209,790 | I would like to have the same editor available on all of the platforms I frequent.
Emacs and Vi are not desired solutions. | 2008/10/16 | [
"https://Stackoverflow.com/questions/209790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] | note that you can use UNIX-style relative path names such as
```
-data ../workspace
```
even under Windows, in case something doesn't like colons or backslashes in parameters, like Jumplist Launcher | I wish people would give an actual example, i learn better with examples rather than syntax.
so here it goes...
```
"C:\MyEclipse Blue Edition\MyEclipse Blue Edition 10\myeclipse-blue.exe" -showlocation -data "C:\EclipseWork\WorkSpace"
```
this command will open eclipse with the specified workspace. this is a workin... |
63,553,515 | ```
app_name = 'app_name'
path('url/<uuid:uuid>',someview.as_view(),name='somename')
def get_url():
return reverse('app_name:somename',args=None)
```
I want get\_url to return 'url/'
Is it possible?
If not, can i somehow get the partial url without the param like **'url/**'? | 2020/08/24 | [
"https://Stackoverflow.com/questions/63553515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13008498/"
] | You can have multiple paths with the same name but with different parameters.
```
app_name = 'app_name'
urlpatterns = [
path('url/', someview.as_view(), name='somename'),
path('url/<str:foo>/', someview.as_view(), name='somename'),
]
```
When you use `reverse` the url pattern that matches the name and param... | You could use [re\_path](https://docs.djangoproject.com/en/dev/ref/urls/#re-path):
```
from django.urls import re_path
urlpatterns = [
re_path('url/(?P<some_id>[0-9]*)$', some_view, name='someview-name'),
]
```
This way, `url/` is valid, `url/12` is valid, but `url/foobar` is not.
Note that when you `return rev... |
34,948,779 | I have several transportation brands, for each one I would like to specify all the available
models as well as the default model.
So I first defined tuples this way:
```
SUZUKI = ('model_1', 'model_2', 'model_3')
FERRARI = ('model_1', 'model_2')
# etc
```
I would like to specify a default model for each brand. Th... | 2016/01/22 | [
"https://Stackoverflow.com/questions/34948779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3298319/"
] | Why not using a dictionary, seems to me like the better way to go. The code itself will get more understandable and easier.
```
brands = {'Suzuki':['model_1', 'model_2'], 'Ferrari':['model_1', 'model_2']}
```
And then just call them normally:
```
brands['Suzuki']
```
Outputs:
```
['model_1', 'model_2']
``` | You could make a class:
```
class Brand(object):
def __init__(*models, default=None):
self.models = *models
self.default = default
assert default is None or default in models
```
Then use it:
```
SUZUKI = Brand('model_1', 'model_2', 'model_3', default='model_1')
FERRARI = Brand('model_1'... |
21,566,379 | I intend to fit a 2D Gaussian function to images showing a laser beam to get its parameters like `FWHM` and position. So far I tried to understand how to define a 2D Gaussian function in Python and how to pass x and y variables to it.
I've written a little script which defines that function, plots it, adds some noise ... | 2014/02/05 | [
"https://Stackoverflow.com/questions/21566379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3273102/"
] | The output of `twoD_Gaussian` needs to be 1D. What you can do is add a `.ravel()` onto the end of the last line, like this:
```
def twoD_Gaussian(xy, amplitude, xo, yo, sigma_x, sigma_y, theta, offset):
x, y = xy
xo = float(xo)
yo = float(yo)
a = (np.cos(theta)**2)/(2*sigma_x**2) + (np.sin(theta)**... | `curve_fit()` wants to the dimension of `xdata` to be `(2,n*m)` and not `(2,n,m)`. `ydata` should have shape `(n*m)` not `(n,m)` respectively. So you use `ravel()` to flatten your 2D arrays:
```
xdata = np.vstack((xx.ravel(),yy.ravel()))
ydata = data_noisy.ravel()
popt, pcov = opt.curve_fit(twoD_Gaussian, xdata, ydata... |
21,566,379 | I intend to fit a 2D Gaussian function to images showing a laser beam to get its parameters like `FWHM` and position. So far I tried to understand how to define a 2D Gaussian function in Python and how to pass x and y variables to it.
I've written a little script which defines that function, plots it, adds some noise ... | 2014/02/05 | [
"https://Stackoverflow.com/questions/21566379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3273102/"
] | To expand on Dietrich's answer a bit, I got the following error when running the suggested solution with Python 3.4 (on Ubuntu 14.04):
```
def twoD_Gaussian((x, y), amplitude, xo, yo, sigma_x, sigma_y, theta, offset):
^
SyntaxError: invalid syntax
```
Running `2to3` suggested the following simple f... | `curve_fit()` wants to the dimension of `xdata` to be `(2,n*m)` and not `(2,n,m)`. `ydata` should have shape `(n*m)` not `(n,m)` respectively. So you use `ravel()` to flatten your 2D arrays:
```
xdata = np.vstack((xx.ravel(),yy.ravel()))
ydata = data_noisy.ravel()
popt, pcov = opt.curve_fit(twoD_Gaussian, xdata, ydata... |
21,566,379 | I intend to fit a 2D Gaussian function to images showing a laser beam to get its parameters like `FWHM` and position. So far I tried to understand how to define a 2D Gaussian function in Python and how to pass x and y variables to it.
I've written a little script which defines that function, plots it, adds some noise ... | 2014/02/05 | [
"https://Stackoverflow.com/questions/21566379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3273102/"
] | The output of `twoD_Gaussian` needs to be 1D. What you can do is add a `.ravel()` onto the end of the last line, like this:
```
def twoD_Gaussian(xy, amplitude, xo, yo, sigma_x, sigma_y, theta, offset):
x, y = xy
xo = float(xo)
yo = float(yo)
a = (np.cos(theta)**2)/(2*sigma_x**2) + (np.sin(theta)**... | To expand on Dietrich's answer a bit, I got the following error when running the suggested solution with Python 3.4 (on Ubuntu 14.04):
```
def twoD_Gaussian((x, y), amplitude, xo, yo, sigma_x, sigma_y, theta, offset):
^
SyntaxError: invalid syntax
```
Running `2to3` suggested the following simple f... |
16,302,407 | I have a coworker that I noticed was using his foreachs in the following fashion:
```
foreach ($var as $var) {
// do stuff here
}
```
I have tested the code above and it works correctly to my surprise. Would the PHP gurus like to hop in and tell me why this is wrong? It feels very wrong. | 2013/04/30 | [
"https://Stackoverflow.com/questions/16302407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/595130/"
] | Because it changes the value of `$var`. After the `foreach()` it's no longer an array but is set to the last value in the array.
```
$var = array('apple', 'orange');
foreach ($var as $var) {
echo $var."<br/>";
}
echo $var; //orange
```
If you don't want to change the variable's value, it'll need to be a differen... | Even it feels wrong, it still works because the moment the [*`foreach`*](http://php.net/foreach) starts, PHP internally has already access on the data.
So even `$var` gets overwritten, in memory this data is still present (the original array) and `$var` is set in each iteration to the current value of it.
The concret... |
16,302,407 | I have a coworker that I noticed was using his foreachs in the following fashion:
```
foreach ($var as $var) {
// do stuff here
}
```
I have tested the code above and it works correctly to my surprise. Would the PHP gurus like to hop in and tell me why this is wrong? It feels very wrong. | 2013/04/30 | [
"https://Stackoverflow.com/questions/16302407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/595130/"
] | Because it changes the value of `$var`. After the `foreach()` it's no longer an array but is set to the last value in the array.
```
$var = array('apple', 'orange');
foreach ($var as $var) {
echo $var."<br/>";
}
echo $var; //orange
```
If you don't want to change the variable's value, it'll need to be a differen... | Because it's a loop. Performing:
```
array > string
array > string
```
So
```
foreach ($var AS $var){
/*
Is basically being re-read at the end so your foreach can read the array again to get the next step of the array
array > string
recheck array > string
recheckarray > string
*/
}
``` |
16,302,407 | I have a coworker that I noticed was using his foreachs in the following fashion:
```
foreach ($var as $var) {
// do stuff here
}
```
I have tested the code above and it works correctly to my surprise. Would the PHP gurus like to hop in and tell me why this is wrong? It feels very wrong. | 2013/04/30 | [
"https://Stackoverflow.com/questions/16302407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/595130/"
] | Because it changes the value of `$var`. After the `foreach()` it's no longer an array but is set to the last value in the array.
```
$var = array('apple', 'orange');
foreach ($var as $var) {
echo $var."<br/>";
}
echo $var; //orange
```
If you don't want to change the variable's value, it'll need to be a differen... | Check this expression:
```
$x = array(1,2,3);
foreach ($x as $x) {
echo $x; //prints 123
}
```
What is happening here is that the `foreach` extracts the first element of array `$x` and overrides into `$x` itself. However the array variable `$x` which was on the left side of the `as` keyword remains in internal s... |
16,302,407 | I have a coworker that I noticed was using his foreachs in the following fashion:
```
foreach ($var as $var) {
// do stuff here
}
```
I have tested the code above and it works correctly to my surprise. Would the PHP gurus like to hop in and tell me why this is wrong? It feels very wrong. | 2013/04/30 | [
"https://Stackoverflow.com/questions/16302407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/595130/"
] | Because it changes the value of `$var`. After the `foreach()` it's no longer an array but is set to the last value in the array.
```
$var = array('apple', 'orange');
foreach ($var as $var) {
echo $var."<br/>";
}
echo $var; //orange
```
If you don't want to change the variable's value, it'll need to be a differen... | Your coworker seems to don't need `$var` as an array after the loop anymore. When PHP initializes the foreach loop (what is done only once) it uses the original values from `$var` as it is an array at the moment. Then on every step in the loop the current element of the element is assigned to a *new* var called `var`. ... |
26,031,878 | Have a WPF Datagrid binded to a observablecollection, that it is getting populated from the database, which can be editable or non editable based on a value of a column value.
Now, would like to add a new row in the datagrid through a context menu click which is editable, although already existing rows would be non-e... | 2014/09/25 | [
"https://Stackoverflow.com/questions/26031878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2412341/"
] | I have solved the issue, actually mysql search(select) queries are case insenstive by default.
Thanks for your feed back. | try this,
```
add(Restrictions.ilike("channelCode", "JAVA%"));
``` |
26,031,878 | Have a WPF Datagrid binded to a observablecollection, that it is getting populated from the database, which can be editable or non editable based on a value of a column value.
Now, would like to add a new row in the datagrid through a context menu click which is editable, although already existing rows would be non-e... | 2014/09/25 | [
"https://Stackoverflow.com/questions/26031878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2412341/"
] | I have solved the issue, actually mysql search(select) queries are case insenstive by default.
Thanks for your feed back. | When you add `ignorecase()` then hibernate tries to convert the value to lower case and do the comparision like this:
```
lower(this_.channelCode)<>'JAVA'
```
So this should work without any issues. |
14,495,868 | Why am i getting this error? and here is how i call the streaming API.
```
import tweepy
import sys
creds = json.loads(open('credential.json').read())
tw_consumer_key = creds['tw_consumer_key']
tw_consumer_secret = creds['tw_consumer_secret']
tw_access_token = creds['tw_access_token']
tw_access_token_secret = creds[... | 2013/01/24 | [
"https://Stackoverflow.com/questions/14495868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/235119/"
] | On App Engine, httplib connections (and urllib) will use the Google URL fetch service. [URL Fetch service](https://developers.google.com/appengine/docs/python/urlfetch/overview) means other servers (not the app engine serving instance) perform the request and return the response to the app engine instance, instead of t... | I believe GAE doesn't support httplib.HTTPSConnection. Instead, try an unsecure connection by adding the `secure = False` parameter to the `Stream` constructor:
```
class LiveStream(webapp2.RequestHandler):
def get(self):
streaming_api = tweepy.streaming.Stream(auth, CustomStreamListener(), timeout=60, sec... |
6,261,311 | I need to load an image into my program. I want to allow the user to browse for any image s/he wishes and open. I need a function which asks the user to browse and select the desired file and can generate a string containing the complete path of that particular file. | 2011/06/07 | [
"https://Stackoverflow.com/questions/6261311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/668279/"
] | You don't say on which platform you are working.
If you are working on Windows, the fastest way is to use the OPENFILENAME structure with the GetOpenFileName function as shown in this example: <http://msdn.microsoft.com/en-us/library/ms646829(v=vs.85).aspx#open_file>. You can then use cvLoadImage with the lpstrFile me... | Use fltk, namely: <http://seriss.com/people/erco/fltk/#Fl_File_Browser> |
50,231,159 | This question is related to my other question: [Process list from R to C and access it](https://stackoverflow.com/questions/50062132/process-list-from-r-to-c-and-access-it).
I want to process a list of strings: `<-list(c("ab", "ac"), c("ab", "zd", "fd"), c("de", "re", "te", "zz"))`.
I struggle with processing strings ... | 2018/05/08 | [
"https://Stackoverflow.com/questions/50231159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8538074/"
] | Expanding my comment: a C variable whose content points to the content of the R list must be of type `char ***` since a string is a `char *` and a `vector` of strings is `char **`. Say `target` is that variable. `target[i]` points to the i-th vector of the list; `target[i][j]` is the j-th string of the i-th vector. `ta... | Assuming that `CHAR(VECTOR_ELT(lst, i));` yields a string such as `"hello"`, then `char stor[] = CHAR(VECTOR_ELT(lst, i));` declares a character aray `stor` that is initialized to contain that string.
Then `target[i] = stor;` would make the character pointer `target[i]` point to that string. The next round of the loop... |
3,572,225 | I'm working through "Learning Rails by Example" tutorial by Michael Hartl(11.33).The relevant code is:
---
```
class PagesController < ApplicationController
def home
@title = "Home"
if signed_in?
@micropost = Micropost.new
@feed_items = current_user.feed.paginate(:page => params[:page])
e... | 2010/08/26 | [
"https://Stackoverflow.com/questions/3572225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/431469/"
] | Use the [`not`](http://api.jquery.com/not/) selector.
Example:
```
$('.collapsiblock').click(function(){
$('.collapsiblock').not(this).each(function(){
$(this).slideUp();
});
$(this).slideDown();
})
``` | You could keep track of which element has already been clicked with your own jquery click handler and jquery's data(...) function. Then filter iterating your .collapsiblock items with jquery's filter (...) function to include the items you need. |
3,572,225 | I'm working through "Learning Rails by Example" tutorial by Michael Hartl(11.33).The relevant code is:
---
```
class PagesController < ApplicationController
def home
@title = "Home"
if signed_in?
@micropost = Micropost.new
@feed_items = current_user.feed.paginate(:page => params[:page])
e... | 2010/08/26 | [
"https://Stackoverflow.com/questions/3572225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/431469/"
] | >
> Try this,This is a better way because if you use each function it will load and in the future when you have more than a thousand div it will take a long time to slide up and slide down.
>
>
>
Example:
```
$('.collapsiblock').click(function(){
$('.collapsiblock').not(this).slideUp();
$(this).slideDown();... | You could keep track of which element has already been clicked with your own jquery click handler and jquery's data(...) function. Then filter iterating your .collapsiblock items with jquery's filter (...) function to include the items you need. |
3,572,225 | I'm working through "Learning Rails by Example" tutorial by Michael Hartl(11.33).The relevant code is:
---
```
class PagesController < ApplicationController
def home
@title = "Home"
if signed_in?
@micropost = Micropost.new
@feed_items = current_user.feed.paginate(:page => params[:page])
e... | 2010/08/26 | [
"https://Stackoverflow.com/questions/3572225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/431469/"
] | Use the [`not`](http://api.jquery.com/not/) selector.
Example:
```
$('.collapsiblock').click(function(){
$('.collapsiblock').not(this).each(function(){
$(this).slideUp();
});
$(this).slideDown();
})
``` | >
> Try this,This is a better way because if you use each function it will load and in the future when you have more than a thousand div it will take a long time to slide up and slide down.
>
>
>
Example:
```
$('.collapsiblock').click(function(){
$('.collapsiblock').not(this).slideUp();
$(this).slideDown();... |
4,915,283 | Suppose that some application requires using two stacks whose elements are of the same type. A natural storage structure of such a two-stack data type would consist of two arrays and two top pointers. Explain why this may not be a spacewise efficient implementation. | 2011/02/06 | [
"https://Stackoverflow.com/questions/4915283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/605552/"
] | I think that what this question is getting at is that if you want to represent two stacks simultaneously, it's possible to do so using a single array of elements. In a typical array implementation of a stack, the elements are stored in an array with some amount of "slack space" available for growth. When that space is ... | If the arrays are allocated dynamically then the only possible way of that implementation being size-inefficient is not taking into account intersection between them. It can be taken into account by using algorithms like Huffman compression. On the other hand, if the arrays are allocated statically, that can be really ... |
66,004,043 | So I'm working on a DATE validation. The date format that I'm going to use is `mm/dd/yyyy`. May I ask if it is possible if a `/` will be **automatically** inserted while typing? And, I'm also thinking if how can I validate if the value is a real date or not.
The code below allows the textbox to accept `numbers` and a ... | 2021/02/02 | [
"https://Stackoverflow.com/questions/66004043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6729785/"
] | Using `re.sub` we can try first removing the unwanted repetitive text. Then, do a second replacement to replace remaining newlines with single spaces:
```py
inp = """1
00:00:05.210 --> 00:00:07.710
In this lecture, we're
going to talk about
2
00:00:07.710 --> 00:00:10.815
pattern matching in strings
using regular exp... | I find @Tim Biegeleisen's solution with the complex regex and multiple substitutions a bit confusing so here's another option.
```
import re
_file = """1
00:00:05.210 --> 00:00:07.710
In this lecture, we're
going to talk about
2
00:00:07.710 --> 00:00:10.815
pattern matching in strings
using regular expressions.
3
... |
66,004,043 | So I'm working on a DATE validation. The date format that I'm going to use is `mm/dd/yyyy`. May I ask if it is possible if a `/` will be **automatically** inserted while typing? And, I'm also thinking if how can I validate if the value is a real date or not.
The code below allows the textbox to accept `numbers` and a ... | 2021/02/02 | [
"https://Stackoverflow.com/questions/66004043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6729785/"
] | Using `re.sub` we can try first removing the unwanted repetitive text. Then, do a second replacement to replace remaining newlines with single spaces:
```py
inp = """1
00:00:05.210 --> 00:00:07.710
In this lecture, we're
going to talk about
2
00:00:07.710 --> 00:00:10.815
pattern matching in strings
using regular exp... | You can also match the structure of the data in the file to make sure that it is present.
```
^\d+\r?\n\d{2}:\d{2}:\d{2}\.\d{3} -->.*\r?\n((?:(?!\d+\r?\n\d\d:).*(?:\r?\n|$))*)
```
**Expanation**
* `^` Start of string
* `\d+\r?\n\d{2}:\d{2}:\d{2}\.\d{3} -->.*` Match 1+ digits, a newline and the time like pattern
* `... |
66,004,043 | So I'm working on a DATE validation. The date format that I'm going to use is `mm/dd/yyyy`. May I ask if it is possible if a `/` will be **automatically** inserted while typing? And, I'm also thinking if how can I validate if the value is a real date or not.
The code below allows the textbox to accept `numbers` and a ... | 2021/02/02 | [
"https://Stackoverflow.com/questions/66004043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6729785/"
] | I find @Tim Biegeleisen's solution with the complex regex and multiple substitutions a bit confusing so here's another option.
```
import re
_file = """1
00:00:05.210 --> 00:00:07.710
In this lecture, we're
going to talk about
2
00:00:07.710 --> 00:00:10.815
pattern matching in strings
using regular expressions.
3
... | You can also match the structure of the data in the file to make sure that it is present.
```
^\d+\r?\n\d{2}:\d{2}:\d{2}\.\d{3} -->.*\r?\n((?:(?!\d+\r?\n\d\d:).*(?:\r?\n|$))*)
```
**Expanation**
* `^` Start of string
* `\d+\r?\n\d{2}:\d{2}:\d{2}\.\d{3} -->.*` Match 1+ digits, a newline and the time like pattern
* `... |
30,090,950 | I am currently trying to figure out how to make the correct conversion from two's complement hexadecimal to its base 10 equivalent. We were given an assembly language program that adds and subtracts 32-bit integers and need to take the values of the registers and convert them.
Here is what I've attempted, however, my... | 2015/05/07 | [
"https://Stackoverflow.com/questions/30090950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2792977/"
] | It is simple to add a subview to act as a line. For example:
Swift 4
```
var lineView = UIView(frame: CGRect(x: 0, y: 100, width: 320, height: 1.0))
lineView.layer.borderWidth = 1.0
lineView.layer.borderColor = UIColor.black.cgColor
self.view.addSubview(lineView)
```
Objective C
```
UIView * lineview = [[UIView al... | You can achieve this in **Storyboard**.
All you have to do is drag a `UIView` with `height = 1` and `width` whatever is good for you (ideally equal to screen width). Place it where you want the lines to be. |
30,090,950 | I am currently trying to figure out how to make the correct conversion from two's complement hexadecimal to its base 10 equivalent. We were given an assembly language program that adds and subtracts 32-bit integers and need to take the values of the registers and convert them.
Here is what I've attempted, however, my... | 2015/05/07 | [
"https://Stackoverflow.com/questions/30090950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2792977/"
] | It is simple to add a subview to act as a line. For example:
Swift 4
```
var lineView = UIView(frame: CGRect(x: 0, y: 100, width: 320, height: 1.0))
lineView.layer.borderWidth = 1.0
lineView.layer.borderColor = UIColor.black.cgColor
self.view.addSubview(lineView)
```
Objective C
```
UIView * lineview = [[UIView al... | For Swift 3:
```
let lineView = UIView(frame: CGRect(x:0,
y: self.yourLabel.height - 1 ,
width: self.yourLabel.frame.width,
height: 1.4
... |
30,090,950 | I am currently trying to figure out how to make the correct conversion from two's complement hexadecimal to its base 10 equivalent. We were given an assembly language program that adds and subtracts 32-bit integers and need to take the values of the registers and convert them.
Here is what I've attempted, however, my... | 2015/05/07 | [
"https://Stackoverflow.com/questions/30090950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2792977/"
] | You can achieve this in **Storyboard**.
All you have to do is drag a `UIView` with `height = 1` and `width` whatever is good for you (ideally equal to screen width). Place it where you want the lines to be. | For Swift 3:
```
let lineView = UIView(frame: CGRect(x:0,
y: self.yourLabel.height - 1 ,
width: self.yourLabel.frame.width,
height: 1.4
... |
5,295,714 | i have a problem making a SQL Query with an array in my WHERE clause.
For example:
My Array:
```
$myarray[1] = "hi";
$myarray[2] = "there";
$myarray[3] = "everybody";
```
My MySQL Statement:
```
SELECT * FROM myTable WHERE title='".$myarray[]."'
```
Is there any way to realize that?
I solved it myself like this... | 2011/03/14 | [
"https://Stackoverflow.com/questions/5295714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/625491/"
] | You can use mysql's [IN-function](http://dev.mysql.com/doc/refman/5.5/en/comparison-operators.html#function_in)
EDIT: As amosrevira said, you need to escape you strings in the array.
```
$myarray[1] = "'hi'";
$myarray[2] = "'there'";
$myarray[3] = "'everybody'";
$newarray = implode(", ", $myarray); //makes format 'h... | You can us the `IN` operator. You want it to look like:
```
title IN ('hi', 'there', 'everybody')
```
So you'd do something like:
```
$sql = "SELECT * FROM myTable WHERE title IN '" . implode("','", $myarray) . "';"
```
Note that you need to filter your array for SQL injection issues first. |
5,295,714 | i have a problem making a SQL Query with an array in my WHERE clause.
For example:
My Array:
```
$myarray[1] = "hi";
$myarray[2] = "there";
$myarray[3] = "everybody";
```
My MySQL Statement:
```
SELECT * FROM myTable WHERE title='".$myarray[]."'
```
Is there any way to realize that?
I solved it myself like this... | 2011/03/14 | [
"https://Stackoverflow.com/questions/5295714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/625491/"
] | You can use mysql's [IN-function](http://dev.mysql.com/doc/refman/5.5/en/comparison-operators.html#function_in)
EDIT: As amosrevira said, you need to escape you strings in the array.
```
$myarray[1] = "'hi'";
$myarray[2] = "'there'";
$myarray[3] = "'everybody'";
$newarray = implode(", ", $myarray); //makes format 'h... | You can try use of `IN` in your `WHERE` clause,
```
SELECT * FROM myTable WHERE title IN ('hi', 'there', 'everybody');
```
or
```
SELECT * FROM myTable WHERE title IN ('.implode(',', $myarray).');
``` |
5,295,714 | i have a problem making a SQL Query with an array in my WHERE clause.
For example:
My Array:
```
$myarray[1] = "hi";
$myarray[2] = "there";
$myarray[3] = "everybody";
```
My MySQL Statement:
```
SELECT * FROM myTable WHERE title='".$myarray[]."'
```
Is there any way to realize that?
I solved it myself like this... | 2011/03/14 | [
"https://Stackoverflow.com/questions/5295714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/625491/"
] | You can use mysql's [IN-function](http://dev.mysql.com/doc/refman/5.5/en/comparison-operators.html#function_in)
EDIT: As amosrevira said, you need to escape you strings in the array.
```
$myarray[1] = "'hi'";
$myarray[2] = "'there'";
$myarray[3] = "'everybody'";
$newarray = implode(", ", $myarray); //makes format 'h... | ```
$myarray[1] = "hi";
$myarray[2] = "there";
$myarray[3] = "everybody";
//every quoted string should be escaped according to SQL rules
foreach($myarray as $key => $val) {
$myarray[$key] = mysql_real_escape_string($val);
}
$in_str = "'".implode("', '", $myarray)."'"; //makes format 'hi', 'there', 'everybody'
SEL... |
5,295,714 | i have a problem making a SQL Query with an array in my WHERE clause.
For example:
My Array:
```
$myarray[1] = "hi";
$myarray[2] = "there";
$myarray[3] = "everybody";
```
My MySQL Statement:
```
SELECT * FROM myTable WHERE title='".$myarray[]."'
```
Is there any way to realize that?
I solved it myself like this... | 2011/03/14 | [
"https://Stackoverflow.com/questions/5295714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/625491/"
] | ```
$myarray[1] = "hi";
$myarray[2] = "there";
$myarray[3] = "everybody";
//every quoted string should be escaped according to SQL rules
foreach($myarray as $key => $val) {
$myarray[$key] = mysql_real_escape_string($val);
}
$in_str = "'".implode("', '", $myarray)."'"; //makes format 'hi', 'there', 'everybody'
SEL... | You can us the `IN` operator. You want it to look like:
```
title IN ('hi', 'there', 'everybody')
```
So you'd do something like:
```
$sql = "SELECT * FROM myTable WHERE title IN '" . implode("','", $myarray) . "';"
```
Note that you need to filter your array for SQL injection issues first. |
5,295,714 | i have a problem making a SQL Query with an array in my WHERE clause.
For example:
My Array:
```
$myarray[1] = "hi";
$myarray[2] = "there";
$myarray[3] = "everybody";
```
My MySQL Statement:
```
SELECT * FROM myTable WHERE title='".$myarray[]."'
```
Is there any way to realize that?
I solved it myself like this... | 2011/03/14 | [
"https://Stackoverflow.com/questions/5295714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/625491/"
] | ```
$myarray[1] = "hi";
$myarray[2] = "there";
$myarray[3] = "everybody";
//every quoted string should be escaped according to SQL rules
foreach($myarray as $key => $val) {
$myarray[$key] = mysql_real_escape_string($val);
}
$in_str = "'".implode("', '", $myarray)."'"; //makes format 'hi', 'there', 'everybody'
SEL... | You can try use of `IN` in your `WHERE` clause,
```
SELECT * FROM myTable WHERE title IN ('hi', 'there', 'everybody');
```
or
```
SELECT * FROM myTable WHERE title IN ('.implode(',', $myarray).');
``` |
904,498 | In Excel 2007, I have a table with numbers in Columns F, G, H, I, and J. There is an identifier in Column B.
I need the average of all numbers in Columns F, G, H, I, and J where the identifier in Column B = A14 (i.e. the value in A14).
I tried the following:
```
=AVERAGEIFS('Hours-Backup'!F3:J1048576,'Hours-Backup... | 2015/04/22 | [
"https://superuser.com/questions/904498",
"https://superuser.com",
"https://superuser.com/users/439916/"
] | Two problems. (Or one problem with two heads.) `AVERAGEIFS` help says:
>
> * Unlike the range and criteria arguments in the AVERAGEIF function,
> in AVERAGEIFS each criteria\_range must be the same size and shape as sum\_range.
>
>
>
Well, that’s a typo: “sum\_range” should be “average\_range”.
But, anyway, t... | My approach to situations like this is a couple of helper columns and some array formulas. Hopefully I've set this toy sheet up in the same way as yours:

Here I've set up `A16` as the cell to set which filtered rows you want to retain. `B` is the column of values to ... |
19,045,643 | is it possible to read server credentials from the settings.xml within a pom.xml? I would like to download files as described [here](http://evgeny-goldin.com/wiki/Copy-maven-plugin#Downloading_files%3a_HTTP.2C_SCP.2C_FTP), but avoid to put the credentials in version control.
Thanks in ahead! | 2013/09/27 | [
"https://Stackoverflow.com/questions/19045643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/687901/"
] | I think what you are looking for is profile based properties like shown below:
```
<profile>
<id>jira</id>
<properties>
<jiraUser>user</jiraUser>
<jiraPassword>password</jiraPassword>
</properties>
</profile>
```
You may reference these with `${jiraUser}` and `{jiraPassword}` in your POM.... | What do you mean by settings.xml within a pom.xml (Sorry admin for Posting this in Answers instead of comments, since I cant add comments I am doing this in Answers) |
13,927,363 | I am working on HtmlServices of google apps script. In this script I implemented two functionality, Autocomplete and DataTable, for this used many js and css file. All functionalities are working well but when the script is loaded, its taking too much time. Once the script is loaded completely, then its working fine. T... | 2012/12/18 | [
"https://Stackoverflow.com/questions/13927363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1708445/"
] | I've had the same issue but came to the conclusion that how I'd designed my script contributed to the problem. Originally I designed my script to build the entire page and **then** present it to the user. When the script began, it appeared to take a long time for the first page to present making the page look slow. It ... | It seems that there is a significant lag between when `doGet()` starts, and when `google.script.run` executes the first time. I created a dummy app called Simple which has a similar structure to my app (based off the demo app) that does nothing other than a single jQuery call to set the text in my template.
`doGet()` ... |
19,924,403 | Here the CSS and HTML code is :
CSS:
```
. d {
display: table;
}
.c {
font-size: 80px;
display: table-cell;
vertical-align: super;
text-align: center;
}
```
html:
```
<div class="d"><p class="c">›</p> </div>
```
than... | 2013/11/12 | [
"https://Stackoverflow.com/questions/19924403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1421201/"
] | Short answer: the case weights `weights` in each node are `NULL`, i.e. not stored. The `prettytree` function outputs `weights = 0`, since `sum(NULL)` equals 0 in R.
---
Consider the following `ctree` example:
```
library("party")
x <- ctree(Species ~ ., data=iris)
plot(x, type="simple")
```

y <- cforest(score ~ ., data = readingSkills,
control = cforest_unbiased(mtry = 2, ntree = 50))
tr <- party:::prettytree(y@ensemble[[1]], names(... |
3,528,481 | What are best practices for managing custom logging in Ruby? Should I be monkeypatching logger to do what I want? Or extending from it? Or delegating? What's the rubyish way? I'm sick of custom hacks for this; I'd like something cleaner, and ideally more elegant. | 2010/08/20 | [
"https://Stackoverflow.com/questions/3528481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/90042/"
] | Bates has a [screencast](http://railscasts.com/episodes/56-the-logger) on customizing logger.
And here is a blog post on custom [logging in Rails](http://ianma.wordpress.com/2009/04/08/custom-logging-in-ruby-on-rails/).
Here are some tips on [logging in Rails](https://web.archive.org/web/20100527042613/http://maintai... | There's a Ruby implementation of Slf4j, the popular Java logging framework, imaginatively called [Slf4r](https://github.com/mkristian/slf4r). This separates the actual logging method from the code, and provides a standard interface for logging different message levels. |
3,528,481 | What are best practices for managing custom logging in Ruby? Should I be monkeypatching logger to do what I want? Or extending from it? Or delegating? What's the rubyish way? I'm sick of custom hacks for this; I'd like something cleaner, and ideally more elegant. | 2010/08/20 | [
"https://Stackoverflow.com/questions/3528481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/90042/"
] | According to my experience, log4r is no more popular (and I don't know why these days I can't access log4r's homepage). Instead [logging](https://rubygems.org/gems/logging) is far more better.
FYR
<https://www.ruby-toolbox.com/categories/logging> | There's a Ruby implementation of Slf4j, the popular Java logging framework, imaginatively called [Slf4r](https://github.com/mkristian/slf4r). This separates the actual logging method from the code, and provides a standard interface for logging different message levels. |
62,013,920 | ```
import requests
from bs4 import BeautifulSoup
url ="https://www.hltv.org/stats/matches/mapstatsid/103093/furia-vs-chaos"
headers= {"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"}
response = requests.get(url, headers = headers)
soup = BeautifulSoup(response.content, "html.parser")
#stat_tables = soup.fi... | 2020/05/26 | [
"https://Stackoverflow.com/questions/62013920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1204346/"
] | Please reference this document: [Enable and Disable Change Data Capture (SQL Server)](https://learn.microsoft.com/en-us/sql/relational-databases/track-changes/enable-and-disable-change-data-capture-sql-server?view=sql-server-ver15#enable-change-data-capture-for-a-table)
[](https://i.stack.imgur.com/m4YKC.png) |
9,910,468 | I am trying to use window.location to redirect to a relative url
this variable
```
var redirect = $(this).attr('title');
```
has this value
```
../../000_Movies/_assets/playlist.html
```
this wont redirect
```
window.location = redirect;
``` | 2012/03/28 | [
"https://Stackoverflow.com/questions/9910468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1159429/"
] | If you want to redirect to relative pages you should use:
```
window.location.href = "../../000_Movies/_assets/playlist.html";
``` | You can use:
```
window.location.href = $(this).attr('title');
``` |
72,193,672 | I need to find links on a page consisting of two words.How can this be done with Xpath?
```
<div class="navbar">
<p>
<a href="/navigate/names/a">Aaa aaa</a>
<a href="/navigate/names/b">Bbb</a>
<a href="/navigate/names/c">Ccc ccc</a>
<a href="/navigate/names/d">Ddd</a>
<a href="/navigate/names/e">... | 2022/05/10 | [
"https://Stackoverflow.com/questions/72193672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19089288/"
] | If you can differentiate the strings by the count of spaces, you could use this XPath-1.0 expression:
```
/div/p/a[string-length(normalize-space(.))-string-length(translate(normalize-space(.),' ',''))=1]
```
This matches all two-word-strings. | My 2cts by removing not space characters and also counting spaces
XPath 1: `//a[count(translate(normalize-space(.),"abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ","")) = 1]`
```
echo -e 'cat //a[translate(normalize-space(.),"abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ","") = " "] \... |
41,047,124 | So, I'd like to set the height of the collapsed navigation of bootstrap to 100% height.
e.g. <https://getbootstrap.com/examples/navbar/> this should span over the whole screen.
I did some research and mostly found people using `height: 100vh;` but this is not dynamics, shouldn't matter too much in the end though, but... | 2016/12/08 | [
"https://Stackoverflow.com/questions/41047124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/587680/"
] | The correct way to write your UT is:
```
[TestMethod]
public void TestMethod1()
{
const string FIRST = "First Name";
const string SECOND = "Second Name";
var reader = MockRepository.GenerateStub<IDataReader>();
reader.Stub(x => x.FieldCount).Return(2);
reader.Stub(x => x.GetName(0)).Return(FIRST)... | You should use simply use `Repeat`:
In case you want the same value to be returned:
```
reader.Stub(x => x.GetName(0)).IgnoreArguments().Repeat.Any().Return("My Name");
```
In case you want different values to be returned:
```
reader.Stub(x => x.GetName(0)).IgnoreArguments().Repeat.Once().Return("First Name");
r... |
10,728,309 | I keep getting this error when running this python script (that I know runs and works since I ran it in VI) within eclipse.
Traceback (most recent call last):
File "/home/kt/Documents/workspace/Molly's Scripts/src/ProcessingPARFuMSData.py", line 181, in
annotations = open(sys.argv[1], 'r')
IOError: [Errno 2] No suc... | 2012/05/23 | [
"https://Stackoverflow.com/questions/10728309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1413663/"
] | I had the same issue, but it turned out that my text file was in fact in the wrong place, even though it was in the same directory as my python script. I had to move it into the same *package* as the script, not just the same directory (I did this by simply dragging the text file onto the package name in the sidebar in... | Seems you're launching in the wrong dir. You can configure your launch in run > run configurations. |
41,274,962 | Before asking the question, I have searched stackoverflow, find a related post:
[change segmentControl border color](https://stackoverflow.com/questions/19041035/iphone-ios7-segmented-uisegmentedcontrol-change-only-border-color)
But we can see it is in `objective-c` language.
So how can we change the borderColor of... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41274962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6523163/"
] | You literally just have to convert the code to swift...
```
let customSegmentedControl = UISegmentedControl.appearance()
customSegmentedControl.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.red], for: UIControlState.normal)
```
But I believe the code you posted changes the actual color of the ... | We can set the background image to achieve the effect.
```
let customSegmentedControl = UISegmentedControl.appearance()
//customSegmentedControl.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.red], for: UIControlState.normal)
customSegmentedControl.setBackgroundImage(UIImage.init(named: ... |
41,274,962 | Before asking the question, I have searched stackoverflow, find a related post:
[change segmentControl border color](https://stackoverflow.com/questions/19041035/iphone-ios7-segmented-uisegmentedcontrol-change-only-border-color)
But we can see it is in `objective-c` language.
So how can we change the borderColor of... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41274962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6523163/"
] | You literally just have to convert the code to swift...
```
let customSegmentedControl = UISegmentedControl.appearance()
customSegmentedControl.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.red], for: UIControlState.normal)
```
But I believe the code you posted changes the actual color of the ... | ```
self.segementControl.layer.borderWidth = 0.3
self.segementControl.layer.cornerRadius = 3.0
self.segementControl.layer.borderColor = UIColor.orange.cgColor
``` |
41,274,962 | Before asking the question, I have searched stackoverflow, find a related post:
[change segmentControl border color](https://stackoverflow.com/questions/19041035/iphone-ios7-segmented-uisegmentedcontrol-change-only-border-color)
But we can see it is in `objective-c` language.
So how can we change the borderColor of... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41274962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6523163/"
] | You literally just have to convert the code to swift...
```
let customSegmentedControl = UISegmentedControl.appearance()
customSegmentedControl.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.red], for: UIControlState.normal)
```
But I believe the code you posted changes the actual color of the ... | Add the outlet
```
@IBOutlet weak var customSegment: UISegmentedControl!
```
then in your viewDidload method
```
customSegment.layer.borderWidth = 1.0
customSegment.layer.cornerRadius = 5.0
customSegment.layer.borderColor = UIColor.red.cgColor
customSegment.layer.masksToBounds = true
```
[
But we can see it is in `objective-c` language.
So how can we change the borderColor of... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41274962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6523163/"
] | More simple approach:
```
segmentControl.layer.borderWidth = 1.0
segmentControl.layer.cornerRadius = 5.0
segmentControl.layer.borderColor = UIColor.red.cgColor
segmentControl.layer.masksToBounds = true
``` | We can set the background image to achieve the effect.
```
let customSegmentedControl = UISegmentedControl.appearance()
//customSegmentedControl.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.red], for: UIControlState.normal)
customSegmentedControl.setBackgroundImage(UIImage.init(named: ... |
41,274,962 | Before asking the question, I have searched stackoverflow, find a related post:
[change segmentControl border color](https://stackoverflow.com/questions/19041035/iphone-ios7-segmented-uisegmentedcontrol-change-only-border-color)
But we can see it is in `objective-c` language.
So how can we change the borderColor of... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41274962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6523163/"
] | We can set the background image to achieve the effect.
```
let customSegmentedControl = UISegmentedControl.appearance()
//customSegmentedControl.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.red], for: UIControlState.normal)
customSegmentedControl.setBackgroundImage(UIImage.init(named: ... | ```
self.segementControl.layer.borderWidth = 0.3
self.segementControl.layer.cornerRadius = 3.0
self.segementControl.layer.borderColor = UIColor.orange.cgColor
``` |
41,274,962 | Before asking the question, I have searched stackoverflow, find a related post:
[change segmentControl border color](https://stackoverflow.com/questions/19041035/iphone-ios7-segmented-uisegmentedcontrol-change-only-border-color)
But we can see it is in `objective-c` language.
So how can we change the borderColor of... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41274962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6523163/"
] | Add the outlet
```
@IBOutlet weak var customSegment: UISegmentedControl!
```
then in your viewDidload method
```
customSegment.layer.borderWidth = 1.0
customSegment.layer.cornerRadius = 5.0
customSegment.layer.borderColor = UIColor.red.cgColor
customSegment.layer.masksToBounds = true
```
[![enter ... | We can set the background image to achieve the effect.
```
let customSegmentedControl = UISegmentedControl.appearance()
//customSegmentedControl.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.red], for: UIControlState.normal)
customSegmentedControl.setBackgroundImage(UIImage.init(named: ... |
41,274,962 | Before asking the question, I have searched stackoverflow, find a related post:
[change segmentControl border color](https://stackoverflow.com/questions/19041035/iphone-ios7-segmented-uisegmentedcontrol-change-only-border-color)
But we can see it is in `objective-c` language.
So how can we change the borderColor of... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41274962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6523163/"
] | More simple approach:
```
segmentControl.layer.borderWidth = 1.0
segmentControl.layer.cornerRadius = 5.0
segmentControl.layer.borderColor = UIColor.red.cgColor
segmentControl.layer.masksToBounds = true
``` | ```
self.segementControl.layer.borderWidth = 0.3
self.segementControl.layer.cornerRadius = 3.0
self.segementControl.layer.borderColor = UIColor.orange.cgColor
``` |
41,274,962 | Before asking the question, I have searched stackoverflow, find a related post:
[change segmentControl border color](https://stackoverflow.com/questions/19041035/iphone-ios7-segmented-uisegmentedcontrol-change-only-border-color)
But we can see it is in `objective-c` language.
So how can we change the borderColor of... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41274962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6523163/"
] | More simple approach:
```
segmentControl.layer.borderWidth = 1.0
segmentControl.layer.cornerRadius = 5.0
segmentControl.layer.borderColor = UIColor.red.cgColor
segmentControl.layer.masksToBounds = true
``` | Add the outlet
```
@IBOutlet weak var customSegment: UISegmentedControl!
```
then in your viewDidload method
```
customSegment.layer.borderWidth = 1.0
customSegment.layer.cornerRadius = 5.0
customSegment.layer.borderColor = UIColor.red.cgColor
customSegment.layer.masksToBounds = true
```
[
But we can see it is in `objective-c` language.
So how can we change the borderColor of... | 2016/12/22 | [
"https://Stackoverflow.com/questions/41274962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6523163/"
] | Add the outlet
```
@IBOutlet weak var customSegment: UISegmentedControl!
```
then in your viewDidload method
```
customSegment.layer.borderWidth = 1.0
customSegment.layer.cornerRadius = 5.0
customSegment.layer.borderColor = UIColor.red.cgColor
customSegment.layer.masksToBounds = true
```
[![enter ... | ```
self.segementControl.layer.borderWidth = 0.3
self.segementControl.layer.cornerRadius = 3.0
self.segementControl.layer.borderColor = UIColor.orange.cgColor
``` |
40,438,923 | How do I get the directory Vim is 'looking into'? I want to set up my `vimrc` platform independent so I don't want to put explicit directories. On Linux e.g. vim looks into `~/.vim` and on Windows in `~\vimfiles`. How can I get the directory that is used, to put my files there? | 2016/11/05 | [
"https://Stackoverflow.com/questions/40438923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6950750/"
] | I can't say this is an information we never need as I have one use for it.
In lh-vim-lib, I proceed this way (in [lh#path#vimfiles()](https://github.com/LucHermitte/lh-vim-lib/blob/master/autoload/lh/path.vim#L525)):
* First I build a regex from $HOME (i.e. I replace all slashes and backslahes into `[/\\]`): `:let re... | You can override the default `'runtimepath'` to make Vim use the same `~/.vim/` on Windows, too. Just put this into your `~/.vimrc`:
```
if has('win32') || has('win64')
let &runtimepath = substitute(&runtimepath, '\C\V' . escape($HOME.'/vimfiles', '\'), escape($HOME.'/.vim', '\&'), 'g')
endif
``` |
37,073,289 | I have this table:
```
// numbers
+---------+------------+
| id | numb |
+---------+------------+
| int(11) | bit(10) |
+---------+------------+
| 1 | 1001100111 |
| 2 | 0111000101 |
| 3 | 0001101010 |
| 4 | 1111111011 |
+---------+------------+
```
I'm trying to change *(toggle... | 2016/05/06 | [
"https://Stackoverflow.com/questions/37073289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5259594/"
] | Flipping a bit is done by XOR `^` operation with a mask that has `1`s in positions that you would like to toggle.
This works because the truth table of XOR looks like this:
```
A: 0 0 1 1
B: 0 1 0 1
A^B: 0 1 1 0
```
Note the columns where `B` is `1`: when the corresponding bit in `A` is zero, the result is one,... | You can it easy do with XOR ^ . you can give the operand in any system like 1,2,4,8..., for bit 0,1,2,3 OR b'1', b'10', b'100'. Each bit is set was inverted.
In you Sample is the operand 128 or b'100000000'
**SAMPLE**
```
SELECT b'1110111110' ^ 1 , b'1110111111' ^ 1 ;
SELECT b'1110111110' ^ 128 , b'1100111111' ^ 1... |
13,839 | I am trying to get a spectrum analyser up and running. I found the following code on [Galileo GEN2 Project - Real-Time Audio Spectrum Analyzer](https://communities.intel.com/docs/DOC-23406)1:
```
/*
*
* Galileo GEN2 Project - Real-Time Audio Spectrum Analyzer
* https://communities.intel.com/docs/DOC-23406
*
*
... | 2015/07/31 | [
"https://arduino.stackexchange.com/questions/13839",
"https://arduino.stackexchange.com",
"https://arduino.stackexchange.com/users/6936/"
] | There is no point to having `analogReadResolution()` on AVR devices since that function *only exists* to provide/ensure backwards compatibility with the fixed 10-bit ADC that is found in AVR devices. If you want higher or lower resolution then you will need to perform the appropriate actions manually.
You don't have a... | >
> Also, why do I not have a "Due" in my Board menu?
>
>
>
See:
[](https://i.stack.imgur.com/EeYBw.png)
Then:
[](https://i.stack.imgur.com/x4WJF.png)
---
>
> I selected the Duemilanove... |
49,572,399 | I'm trying to make a function in string that deletes some characters from a provided string.
For example i have
```
"Boll %b (Teeth Alligator (13,8,8,5,5,3,n),20,2,ma)"
```
and i want to edit this to
```
"Boll %b"
```
which means to delete everything between the `"("` and `")"`
So i've made this function... | 2018/03/30 | [
"https://Stackoverflow.com/questions/49572399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3795594/"
] | The `String.range` function can be provided extra options, so you can pass it the `String.CompareOptions.backwards` parameters to get the last instance.
```
func deleteInnerString(with string: String, from firstCharacter: String, to secondCharacter: String) -> String {
guard let leftIndex = (string.range(of: first... | You have to use `.backwards` option for `String.CompareOptions` in `range` function of string. as like below
```
func deleteString(with string: String, from firstCharacter: String, to secondCharacter: String) -> String {
guard let leftIndex = (string.range(of: firstCharacter)?.lowerBound),
let rightIndex =... |
49,572,399 | I'm trying to make a function in string that deletes some characters from a provided string.
For example i have
```
"Boll %b (Teeth Alligator (13,8,8,5,5,3,n),20,2,ma)"
```
and i want to edit this to
```
"Boll %b"
```
which means to delete everything between the `"("` and `")"`
So i've made this function... | 2018/03/30 | [
"https://Stackoverflow.com/questions/49572399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3795594/"
] | The `String.range` function can be provided extra options, so you can pass it the `String.CompareOptions.backwards` parameters to get the last instance.
```
func deleteInnerString(with string: String, from firstCharacter: String, to secondCharacter: String) -> String {
guard let leftIndex = (string.range(of: first... | Please note that your strategy won't work with non nested parenthesis.
E.g. this input
```
a(b)c(d)e
```
With your approach will produce this output
```
ae
```
Which IMHO is not correct.
Solution
--------
This solution instead will work with **nested** and **non nested** parenthesis
```
let text = "a(b)c(d)e... |
49,572,399 | I'm trying to make a function in string that deletes some characters from a provided string.
For example i have
```
"Boll %b (Teeth Alligator (13,8,8,5,5,3,n),20,2,ma)"
```
and i want to edit this to
```
"Boll %b"
```
which means to delete everything between the `"("` and `")"`
So i've made this function... | 2018/03/30 | [
"https://Stackoverflow.com/questions/49572399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3795594/"
] | Please note that your strategy won't work with non nested parenthesis.
E.g. this input
```
a(b)c(d)e
```
With your approach will produce this output
```
ae
```
Which IMHO is not correct.
Solution
--------
This solution instead will work with **nested** and **non nested** parenthesis
```
let text = "a(b)c(d)e... | You have to use `.backwards` option for `String.CompareOptions` in `range` function of string. as like below
```
func deleteString(with string: String, from firstCharacter: String, to secondCharacter: String) -> String {
guard let leftIndex = (string.range(of: firstCharacter)?.lowerBound),
let rightIndex =... |
25,490,814 | I have an interface in F#
```
type IStongList =
abstract member ToStringList: float * float list
```
And I'm having trouble making a a list of float,float tuples.
```
type MyTypw = struct
val L1: float
val L2: float
val M1: float
val M2: float
// . . .
interface IStrongList with
... | 2014/08/25 | [
"https://Stackoverflow.com/questions/25490814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/95195/"
] | A `float * float list` is a tuple consisting of a `float` and a `float list`, *not* a list of tuples consisting of two `float`s. For that you should use `(float * float) list`:
```
type IStrongList =
abstract member ToStrongList: (float * float) list
```
If you change your interface like this, the rest of your c... | Problem is not with your implementation, but with the interface declaration itself.
`float * float list` means a tuple of `float` and `float list`. To get a list of tuples of `float` and `float` you need `(float * float) list`:
```
type IStongList =
abstract member ToStringList: (float * float) list
``` |
29,450,131 | I built an iOS app with a companion Apple Watch app and recently submitted it to the App Store. This morning, it was rejected for failing to install. Here are the steps to reproduce:
1. Install the app on iPhone
2. Launch the companion app
3. Toggle the "Show App on Apple Watch" switch
4. The app attempts to install o... | 2015/04/04 | [
"https://Stackoverflow.com/questions/29450131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4688605/"
] | Have you ever opened the project in Xcode 6.3? If so, it likely set your deployment target to iOS 8.3, which will cause this error. | The problem is that if you opened your project in Xcode 6.3 at some point, it updates your deployment target to iOS 8.3. This however isn't reflected in the project's UI, you have to right click your project file and show contents, then open up your project.pbxroj and search for deployment target and change it to 8.2 |
29,450,131 | I built an iOS app with a companion Apple Watch app and recently submitted it to the App Store. This morning, it was rejected for failing to install. Here are the steps to reproduce:
1. Install the app on iPhone
2. Launch the companion app
3. Toggle the "Show App on Apple Watch" switch
4. The app attempts to install o... | 2015/04/04 | [
"https://Stackoverflow.com/questions/29450131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4688605/"
] | Have you ever opened the project in Xcode 6.3? If so, it likely set your deployment target to iOS 8.3, which will cause this error. | I had exactly the same error.
Went to the Apple developer portal website and to the devices section.
Then I had to go through the 'device reset' procedure.
The reason being that I had entered a new developer programme year. It seems that it had refused to provision the device until I went through that reset - not that... |
29,450,131 | I built an iOS app with a companion Apple Watch app and recently submitted it to the App Store. This morning, it was rejected for failing to install. Here are the steps to reproduce:
1. Install the app on iPhone
2. Launch the companion app
3. Toggle the "Show App on Apple Watch" switch
4. The app attempts to install o... | 2015/04/04 | [
"https://Stackoverflow.com/questions/29450131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4688605/"
] | The problem is that if you opened your project in Xcode 6.3 at some point, it updates your deployment target to iOS 8.3. This however isn't reflected in the project's UI, you have to right click your project file and show contents, then open up your project.pbxroj and search for deployment target and change it to 8.2 | I had exactly the same error.
Went to the Apple developer portal website and to the devices section.
Then I had to go through the 'device reset' procedure.
The reason being that I had entered a new developer programme year. It seems that it had refused to provision the device until I went through that reset - not that... |
6,361,681 | i'm trying to query the `ContactContract` ContentProvider and obtain the data that the following algorithm would obtain:
```
given a phone number (input), return record...:
if(recordNumber has 7 digits) {
if('%recordNumber' LIKE 'inputNumber') {
return recordDisplayName;
}
} else if(recordNumber has 10... | 2011/06/15 | [
"https://Stackoverflow.com/questions/6361681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/329993/"
] | queries to ContentProviders are a little different, and unforgiving on the formatting. for ContentProviders, if you want to use '%' as a wildcard character, the '%' must be concatenated to the argument in the WHERE clause, rather than as a part of the clause itself.
correct:
```
Cursor cursor = getContentResolver().q... | Use ContactsContract.CommonDataKinds.Phone.NORMALIZED\_NUMBER instead of ContactsContract.CommonDataKinds.Phone.NUMBER |
19,490,300 | Is there a way to inspect Shadow DOM elements in Firefox like you can do with the Chrome dev tools? | 2013/10/21 | [
"https://Stackoverflow.com/questions/19490300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2902419/"
] | Yes, we have added shadow DOM inspection to Firefox 65.0+ DevTools.
Shadow DOM in normal content pages is always displayed e.g.

By default shadow DOM for built in browser features is not displayed e.g here is a video element:

To ena... | 1. Type `about:config` in the browser address bar.
2. Set `devtools.inspector.showUserAgentShadowRoots` to `true` *// not needed for Firefox 76+*
3. Set `devtools.inspector.showAllAnonymousContent` to `true` **(Firefox 76+)**
[](https://i.stack.imgur.... |
263,326 | I want to calculate $\mathbb{E} \left[\left(\int\_0^tB\_s\text{d}B\_s\right)^3\right]$ where $B\_t$ is a standard Brownian motion. Using Ito's formula for $f:\mathbb{R}\rightarrow\mathbb{R}$ with $f(x)=x^2$ we can find that $\int\_0^tB\_s\text{d}B\_s=\dfrac{B^2\_t}{2}-\dfrac{t}{2}$.
Then:
$\mathbb{E} \left[\left(\int\_... | 2012/12/21 | [
"https://math.stackexchange.com/questions/263326",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/50118/"
] | No, I think you are right. The formula
$$\int\_0^t B\_s \, dB\_s = \frac{1}{2} (B\_t^2-t)$$
can be found in almost all books about SDE's. And you could also calculate the given moments using that
$$B\_t^2 -t = t \cdot \bigg( X\_t^2-1 \bigg)$$
where $X\_t := \frac{B\_t}{\sqrt{t}}$. $X\_t^2$ is $\chi\_1^2$-distribute... | For example, if $\mathbb{E}[X] = 0$, we cannot conclude that $\mathbb{E}[X^2] = 0$, etc. An example is $X = Z \sim \mathcal{N}(0, 1)$, where $\mathbb{E}[X] = 0$ but $\mathbb{E}[X^2] > 0$ since $X^2$ is never negative. |
55,090,558 | How to remove complete record of same object in array please help me this, I am using below funtion but its only remove one value I want remove complete object of same object
```
var data = [{
"QuestionOid": 1,
"name": "hello",
"label": "world"
}, {
"QuestionOid": 2,
"name": "abc",
"label": "xyz... | 2019/03/10 | [
"https://Stackoverflow.com/questions/55090558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10458908/"
] | Your question seems to imply that "tokenizing" is some kind of mysterious and complicated process. But in fact, the thing you are trying to do is exactly *tokenizing*.
Here is a perfectly valid way to read the file you show, break it up into tokens, and store it in a data structure:
```
def read_file_data(data_file_p... | Pandas does many magical things, so maybe that is prettier for you?
```
import pandas as pd
pd.read_csv('input.txt',sep = ' ',header=None,index_col=0)
```
This gives you a dataframe that you can manipulate further:
```
0 1
Nom NMS-01
MAC AAAAAAAAAAA
UDPport 2019
TCPport 9129
``` |
3,391,638 | The direction of the gradient is along the direction of the maximum ascent, or along the directional derivative that has by the most positive value, but when talking about level surfaces, it is agued that gradient is always perpendicular to the tangent plane? This is confusing me a lot? Have I not clearly understood th... | 2019/10/13 | [
"https://math.stackexchange.com/questions/3391638",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/714290/"
] | Hint:
-----
For $m = n$ , the condition is always True.
Consider $ m \ne n $ such that : $$\frac mn = x \text{ and } \frac nm = y \space \space $$
Then $$\frac1x + x = n \space \space \text{ such that } n\in \mathbb Z$$
Can you find the values of $x$ for which $\frac1x + x $ is an integer? | **Hint** Let $d=gcd(m,n)$. Write
$$m=dm' \\
n=d n'$$
Then, $gcd(m',n')=1$ and
$$\frac{m'}{n'}+\frac{n'}{m'} \in \mathbb Z$$
Thus
$$m'n'|(m')^2+(n')^2$$
Deduce from here that $m'| (n')^2$. Since $gcd(m',n')=1$, you'll get that $m'=\pm 1$.
Same way $n'|(m')^2$ will imply that $n'=\pm 1$. |
3,391,638 | The direction of the gradient is along the direction of the maximum ascent, or along the directional derivative that has by the most positive value, but when talking about level surfaces, it is agued that gradient is always perpendicular to the tangent plane? This is confusing me a lot? Have I not clearly understood th... | 2019/10/13 | [
"https://math.stackexchange.com/questions/3391638",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/714290/"
] | Hint:
-----
For $m = n$ , the condition is always True.
Consider $ m \ne n $ such that : $$\frac mn = x \text{ and } \frac nm = y \space \space $$
Then $$\frac1x + x = n \space \space \text{ such that } n\in \mathbb Z$$
Can you find the values of $x$ for which $\frac1x + x $ is an integer? | Clearly, the expression does not change when we multiply $n,m$ by the same factor. Hence consider first the case that $\gcd(n,m)=1$. Then
$$\frac nm+\frac mn =\frac{n^2+m^2}{nm}=2+\frac{(n+m)^2}{nm}.$$
As $\gcd(n+m,n)=\gcd(n,m)=1$ and $\gcd(n+m,m)=\gcd(n,m)=1$, the fraction at the end is already in shortest terms, perh... |
54,742,207 | I want to set the drawable image to the end of the text but it shows the end of the text view.
**Here is my code**
```
<TextView
android:id="@+id/tv_overweight_messsage"
android:layout_width="wrap_content"
android:layout_height="wrap_content
android:layout_marginTop="@dimen/activity_marginVertical... | 2019/02/18 | [
"https://Stackoverflow.com/questions/54742207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9030938/"
] | You can embed an [`ImageSpan`](https://developer.android.com/reference/android/text/style/ImageSpan) in a [`SpannableString`](https://developer.android.com/reference/android/text/SpannableString) and set the [`TextView`](https://developer.android.com/reference/android/widget/TextView) to display that. For example:
```... | Check this -
```
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/ic_arrow_back_black_24dp"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp"
... |
54,742,207 | I want to set the drawable image to the end of the text but it shows the end of the text view.
**Here is my code**
```
<TextView
android:id="@+id/tv_overweight_messsage"
android:layout_width="wrap_content"
android:layout_height="wrap_content
android:layout_marginTop="@dimen/activity_marginVertical... | 2019/02/18 | [
"https://Stackoverflow.com/questions/54742207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9030938/"
] | You can embed an [`ImageSpan`](https://developer.android.com/reference/android/text/style/ImageSpan) in a [`SpannableString`](https://developer.android.com/reference/android/text/SpannableString) and set the [`TextView`](https://developer.android.com/reference/android/widget/TextView) to display that. For example:
```... | Try setting
```
android:layout_width="match_parent"
``` |
54,742,207 | I want to set the drawable image to the end of the text but it shows the end of the text view.
**Here is my code**
```
<TextView
android:id="@+id/tv_overweight_messsage"
android:layout_width="wrap_content"
android:layout_height="wrap_content
android:layout_marginTop="@dimen/activity_marginVertical... | 2019/02/18 | [
"https://Stackoverflow.com/questions/54742207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9030938/"
] | You can embed an [`ImageSpan`](https://developer.android.com/reference/android/text/style/ImageSpan) in a [`SpannableString`](https://developer.android.com/reference/android/text/SpannableString) and set the [`TextView`](https://developer.android.com/reference/android/widget/TextView) to display that. For example:
```... | You need to use `android:drawableEnd` instead of `drawableRight`. |
54,742,207 | I want to set the drawable image to the end of the text but it shows the end of the text view.
**Here is my code**
```
<TextView
android:id="@+id/tv_overweight_messsage"
android:layout_width="wrap_content"
android:layout_height="wrap_content
android:layout_marginTop="@dimen/activity_marginVertical... | 2019/02/18 | [
"https://Stackoverflow.com/questions/54742207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9030938/"
] | Try setting
```
android:layout_width="match_parent"
``` | Check this -
```
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/ic_arrow_back_black_24dp"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp"
... |
54,742,207 | I want to set the drawable image to the end of the text but it shows the end of the text view.
**Here is my code**
```
<TextView
android:id="@+id/tv_overweight_messsage"
android:layout_width="wrap_content"
android:layout_height="wrap_content
android:layout_marginTop="@dimen/activity_marginVertical... | 2019/02/18 | [
"https://Stackoverflow.com/questions/54742207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9030938/"
] | Try setting
```
android:layout_width="match_parent"
``` | You need to use `android:drawableEnd` instead of `drawableRight`. |
54,328,671 | How can change a specific part of an image src using jQuery after the page is being loaded?
This is an example link,
`<img src="https://example.com/73832d3c5fca_175x175_c0b~bn1v1.jpg">`
I want to replace the `b1n1v1` with `bn1v1` after the page is being fully rendered.
This is what I have tried to do so far but it ... | 2019/01/23 | [
"https://Stackoverflow.com/questions/54328671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2951653/"
] | Loop each images and replace the same `.attr('src')`
```
$(document).ready(function() {
$('img').each(function(){
$(this).attr('src',$(this).attr('src').replace("b1n1v1", "bn1v1"));
});
});
```
**each** <https://api.jquery.com/each/> | 1. Add a class to that image `imageClass`.
`$('.imageClass').attr('src').replace('bn1nv1', 'bn1v1');` |
54,328,671 | How can change a specific part of an image src using jQuery after the page is being loaded?
This is an example link,
`<img src="https://example.com/73832d3c5fca_175x175_c0b~bn1v1.jpg">`
I want to replace the `b1n1v1` with `bn1v1` after the page is being fully rendered.
This is what I have tried to do so far but it ... | 2019/01/23 | [
"https://Stackoverflow.com/questions/54328671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2951653/"
] | Your syntax isn't quite right as `this` refers to the `window` and `return` is redundant at that point.
To make this work for all `img` elements in the page you need to loop through them. To do that you can provide a function to `attr()` which accepts the current value as an argument and returns the new value. Try th... | Loop each images and replace the same `.attr('src')`
```
$(document).ready(function() {
$('img').each(function(){
$(this).attr('src',$(this).attr('src').replace("b1n1v1", "bn1v1"));
});
});
```
**each** <https://api.jquery.com/each/> |
54,328,671 | How can change a specific part of an image src using jQuery after the page is being loaded?
This is an example link,
`<img src="https://example.com/73832d3c5fca_175x175_c0b~bn1v1.jpg">`
I want to replace the `b1n1v1` with `bn1v1` after the page is being fully rendered.
This is what I have tried to do so far but it ... | 2019/01/23 | [
"https://Stackoverflow.com/questions/54328671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2951653/"
] | Your syntax isn't quite right as `this` refers to the `window` and `return` is redundant at that point.
To make this work for all `img` elements in the page you need to loop through them. To do that you can provide a function to `attr()` which accepts the current value as an argument and returns the new value. Try th... | 1. Add a class to that image `imageClass`.
`$('.imageClass').attr('src').replace('bn1nv1', 'bn1v1');` |
36,249,196 | I have created a MVC structure to save a new record for patient and i keep getting 404 error. Here is my code,
Patient.java
```
public class Patient {
private int patient_ID;
private String name;
private String gender;
private int age;
private Date dob;
public Patient(){
}
public Patient(int patient_ID, String na... | 2016/03/27 | [
"https://Stackoverflow.com/questions/36249196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4074409/"
] | When data are sent to controller, All data are sent as String.
So,dob field has been sent as String also. When data are being copied in Model **Patient**, dob field is date type.
Spring is not initially configured by default for automatic conversion from String to Date type. Spring does not know that this is a Date, ... | Uhm, that date field (dob) is suspect, how do your framework know how to cast it without something like:
```
@DateTimeFormat(pattern = "yyyy-MM-dd")
``` |
36,249,196 | I have created a MVC structure to save a new record for patient and i keep getting 404 error. Here is my code,
Patient.java
```
public class Patient {
private int patient_ID;
private String name;
private String gender;
private int age;
private Date dob;
public Patient(){
}
public Patient(int patient_ID, String na... | 2016/03/27 | [
"https://Stackoverflow.com/questions/36249196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4074409/"
] | When data are sent to controller, All data are sent as String.
So,dob field has been sent as String also. When data are being copied in Model **Patient**, dob field is date type.
Spring is not initially configured by default for automatic conversion from String to Date type. Spring does not know that this is a Date, ... | Try this
`action="save"`
to
`action="savePatient"`. Since there is no action called `save` in your controller class. |
37,021,147 | I have two tables below
subcategorytbl
```
sub_id sub_title sub_parent_id
1 For rent 0
2 Car 1
3 Motorcycle 1
4 For Sale 0
5 Boat 4
```
itemtbl
```
item_id sub_id
1 2
2 ... | 2016/05/04 | [
"https://Stackoverflow.com/questions/37021147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5541519/"
] | To get the date, you can do
```
Date myDate = cell.getDateCellValue()
```
and then use SimpleDateFormat like your example :
```
if(DateUtil.isCellDateFormatted(cell)){
Date myDate = cell.getDateCellValue();
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
String result = formatter.format(myDat... | You should take date as a string in the file area. My reader like this.
```
switch (cell.getCellType()) {
case Cell.CELL_TYPE_NUMERIC:
cellValue = String.valueOf((long) cell.getNumericCellValue());
break;
case Cell.CELL_TYPE_STRING:
... |
9,386,595 | We have a whole bunch of websites with very similar web.config files.
Can you centralise the duplicate configs in 1 config file before the root directory of each website? Or is the only option machine.config?
We are looking to centralise an assembly reference in the GAC.
Structure:
* Containing Directory
+ Website... | 2012/02/21 | [
"https://Stackoverflow.com/questions/9386595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/972457/"
] | [Python Decorators](https://stackoverflow.com/questions/739654/understanding-python-decorators) are what you want.
You said the except block is always the same. Make a custom decorator that does what you want. You'll have to apply this to each function/method but it sure does save duplication.
```
def handleError(fun... | The content inside your `try` block is the interesting stuff, so that should be in functions. Then just select which function you want, and call it, wrapped by your exceptions. You could even write the exception code as a function, and pass the selected function to this as an argument. e.g.
```
def foo():
num=rand... |
9,386,595 | We have a whole bunch of websites with very similar web.config files.
Can you centralise the duplicate configs in 1 config file before the root directory of each website? Or is the only option machine.config?
We are looking to centralise an assembly reference in the GAC.
Structure:
* Containing Directory
+ Website... | 2012/02/21 | [
"https://Stackoverflow.com/questions/9386595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/972457/"
] | [Python Decorators](https://stackoverflow.com/questions/739654/understanding-python-decorators) are what you want.
You said the except block is always the same. Make a custom decorator that does what you want. You'll have to apply this to each function/method but it sure does save duplication.
```
def handleError(fun... | If those are your actual functions it would be easy to generalize them.
You could create one general function
```
def general(bottom_num, top_num):
num=random.random()
try:
if num>top_num: print 'OK'
elif num>bottom_num: raise NameError('Too Small')
else: raise KeyboardInterrupt
except NameError:
... |
9,386,595 | We have a whole bunch of websites with very similar web.config files.
Can you centralise the duplicate configs in 1 config file before the root directory of each website? Or is the only option machine.config?
We are looking to centralise an assembly reference in the GAC.
Structure:
* Containing Directory
+ Website... | 2012/02/21 | [
"https://Stackoverflow.com/questions/9386595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/972457/"
] | [Python Decorators](https://stackoverflow.com/questions/739654/understanding-python-decorators) are what you want.
You said the except block is always the same. Make a custom decorator that does what you want. You'll have to apply this to each function/method but it sure does save duplication.
```
def handleError(fun... | The answer above does not apply for Functions that take arguments - for the later case, I think you would want something like this:
```
def handleError(f):
def handleProblems(*args, **kwargs):
try:
return f(*args, **kwargs)
except Exception:
print "Oh noes"
return handl... |
9,386,595 | We have a whole bunch of websites with very similar web.config files.
Can you centralise the duplicate configs in 1 config file before the root directory of each website? Or is the only option machine.config?
We are looking to centralise an assembly reference in the GAC.
Structure:
* Containing Directory
+ Website... | 2012/02/21 | [
"https://Stackoverflow.com/questions/9386595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/972457/"
] | [Python Decorators](https://stackoverflow.com/questions/739654/understanding-python-decorators) are what you want.
You said the except block is always the same. Make a custom decorator that does what you want. You'll have to apply this to each function/method but it sure does save duplication.
```
def handleError(fun... | I ran into the same scenario recently, in my case I have some custom exceptions based on which I need to log or raise the Exception further. I have created a decorator method to handle the exceptions as per type.
```
try:
obj.some_method()
except Exception as e:
catch_and_log_exception(e)
def catch_and_log_exc... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.