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 |
|---|---|---|---|---|---|
49,761,972 | Assuming I want to ensure that `myKey` in `{ myKey: '' }` only contains the strings `foo`, `bar`, `baz`, I could achieve this in two ways.
```
// with a String Literal Type
type MyKeyType = 'foo' | 'bar' | 'baz';
// or with a String Enum
enum MyKeyType {
FOO = 'foo',
BAR = 'bar',
... | 2018/04/10 | [
"https://Stackoverflow.com/questions/49761972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6191996/"
] | The key thing to understand is that *the values of string enums are opaque*.
The intended use case for a string enum is that you don't want other code to know or care what the literal string backing `MyKeyType.FOO` is. This means that you won't be able to, say, pass the *literal string* `"bar"` to a function accepting... | One benefit by using enum instead of string literal is that you can use it also in places that you don't declare the types.
for example -
```
assert.equal(result.keyType, KeyType.FOO)
``` |
49,761,972 | Assuming I want to ensure that `myKey` in `{ myKey: '' }` only contains the strings `foo`, `bar`, `baz`, I could achieve this in two ways.
```
// with a String Literal Type
type MyKeyType = 'foo' | 'bar' | 'baz';
// or with a String Enum
enum MyKeyType {
FOO = 'foo',
BAR = 'bar',
... | 2018/04/10 | [
"https://Stackoverflow.com/questions/49761972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6191996/"
] | Well, there is a **difference** between string enums and literal types in the transpiled code.
Compare the **Typescript** Code
```
// with a String Literal Type
type MyKeyType1 = 'foo' | 'bar' | 'baz';
// or with a String Enum
enum MyKeyType2 {
FOO = 'foo',
BAR = 'bar',
BAZ = 'baz'
}
```
With the **tr... | One benefit for an enum at development time is that you will see the list of options easily via intellisense:
[](https://i.stack.imgur.com/X3IJr.png)
Similarly, you could change an enum value easily using refactoring tools, instead of changing a stri... |
49,761,972 | Assuming I want to ensure that `myKey` in `{ myKey: '' }` only contains the strings `foo`, `bar`, `baz`, I could achieve this in two ways.
```
// with a String Literal Type
type MyKeyType = 'foo' | 'bar' | 'baz';
// or with a String Enum
enum MyKeyType {
FOO = 'foo',
BAR = 'bar',
... | 2018/04/10 | [
"https://Stackoverflow.com/questions/49761972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6191996/"
] | One benefit for an enum at development time is that you will see the list of options easily via intellisense:
[](https://i.stack.imgur.com/X3IJr.png)
Similarly, you could change an enum value easily using refactoring tools, instead of changing a stri... | A big downside of enum is that if you use number instead of string, the entirely enum is not safety in my opinion: i can always assign any number value to a variable of this kind
```
enum TYPE {MAN = 1, WOMAN = 2, BOY = 3, GIRL = 4};
let foo: TYPE = TYPE.MAN;
foo = 37.14; //no problem for compiler
``` |
49,761,972 | Assuming I want to ensure that `myKey` in `{ myKey: '' }` only contains the strings `foo`, `bar`, `baz`, I could achieve this in two ways.
```
// with a String Literal Type
type MyKeyType = 'foo' | 'bar' | 'baz';
// or with a String Enum
enum MyKeyType {
FOO = 'foo',
BAR = 'bar',
... | 2018/04/10 | [
"https://Stackoverflow.com/questions/49761972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6191996/"
] | One benefit for an enum at development time is that you will see the list of options easily via intellisense:
[](https://i.stack.imgur.com/X3IJr.png)
Similarly, you could change an enum value easily using refactoring tools, instead of changing a stri... | One benefit by using enum instead of string literal is that you can use it also in places that you don't declare the types.
for example -
```
assert.equal(result.keyType, KeyType.FOO)
``` |
49,761,972 | Assuming I want to ensure that `myKey` in `{ myKey: '' }` only contains the strings `foo`, `bar`, `baz`, I could achieve this in two ways.
```
// with a String Literal Type
type MyKeyType = 'foo' | 'bar' | 'baz';
// or with a String Enum
enum MyKeyType {
FOO = 'foo',
BAR = 'bar',
... | 2018/04/10 | [
"https://Stackoverflow.com/questions/49761972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6191996/"
] | Well, there is a **difference** between string enums and literal types in the transpiled code.
Compare the **Typescript** Code
```
// with a String Literal Type
type MyKeyType1 = 'foo' | 'bar' | 'baz';
// or with a String Enum
enum MyKeyType2 {
FOO = 'foo',
BAR = 'bar',
BAZ = 'baz'
}
```
With the **tr... | A big downside of enum is that if you use number instead of string, the entirely enum is not safety in my opinion: i can always assign any number value to a variable of this kind
```
enum TYPE {MAN = 1, WOMAN = 2, BOY = 3, GIRL = 4};
let foo: TYPE = TYPE.MAN;
foo = 37.14; //no problem for compiler
``` |
49,761,972 | Assuming I want to ensure that `myKey` in `{ myKey: '' }` only contains the strings `foo`, `bar`, `baz`, I could achieve this in two ways.
```
// with a String Literal Type
type MyKeyType = 'foo' | 'bar' | 'baz';
// or with a String Enum
enum MyKeyType {
FOO = 'foo',
BAR = 'bar',
... | 2018/04/10 | [
"https://Stackoverflow.com/questions/49761972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6191996/"
] | Well, there is a **difference** between string enums and literal types in the transpiled code.
Compare the **Typescript** Code
```
// with a String Literal Type
type MyKeyType1 = 'foo' | 'bar' | 'baz';
// or with a String Enum
enum MyKeyType2 {
FOO = 'foo',
BAR = 'bar',
BAZ = 'baz'
}
```
With the **tr... | One benefit by using enum instead of string literal is that you can use it also in places that you don't declare the types.
for example -
```
assert.equal(result.keyType, KeyType.FOO)
``` |
39,722,669 | I have several text files where each line starts with a group code, and each data item is separated by pipe characters. There is a specific group that will sometimes have data, and sometimes have no data, and will therefore only have the group code and pipes. I am trying to remove these groups with no data, while keepi... | 2016/09/27 | [
"https://Stackoverflow.com/questions/39722669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4388475/"
] | Try using another file:
```
FindStr/RV "^A05||" MyFile.txt>AnotherFile.txt
```
Then if needs be **del**ete **Myfile.txt** & **ren**ame **AnotherFile.txt MyFile.txt** | You are almost there, but there are two issues in your command line:
```
type MYFILE.txt | findstr /v "A05|||" > MYFILE.txt
```
1. The redirection `> MYFILE.txt` is applied to the entire command line, so when redirection is prepared, the (new) empty file `MYFILE.txt` is created first, then the command line is execut... |
63,211 | I am trying to run haproxy in front of tomcat on a Solaris x86 box, but I am getting intermittent failures. At seemingly random intervals, the request just hangs until haproxy times out the connection.
I thought maybe it was my app, but I've been able to reproduce it with the tomcat manager app, and hitting tomcat di... | 2009/09/08 | [
"https://serverfault.com/questions/63211",
"https://serverfault.com",
"https://serverfault.com/users/-1/"
] | I suspect that your Tomcat is pausing for a full garbage collection, which is why it is not responding or logging anything. See [here](http://www.infoq.com/news/2010/04/cliff_click_gc_pauses/) for more information on this problem. | If you turn on the haproxy statistics server, the extra information may help you debug
* add "stats enable" to your "listen" section
* browse to [<http://your-proxy:81/haproxy?stats>](http://your-proxy:81/haproxy?stats) |
63,211 | I am trying to run haproxy in front of tomcat on a Solaris x86 box, but I am getting intermittent failures. At seemingly random intervals, the request just hangs until haproxy times out the connection.
I thought maybe it was my app, but I've been able to reproduce it with the tomcat manager app, and hitting tomcat di... | 2009/09/08 | [
"https://serverfault.com/questions/63211",
"https://serverfault.com",
"https://serverfault.com/users/-1/"
] | I suspect that your Tomcat is pausing for a full garbage collection, which is why it is not responding or logging anything. See [here](http://www.infoq.com/news/2010/04/cliff_click_gc_pauses/) for more information on this problem. | Well, you should run tcpdump between haproxy and netcat to figure out what's happening. Haproxy says it did not get the response, which may be discuted, but it is clear it has connected and sent the request otherwise it could not be waiting for a header. The fact that tomcat does not see any incoming request is troubli... |
64,873,395 | I have data like this
```
Name valuta price Type Type2
A USD 10 Acc 1
B USD 30 Acc 2
C SGD 20 Acc 3
D SGD 05 Acc 4
A SGD 35 ... | 2020/11/17 | [
"https://Stackoverflow.com/questions/64873395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10766911/"
] | You can do it with `MAX()` window function in the `ORDER BY` clause:
```
select Name, valuta, sum(price) price, type, type2
from tablename
group by Name, valuta, type, type2
order by max(sum(price)) over (partition by Name) desc,
Name,
sum(price) desc
```
See the [demo](https://dbfiddle.uk/?rdbms=... | For the above question, following query will work: (Assume table name - data)
```sql
select Name , valuta , sum(price) as price , Type, Type2
from data
group by 1,2,4,5
order by sum(price) desc ;
``` |
64,873,395 | I have data like this
```
Name valuta price Type Type2
A USD 10 Acc 1
B USD 30 Acc 2
C SGD 20 Acc 3
D SGD 05 Acc 4
A SGD 35 ... | 2020/11/17 | [
"https://Stackoverflow.com/questions/64873395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10766911/"
] | You can do it with `MAX()` window function in the `ORDER BY` clause:
```
select Name, valuta, sum(price) price, type, type2
from tablename
group by Name, valuta, type, type2
order by max(sum(price)) over (partition by Name) desc,
Name,
sum(price) desc
```
See the [demo](https://dbfiddle.uk/?rdbms=... | I know you said Type2 is unique based on Name, but you still need to include it in the GROUP BY (or else use a case statement to derive the value, or JOIN to a lookup table).
The following should give you the correct results.
```
SELECT Name, Valuta, SUM(Price), Type, Type2
FROM Table
GROUP BY Name, Valuta, Type, Typ... |
8,161 | I have converted an edge loop to a curve. The edge loop itself was fairly low poly. I want the curve to look smooth so I tried to increase the resolution of it but it looks exactly the same.

Is there a way I can get the curve to be a smooth interpol... | 2014/03/29 | [
"https://blender.stackexchange.com/questions/8161",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/1476/"
] | This is because the converted curve is a *Poly* spline.
To convert it to a smoothly interpolated curve:
1. Convert it to a Bezier or NURBS spline in *3D view > Tool shelf > Curve Tools > Set Spline Type*:

2. Then convert all the Control Vertices to... | After converting the mesh to a curve, go into edit mode, then in the Modeling section of the Tools tab, click on Smooth several times.
 |
18,653,163 | I have a project PROJECT\_A which contains mdf file database.
In the solution of this project I added one new project - PROJECT\_B.
My question is:Can I use .mdf file from PROJECT\_A in PROJECT\_B? | 2013/09/06 | [
"https://Stackoverflow.com/questions/18653163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2281755/"
] | You can add .mdf file as a [Link Reference](http://support.microsoft.com/kb/306234) to project B
Right click project B and then properties > Add Reference > Existing Item > Select the .mdf file and in the add button select `Add As Link` option. | Yes, you can use single .mdf file in multiple projects. However it is not recommended since it may cause 'access denied' error. It is also a bad practice. You should be using per .mdf file per project/application. |
53,924 | Preface this by saying I will be launching this script whether it be applescript or bash script with Alfred.app.
Sorry to be so blunt and unknowledgable but I need to run a couple lines of bash in an applescript. I think a simple bash script is capable but I do not know for sure. Here are the details (note that the co... | 2012/06/17 | [
"https://apple.stackexchange.com/questions/53924",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/24084/"
] | As @laaph mentioned, if you just want to run bash commands, use a bash script.
There are, however, a few issues with your commands.
Your script has to look like:
```
#!/bin/sh
pushd ~/Library/Vidalia
rm vidalia.conf
unzip vidalia.conf.zip
popd
open /Applications/Vidalia.app
```
If you didn't change to the correct... | What you have so far is exactly what you want, and to open a program, use "open", so your script will look like this:
```
rm ~/Library/Vidalia/vidalia.conf
unzip ~/Library/Vidalia/vidalia.conf.zip
open /Applications/Vidallia.app
```
There are all sorts of tricks to monitor if Vidalia is running or not, so if you wer... |
703,542 | I've been trying to figure out this integral via use of residues:
$$\int\_{-\infty}^{\infty} \displaystyle \frac{\cos{5x}}{x^4+1}dx$$
The usual semicircle contour wont work for this guy as the integrated is unbounded.
My idea came from a book I was reading on contour integration, where we let
$$f(z) = \displaystyle\... | 2014/03/07 | [
"https://math.stackexchange.com/questions/703542",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/17243/"
] | I've given the skeleton of my work below. Fill in any missing pieces and check your answer against mine.
Using $\gamma=[-R,R]\cup Re^{i[0,\pi]}$ and the simple poles at $\frac{1+i}{\sqrt2}$ and $\frac{-1+i}{\sqrt2}$ inside $\gamma$
$$
\begin{align}
\int\_{-\infty}^\infty\frac{\cos(5x)}{x^4+1}\mathrm{d}x
&=\mathrm{Re}\... | No need to compute two different integrals. Note that $\cos 5x = \operatorname{Re} e^{5ix}$. Put
$$ f(z) = \frac{e^{5iz}}{z^4+1} $$
and integrate over the boundary of a half-disc in the upper half-plane. On the semi-circle $C\_R^+$:
$$
\left| \int\_{C\_R^+} \frac{e^{5iz}}{z^4+1} \right| \le \frac{1}{R^4-1} \cdot \pi R ... |
293,983 | I am looking for ways to make a mobile power supply for 10 units of MG996R servo motors, each of which can draw up to around 800 mA to 1 A and operate between 4.8 V to 7.2 V.
I have 12 Eneloop AA batteries (BK-3MCCA8BA), and from [Panasonic Eneloop BK-3MCC (4th gen) - where I can find maximum discharge current?](https... | 2017/03/22 | [
"https://electronics.stackexchange.com/questions/293983",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/142940/"
] | This one is really clear, surprisingly clear in fact ... downright enlightened. That additional wording that MicroChip put in ... "true ..." makes it a very safe bet that you can perform whatever routing function through that pin you wish to ease your layout. The only caveat is not to put a sensitive net through the pi... | NC or 'No connect' usually means 'Not connected', unless the datasheet says otherwise.
DNC or 'DO NOT CONNECT' means do not connect for any reason. (and is could be a factor pin used for manufacturing, or other purposes) |
8,700,063 | This is an interview question: Design a data structure to perform the following operation efficiently: `boolean isPrefix(String s1, String s2)`.
I guess we can create a `multimap`, which maps prefixes to their strings. For instance,
```
strings: "aa", "ab", "abc", "ba", "ca"
multimap: "a" -> ["aa", "ab", "abc"]
... | 2012/01/02 | [
"https://Stackoverflow.com/questions/8700063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/521070/"
] | The trie data structure would seem like an obvious answer, but the problem as stated doesn't require an advanced data structure. A simple string comparison will suffice and would be very fast. Ultimately, if you want to validate that one string is a prefix of another, you will have to compare every character at corresp... | The most effective storage for prefix information is probably the [trie](http://en.wikipedia.org/wiki/Trie).
In this, the strings correspond to nodes in a tree where one string has another as a prefix exactly when its node is below the other in the tree. |
58,710,504 | Opencart generates its sitemap on the fly and this is a problem in a big catalogs over 10.000 products. So I have modified the function to generate a static sitemap in an XML file.
When I access to my <http://localhost/index.php?route=extension/feed/google_sitemap> I generate a sitemap-google.xml file without problems... | 2019/11/05 | [
"https://Stackoverflow.com/questions/58710504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9417576/"
] | Reflection is based on the assembly’s *metadata*. What you seem to want would need to involve some kind of *source code* inspection to figure out all the concrete generic types created at runtime. Possible? Yes, the compiler does it, but not with reflection. | This is not what you're after but you could go a level deeper and get all methods of all types and collect all return types and the types of all arguments.
Just to be clear, this is nothing close to code analysis that your task requires. This just gives your a little bit more info. |
69,031,724 | This is the code I usually write:
```
alignas(16) __m128 myBuffer[8];
```
But maybe (since the object-array is 128\*8 bit = 128 byte) I should write:
```
alignas(128) __m128 myBuffer[8];
```
Or, "since the first 16 byte are aligned" in the first example, the rest will be automatically aligned in memory? | 2021/09/02 | [
"https://Stackoverflow.com/questions/69031724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/365251/"
] | 128-bit SIMD data types must be aligned on 16 bytes. The compiler already knows that, so it's not needed to align `__m128` manually. See for example, [MSVC docs on `__m128`](https://learn.microsoft.com/en-us/cpp/cpp/m128?view=msvc-160):
>
> Variables of type `__m128` are automatically aligned on 16-byte boundaries.
>... | >
> is correct to use alignas(16) for an array[8] of m128?
>
>
>
It's not technically wrong, but according to documentation `__m128` is aligned to 16 bytes, so it's unnecessary to use `alignas`.
>
> But maybe ... I should write: `alignas(128)`
>
>
>
If your goal is to align to 128 bytes, then you can achieve... |
8,644,259 | I need to know, in android sdk 4.0
the following line says that 'the file is not found'. But the webview loads perfectly in sdk 2.2 and 2.3 etc.
```
mWebView.loadUrl("file:///android_asset/currentLocation.html?width_="+grosswt+"&height_="+grossht);
```
Is there any other way to send query string with url in androi... | 2011/12/27 | [
"https://Stackoverflow.com/questions/8644259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761132/"
] | There seems to be a known bug with Android - <http://code.google.com/p/android/issues/detail?id=17535> | According to this:
<http://developer.android.com/reference/android/webkit/WebView.html#loadUrl(java.lang.String>) the method remains.
I think the problem is with the path to the assets... |
8,644,259 | I need to know, in android sdk 4.0
the following line says that 'the file is not found'. But the webview loads perfectly in sdk 2.2 and 2.3 etc.
```
mWebView.loadUrl("file:///android_asset/currentLocation.html?width_="+grosswt+"&height_="+grossht);
```
Is there any other way to send query string with url in androi... | 2011/12/27 | [
"https://Stackoverflow.com/questions/8644259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761132/"
] | Yes, this is a known bug, even in ICS.
Google don't feel like fixing it.
<http://code.google.com/p/android/issues/detail?id=17535> | According to this:
<http://developer.android.com/reference/android/webkit/WebView.html#loadUrl(java.lang.String>) the method remains.
I think the problem is with the path to the assets... |
8,644,259 | I need to know, in android sdk 4.0
the following line says that 'the file is not found'. But the webview loads perfectly in sdk 2.2 and 2.3 etc.
```
mWebView.loadUrl("file:///android_asset/currentLocation.html?width_="+grosswt+"&height_="+grossht);
```
Is there any other way to send query string with url in androi... | 2011/12/27 | [
"https://Stackoverflow.com/questions/8644259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761132/"
] | This is a well known bug:
<http://code.google.com/p/android/issues/detail?id=17535>
You can find a workaround for Honeycomb and ICS here:
<http://bricolsoftconsulting.com/fixing-the-broken-honeycomb-and-ics-webview/> | According to this:
<http://developer.android.com/reference/android/webkit/WebView.html#loadUrl(java.lang.String>) the method remains.
I think the problem is with the path to the assets... |
8,644,259 | I need to know, in android sdk 4.0
the following line says that 'the file is not found'. But the webview loads perfectly in sdk 2.2 and 2.3 etc.
```
mWebView.loadUrl("file:///android_asset/currentLocation.html?width_="+grosswt+"&height_="+grossht);
```
Is there any other way to send query string with url in androi... | 2011/12/27 | [
"https://Stackoverflow.com/questions/8644259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761132/"
] | you have to do like this
```
String data = "<html><body><img src='your source url' width='1000' Height='1000'></body></html>";
wbView.loadData(data, "text/html", null);
```
this solves my problem . I checked it in android 4.0,4.1,4.2 works great, hope it solves your problem . | According to this:
<http://developer.android.com/reference/android/webkit/WebView.html#loadUrl(java.lang.String>) the method remains.
I think the problem is with the path to the assets... |
8,644,259 | I need to know, in android sdk 4.0
the following line says that 'the file is not found'. But the webview loads perfectly in sdk 2.2 and 2.3 etc.
```
mWebView.loadUrl("file:///android_asset/currentLocation.html?width_="+grosswt+"&height_="+grossht);
```
Is there any other way to send query string with url in androi... | 2011/12/27 | [
"https://Stackoverflow.com/questions/8644259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761132/"
] | Yes, this is a known bug, even in ICS.
Google don't feel like fixing it.
<http://code.google.com/p/android/issues/detail?id=17535> | There seems to be a known bug with Android - <http://code.google.com/p/android/issues/detail?id=17535> |
8,644,259 | I need to know, in android sdk 4.0
the following line says that 'the file is not found'. But the webview loads perfectly in sdk 2.2 and 2.3 etc.
```
mWebView.loadUrl("file:///android_asset/currentLocation.html?width_="+grosswt+"&height_="+grossht);
```
Is there any other way to send query string with url in androi... | 2011/12/27 | [
"https://Stackoverflow.com/questions/8644259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761132/"
] | Yes, this is a known bug, even in ICS.
Google don't feel like fixing it.
<http://code.google.com/p/android/issues/detail?id=17535> | This is a well known bug:
<http://code.google.com/p/android/issues/detail?id=17535>
You can find a workaround for Honeycomb and ICS here:
<http://bricolsoftconsulting.com/fixing-the-broken-honeycomb-and-ics-webview/> |
8,644,259 | I need to know, in android sdk 4.0
the following line says that 'the file is not found'. But the webview loads perfectly in sdk 2.2 and 2.3 etc.
```
mWebView.loadUrl("file:///android_asset/currentLocation.html?width_="+grosswt+"&height_="+grossht);
```
Is there any other way to send query string with url in androi... | 2011/12/27 | [
"https://Stackoverflow.com/questions/8644259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761132/"
] | Yes, this is a known bug, even in ICS.
Google don't feel like fixing it.
<http://code.google.com/p/android/issues/detail?id=17535> | you have to do like this
```
String data = "<html><body><img src='your source url' width='1000' Height='1000'></body></html>";
wbView.loadData(data, "text/html", null);
```
this solves my problem . I checked it in android 4.0,4.1,4.2 works great, hope it solves your problem . |
17,895,602 | I'm using asp.net web service .asmx to transport json data. I have following code which seems not to be working.
```
$.ajax({
type: "POST",
url: "../../App_Code/jsonWebService/getValue",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType... | 2013/07/27 | [
"https://Stackoverflow.com/questions/17895602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1834764/"
] | you need to convert your text into array first, because what your doing right now includes a `,` in your regexp pattern
```
$stop_ips_masks = file_get_contents('array.txt');
$stop_ips_masks = explode("," $stop_ips_masks);
```
You might also need to do a trim operation and remove the newlines as well. it would be eas... | I believe your issue is the quotes and tailing comma. While needed to make a array in php they are invalid when sourced from the file.
```
$stop_ips_masks = file('array.txt', FILE_IGNORE_NEWLINES);
foreach ( $stop_ips_masks as $k=>$v )
{
$v = trim(rtrim($v, ","), '"');
if ( preg_match(... |
17,895,602 | I'm using asp.net web service .asmx to transport json data. I have following code which seems not to be working.
```
$.ajax({
type: "POST",
url: "../../App_Code/jsonWebService/getValue",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType... | 2013/07/27 | [
"https://Stackoverflow.com/questions/17895602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1834764/"
] | you need to convert your text into array first, because what your doing right now includes a `,` in your regexp pattern
```
$stop_ips_masks = file_get_contents('array.txt');
$stop_ips_masks = explode("," $stop_ips_masks);
```
You might also need to do a trim operation and remove the newlines as well. it would be eas... | Another option is to store your strings "raw" in the file as lines:
```
66\.249\.[6-9][0-9]\.[0-9]+
74\.125\.[0-9]+\.[0-9]+
```
Then read the file, putting each line into the array:
```
$array = file('array.txt');
``` |
17,895,602 | I'm using asp.net web service .asmx to transport json data. I have following code which seems not to be working.
```
$.ajax({
type: "POST",
url: "../../App_Code/jsonWebService/getValue",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType... | 2013/07/27 | [
"https://Stackoverflow.com/questions/17895602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1834764/"
] | you need to convert your text into array first, because what your doing right now includes a `,` in your regexp pattern
```
$stop_ips_masks = file_get_contents('array.txt');
$stop_ips_masks = explode("," $stop_ips_masks);
```
You might also need to do a trim operation and remove the newlines as well. it would be eas... | Try something like;
```
<?
$file = file('array.txt');
$stop_ips_masks = explode(",",$file);
foreach ( $stop_ips_masks as $k=>$v )
{
if ( preg_match( '#^'.$v.'$#', $_SERVER['REMOTE_ADDR']) )
echo found;
}
?>
``` |
18,889,688 | I'm trying to test a `HttpServletRequest` and for that I have used [Mockito](http://code.google.com/p/mockito/) as follow:
```
HttpServletRequest mockedRequest = Mockito.mock(HttpServletRequest.class);
```
now before putting the http-request in `assert` methods I just want to build a simple http header as below wit... | 2013/09/19 | [
"https://Stackoverflow.com/questions/18889688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/277740/"
] | You can just stub the calls to request.getHeaders etc. or if you can add a dependency, [Spring-test](http://mvnrepository.com/artifact/org.springframework/spring-test/3.2.0.RELEASE) has a `MockHttpServletRequest` that you could use (see [here](http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/test... | The above answer uses `MockHttpServletRequest`.
If one would like to use `Mockito.mock(HttpServletRequest.class)` , then could stub the request as follows.
```
final HttpServletResponse response = mock(HttpServletResponse.class);
when(request.getHeader("host")).thenReturn("stackoverflow.com");
when(request.getHeader(... |
10,883,786 | I'm working on a codebase with multiple blocks of code setting some behavior on document.ready() (jQuery). Is there a way to enforce that one specific block is called before any of the others?
Background:
I need to detect JS errors in an automated testing environment, so I need the code that starts logging JS errors ... | 2012/06/04 | [
"https://Stackoverflow.com/questions/10883786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/803923/"
] | You should be able to use [holdReady](http://api.jquery.com/jQuery.holdReady/) to do this. As long as it is included before your ready events, you can run your own code and then trigger the other ready events. | You can execute the logging start code in DOMReady and other initialization in load. Or you could make your own initialization manager which calls your logging start code first and then all other initialization callbacks (provided that those are registered with your manager and not jQuery, unless you want to hack jQuer... |
10,883,786 | I'm working on a codebase with multiple blocks of code setting some behavior on document.ready() (jQuery). Is there a way to enforce that one specific block is called before any of the others?
Background:
I need to detect JS errors in an automated testing environment, so I need the code that starts logging JS errors ... | 2012/06/04 | [
"https://Stackoverflow.com/questions/10883786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/803923/"
] | `document.ready()` callbacks are called in the order they were registered. If you register your testing callback first, it will be called first.
Also if your testing code does not actually need to manipulate the DOM, then you may be able to run it as the code is parsed and not wait until the DOM is ready which would r... | You can execute the logging start code in DOMReady and other initialization in load. Or you could make your own initialization manager which calls your logging start code first and then all other initialization callbacks (provided that those are registered with your manager and not jQuery, unless you want to hack jQuer... |
10,883,786 | I'm working on a codebase with multiple blocks of code setting some behavior on document.ready() (jQuery). Is there a way to enforce that one specific block is called before any of the others?
Background:
I need to detect JS errors in an automated testing environment, so I need the code that starts logging JS errors ... | 2012/06/04 | [
"https://Stackoverflow.com/questions/10883786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/803923/"
] | As @jfriend00 mention that `ready callbacks are called in the order they were registered.`
So even if this code block called on the beginning, you can set another callback in it so it'll be executed on endmost.
```js
jQuery(document).ready(function(){
jQuery(document).ready(function(){
// This block will ... | You can execute the logging start code in DOMReady and other initialization in load. Or you could make your own initialization manager which calls your logging start code first and then all other initialization callbacks (provided that those are registered with your manager and not jQuery, unless you want to hack jQuer... |
10,883,786 | I'm working on a codebase with multiple blocks of code setting some behavior on document.ready() (jQuery). Is there a way to enforce that one specific block is called before any of the others?
Background:
I need to detect JS errors in an automated testing environment, so I need the code that starts logging JS errors ... | 2012/06/04 | [
"https://Stackoverflow.com/questions/10883786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/803923/"
] | I was trying to do something similar, I was loading a bunch of polyfills that had .ready() functions, but I also had my own .ready()s on page that I needed executed first, though the polyfills were loaded in the header.
I found a nice way around it by having a .ready() very early on (right after jQuery loads) that exe... | You can execute the logging start code in DOMReady and other initialization in load. Or you could make your own initialization manager which calls your logging start code first and then all other initialization callbacks (provided that those are registered with your manager and not jQuery, unless you want to hack jQuer... |
10,883,786 | I'm working on a codebase with multiple blocks of code setting some behavior on document.ready() (jQuery). Is there a way to enforce that one specific block is called before any of the others?
Background:
I need to detect JS errors in an automated testing environment, so I need the code that starts logging JS errors ... | 2012/06/04 | [
"https://Stackoverflow.com/questions/10883786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/803923/"
] | `document.ready()` callbacks are called in the order they were registered. If you register your testing callback first, it will be called first.
Also if your testing code does not actually need to manipulate the DOM, then you may be able to run it as the code is parsed and not wait until the DOM is ready which would r... | You should be able to use [holdReady](http://api.jquery.com/jQuery.holdReady/) to do this. As long as it is included before your ready events, you can run your own code and then trigger the other ready events. |
10,883,786 | I'm working on a codebase with multiple blocks of code setting some behavior on document.ready() (jQuery). Is there a way to enforce that one specific block is called before any of the others?
Background:
I need to detect JS errors in an automated testing environment, so I need the code that starts logging JS errors ... | 2012/06/04 | [
"https://Stackoverflow.com/questions/10883786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/803923/"
] | As @jfriend00 mention that `ready callbacks are called in the order they were registered.`
So even if this code block called on the beginning, you can set another callback in it so it'll be executed on endmost.
```js
jQuery(document).ready(function(){
jQuery(document).ready(function(){
// This block will ... | You should be able to use [holdReady](http://api.jquery.com/jQuery.holdReady/) to do this. As long as it is included before your ready events, you can run your own code and then trigger the other ready events. |
10,883,786 | I'm working on a codebase with multiple blocks of code setting some behavior on document.ready() (jQuery). Is there a way to enforce that one specific block is called before any of the others?
Background:
I need to detect JS errors in an automated testing environment, so I need the code that starts logging JS errors ... | 2012/06/04 | [
"https://Stackoverflow.com/questions/10883786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/803923/"
] | You should be able to use [holdReady](http://api.jquery.com/jQuery.holdReady/) to do this. As long as it is included before your ready events, you can run your own code and then trigger the other ready events. | I was trying to do something similar, I was loading a bunch of polyfills that had .ready() functions, but I also had my own .ready()s on page that I needed executed first, though the polyfills were loaded in the header.
I found a nice way around it by having a .ready() very early on (right after jQuery loads) that exe... |
10,883,786 | I'm working on a codebase with multiple blocks of code setting some behavior on document.ready() (jQuery). Is there a way to enforce that one specific block is called before any of the others?
Background:
I need to detect JS errors in an automated testing environment, so I need the code that starts logging JS errors ... | 2012/06/04 | [
"https://Stackoverflow.com/questions/10883786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/803923/"
] | `document.ready()` callbacks are called in the order they were registered. If you register your testing callback first, it will be called first.
Also if your testing code does not actually need to manipulate the DOM, then you may be able to run it as the code is parsed and not wait until the DOM is ready which would r... | As @jfriend00 mention that `ready callbacks are called in the order they were registered.`
So even if this code block called on the beginning, you can set another callback in it so it'll be executed on endmost.
```js
jQuery(document).ready(function(){
jQuery(document).ready(function(){
// This block will ... |
10,883,786 | I'm working on a codebase with multiple blocks of code setting some behavior on document.ready() (jQuery). Is there a way to enforce that one specific block is called before any of the others?
Background:
I need to detect JS errors in an automated testing environment, so I need the code that starts logging JS errors ... | 2012/06/04 | [
"https://Stackoverflow.com/questions/10883786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/803923/"
] | `document.ready()` callbacks are called in the order they were registered. If you register your testing callback first, it will be called first.
Also if your testing code does not actually need to manipulate the DOM, then you may be able to run it as the code is parsed and not wait until the DOM is ready which would r... | I was trying to do something similar, I was loading a bunch of polyfills that had .ready() functions, but I also had my own .ready()s on page that I needed executed first, though the polyfills were loaded in the header.
I found a nice way around it by having a .ready() very early on (right after jQuery loads) that exe... |
10,883,786 | I'm working on a codebase with multiple blocks of code setting some behavior on document.ready() (jQuery). Is there a way to enforce that one specific block is called before any of the others?
Background:
I need to detect JS errors in an automated testing environment, so I need the code that starts logging JS errors ... | 2012/06/04 | [
"https://Stackoverflow.com/questions/10883786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/803923/"
] | As @jfriend00 mention that `ready callbacks are called in the order they were registered.`
So even if this code block called on the beginning, you can set another callback in it so it'll be executed on endmost.
```js
jQuery(document).ready(function(){
jQuery(document).ready(function(){
// This block will ... | I was trying to do something similar, I was loading a bunch of polyfills that had .ready() functions, but I also had my own .ready()s on page that I needed executed first, though the polyfills were loaded in the header.
I found a nice way around it by having a .ready() very early on (right after jQuery loads) that exe... |
46,619,261 | I want to send a message to websocket from `java` code.
This is configuration class for `websockets`
```
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
private WebSocketHandler handler;
public WebSocketConfig(WebSocketHandler handler) {
this.handler = ha... | 2017/10/07 | [
"https://Stackoverflow.com/questions/46619261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1432980/"
] | A bit late but if you're using API 21+, you can set the secondary progress tint to be transparent:
```
android:secondaryProgressTint="@android:color/transparent"
``` | I was facing the same issue too. I figured it out. The drawable at 1 index changes that shadow color. You can set it to the much lighter color of your actual filled star color.
```
RatingBar ratingBar = footer.findViewById(R.id.ratingBar);
LayerDrawable stars = (LayerDrawable) ratingBar.getProgressDrawable();
... |
23,239 | This question may sound rhetorical or not well posed, but I wonder what the economic viability or sustainability of certain Emirates routes is.
Among its 164 destinations, Emirates is currently serving a whole host of non-major airports (airports which, according to [this list](https://en.wikipedia.org/wiki/List_of_th... | 2015/11/28 | [
"https://aviation.stackexchange.com/questions/23239",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/11885/"
] | Don't forget that aircraft size and link capacity are only loosely related, because it also depends on how many flights there are.
For example in case of Prague, I counted 6 departures to Frakfurt and 7 to Amsterdam a day, while only 2 to Dubai (the Emirates B77W and one SmartWings B738). So while the flights to Frank... | >
> [C]ouldn't the people living around Bologna take a train to Milan to get to Dubai... ?
>
>
>
Maybe. But even if they can, it's much less convenient. By the time you've factored in taking a train from the outskirts of your city to the centre, waiting for the connection, taking the one-hour train, arriving earli... |
23,239 | This question may sound rhetorical or not well posed, but I wonder what the economic viability or sustainability of certain Emirates routes is.
Among its 164 destinations, Emirates is currently serving a whole host of non-major airports (airports which, according to [this list](https://en.wikipedia.org/wiki/List_of_th... | 2015/11/28 | [
"https://aviation.stackexchange.com/questions/23239",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/11885/"
] | Eurostats provides information EU air passengers information, [it details air passengers transport Each of EU countries and their main airport partner.](http://ec.europa.eu/eurostat/help/new-eurostat-website?p_auth=82MXqaAJ&p_p_id=estatsearchportlet_WAR_estatsearchportlet&p_p_lifecycle=1&p_p_state=maximized&p_p_mode=vi... | It's very simple. Emirates is HEAVILY subsidized by the government of UAE. They are privately held by a government investment corporation which means any data on yield, load factors, PRASM, CASM, or profits are not to be trusted. They are trying to flood certain markets with capacity in order to kill competition and ga... |
23,239 | This question may sound rhetorical or not well posed, but I wonder what the economic viability or sustainability of certain Emirates routes is.
Among its 164 destinations, Emirates is currently serving a whole host of non-major airports (airports which, according to [this list](https://en.wikipedia.org/wiki/List_of_th... | 2015/11/28 | [
"https://aviation.stackexchange.com/questions/23239",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/11885/"
] | Don't forget that aircraft size and link capacity are only loosely related, because it also depends on how many flights there are.
For example in case of Prague, I counted 6 departures to Frakfurt and 7 to Amsterdam a day, while only 2 to Dubai (the Emirates B77W and one SmartWings B738). So while the flights to Frank... | It's very simple. Emirates is HEAVILY subsidized by the government of UAE. They are privately held by a government investment corporation which means any data on yield, load factors, PRASM, CASM, or profits are not to be trusted. They are trying to flood certain markets with capacity in order to kill competition and ga... |
23,239 | This question may sound rhetorical or not well posed, but I wonder what the economic viability or sustainability of certain Emirates routes is.
Among its 164 destinations, Emirates is currently serving a whole host of non-major airports (airports which, according to [this list](https://en.wikipedia.org/wiki/List_of_th... | 2015/11/28 | [
"https://aviation.stackexchange.com/questions/23239",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/11885/"
] | There are many reasons an airline may fly to a given destination and the economics of air travel are complex to say the least. I would like to fist address your question
>
> couldn't the people living around Bologna take a train to Milan to get
> to Dubai
>
>
>
Sure they could but airlines don't only service lo... | I guess one of the reasons for this wide-body use is because this is the primary aircraft for medium-haul routes in the Emirates Network. The 777 for Emirates is the workhorse of the Emirates airline and it has contributed to it's success. But in reality I do agree with you. Many Emirates routes that I have seen on You... |
23,239 | This question may sound rhetorical or not well posed, but I wonder what the economic viability or sustainability of certain Emirates routes is.
Among its 164 destinations, Emirates is currently serving a whole host of non-major airports (airports which, according to [this list](https://en.wikipedia.org/wiki/List_of_th... | 2015/11/28 | [
"https://aviation.stackexchange.com/questions/23239",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/11885/"
] | I may try and answer for Bologna which could be a similar case as for other supposedly non busy airports. (I am from Bologna myself!)
I think the reason is that even though the airport is not on the top 30, Bologna itself is one of the busiest economic hubs in Italy. For example from here we have factories like Ferrar... | I guess one of the reasons for this wide-body use is because this is the primary aircraft for medium-haul routes in the Emirates Network. The 777 for Emirates is the workhorse of the Emirates airline and it has contributed to it's success. But in reality I do agree with you. Many Emirates routes that I have seen on You... |
23,239 | This question may sound rhetorical or not well posed, but I wonder what the economic viability or sustainability of certain Emirates routes is.
Among its 164 destinations, Emirates is currently serving a whole host of non-major airports (airports which, according to [this list](https://en.wikipedia.org/wiki/List_of_th... | 2015/11/28 | [
"https://aviation.stackexchange.com/questions/23239",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/11885/"
] | There are many reasons an airline may fly to a given destination and the economics of air travel are complex to say the least. I would like to fist address your question
>
> couldn't the people living around Bologna take a train to Milan to get
> to Dubai
>
>
>
Sure they could but airlines don't only service lo... | Don't forget that aircraft size and link capacity are only loosely related, because it also depends on how many flights there are.
For example in case of Prague, I counted 6 departures to Frakfurt and 7 to Amsterdam a day, while only 2 to Dubai (the Emirates B77W and one SmartWings B738). So while the flights to Frank... |
23,239 | This question may sound rhetorical or not well posed, but I wonder what the economic viability or sustainability of certain Emirates routes is.
Among its 164 destinations, Emirates is currently serving a whole host of non-major airports (airports which, according to [this list](https://en.wikipedia.org/wiki/List_of_th... | 2015/11/28 | [
"https://aviation.stackexchange.com/questions/23239",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/11885/"
] | Eurostats provides information EU air passengers information, [it details air passengers transport Each of EU countries and their main airport partner.](http://ec.europa.eu/eurostat/help/new-eurostat-website?p_auth=82MXqaAJ&p_p_id=estatsearchportlet_WAR_estatsearchportlet&p_p_lifecycle=1&p_p_state=maximized&p_p_mode=vi... | I don't think you have to dig much deeper that the fact that Emirates is exclusively an international carrier; and they have decided to standardize their fleet on the 777 and the A380 - this is actually more economical for them since they are able to get cost savings by only servicing two kinds of airframes.
Overall f... |
23,239 | This question may sound rhetorical or not well posed, but I wonder what the economic viability or sustainability of certain Emirates routes is.
Among its 164 destinations, Emirates is currently serving a whole host of non-major airports (airports which, according to [this list](https://en.wikipedia.org/wiki/List_of_th... | 2015/11/28 | [
"https://aviation.stackexchange.com/questions/23239",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/11885/"
] | There are many reasons an airline may fly to a given destination and the economics of air travel are complex to say the least. I would like to fist address your question
>
> couldn't the people living around Bologna take a train to Milan to get
> to Dubai
>
>
>
Sure they could but airlines don't only service lo... | It's very simple. Emirates is HEAVILY subsidized by the government of UAE. They are privately held by a government investment corporation which means any data on yield, load factors, PRASM, CASM, or profits are not to be trusted. They are trying to flood certain markets with capacity in order to kill competition and ga... |
23,239 | This question may sound rhetorical or not well posed, but I wonder what the economic viability or sustainability of certain Emirates routes is.
Among its 164 destinations, Emirates is currently serving a whole host of non-major airports (airports which, according to [this list](https://en.wikipedia.org/wiki/List_of_th... | 2015/11/28 | [
"https://aviation.stackexchange.com/questions/23239",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/11885/"
] | Eurostats provides information EU air passengers information, [it details air passengers transport Each of EU countries and their main airport partner.](http://ec.europa.eu/eurostat/help/new-eurostat-website?p_auth=82MXqaAJ&p_p_id=estatsearchportlet_WAR_estatsearchportlet&p_p_lifecycle=1&p_p_state=maximized&p_p_mode=vi... | I guess one of the reasons for this wide-body use is because this is the primary aircraft for medium-haul routes in the Emirates Network. The 777 for Emirates is the workhorse of the Emirates airline and it has contributed to it's success. But in reality I do agree with you. Many Emirates routes that I have seen on You... |
23,239 | This question may sound rhetorical or not well posed, but I wonder what the economic viability or sustainability of certain Emirates routes is.
Among its 164 destinations, Emirates is currently serving a whole host of non-major airports (airports which, according to [this list](https://en.wikipedia.org/wiki/List_of_th... | 2015/11/28 | [
"https://aviation.stackexchange.com/questions/23239",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/11885/"
] | Don't forget that aircraft size and link capacity are only loosely related, because it also depends on how many flights there are.
For example in case of Prague, I counted 6 departures to Frakfurt and 7 to Amsterdam a day, while only 2 to Dubai (the Emirates B77W and one SmartWings B738). So while the flights to Frank... | I guess one of the reasons for this wide-body use is because this is the primary aircraft for medium-haul routes in the Emirates Network. The 777 for Emirates is the workhorse of the Emirates airline and it has contributed to it's success. But in reality I do agree with you. Many Emirates routes that I have seen on You... |
42,309,571 | I've got this fragment of automatically-generated HTML:
```
<label><input type="radio" name="question24_answer" value="A">A)
H<sub>0</sub>: p = 0.0016<br/>H<sub>1</sub>: p < 0.0016</label>
```
This produces the following:
[](https:... | 2017/02/18 | [
"https://Stackoverflow.com/questions/42309571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3063736/"
] | >
> Any solution needs to be something that can be done automatically.
>
>
>
I believe that would rule out a pure HTML solution to which is the only tag your question has. So at the risk of ignoring the fact there's no CSS or JavaScript tag, I'll suggest JavaScript right off and a little bit of CSS.
1. `.querySel... | Ideally, any visual changes you would like to make should be done with CSS.
However if this must be done with just html with no in-line styling, you can simply add some non-breaking spaces (` `) to achieve this effect, along with an additional `<br>` tag.
```
<label><input type="radio" name="question24_answer" va... |
42,309,571 | I've got this fragment of automatically-generated HTML:
```
<label><input type="radio" name="question24_answer" value="A">A)
H<sub>0</sub>: p = 0.0016<br/>H<sub>1</sub>: p < 0.0016</label>
```
This produces the following:
[](https:... | 2017/02/18 | [
"https://Stackoverflow.com/questions/42309571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3063736/"
] | >
> Any solution needs to be something that can be done automatically.
>
>
>
I believe that would rule out a pure HTML solution to which is the only tag your question has. So at the risk of ignoring the fact there's no CSS or JavaScript tag, I'll suggest JavaScript right off and a little bit of CSS.
1. `.querySel... | Maybe with a list?
```html
<label><input type="radio" name="question24_answer" value="A">A)
<ul style="list-style: none; margin-top: 0;"><li>H<sub>0</sub>: p = 0.0016</li><li>H<sub>1</sub>: p < 0.0016</li></label>
``` |
65,027,547 | I'm using using this data to fill a FlatList, each item contains a LinearGradient
```
const DATA = [
{
id: 'bd7acbea-c1b1-46c2-aed5-3ad53abb28ba',
title: 'First Item',
firstColor: "#f472a7",
secondColor: "#d84351"
},
{
id: '3ac68afc-c605-48d3-a4f8-fbd91aa97f63',
title: 'Second Item',
... | 2020/11/26 | [
"https://Stackoverflow.com/questions/65027547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6596416/"
] | Since Python 3.7, keys in dict are ordered.
-------------------------------------------
You can use enumerate in order to keep track of the position of the element in the dict while iterating over it. Then, you use the `i` as an index on each row of the 2d list, convert each value to int and do a sum of the result.
`... | Use pandas
```
#!pip install pandas
import pandas as pd
pd.DataFrame(List2d, columns=dictionary.keys()).astype(int).sum(axis=0).to_dict()
```
output:
```
{'New York': 67, 'London': 201, 'Tokyo': 102, 'Toronto': 1067}
``` |
65,462,499 | I am trying to use grep with the `pwd` command.
So, if i enter `pwd`, it shows me something like:
```
/home/hrq/my-project/
```
But, for purposes of a script i am making, i need to use it with grep, so it only prints what is after `hrq/`, so i need to hide my home folder always (the `/home/hrq/`) excerpt, and show ... | 2020/12/27 | [
"https://Stackoverflow.com/questions/65462499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10113447/"
] | Given:
```
$ pwd
/home/foo/tmp
$ echo "$PWD"
/home/foo/tmp
```
Depending on what it is you really want to do, either of these is probably what you really should be using rather than trying to use grep:
```
$ basename "$PWD"
tmp
$ echo "${PWD#/home/foo/}"
tmp
``` | Use `grep -Po 'hrq/\K.*'`, for example:
```
grep -Po 'hrq/\K.*' <<< '/home/hrq/my-project/'
my-project/
```
Here, `grep` uses the following options:
`-P` : Use Perl regexes.
`-o` : Print the matches only (1 match per line), not the entire lines.
`\K` : Cause the regex engine to "keep" everything it had matche... |
1,842,608 | I'm using Python to write a regular expression for replacing parts of the string with a XML node.
The source string looks like:
```
Hello
REPLACE(str1) this is to replace
REPLACE(str2) this is to replace
```
And the result string should be like:
```
Hello
<replace name="str1"> this is to replace </replace>
<repl... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1842608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/150324/"
] | What makes your problem a little bit tricky is that you want to match inside of a multiline string. You need to use the `re.MULTILINE` flag to make that work.
Then, you need to match some groups inside your source string, and use those groups in the final output. Here is code that works to solve your problem:
```
imp... | Maybe like this ?
```
import re
mystr = """Hello
REPLACE(str1) this is to replace
REPLACE(str2) this is to replace"""
prog = re.compile(r'REPLACE\((.*?)\)\s(.*)')
for line in mystr.split("\n"):
print prog.sub(r'< replace name="\1" > \2',line)
``` |
1,842,608 | I'm using Python to write a regular expression for replacing parts of the string with a XML node.
The source string looks like:
```
Hello
REPLACE(str1) this is to replace
REPLACE(str2) this is to replace
```
And the result string should be like:
```
Hello
<replace name="str1"> this is to replace </replace>
<repl... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1842608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/150324/"
] | Here is an [excellent tutorial](http://www.amk.ca/python/howto/regex/) on how to write regular expressions in Python. | Here is a solution using pyparsing. I know you specifically asked about a regex solution, but if your requirements change, you might find it easier to expand a pyparsing parser. Or a pyparsing prototype solution might give you a little more insight into the problem leading toward a regex or other final implementation.
... |
1,842,608 | I'm using Python to write a regular expression for replacing parts of the string with a XML node.
The source string looks like:
```
Hello
REPLACE(str1) this is to replace
REPLACE(str2) this is to replace
```
And the result string should be like:
```
Hello
<replace name="str1"> this is to replace </replace>
<repl... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1842608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/150324/"
] | Here is a solution using pyparsing. I know you specifically asked about a regex solution, but if your requirements change, you might find it easier to expand a pyparsing parser. Or a pyparsing prototype solution might give you a little more insight into the problem leading toward a regex or other final implementation.
... | Something like this should work:
```
import re,sys
f = open( sys.argv[1], 'r' )
for i in f:
g = re.match( r'REPLACE\((.*)\)(.*)', i )
if g is None:
print i
else:
print '<replace name=\"%s\">%s</replace>' % (g.group(1),g.group(2))
f.close()
``` |
1,842,608 | I'm using Python to write a regular expression for replacing parts of the string with a XML node.
The source string looks like:
```
Hello
REPLACE(str1) this is to replace
REPLACE(str2) this is to replace
```
And the result string should be like:
```
Hello
<replace name="str1"> this is to replace </replace>
<repl... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1842608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/150324/"
] | What makes your problem a little bit tricky is that you want to match inside of a multiline string. You need to use the `re.MULTILINE` flag to make that work.
Then, you need to match some groups inside your source string, and use those groups in the final output. Here is code that works to solve your problem:
```
imp... | ```
import re
a="""Hello
REPLACE(str1) this is to replace
REPLACE(str2) this is to replace"""
regex = re.compile(r"^REPLACE\(([^)]+)\)\s+(.*)$", re.MULTILINE)
b=re.sub(regex, r'< replace name="\1" > \2 < /replace >', a)
print b
```
will do the replace in one line. |
1,842,608 | I'm using Python to write a regular expression for replacing parts of the string with a XML node.
The source string looks like:
```
Hello
REPLACE(str1) this is to replace
REPLACE(str2) this is to replace
```
And the result string should be like:
```
Hello
<replace name="str1"> this is to replace </replace>
<repl... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1842608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/150324/"
] | What makes your problem a little bit tricky is that you want to match inside of a multiline string. You need to use the `re.MULTILINE` flag to make that work.
Then, you need to match some groups inside your source string, and use those groups in the final output. Here is code that works to solve your problem:
```
imp... | Something like this should work:
```
import re,sys
f = open( sys.argv[1], 'r' )
for i in f:
g = re.match( r'REPLACE\((.*)\)(.*)', i )
if g is None:
print i
else:
print '<replace name=\"%s\">%s</replace>' % (g.group(1),g.group(2))
f.close()
``` |
1,842,608 | I'm using Python to write a regular expression for replacing parts of the string with a XML node.
The source string looks like:
```
Hello
REPLACE(str1) this is to replace
REPLACE(str2) this is to replace
```
And the result string should be like:
```
Hello
<replace name="str1"> this is to replace </replace>
<repl... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1842608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/150324/"
] | What makes your problem a little bit tricky is that you want to match inside of a multiline string. You need to use the `re.MULTILINE` flag to make that work.
Then, you need to match some groups inside your source string, and use those groups in the final output. Here is code that works to solve your problem:
```
imp... | Here is a solution using pyparsing. I know you specifically asked about a regex solution, but if your requirements change, you might find it easier to expand a pyparsing parser. Or a pyparsing prototype solution might give you a little more insight into the problem leading toward a regex or other final implementation.
... |
1,842,608 | I'm using Python to write a regular expression for replacing parts of the string with a XML node.
The source string looks like:
```
Hello
REPLACE(str1) this is to replace
REPLACE(str2) this is to replace
```
And the result string should be like:
```
Hello
<replace name="str1"> this is to replace </replace>
<repl... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1842608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/150324/"
] | Here is an [excellent tutorial](http://www.amk.ca/python/howto/regex/) on how to write regular expressions in Python. | Something like this should work:
```
import re,sys
f = open( sys.argv[1], 'r' )
for i in f:
g = re.match( r'REPLACE\((.*)\)(.*)', i )
if g is None:
print i
else:
print '<replace name=\"%s\">%s</replace>' % (g.group(1),g.group(2))
f.close()
``` |
1,842,608 | I'm using Python to write a regular expression for replacing parts of the string with a XML node.
The source string looks like:
```
Hello
REPLACE(str1) this is to replace
REPLACE(str2) this is to replace
```
And the result string should be like:
```
Hello
<replace name="str1"> this is to replace </replace>
<repl... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1842608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/150324/"
] | Here is a solution using pyparsing. I know you specifically asked about a regex solution, but if your requirements change, you might find it easier to expand a pyparsing parser. Or a pyparsing prototype solution might give you a little more insight into the problem leading toward a regex or other final implementation.
... | Maybe like this ?
```
import re
mystr = """Hello
REPLACE(str1) this is to replace
REPLACE(str2) this is to replace"""
prog = re.compile(r'REPLACE\((.*?)\)\s(.*)')
for line in mystr.split("\n"):
print prog.sub(r'< replace name="\1" > \2',line)
``` |
1,842,608 | I'm using Python to write a regular expression for replacing parts of the string with a XML node.
The source string looks like:
```
Hello
REPLACE(str1) this is to replace
REPLACE(str2) this is to replace
```
And the result string should be like:
```
Hello
<replace name="str1"> this is to replace </replace>
<repl... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1842608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/150324/"
] | Here is an [excellent tutorial](http://www.amk.ca/python/howto/regex/) on how to write regular expressions in Python. | ```
import re
a="""Hello
REPLACE(str1) this is to replace
REPLACE(str2) this is to replace"""
regex = re.compile(r"^REPLACE\(([^)]+)\)\s+(.*)$", re.MULTILINE)
b=re.sub(regex, r'< replace name="\1" > \2 < /replace >', a)
print b
```
will do the replace in one line. |
1,842,608 | I'm using Python to write a regular expression for replacing parts of the string with a XML node.
The source string looks like:
```
Hello
REPLACE(str1) this is to replace
REPLACE(str2) this is to replace
```
And the result string should be like:
```
Hello
<replace name="str1"> this is to replace </replace>
<repl... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1842608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/150324/"
] | Here is a solution using pyparsing. I know you specifically asked about a regex solution, but if your requirements change, you might find it easier to expand a pyparsing parser. Or a pyparsing prototype solution might give you a little more insight into the problem leading toward a regex or other final implementation.
... | ```
import re
a="""Hello
REPLACE(str1) this is to replace
REPLACE(str2) this is to replace"""
regex = re.compile(r"^REPLACE\(([^)]+)\)\s+(.*)$", re.MULTILINE)
b=re.sub(regex, r'< replace name="\1" > \2 < /replace >', a)
print b
```
will do the replace in one line. |
117,371 | I'm an intern in an industrial company in Brazil and it happens that I'm using excel a lot. I just started playing with VBA couple of days ago, and I'm amused of how many things it can do for me!
I don't have a strong programming background, so I'm learning by doing. The code is working fine and it takes less than 15 ... | 2016/01/20 | [
"https://codereview.stackexchange.com/questions/117371",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/95263/"
] | An idea for you:
Right now, your code is assuming all sorts of things about worksheets in **other** workbooks including, but not limited to:
* The names of the other workbooks' worksheets
* The location of the data within those sheets
If any of those workbooks change you'll have to go through every macro that intera... | >
> My main goal is to keep the code simple and efficient. I'll be leaving the company in the next months and I'd like it to be easy to maintain and use. What I'm asking is a better way to write readable code, with performance as a secondary concern.
>
>
>
In all manner of repeated processes with minimal variation... |
117,371 | I'm an intern in an industrial company in Brazil and it happens that I'm using excel a lot. I just started playing with VBA couple of days ago, and I'm amused of how many things it can do for me!
I don't have a strong programming background, so I'm learning by doing. The code is working fine and it takes less than 15 ... | 2016/01/20 | [
"https://codereview.stackexchange.com/questions/117371",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/95263/"
] | An idea for you:
Right now, your code is assuming all sorts of things about worksheets in **other** workbooks including, but not limited to:
* The names of the other workbooks' worksheets
* The location of the data within those sheets
If any of those workbooks change you'll have to go through every macro that intera... | So, here's the deal with getting data from closed workbooks... *you don't actually have to open them*.
Add a reference to the ADODB library and use it to *query* the workbooks as data sources. A bit of searching "use ADODB to query Excel worksheet" should put you onto a much faster solution. The hard part will be gett... |
23,081,395 | I am facing issue to start my tomcat server in netbeans. I am getting error when I click on start button
```
"Starting of tomact failed, check whether the /Application/NetBeans/apache-tomcat-7.0.52/bin/catalina/sh and related scripts are executable."
```
For more details please check screenshot
![enter image descr... | 2014/04/15 | [
"https://Stackoverflow.com/questions/23081395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1331568/"
] | You should run from the command line / shell if you can though I realize you want to run from Netbeans in this case.
Also make sure that all your `.sh` scripts are executable (do a `chmod`) because otherwise they cannot be called.
Lastly, make sure you have the right permissions to run the scripts.
Once you are beyo... | You can make `catalina.sh` runnable by executing following command in terminal
```
chmod 755 <your tomcat location>/bin/catalina.sh
``` |
21,339,759 | I have an situation where I need to save a hibernate object, but I am not sure whether an ID would be assigned by calling app (using special logic with in a range - unique) or not.
If the ID is not assigned, I need hibernate to generate an ID higher than the possible ID range which the app would input (i know the ran... | 2014/01/24 | [
"https://Stackoverflow.com/questions/21339759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3233126/"
] | Actually you will still need to do some stuff with your Models in your controller. Use Repository Pattern do to so, which is pretty similar of querying your models in your controller, but being less verbose:
```
public function serve($company)
{
return View::make('layouts.singlereview')->withReview(with(new Review... | Also, while you are on the subject of creating good code, you might as well check out Eloquent relationships. They may require database restructuring for certain occurrences, but most of the time you should be good.
With the code you have provided, I can assume that review and company are in a one-to-one relationship... |
84,249 | When Finn and Rose Tico were in the jail cell where they met the thief, why was the thief even there, if he could just easily escape with basically no effort? | 2017/12/27 | [
"https://movies.stackexchange.com/questions/84249",
"https://movies.stackexchange.com",
"https://movies.stackexchange.com/users/60426/"
] | From my interpretation, DJ seemed to be bored before he encountered Finn and crew. He had a very relaxed demeanor, indicating that he wasn't stressed out about where he was at all because, as we find out, he could leave at any time.
I think he was probably captured after breaking in somewhere, possibly stealing someth... | DJ has a strange gait, way of talking, and general attitude, so what happens later throws this into question a bit, but I got the very distinct impression that he was thrown in there as a drunk and was sleeping off the alcohol. Finn and Rose being noisy woke him up, so he decided it was time to go. |
84,249 | When Finn and Rose Tico were in the jail cell where they met the thief, why was the thief even there, if he could just easily escape with basically no effort? | 2017/12/27 | [
"https://movies.stackexchange.com/questions/84249",
"https://movies.stackexchange.com",
"https://movies.stackexchange.com/users/60426/"
] | From my interpretation, DJ seemed to be bored before he encountered Finn and crew. He had a very relaxed demeanor, indicating that he wasn't stressed out about where he was at all because, as we find out, he could leave at any time.
I think he was probably captured after breaking in somewhere, possibly stealing someth... | Well DJ is not actually the character's real name, but is an abreviation for the philosophy of what DJ believes in: **Don't Join**.
>
> The Star Wars The Last Jedi The Visual Dictionary reveals "DJ" aren't
> his initials but actually stands for "Don't Join." Indeed, his cap
> bears a tin plate with the motto "don't... |
84,249 | When Finn and Rose Tico were in the jail cell where they met the thief, why was the thief even there, if he could just easily escape with basically no effort? | 2017/12/27 | [
"https://movies.stackexchange.com/questions/84249",
"https://movies.stackexchange.com",
"https://movies.stackexchange.com/users/60426/"
] | He got himself arrested so the police would stop bothering him.
===============================================================
Taken from p. 65 of *The Last Jedi Visual Dictionary*:
>
> Already known to local authorities, **DJ purposely arranges his own arrest** for a petty crime. The jail is the only place he can ... | From my interpretation, DJ seemed to be bored before he encountered Finn and crew. He had a very relaxed demeanor, indicating that he wasn't stressed out about where he was at all because, as we find out, he could leave at any time.
I think he was probably captured after breaking in somewhere, possibly stealing someth... |
84,249 | When Finn and Rose Tico were in the jail cell where they met the thief, why was the thief even there, if he could just easily escape with basically no effort? | 2017/12/27 | [
"https://movies.stackexchange.com/questions/84249",
"https://movies.stackexchange.com",
"https://movies.stackexchange.com/users/60426/"
] | Well DJ is not actually the character's real name, but is an abreviation for the philosophy of what DJ believes in: **Don't Join**.
>
> The Star Wars The Last Jedi The Visual Dictionary reveals "DJ" aren't
> his initials but actually stands for "Don't Join." Indeed, his cap
> bears a tin plate with the motto "don't... | DJ has a strange gait, way of talking, and general attitude, so what happens later throws this into question a bit, but I got the very distinct impression that he was thrown in there as a drunk and was sleeping off the alcohol. Finn and Rose being noisy woke him up, so he decided it was time to go. |
84,249 | When Finn and Rose Tico were in the jail cell where they met the thief, why was the thief even there, if he could just easily escape with basically no effort? | 2017/12/27 | [
"https://movies.stackexchange.com/questions/84249",
"https://movies.stackexchange.com",
"https://movies.stackexchange.com/users/60426/"
] | He got himself arrested so the police would stop bothering him.
===============================================================
Taken from p. 65 of *The Last Jedi Visual Dictionary*:
>
> Already known to local authorities, **DJ purposely arranges his own arrest** for a petty crime. The jail is the only place he can ... | DJ has a strange gait, way of talking, and general attitude, so what happens later throws this into question a bit, but I got the very distinct impression that he was thrown in there as a drunk and was sleeping off the alcohol. Finn and Rose being noisy woke him up, so he decided it was time to go. |
84,249 | When Finn and Rose Tico were in the jail cell where they met the thief, why was the thief even there, if he could just easily escape with basically no effort? | 2017/12/27 | [
"https://movies.stackexchange.com/questions/84249",
"https://movies.stackexchange.com",
"https://movies.stackexchange.com/users/60426/"
] | He got himself arrested so the police would stop bothering him.
===============================================================
Taken from p. 65 of *The Last Jedi Visual Dictionary*:
>
> Already known to local authorities, **DJ purposely arranges his own arrest** for a petty crime. The jail is the only place he can ... | Well DJ is not actually the character's real name, but is an abreviation for the philosophy of what DJ believes in: **Don't Join**.
>
> The Star Wars The Last Jedi The Visual Dictionary reveals "DJ" aren't
> his initials but actually stands for "Don't Join." Indeed, his cap
> bears a tin plate with the motto "don't... |
26,236,662 | How can I create a script that checks if a process is running, and when it is not running executes a line of codes? And let the script check every minute?
I was thinking of something like this:
```
#! /bin/bash
case "$(pidof Program.exe | wc -w)" in
0) echo "Restarting Program: $(date)" >> /var/log/ProgramLog.txt
(... | 2014/10/07 | [
"https://Stackoverflow.com/questions/26236662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3572440/"
] | The monit (small software) will do all this job for you:
Please look here:
```
https://mmonit.com/monit/documentation/
``` | IIUC you're trying to make sure there's always one instance of your program running on the machine. Have you considered adding this program to `/etc/inittab`? With this file you can configure your init system to run the program for you and restart whenever it exits (crashes).
Some more information: <http://unixhelp.ed.... |
12,664 | I am using a Microsoft template for adding Training and Courses for people to register for. Everything is working fine, but I want to add a field to the Courses list. I want to add a field to indicate what type of staff this course is for, eg HR, Health & Safety, Admin, etc.
So I have searched all over for answers to ... | 2011/05/13 | [
"https://sharepoint.stackexchange.com/questions/12664",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/3393/"
] | Looks like ff12 is already defined somewhere else in the page and it's probably re-writing with \_1 at the end.
1. Can you just try drag and drop the field from the Data Source and let the designer figure out the field names?
OR
1. Can you try adding the "Custom Edit Form" in another page and then copy the FieldDes... | I may have not read or got good grasp of your needs. Why not implement Content Type? You could have feature for your custom fields (aka columns) and set attribute like diplay on edit form=true, show on view = true (etc.) |
12,664 | I am using a Microsoft template for adding Training and Courses for people to register for. Everything is working fine, but I want to add a field to the Courses list. I want to add a field to indicate what type of staff this course is for, eg HR, Health & Safety, Admin, etc.
So I have searched all over for answers to ... | 2011/05/13 | [
"https://sharepoint.stackexchange.com/questions/12664",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/3393/"
] | Many of the ["Fabulous 40" templates](http://technet.microsoft.com/en-us/windowsserver/sharepoint/bb407286.aspx) have customized forms. (You'll probably debate the fabulous part of the name at this point.)
It looks like you are doing roughly the right things in the forms, but it's a little hard to tell where it's goin... | Looks like ff12 is already defined somewhere else in the page and it's probably re-writing with \_1 at the end.
1. Can you just try drag and drop the field from the Data Source and let the designer figure out the field names?
OR
1. Can you try adding the "Custom Edit Form" in another page and then copy the FieldDes... |
12,664 | I am using a Microsoft template for adding Training and Courses for people to register for. Everything is working fine, but I want to add a field to the Courses list. I want to add a field to indicate what type of staff this course is for, eg HR, Health & Safety, Admin, etc.
So I have searched all over for answers to ... | 2011/05/13 | [
"https://sharepoint.stackexchange.com/questions/12664",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/3393/"
] | Many of the ["Fabulous 40" templates](http://technet.microsoft.com/en-us/windowsserver/sharepoint/bb407286.aspx) have customized forms. (You'll probably debate the fabulous part of the name at this point.)
It looks like you are doing roughly the right things in the forms, but it's a little hard to tell where it's goin... | I may have not read or got good grasp of your needs. Why not implement Content Type? You could have feature for your custom fields (aka columns) and set attribute like diplay on edit form=true, show on view = true (etc.) |
787,992 | Let $G$ be a reductive group and $B$ a Borel subgroup. The Bruhat decomposition allows us to write (where $W$ is the Weyl group):
$$ G/B = \coprod\_{w\in W} BwB$$
Why is this form the same as looking at the $G$-orbit decomposition ($G$ acting diagonally):
$$ (G/B)^2 = \coprod\_{w\in W} G\cdot (eB,wB)$$
I believe this... | 2014/05/09 | [
"https://math.stackexchange.com/questions/787992",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/130769/"
] | So, suppose
$$G/B = \coprod\_{w \in W} B w B.$$
Then, pick $(gB, hB) \in (G/B)^{2}.$ We can find $w$ such that $g^{-1}h \in BwB$. Say $g^{-1}hB = bwB$. Then, $b^{-1}g^{-1}h \in wB$ and hence,
$$(gB, hB) = gb(eB, b^{-1}g^{-1}hB) = gb(eB, wB).$$
Hence, $(G/B)^{2} \subseteq \coprod\_{w \in W} G\cdot (eB, wB)$, and the... | This is just an instance of the following general fact. Suppose a group $G$ acts *transitively* on two sets $X,Y$. Choose any $x\_0\in X$ and $y\_0\in Y$, and put $\def\Stab{\operatorname{Stab}\_G}H\_x=\Stab(x\_0)$ and $H\_y=\Stab(y\_0)$. Then there is a bijection between on one hand the orbits of $G$ acting componentw... |
60,231,231 | I'm trying to make a regex to identify a comment. It has to start with // and end with a new line or a \*) pattern. | 2020/02/14 | [
"https://Stackoverflow.com/questions/60231231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12899942/"
] | Set `closeOnSelect` to `false`
```
<ng-select [items]="items"
bindLabel="name"
bindValue="id"
[multiple]="true"
[closeOnSelect]="false"
placeholder="Select categories"
[(ngModel)]="selectedCategories">
</ng-select>
``` | Try using the `isOpen` property:
```
<ng-select [items]="items"
[isOpen]="true" // <--- This one
bindLabel="name"
bindValue="id"
[multiple]="true"
placeholder="Select categories"
[(ngModel)]="selectedCategories">
</ng-select>
``` |
14,888,843 | I have my two log files in my django root dir called `apache.error.log` and `django.log`. In my `app/static` folder I have the HTML file `mylog.html`. Now I want to view those log files inside that HTML page.
Is this possible? I want to view the last 20 lines of both files. basically something like `tail -f`, but insi... | 2013/02/15 | [
"https://Stackoverflow.com/questions/14888843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2024264/"
] | If you're using Class Based Views:
```
class LogTemplateView(TemplateView):
template_name = "mylog.html"
apache_log_file = "apache.error.log"
django_log_file = "django.log"
def get_context_data(self, **kwargs):
"""
This has been overriden to give the template access to the log files.
... | Create a new view in Django
in the controller, `import os`
use `lastLines = os.popen("tail /path/to/logFile").read()`
show these `listLines` in the view |
62,116,031 | I have a `SerialPort` object. I have put an event handler on this to monitor disposal, exceptions and received data events:
```
mySp.DataReceived += sp_DataReceived;
mySp.ErrorReceived += sp_ErrorReceived;
mySp.Disposed += sp_Disposed;
```
After a few minutes I stop receiving data, but I have good reason to believe ... | 2020/05/31 | [
"https://Stackoverflow.com/questions/62116031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12683473/"
] | With the GC we can never say if it is or when it is collected - only if it **CAN** be collected. The rule is "the GC can collect everything that does not have a chain of strong references to a application root." If you got that, the GC will not touch it. If you do not have it the GC may touch it - eventually.
Running ... | To answer the question "how do I know if my objects are collected":
1. Inspect the code. Ensure that you keep a reference to the object in question.
2. You can wrap the object and add a [finalizer](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/destructors) to the wrapper. If you... |
40,889,351 | Can you please advise how i can implement this sql query:
```
select * from products where (category, category2, category3) in (2, 138, 136, 125)
```
Error:
```
#1241 - Operand should contain 3 column(s)
``` | 2016/11/30 | [
"https://Stackoverflow.com/questions/40889351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7230953/"
] | 1) input variable : continuous / output variable : categorical
C4.5 algorithm solve this situation.
[C4.5](https://en.wikipedia.org/wiki/C4.5_algorithm)
In order to handle continuous attributes, C4.5 creates a threshold and then splits the list into those whose attribute value is above the threshold and those that ... | I can explain the concept at a very high level.
The main goal of the algorithm is to find an attribute that we will use for the first split. We can use various impurity metrics to evaluate the most significant attribute. Those impurity metrics can be Information Gain, Entropy, Gain Ratio, etc. But, if the decision var... |
49,819,295 | In Xamarin.Android, to load an image using FFImageLoading, a ImageViewAsync must be used instead of a standard ImageView.
I couldn't find what I can use if I wanna load my image into an ImageButton. Didn't find an "ImageButtonAsync". | 2018/04/13 | [
"https://Stackoverflow.com/questions/49819295",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Dont know if this is relevant or not. I gave my svg a tap gesture to get it working like a button.
first reference the FFImageLoading.Svg.Forms in your xaml
```
namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"
```
second add the svgImage with a tap gesture
```
<ffimageloadingsvg:SvgCachedI... | AFAIK there is no particular `ImageButton` to use with FFImageLoading but you can use directly an `ImageViewAsync` set it as `android:clickable="true"` and add the click event.
And as stated [here](https://stackoverflow.com/questions/5847136/difference-between-a-clickable-imageview-and-imagebutton?utm_medium=organic&u... |
3,347,504 | I have the following **HashMap**:
```
HashMap<String,Object> fileObj = new HashMap<String,Object>();
ArrayList<String> cols = new ArrayList<String>();
cols.add("a");
cols.add("b");
cols.add("c");
fileObj.put("mylist",cols);
```
I write it to a file as follows:
```
File file = new File("temp");
FileOut... | 2010/07/27 | [
"https://Stackoverflow.com/questions/3347504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/403828/"
] | I believe you´re making a common mistake. You forgot to close the stream after using it!
```
File file = new File("temp");
FileOutputStream f = new FileOutputStream(file);
ObjectOutputStream s = new ObjectOutputStream(f);
s.writeObject(fileObj);
s.close();
``` | Your first line:
```
HashMap<String,Object> fileObj = new HashMap<String,Object>();
```
gave me pause, as the values are not guaranteed to be `Serializable` and thus may not be written out correctly. You should really define the object as a `HashMap<String, Serializable>` (or if you prefer, simpy `Map<String, Serial... |
3,347,504 | I have the following **HashMap**:
```
HashMap<String,Object> fileObj = new HashMap<String,Object>();
ArrayList<String> cols = new ArrayList<String>();
cols.add("a");
cols.add("b");
cols.add("c");
fileObj.put("mylist",cols);
```
I write it to a file as follows:
```
File file = new File("temp");
FileOut... | 2010/07/27 | [
"https://Stackoverflow.com/questions/3347504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/403828/"
] | I believe you´re making a common mistake. You forgot to close the stream after using it!
```
File file = new File("temp");
FileOutputStream f = new FileOutputStream(file);
ObjectOutputStream s = new ObjectOutputStream(f);
s.writeObject(fileObj);
s.close();
``` | I believe you're getting what you're saving. Have you inspected the map before you save it? In `HashMap`:
```
/**
* The default initial capacity - MUST be a power of two.
*/
static final int DEFAULT_INITIAL_CAPACITY = 16;
```
e.g. the default `HashMap` will start off with 16 `null`s. You use one of the buckets, so... |
3,347,504 | I have the following **HashMap**:
```
HashMap<String,Object> fileObj = new HashMap<String,Object>();
ArrayList<String> cols = new ArrayList<String>();
cols.add("a");
cols.add("b");
cols.add("c");
fileObj.put("mylist",cols);
```
I write it to a file as follows:
```
File file = new File("temp");
FileOut... | 2010/07/27 | [
"https://Stackoverflow.com/questions/3347504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/403828/"
] | You appear to be confusing the internal resprentation of a HashMap with how the HashMap behaves. The collections are the same. Here is a simple test to prove it to you.
```
public static void main(String... args)
throws IOException, ClassNotFoundException {
HashMap<String, Object> fileO... | I believe you´re making a common mistake. You forgot to close the stream after using it!
```
File file = new File("temp");
FileOutputStream f = new FileOutputStream(file);
ObjectOutputStream s = new ObjectOutputStream(f);
s.writeObject(fileObj);
s.close();
``` |
3,347,504 | I have the following **HashMap**:
```
HashMap<String,Object> fileObj = new HashMap<String,Object>();
ArrayList<String> cols = new ArrayList<String>();
cols.add("a");
cols.add("b");
cols.add("c");
fileObj.put("mylist",cols);
```
I write it to a file as follows:
```
File file = new File("temp");
FileOut... | 2010/07/27 | [
"https://Stackoverflow.com/questions/3347504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/403828/"
] | You appear to be confusing the internal resprentation of a HashMap with how the HashMap behaves. The collections are the same. Here is a simple test to prove it to you.
```
public static void main(String... args)
throws IOException, ClassNotFoundException {
HashMap<String, Object> fileO... | Your first line:
```
HashMap<String,Object> fileObj = new HashMap<String,Object>();
```
gave me pause, as the values are not guaranteed to be `Serializable` and thus may not be written out correctly. You should really define the object as a `HashMap<String, Serializable>` (or if you prefer, simpy `Map<String, Serial... |
3,347,504 | I have the following **HashMap**:
```
HashMap<String,Object> fileObj = new HashMap<String,Object>();
ArrayList<String> cols = new ArrayList<String>();
cols.add("a");
cols.add("b");
cols.add("c");
fileObj.put("mylist",cols);
```
I write it to a file as follows:
```
File file = new File("temp");
FileOut... | 2010/07/27 | [
"https://Stackoverflow.com/questions/3347504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/403828/"
] | you can also use JSON file to read and write MAP object.
>
> To write map object into JSON file
>
>
>
```
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", "Suson");
map.put("age", 26);
// write JSON to a file
mapper.writeV... | Your first line:
```
HashMap<String,Object> fileObj = new HashMap<String,Object>();
```
gave me pause, as the values are not guaranteed to be `Serializable` and thus may not be written out correctly. You should really define the object as a `HashMap<String, Serializable>` (or if you prefer, simpy `Map<String, Serial... |
3,347,504 | I have the following **HashMap**:
```
HashMap<String,Object> fileObj = new HashMap<String,Object>();
ArrayList<String> cols = new ArrayList<String>();
cols.add("a");
cols.add("b");
cols.add("c");
fileObj.put("mylist",cols);
```
I write it to a file as follows:
```
File file = new File("temp");
FileOut... | 2010/07/27 | [
"https://Stackoverflow.com/questions/3347504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/403828/"
] | You appear to be confusing the internal resprentation of a HashMap with how the HashMap behaves. The collections are the same. Here is a simple test to prove it to you.
```
public static void main(String... args)
throws IOException, ClassNotFoundException {
HashMap<String, Object> fileO... | I believe you're getting what you're saving. Have you inspected the map before you save it? In `HashMap`:
```
/**
* The default initial capacity - MUST be a power of two.
*/
static final int DEFAULT_INITIAL_CAPACITY = 16;
```
e.g. the default `HashMap` will start off with 16 `null`s. You use one of the buckets, so... |
3,347,504 | I have the following **HashMap**:
```
HashMap<String,Object> fileObj = new HashMap<String,Object>();
ArrayList<String> cols = new ArrayList<String>();
cols.add("a");
cols.add("b");
cols.add("c");
fileObj.put("mylist",cols);
```
I write it to a file as follows:
```
File file = new File("temp");
FileOut... | 2010/07/27 | [
"https://Stackoverflow.com/questions/3347504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/403828/"
] | you can also use JSON file to read and write MAP object.
>
> To write map object into JSON file
>
>
>
```
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", "Suson");
map.put("age", 26);
// write JSON to a file
mapper.writeV... | I believe you're getting what you're saving. Have you inspected the map before you save it? In `HashMap`:
```
/**
* The default initial capacity - MUST be a power of two.
*/
static final int DEFAULT_INITIAL_CAPACITY = 16;
```
e.g. the default `HashMap` will start off with 16 `null`s. You use one of the buckets, so... |
3,347,504 | I have the following **HashMap**:
```
HashMap<String,Object> fileObj = new HashMap<String,Object>();
ArrayList<String> cols = new ArrayList<String>();
cols.add("a");
cols.add("b");
cols.add("c");
fileObj.put("mylist",cols);
```
I write it to a file as follows:
```
File file = new File("temp");
FileOut... | 2010/07/27 | [
"https://Stackoverflow.com/questions/3347504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/403828/"
] | You appear to be confusing the internal resprentation of a HashMap with how the HashMap behaves. The collections are the same. Here is a simple test to prove it to you.
```
public static void main(String... args)
throws IOException, ClassNotFoundException {
HashMap<String, Object> fileO... | you can also use JSON file to read and write MAP object.
>
> To write map object into JSON file
>
>
>
```
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", "Suson");
map.put("age", 26);
// write JSON to a file
mapper.writeV... |
14,996,632 | There are some `C#` console applications that started by **Windows scheduler**.
How can I gather work progress from any of them (using internal data available only in concrete console application)?
In other words, I want to show some data from running console application on my asp.net webforms website.
How ca... | 2013/02/21 | [
"https://Stackoverflow.com/questions/14996632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2083527/"
] | Host a http server inside the console app that the website can communicate with. I already kind of do this using self host signal r inside a tray application and it works a treat.
<https://github.com/SignalR/SignalR/wiki/Self-host> | I would preferred old good [.NET Remouting](http://msdn.microsoft.com/en-us/library/kwdt6w2k%28v=vs.100%29.aspx) for this (check out [simple example for it](http://www.codeproject.com/Articles/10045/NET-Remoting-Sample)). But you can use WCF with NetNamedPipesBinding or NetTcpBinding binding. |
25,409,822 | In my package, before I perform a query on my database I check if some of the params provided are valid:
```
//check
if(!$this->checkId($id)) //error
//do the query
$user = User::find($id);
```
What's the best way to handle this in a laravel package?
Throw an error? If so, which kind? Do an app abort? | 2014/08/20 | [
"https://Stackoverflow.com/questions/25409822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1013512/"
] | Using findOrFail()
------------------
There is a pretty good method that Laravel provides just for this case called `findOrFail()`.
What you can do is use that and then catch the exception.
```
try {
$user = User::findOrFail($queryParam);
} catch(ModelNotFoundException $e) {
// Do things that should happen h... | I would use Event Listeners for the most control.
Create an `events.php` in your `app` directory and include it in `app/start/global.php`
Or, you can register anywhere in your package.
Create a listener:
```
Event::listen('paramCheck.noId', function($id)
{
// do some logic, log something, return something, thro... |
34,726,185 | Imagine I'm building a blog system where a user can upload images for a blog post. I have a problem mapping the uploaded images with user and their blog post.
Here's the flow :
1. User uploaded some pictures, it's saved to the server.
2. I store the image name in the related table, means later I can
retrieve images b... | 2016/01/11 | [
"https://Stackoverflow.com/questions/34726185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5485528/"
] | You can do the fading with just css transitions all you need to do is use jquery toggleClass function when the window reaches 150px.
Try the following:
```
$(window).on( "scroll", function() {
$('#secondNav').toggleClass('scrolled', $(this).scrollTop() > 150);
});
```
and the css
```
#secondNav.navbar-default... | Are you using jQuery? if so, maybe something like this?
```
$('#div').click(() => {
$('#div').fadeOut();
$('#div')
.css('background-color', 'green')
.fadeIn();
});
```
<https://jsfiddle.net/53n2o76g/> |
34,726,185 | Imagine I'm building a blog system where a user can upload images for a blog post. I have a problem mapping the uploaded images with user and their blog post.
Here's the flow :
1. User uploaded some pictures, it's saved to the server.
2. I store the image name in the related table, means later I can
retrieve images b... | 2016/01/11 | [
"https://Stackoverflow.com/questions/34726185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5485528/"
] | I have a difficult solution. You can create two `navbar`. second `nav` should be hidden. when you `scroll` more than `150px`, then it should be `fade in` with fixed position. Below my jQuery code is
```
$(window).scroll(function(){
var scrolled = $(window).scrollTop();
if(scrolled>149){
$('#second_nav'... | Are you using jQuery? if so, maybe something like this?
```
$('#div').click(() => {
$('#div').fadeOut();
$('#div')
.css('background-color', 'green')
.fadeIn();
});
```
<https://jsfiddle.net/53n2o76g/> |
34,726,185 | Imagine I'm building a blog system where a user can upload images for a blog post. I have a problem mapping the uploaded images with user and their blog post.
Here's the flow :
1. User uploaded some pictures, it's saved to the server.
2. I store the image name in the related table, means later I can
retrieve images b... | 2016/01/11 | [
"https://Stackoverflow.com/questions/34726185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5485528/"
] | You can do the fading with just css transitions all you need to do is use jquery toggleClass function when the window reaches 150px.
Try the following:
```
$(window).on( "scroll", function() {
$('#secondNav').toggleClass('scrolled', $(this).scrollTop() > 150);
});
```
and the css
```
#secondNav.navbar-default... | I have a difficult solution. You can create two `navbar`. second `nav` should be hidden. when you `scroll` more than `150px`, then it should be `fade in` with fixed position. Below my jQuery code is
```
$(window).scroll(function(){
var scrolled = $(window).scrollTop();
if(scrolled>149){
$('#second_nav'... |
90,189 | I tried to sync the blockchain and, though I have ample free disk space (>500 GB on my computer, the chain is ~265) I've been having a hard time. So, how can I use an SPV node to send transactions and/or view the blockchain?
NOTE: don't do this if you don't have to because the blockchain needs nodes to ensure adequate... | 2019/09/03 | [
"https://bitcoin.stackexchange.com/questions/90189",
"https://bitcoin.stackexchange.com",
"https://bitcoin.stackexchange.com/users/96148/"
] | Try Electrum. Exact details on how to install depend on Linux distribution used.
Also Wasabi Wallet could be good choice, easy to setup. | Since your constraint is the blockchain size, it seems you would be fine with running bitcoind with `--prune` enabled to something like 2gb or similar. This is technically not an SPV solution, but you would have access to the bitcoin-qt gui ( if that's the version of bitcoind you have installed ) and you'd be able to r... |
324,562 | ```
telnet www.ietf.org 80
GET /rfc.html HTTP/1.1
Host: www.ietf.org
```
This sequence of commands starts up a telnet (i.e., TCP) connection to port 80 on
IETF’s Web server, www.ietf.org. Then comes the GET command naming the
path of the URL and the protocol. Try servers and URLs of your choosing. The
next line is th... | 2016/11/19 | [
"https://unix.stackexchange.com/questions/324562",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/674/"
] | To reconfigure the keyboard in Debian, run (as `root`, or using `sudo`):
```
dpkg-reconfigure keyboard-configuration
```
Link to official Debian documentation [here](https://wiki.debian.org/Keyboard).
If your keys are "random" (I have been there, not fun!), try to find the characters needed to execute the command a... | If you have access to another computer you can `ssh` to your Pi and reset the keyboard that way.
I cannot give you a recommended keyboard layout for a direct console connection because that varies from keyboard to keyboard and I don't have a Mac keyboard to test against. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.