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 |
|---|---|---|---|---|---|
15,009,022 | I was reading this <http://msdn.microsoft.com/en-us/library/87d83y5b(v=vs.80).aspx> but I am wondering, what is the difference between or benefit of using interfaces as opposed to simply creating a class with properties and adding it to your class via "`using MyClass.cs`?" It seems like either way you have to instantia... | 2013/02/21 | [
"https://Stackoverflow.com/questions/15009022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1477388/"
] | An interface is *not* so you can use the interface's objects. It's, rather, so that you *must* **create** those objects. | I don't see how the two are even similar. An interface defines how your code is used by clients. The using keyword (which should be followed by a namespace name rather than a file name) simply lets you use objects in that namespace without prefixing them with the entire namespace each time.
A more common question is w... |
15,009,022 | I was reading this <http://msdn.microsoft.com/en-us/library/87d83y5b(v=vs.80).aspx> but I am wondering, what is the difference between or benefit of using interfaces as opposed to simply creating a class with properties and adding it to your class via "`using MyClass.cs`?" It seems like either way you have to instantia... | 2013/02/21 | [
"https://Stackoverflow.com/questions/15009022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1477388/"
] | An interface is *not* so you can use the interface's objects. It's, rather, so that you *must* **create** those objects. | Interface only contains the signature of your logic. It must be implemented fully in your child class. We use "using" clause when we want to include namespace which is different then the namespace of your project, but if your class or interface is in the same namespace you don't need to use "using" clause.
You can in... |
6,924,048 | I use Richfaces in my Project and I really like the Kickass Code Completion in IntelliJ. But somehow I am not able to autocomplete the Richfaces Stuff. Here is my relevant part of my XHTML file:
```
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://ja... | 2011/08/03 | [
"https://Stackoverflow.com/questions/6924048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/441467/"
] | Here is the tutorial links:
<http://blog.maxaller.name/2010/05/attaching-a-sticky-headerfooter-to-an-android-listview/>
<http://www.vogella.de/articles/AndroidListView/article.html>
<http://www.vogella.de/articles/AndroidListView/article.html#headerfooter> | You may need to add in your xml two `TextViews`. One before your `ListView`, the other one, right under the `ListView`. |
6,924,048 | I use Richfaces in my Project and I really like the Kickass Code Completion in IntelliJ. But somehow I am not able to autocomplete the Richfaces Stuff. Here is my relevant part of my XHTML file:
```
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://ja... | 2011/08/03 | [
"https://Stackoverflow.com/questions/6924048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/441467/"
] | Here is the tutorial links:
<http://blog.maxaller.name/2010/05/attaching-a-sticky-headerfooter-to-an-android-listview/>
<http://www.vogella.de/articles/AndroidListView/article.html>
<http://www.vogella.de/articles/AndroidListView/article.html#headerfooter> | here comes a snippet for the ListView with header+footer;
```
<LinearLayout android:id="@+id/lay_listitems"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/white"
... |
6,924,048 | I use Richfaces in my Project and I really like the Kickass Code Completion in IntelliJ. But somehow I am not able to autocomplete the Richfaces Stuff. Here is my relevant part of my XHTML file:
```
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://ja... | 2011/08/03 | [
"https://Stackoverflow.com/questions/6924048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/441467/"
] | Here is the tutorial links:
<http://blog.maxaller.name/2010/05/attaching-a-sticky-headerfooter-to-an-android-listview/>
<http://www.vogella.de/articles/AndroidListView/article.html>
<http://www.vogella.de/articles/AndroidListView/article.html#headerfooter> | This may be late but hope this may help someone. :-)
```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:text=... |
6,924,048 | I use Richfaces in my Project and I really like the Kickass Code Completion in IntelliJ. But somehow I am not able to autocomplete the Richfaces Stuff. Here is my relevant part of my XHTML file:
```
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://ja... | 2011/08/03 | [
"https://Stackoverflow.com/questions/6924048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/441467/"
] | You may need to add in your xml two `TextViews`. One before your `ListView`, the other one, right under the `ListView`. | This may be late but hope this may help someone. :-)
```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:text=... |
6,924,048 | I use Richfaces in my Project and I really like the Kickass Code Completion in IntelliJ. But somehow I am not able to autocomplete the Richfaces Stuff. Here is my relevant part of my XHTML file:
```
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://ja... | 2011/08/03 | [
"https://Stackoverflow.com/questions/6924048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/441467/"
] | here comes a snippet for the ListView with header+footer;
```
<LinearLayout android:id="@+id/lay_listitems"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/white"
... | This may be late but hope this may help someone. :-)
```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:text=... |
40,742,033 | I have this table:
```
Profile_id Phase_id order
30087853 30021628 525
30087853 30021635 523
30087853 30021673 122
30087853 30021703 521
```
from the above I would like to get profile\_id along with this phase\_id, which has lowest order\_num, so the outcome will be like:
```
Profile_id ... | 2016/11/22 | [
"https://Stackoverflow.com/questions/40742033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7194407/"
] | You didn't specify your DBMS so this is standard SQL:
```
select profile_id, phase_id, "order"
from (
select profile_id, phase_id, "order",
row_number() over (partition by profile_id order by "order") as rn
from the_table
) t
where rn = 1;
```
Online example: <http://rextester.com/MAUV44954> | CREATE TABLE #table(Profile\_id INT, Phase\_id INT, \_order INT)
INSERT INTO #table(Profile\_id , Phase\_id , \_order )
SELECT 30087853,30021628,525 UNION ALL
SELECT 30087853,30021635,523 UNION ALL
SELECT 30087853,30021673,122 UNION ALL
SELECT 30087853,30021703,521
SELECT \*
FROM #table T1
JOIN
(
SELECT Profile\_id ... |
40,742,033 | I have this table:
```
Profile_id Phase_id order
30087853 30021628 525
30087853 30021635 523
30087853 30021673 122
30087853 30021703 521
```
from the above I would like to get profile\_id along with this phase\_id, which has lowest order\_num, so the outcome will be like:
```
Profile_id ... | 2016/11/22 | [
"https://Stackoverflow.com/questions/40742033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7194407/"
] | Without a sub-query or self-join you can use also this one:
```
SELECT Profile_id, MIN("order") as "order",
MIN(Phase_id) KEEP (DENSE_RANK FIRST ORDER BY "order") AS Phase_id
FROM your_table
GROUP BY Profile_id;
``` | CREATE TABLE #table(Profile\_id INT, Phase\_id INT, \_order INT)
INSERT INTO #table(Profile\_id , Phase\_id , \_order )
SELECT 30087853,30021628,525 UNION ALL
SELECT 30087853,30021635,523 UNION ALL
SELECT 30087853,30021673,122 UNION ALL
SELECT 30087853,30021703,521
SELECT \*
FROM #table T1
JOIN
(
SELECT Profile\_id ... |
40,742,033 | I have this table:
```
Profile_id Phase_id order
30087853 30021628 525
30087853 30021635 523
30087853 30021673 122
30087853 30021703 521
```
from the above I would like to get profile\_id along with this phase\_id, which has lowest order\_num, so the outcome will be like:
```
Profile_id ... | 2016/11/22 | [
"https://Stackoverflow.com/questions/40742033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7194407/"
] | You didn't specify your DBMS so this is standard SQL:
```
select profile_id, phase_id, "order"
from (
select profile_id, phase_id, "order",
row_number() over (partition by profile_id order by "order") as rn
from the_table
) t
where rn = 1;
```
Online example: <http://rextester.com/MAUV44954> | Without a sub-query or self-join you can use also this one:
```
SELECT Profile_id, MIN("order") as "order",
MIN(Phase_id) KEEP (DENSE_RANK FIRST ORDER BY "order") AS Phase_id
FROM your_table
GROUP BY Profile_id;
``` |
63,581,399 | I have a string column (`cmpstn_val`) which has values with decimal points embedded - like this:
```
cust_nm | cmpstn_val
--------+------------------------
John | 123.384501928340000
Mark | 443.827345985
Peter | 145.320004
Mike | 678.293845012000000010
```
Firstly, I have to consider only the part that ap... | 2020/08/25 | [
"https://Stackoverflow.com/questions/63581399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14029222/"
] | One method is:
```
select len(stuff(cmpstn_val, 1, charindex('.', cmpstn_val), '')) as num_digits_after_dot
```
If you want the longest one:
```
select top (1) t.*
from t
order by len(stuff(cmpstn_val, 1, charindex('.', cmpstn_val), '')) desc;
```
[Here](https://dbfiddle.uk/?rdbms=sqlserver_2019&fiddle=52c6fa990d... | Using `parsename` with `len`. This one works if the string after the decimal is at most 128 characters.
```
select top (1) *
from t
order by len(parsename(cmpstn_val,1)) desc;
```
This one is probably more reliable since the string before decimal looks more likely to be shorter
```
select top (1) *
from t
order by ... |
63,581,399 | I have a string column (`cmpstn_val`) which has values with decimal points embedded - like this:
```
cust_nm | cmpstn_val
--------+------------------------
John | 123.384501928340000
Mark | 443.827345985
Peter | 145.320004
Mike | 678.293845012000000010
```
Firstly, I have to consider only the part that ap... | 2020/08/25 | [
"https://Stackoverflow.com/questions/63581399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14029222/"
] | One method is:
```
select len(stuff(cmpstn_val, 1, charindex('.', cmpstn_val), '')) as num_digits_after_dot
```
If you want the longest one:
```
select top (1) t.*
from t
order by len(stuff(cmpstn_val, 1, charindex('.', cmpstn_val), '')) desc;
```
[Here](https://dbfiddle.uk/?rdbms=sqlserver_2019&fiddle=52c6fa990d... | Slightly different way to use `parsename`, return that portion also, filter out any values that don't contain a decimal, and optionally deal with ties.
```
;WITH x AS
(
SELECT *, digits = PARSENAME(cmpstn_val,1)
FROM dbo.tablename
WHERE cmpstn_val LIKE '%.%'
)
SELECT TOP (1) WITH TIES
* FROM x
ORDER BY L... |
63,581,399 | I have a string column (`cmpstn_val`) which has values with decimal points embedded - like this:
```
cust_nm | cmpstn_val
--------+------------------------
John | 123.384501928340000
Mark | 443.827345985
Peter | 145.320004
Mike | 678.293845012000000010
```
Firstly, I have to consider only the part that ap... | 2020/08/25 | [
"https://Stackoverflow.com/questions/63581399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14029222/"
] | One method is:
```
select len(stuff(cmpstn_val, 1, charindex('.', cmpstn_val), '')) as num_digits_after_dot
```
If you want the longest one:
```
select top (1) t.*
from t
order by len(stuff(cmpstn_val, 1, charindex('.', cmpstn_val), '')) desc;
```
[Here](https://dbfiddle.uk/?rdbms=sqlserver_2019&fiddle=52c6fa990d... | You can use `String functions`.`CHARINDEX function` - to get '.' position in the field (`CHARINDEX('.',cmpstn_val`) and
then
using `SUBSTRING function` - we cut the string from the dot till the end (`SUBSTRING(cmpstn_val,CHARINDEX('.',cmpstn_val)+1,LEN(cmpstn_val))`).At last just get the `LEN`(number of digits):
```
... |
47,824,417 | I have a ScrollView and a ConstraintLayout with some views inside, but it is not scrolling. I saw in other related questions some advice to add:
```
android:fillViewport="true"
```
to the layout and I ever tried with NestedScrollView and change the position of ScrollView, but nothing helps.
My fragment layout is:
... | 2017/12/15 | [
"https://Stackoverflow.com/questions/47824417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4785114/"
] | The problems that I noticed:
* Your cross-entropy loss is wrong (see [this question](https://stackoverflow.com/q/46291253/712995) for details, in short you're computing *binary* cross-entropy).
* I dropped manual gradient computation in favor of `tf.train.AdamOptimizer`.
* I dropped the split of the input of `x` (it's... | This is because the model is not using the same weights & biases for inference on CPU as well as on the other GPU devices.
For example:
```
for i in range(0,2):
with tf.device(('/gpu:{0}').format(i)):
with tf.variable_scope(('scope_gpu_{0}').format(i)) as infer_scope:
yy=model_forward(x_dict[(... |
47,824,417 | I have a ScrollView and a ConstraintLayout with some views inside, but it is not scrolling. I saw in other related questions some advice to add:
```
android:fillViewport="true"
```
to the layout and I ever tried with NestedScrollView and change the position of ScrollView, but nothing helps.
My fragment layout is:
... | 2017/12/15 | [
"https://Stackoverflow.com/questions/47824417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4785114/"
] | Along with the points mentioned in the first two answers, take a look at `return average_grads` in average\_gradients function, it's returning from the 1st iteration of the first for loop, meaning the gradients will only apply to the first variable (probably w0). Hence only w0 is getting updated and so you are getting ... | This is because the model is not using the same weights & biases for inference on CPU as well as on the other GPU devices.
For example:
```
for i in range(0,2):
with tf.device(('/gpu:{0}').format(i)):
with tf.variable_scope(('scope_gpu_{0}').format(i)) as infer_scope:
yy=model_forward(x_dict[(... |
5,932,227 | I've tried
```
text = nltk.word_tokenize("hello, my name is John")
words = nltk.pos_tag(text)
for w in words:
print "%s = %s" % (w[0], w[1])
```
And I got:
```
hello = NN
, = ,
my = PRP$
name = NN
is = VBZ
John = NNP
``` | 2011/05/09 | [
"https://Stackoverflow.com/questions/5932227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260610/"
] | According to the Penn Treebank tagset, *hello* is definitely an interjection and is consistently tagged UH. The problem you're running into is that the taggers that NLTK ships with were most likely trained on the part of the Wall Street Journal section of the Penn Treebank that is available for free, which unfortunatel... | NLTK use it own tagger to tag part of speech.
But the accuracy will vary from text to text. It is because the tagger was trained using a corpus provided by NLTK itself. The corpus could be about anything.
The corpus is not similar to your text, then the tagger will fail to tag your text because the context, style is ... |
5,932,227 | I've tried
```
text = nltk.word_tokenize("hello, my name is John")
words = nltk.pos_tag(text)
for w in words:
print "%s = %s" % (w[0], w[1])
```
And I got:
```
hello = NN
, = ,
my = PRP$
name = NN
is = VBZ
John = NNP
``` | 2011/05/09 | [
"https://Stackoverflow.com/questions/5932227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260610/"
] | According to the Penn Treebank tagset, *hello* is definitely an interjection and is consistently tagged UH. The problem you're running into is that the taggers that NLTK ships with were most likely trained on the part of the Wall Street Journal section of the Penn Treebank that is available for free, which unfortunatel... | Look in any dictionary and you will find hello defined as a "noun" (e.g. Longman). It's often described as an "exclamation" or "interjection" but the tag "noun" is not incorrect. |
7,984,703 | Suppose I have two geolocations(points) on google map,now I want to highlight an optimal route between these two points through different cities.How can I do this ? I have searched on internet and found [Drawing a line/path on Google Maps](https://stackoverflow.com/questions/2176397/drawing-a-line-path-on-google-maps) ... | 2011/11/02 | [
"https://Stackoverflow.com/questions/7984703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/751223/"
] | Perhaps it was a tail-recursive call. GCC has some pass doing tail-recursive optimization.
But why should you bother? If the called function is an `extern` function, then it is public, and GCC should call it following the ABI conventions (which means that it follows the calling convention).
You should not care if the... | jmp has less overhead than call. jmp just jumps, call pushes some stuff on stack and jumps |
7,984,703 | Suppose I have two geolocations(points) on google map,now I want to highlight an optimal route between these two points through different cities.How can I do this ? I have searched on internet and found [Drawing a line/path on Google Maps](https://stackoverflow.com/questions/2176397/drawing-a-line-path-on-google-maps) ... | 2011/11/02 | [
"https://Stackoverflow.com/questions/7984703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/751223/"
] | As you don't show an example, I can only guess: the called function has the same return type as the calling one, and this works like
```
return func2(...)
```
or has no return type at all (`void`).
In this case, "we" leave "our" return address on the stack, leaving it to "them" to use it to return to "our" caller. | Perhaps it was a tail-recursive call. GCC has some pass doing tail-recursive optimization.
But why should you bother? If the called function is an `extern` function, then it is public, and GCC should call it following the ABI conventions (which means that it follows the calling convention).
You should not care if the... |
7,984,703 | Suppose I have two geolocations(points) on google map,now I want to highlight an optimal route between these two points through different cities.How can I do this ? I have searched on internet and found [Drawing a line/path on Google Maps](https://stackoverflow.com/questions/2176397/drawing-a-line-path-on-google-maps) ... | 2011/11/02 | [
"https://Stackoverflow.com/questions/7984703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/751223/"
] | Perhaps it was a tail-recursive call. GCC has some pass doing tail-recursive optimization.
But why should you bother? If the called function is an `extern` function, then it is public, and GCC should call it following the ABI conventions (which means that it follows the calling convention).
You should not care if the... | I'm assuming that this is a tail call, meaning either the current function returns the result of the called function unmodified, or (for a function that returns void) returns immediately after the function call. In either case, it is not necessary to use `call`.
The `call` instruction performs two functions. First, it... |
7,984,703 | Suppose I have two geolocations(points) on google map,now I want to highlight an optimal route between these two points through different cities.How can I do this ? I have searched on internet and found [Drawing a line/path on Google Maps](https://stackoverflow.com/questions/2176397/drawing-a-line-path-on-google-maps) ... | 2011/11/02 | [
"https://Stackoverflow.com/questions/7984703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/751223/"
] | Perhaps it was a tail-recursive call. GCC has some pass doing tail-recursive optimization.
But why should you bother? If the called function is an `extern` function, then it is public, and GCC should call it following the ABI conventions (which means that it follows the calling convention).
You should not care if the... | You will never know, but one of the likely reasons is "cache" (among other reasons such as the already mentioned tail call optimization).
Inlining can make code faster and it can make code slower, because more code means less of it will be in the L1 cache at one time.
A JMP allows the compiler to reuse the same piece... |
7,984,703 | Suppose I have two geolocations(points) on google map,now I want to highlight an optimal route between these two points through different cities.How can I do this ? I have searched on internet and found [Drawing a line/path on Google Maps](https://stackoverflow.com/questions/2176397/drawing-a-line-path-on-google-maps) ... | 2011/11/02 | [
"https://Stackoverflow.com/questions/7984703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/751223/"
] | As you don't show an example, I can only guess: the called function has the same return type as the calling one, and this works like
```
return func2(...)
```
or has no return type at all (`void`).
In this case, "we" leave "our" return address on the stack, leaving it to "them" to use it to return to "our" caller. | jmp has less overhead than call. jmp just jumps, call pushes some stuff on stack and jumps |
7,984,703 | Suppose I have two geolocations(points) on google map,now I want to highlight an optimal route between these two points through different cities.How can I do this ? I have searched on internet and found [Drawing a line/path on Google Maps](https://stackoverflow.com/questions/2176397/drawing-a-line-path-on-google-maps) ... | 2011/11/02 | [
"https://Stackoverflow.com/questions/7984703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/751223/"
] | jmp has less overhead than call. jmp just jumps, call pushes some stuff on stack and jumps | You will never know, but one of the likely reasons is "cache" (among other reasons such as the already mentioned tail call optimization).
Inlining can make code faster and it can make code slower, because more code means less of it will be in the L1 cache at one time.
A JMP allows the compiler to reuse the same piece... |
7,984,703 | Suppose I have two geolocations(points) on google map,now I want to highlight an optimal route between these two points through different cities.How can I do this ? I have searched on internet and found [Drawing a line/path on Google Maps](https://stackoverflow.com/questions/2176397/drawing-a-line-path-on-google-maps) ... | 2011/11/02 | [
"https://Stackoverflow.com/questions/7984703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/751223/"
] | As you don't show an example, I can only guess: the called function has the same return type as the calling one, and this works like
```
return func2(...)
```
or has no return type at all (`void`).
In this case, "we" leave "our" return address on the stack, leaving it to "them" to use it to return to "our" caller. | I'm assuming that this is a tail call, meaning either the current function returns the result of the called function unmodified, or (for a function that returns void) returns immediately after the function call. In either case, it is not necessary to use `call`.
The `call` instruction performs two functions. First, it... |
7,984,703 | Suppose I have two geolocations(points) on google map,now I want to highlight an optimal route between these two points through different cities.How can I do this ? I have searched on internet and found [Drawing a line/path on Google Maps](https://stackoverflow.com/questions/2176397/drawing-a-line-path-on-google-maps) ... | 2011/11/02 | [
"https://Stackoverflow.com/questions/7984703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/751223/"
] | As you don't show an example, I can only guess: the called function has the same return type as the calling one, and this works like
```
return func2(...)
```
or has no return type at all (`void`).
In this case, "we" leave "our" return address on the stack, leaving it to "them" to use it to return to "our" caller. | You will never know, but one of the likely reasons is "cache" (among other reasons such as the already mentioned tail call optimization).
Inlining can make code faster and it can make code slower, because more code means less of it will be in the L1 cache at one time.
A JMP allows the compiler to reuse the same piece... |
7,984,703 | Suppose I have two geolocations(points) on google map,now I want to highlight an optimal route between these two points through different cities.How can I do this ? I have searched on internet and found [Drawing a line/path on Google Maps](https://stackoverflow.com/questions/2176397/drawing-a-line-path-on-google-maps) ... | 2011/11/02 | [
"https://Stackoverflow.com/questions/7984703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/751223/"
] | I'm assuming that this is a tail call, meaning either the current function returns the result of the called function unmodified, or (for a function that returns void) returns immediately after the function call. In either case, it is not necessary to use `call`.
The `call` instruction performs two functions. First, it... | You will never know, but one of the likely reasons is "cache" (among other reasons such as the already mentioned tail call optimization).
Inlining can make code faster and it can make code slower, because more code means less of it will be in the L1 cache at one time.
A JMP allows the compiler to reuse the same piece... |
53,964,623 | I was ask to write a function in erlang that given a list of integer and an integer, will return all integer smaller than or equal to the integer. Example sive ([1,2,3,4,5 ],3)=[1,2,3] | 2018/12/28 | [
"https://Stackoverflow.com/questions/53964623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10785849/"
] | List comprehensions are explained here:
* <http://erlang.org/doc/programming_examples/list_comprehensions.html>
* <https://learnyousomeerlang.com/starting-out-for-real#list-comprehensions> | If you'd like to use function instead you can check [filter/2](http://erlang.org/doc/man/lists.html#filter-2). |
72,201,260 | I have a form, when I enter une value for example `test`, I would like to retrieve the value in a modal, please.
1))
[](https://i.stack.imgur.com/4haFu.png)
2))
[](https://i.stack.... | 2022/05/11 | [
"https://Stackoverflow.com/questions/72201260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18237732/"
] | Short answer is: No.
It's best practice with containers to have one process per container. The container has an entrypoint, basically a command that is executed when starting the container. This entrypoint will be the command that starts your process. If you want more than one process, you need to have a script in the... | It's not clear what you mean with CMS (content/customer/... management system). Nonetheless, milestones on the way to create/sepearte an application (monolith/mcsvs) would propably be:
* if the application is a smaller one, start with a monolithic structure (whole application as an executable on a application/webserve... |
72,201,260 | I have a form, when I enter une value for example `test`, I would like to retrieve the value in a modal, please.
1))
[](https://i.stack.imgur.com/4haFu.png)
2))
[](https://i.stack.... | 2022/05/11 | [
"https://Stackoverflow.com/questions/72201260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18237732/"
] | Short answer is: No.
It's best practice with containers to have one process per container. The container has an entrypoint, basically a command that is executed when starting the container. This entrypoint will be the command that starts your process. If you want more than one process, you need to have a script in the... | That's a fair question that most of us go through at some point. One tends to have everything in the same container for convenience but then later regret that choice.
So, best to do it right from the start and to have one container for the app and one for the database.
According to [Docker's documentation](https://do... |
72,201,260 | I have a form, when I enter une value for example `test`, I would like to retrieve the value in a modal, please.
1))
[](https://i.stack.imgur.com/4haFu.png)
2))
[](https://i.stack.... | 2022/05/11 | [
"https://Stackoverflow.com/questions/72201260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18237732/"
] | That's a fair question that most of us go through at some point. One tends to have everything in the same container for convenience but then later regret that choice.
So, best to do it right from the start and to have one container for the app and one for the database.
According to [Docker's documentation](https://do... | It's not clear what you mean with CMS (content/customer/... management system). Nonetheless, milestones on the way to create/sepearte an application (monolith/mcsvs) would propably be:
* if the application is a smaller one, start with a monolithic structure (whole application as an executable on a application/webserve... |
29,257,756 | I have two tables, `Users` and `Company`.
I want to transfer values from a `Active` column in the `Users` table to the `Active` column in the `Company` table, where the `CompanyID` in matches `ID`.
This is an example table. It has many thousands of rows, and there is 1 on 1 relationship between `Company` and `Users... | 2015/03/25 | [
"https://Stackoverflow.com/questions/29257756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1515143/"
] | You can simply perform an `UPDATE` that uses a `JOIN` between the two tables like so:
```
UPDATE c
SET Active = u.Active
FROM Company c
INNER JOIN Users u ON u.CompanyId = c.ID
```
**Full working sample code:**
```
CREATE TABLE #Users
(
CompanyId INT ,
Active BIT
)
INSERT INTO #Users
(... | That should do the trick for you.
```
DECLARE @Users TABLE (CompanyID INT, Active BIT);
DECLARE @Companies TABLE (CompanyID INT, Active BIT);
INSERT INTO @Users (CompanyID, Active)
VALUES (458, 1), (685, 1), (58, 0)
INSERT INTO @Companies (CompanyID)
VALUES (5),(3),(58),(685)
SELECT C.CompanyID, U.Active
FROM @Comp... |
29,257,756 | I have two tables, `Users` and `Company`.
I want to transfer values from a `Active` column in the `Users` table to the `Active` column in the `Company` table, where the `CompanyID` in matches `ID`.
This is an example table. It has many thousands of rows, and there is 1 on 1 relationship between `Company` and `Users... | 2015/03/25 | [
"https://Stackoverflow.com/questions/29257756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1515143/"
] | That should do the trick for you.
```
DECLARE @Users TABLE (CompanyID INT, Active BIT);
DECLARE @Companies TABLE (CompanyID INT, Active BIT);
INSERT INTO @Users (CompanyID, Active)
VALUES (458, 1), (685, 1), (58, 0)
INSERT INTO @Companies (CompanyID)
VALUES (5),(3),(58),(685)
SELECT C.CompanyID, U.Active
FROM @Comp... | Assuming you have more users for each company, I would assume that 1 active user would result in an active company.
```
UPDATE
Company
SET Active = (SELECT top 1 Active
FROM Users
WHERE CompanyId = Company.id
ORDER BY Active DESC)
``` |
29,257,756 | I have two tables, `Users` and `Company`.
I want to transfer values from a `Active` column in the `Users` table to the `Active` column in the `Company` table, where the `CompanyID` in matches `ID`.
This is an example table. It has many thousands of rows, and there is 1 on 1 relationship between `Company` and `Users... | 2015/03/25 | [
"https://Stackoverflow.com/questions/29257756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1515143/"
] | That should do the trick for you.
```
DECLARE @Users TABLE (CompanyID INT, Active BIT);
DECLARE @Companies TABLE (CompanyID INT, Active BIT);
INSERT INTO @Users (CompanyID, Active)
VALUES (458, 1), (685, 1), (58, 0)
INSERT INTO @Companies (CompanyID)
VALUES (5),(3),(58),(685)
SELECT C.CompanyID, U.Active
FROM @Comp... | ```
UPDATE Company
SET Company.Active = u.Active from Users u
where Company.ID = u.CompanyID
``` |
29,257,756 | I have two tables, `Users` and `Company`.
I want to transfer values from a `Active` column in the `Users` table to the `Active` column in the `Company` table, where the `CompanyID` in matches `ID`.
This is an example table. It has many thousands of rows, and there is 1 on 1 relationship between `Company` and `Users... | 2015/03/25 | [
"https://Stackoverflow.com/questions/29257756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1515143/"
] | You can simply perform an `UPDATE` that uses a `JOIN` between the two tables like so:
```
UPDATE c
SET Active = u.Active
FROM Company c
INNER JOIN Users u ON u.CompanyId = c.ID
```
**Full working sample code:**
```
CREATE TABLE #Users
(
CompanyId INT ,
Active BIT
)
INSERT INTO #Users
(... | Assuming you have more users for each company, I would assume that 1 active user would result in an active company.
```
UPDATE
Company
SET Active = (SELECT top 1 Active
FROM Users
WHERE CompanyId = Company.id
ORDER BY Active DESC)
``` |
29,257,756 | I have two tables, `Users` and `Company`.
I want to transfer values from a `Active` column in the `Users` table to the `Active` column in the `Company` table, where the `CompanyID` in matches `ID`.
This is an example table. It has many thousands of rows, and there is 1 on 1 relationship between `Company` and `Users... | 2015/03/25 | [
"https://Stackoverflow.com/questions/29257756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1515143/"
] | You can simply perform an `UPDATE` that uses a `JOIN` between the two tables like so:
```
UPDATE c
SET Active = u.Active
FROM Company c
INNER JOIN Users u ON u.CompanyId = c.ID
```
**Full working sample code:**
```
CREATE TABLE #Users
(
CompanyId INT ,
Active BIT
)
INSERT INTO #Users
(... | ```
UPDATE Company
SET Company.Active = u.Active from Users u
where Company.ID = u.CompanyID
``` |
29,257,756 | I have two tables, `Users` and `Company`.
I want to transfer values from a `Active` column in the `Users` table to the `Active` column in the `Company` table, where the `CompanyID` in matches `ID`.
This is an example table. It has many thousands of rows, and there is 1 on 1 relationship between `Company` and `Users... | 2015/03/25 | [
"https://Stackoverflow.com/questions/29257756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1515143/"
] | Assuming you have more users for each company, I would assume that 1 active user would result in an active company.
```
UPDATE
Company
SET Active = (SELECT top 1 Active
FROM Users
WHERE CompanyId = Company.id
ORDER BY Active DESC)
``` | ```
UPDATE Company
SET Company.Active = u.Active from Users u
where Company.ID = u.CompanyID
``` |
4,340,609 | You can get the current class name, assuming RTTI is enabled, using typeid(this).name() at runtime.
I would like to be able to get the name of the base class for "this". Is that possible? I'm not using multiple inheritance, in case that makes a difference. | 2010/12/02 | [
"https://Stackoverflow.com/questions/4340609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25823/"
] | No sir. Sorry. And your method of getting the class name this way is implementation-dependent. On my implementation, I get the mangled name. | No, it is not, and the reason you need this feature is dubious :) |
4,340,609 | You can get the current class name, assuming RTTI is enabled, using typeid(this).name() at runtime.
I would like to be able to get the name of the base class for "this". Is that possible? I'm not using multiple inheritance, in case that makes a difference. | 2010/12/02 | [
"https://Stackoverflow.com/questions/4340609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25823/"
] | Plus, I don't think that you can count on `typeid(this).name()` to give you a class name (AFAIK the exact value to be returned is implementation-defined). | No sir. Sorry. And your method of getting the class name this way is implementation-dependent. On my implementation, I get the mangled name. |
4,340,609 | You can get the current class name, assuming RTTI is enabled, using typeid(this).name() at runtime.
I would like to be able to get the name of the base class for "this". Is that possible? I'm not using multiple inheritance, in case that makes a difference. | 2010/12/02 | [
"https://Stackoverflow.com/questions/4340609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25823/"
] | Plus, I don't think that you can count on `typeid(this).name()` to give you a class name (AFAIK the exact value to be returned is implementation-defined). | No, it is not, and the reason you need this feature is dubious :) |
4,340,609 | You can get the current class name, assuming RTTI is enabled, using typeid(this).name() at runtime.
I would like to be able to get the name of the base class for "this". Is that possible? I'm not using multiple inheritance, in case that makes a difference. | 2010/12/02 | [
"https://Stackoverflow.com/questions/4340609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25823/"
] | The information can't reliably be retrieved because it isn't reliably stored anywhere, in turn because the C++ philosophy is not to give you things unless you explicitly ask for them. | No, it is not, and the reason you need this feature is dubious :) |
4,340,609 | You can get the current class name, assuming RTTI is enabled, using typeid(this).name() at runtime.
I would like to be able to get the name of the base class for "this". Is that possible? I'm not using multiple inheritance, in case that makes a difference. | 2010/12/02 | [
"https://Stackoverflow.com/questions/4340609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25823/"
] | Plus, I don't think that you can count on `typeid(this).name()` to give you a class name (AFAIK the exact value to be returned is implementation-defined). | The information can't reliably be retrieved because it isn't reliably stored anywhere, in turn because the C++ philosophy is not to give you things unless you explicitly ask for them. |
20,280,757 | I have a question regarding fetch data in the form of table. i have a table with a single row now i just want amount increased on the basis on given logic..
like
```
1st row amount=1200,
2nd row amount=1320(1200+120),
3rd row amount=1452(1320+132)
```
logic is 10% add with previous amount
My table is
```
Sno - ... | 2013/11/29 | [
"https://Stackoverflow.com/questions/20280757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3016777/"
] | ```
WITH COUNTER(RN)
AS
(
SELECT ROW_NUMBER() OVER(ORDER BY object_id)
FROM sys.objects
),
A(RN, value)
AS
(
SELECT CAST(1 as bigint),
CAST(1200 as decimal(20, 0))
UNION ALL
SELECT COUNTER.RN,
CAST(A.value*1.1 as decimal... | This does what you ask for:
```
select sno, name, amount from table1
union select sno+1, name, amount*1.1 from table1
union select sno+2, name, amount*1.1*1.1 from table1
```
But it's not very flexible. E.g. if there are multiple rows you might get duplicate 'sno' numbers. |
20,280,757 | I have a question regarding fetch data in the form of table. i have a table with a single row now i just want amount increased on the basis on given logic..
like
```
1st row amount=1200,
2nd row amount=1320(1200+120),
3rd row amount=1452(1320+132)
```
logic is 10% add with previous amount
My table is
```
Sno - ... | 2013/11/29 | [
"https://Stackoverflow.com/questions/20280757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3016777/"
] | This has exactly the same limitation as WadimX's answer, but it'll do 100 rows. To produce your example output given your input table (which I'll refer to as `example`):
```
;WITH nums AS
(SELECT 1 AS RowNum, Name, Amount
FROM (SELECT Name, Amount FROM example) s
UNION ALL
SELECT RowNum + 1 As RowNum, N... | This does what you ask for:
```
select sno, name, amount from table1
union select sno+1, name, amount*1.1 from table1
union select sno+2, name, amount*1.1*1.1 from table1
```
But it's not very flexible. E.g. if there are multiple rows you might get duplicate 'sno' numbers. |
20,280,757 | I have a question regarding fetch data in the form of table. i have a table with a single row now i just want amount increased on the basis on given logic..
like
```
1st row amount=1200,
2nd row amount=1320(1200+120),
3rd row amount=1452(1320+132)
```
logic is 10% add with previous amount
My table is
```
Sno - ... | 2013/11/29 | [
"https://Stackoverflow.com/questions/20280757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3016777/"
] | ```
WITH COUNTER(RN)
AS
(
SELECT ROW_NUMBER() OVER(ORDER BY object_id)
FROM sys.objects
),
A(RN, value)
AS
(
SELECT CAST(1 as bigint),
CAST(1200 as decimal(20, 0))
UNION ALL
SELECT COUNTER.RN,
CAST(A.value*1.1 as decimal... | Remodified answer to use cte instead:
```
DECLARE @T TABLE (sno INT, name CHAR(1), amount INT)
INSERT INTO @T
SELECT 1, 'a', 1200
;WITH cte AS (
SELECT sno, name, amount
FROM @T
WHERE sno = 1
UNION ALL
SELECT sno+1, name, amount + amount / 10
FROM cte
WHERE sno+1 <= 100
)
SELECT *
FRO... |
20,280,757 | I have a question regarding fetch data in the form of table. i have a table with a single row now i just want amount increased on the basis on given logic..
like
```
1st row amount=1200,
2nd row amount=1320(1200+120),
3rd row amount=1452(1320+132)
```
logic is 10% add with previous amount
My table is
```
Sno - ... | 2013/11/29 | [
"https://Stackoverflow.com/questions/20280757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3016777/"
] | This has exactly the same limitation as WadimX's answer, but it'll do 100 rows. To produce your example output given your input table (which I'll refer to as `example`):
```
;WITH nums AS
(SELECT 1 AS RowNum, Name, Amount
FROM (SELECT Name, Amount FROM example) s
UNION ALL
SELECT RowNum + 1 As RowNum, N... | ```
WITH COUNTER(RN)
AS
(
SELECT ROW_NUMBER() OVER(ORDER BY object_id)
FROM sys.objects
),
A(RN, value)
AS
(
SELECT CAST(1 as bigint),
CAST(1200 as decimal(20, 0))
UNION ALL
SELECT COUNTER.RN,
CAST(A.value*1.1 as decimal... |
20,280,757 | I have a question regarding fetch data in the form of table. i have a table with a single row now i just want amount increased on the basis on given logic..
like
```
1st row amount=1200,
2nd row amount=1320(1200+120),
3rd row amount=1452(1320+132)
```
logic is 10% add with previous amount
My table is
```
Sno - ... | 2013/11/29 | [
"https://Stackoverflow.com/questions/20280757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3016777/"
] | This has exactly the same limitation as WadimX's answer, but it'll do 100 rows. To produce your example output given your input table (which I'll refer to as `example`):
```
;WITH nums AS
(SELECT 1 AS RowNum, Name, Amount
FROM (SELECT Name, Amount FROM example) s
UNION ALL
SELECT RowNum + 1 As RowNum, N... | Remodified answer to use cte instead:
```
DECLARE @T TABLE (sno INT, name CHAR(1), amount INT)
INSERT INTO @T
SELECT 1, 'a', 1200
;WITH cte AS (
SELECT sno, name, amount
FROM @T
WHERE sno = 1
UNION ALL
SELECT sno+1, name, amount + amount / 10
FROM cte
WHERE sno+1 <= 100
)
SELECT *
FRO... |
30,103,425 | I am trying to find the dominant color of an image. I am using [ColorMine](https://github.com/THEjoezack/ColorMine) to do the color comparison. Basically I have a template of colors that I compare each pixel against.
The color with the least distance gets elected from the template as the representative of that pixel.
... | 2015/05/07 | [
"https://Stackoverflow.com/questions/30103425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/127602/"
] | I had to do something similar. As input colors I used all values in System.Drawing.KnownColor, but you can change that part pretty easily.
The code below gets the color most often used in an image and then tries to match it a known color.
```
class Program
{
static void Main(string[] args)
{
var image... | It looks to me like your starting values for `ColourTemplate` is a little off what you expect them to be.
One solution would be to categorise all a whole range of colours (try googling "CIE colour"), and seeing where you agree and disagree with your programs categorisation.
Pseudo code:
```
Image CategoriseImage (... |
30,103,425 | I am trying to find the dominant color of an image. I am using [ColorMine](https://github.com/THEjoezack/ColorMine) to do the color comparison. Basically I have a template of colors that I compare each pixel against.
The color with the least distance gets elected from the template as the representative of that pixel.
... | 2015/05/07 | [
"https://Stackoverflow.com/questions/30103425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/127602/"
] | I had to do something similar. As input colors I used all values in System.Drawing.KnownColor, but you can change that part pretty easily.
The code below gets the color most often used in an image and then tries to match it a known color.
```
class Program
{
static void Main(string[] args)
{
var image... | Its difficult to interpret what 'dominant color' really means in your question without a more precise definition or knowing what the application is.
The [Image Color Summarizer](http://mkweb.bcgsc.ca/color_summarizer/?examples) web service examples show that a straight pixel average is pretty good.
You can try some o... |
18,534,591 | I am developing a command line node module and would like to be able to launch it via links on a website.
I want to register a custom protocol `my-module://` such that links would have the following format: `my-module://action:some-action` and clicking on them would start the node package.
If there isn't a node API f... | 2013/08/30 | [
"https://Stackoverflow.com/questions/18534591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/568805/"
] | Its an interesting idea. I don't think there is currently a cross platform node.js solution out there. I did come across this thread of people asking for the same thing:
```
https://github.com/rogerwang/node-webkit/issues/951
```
Electron now supports it with the [`app.setAsDefaultProtocolClient`](http://electron.at... | Here's how I did on Mac OS with an application NW.js :
1. Open the app `/Applications/Utilities/Script Editor`
type the following code in the editor
```
on open location this_URL
do shell script "/Applications/X.app/Contents/MacOS/x '" & this_URL & "'"
end open location
```
Replace *X* by the name of your App.
... |
18,534,591 | I am developing a command line node module and would like to be able to launch it via links on a website.
I want to register a custom protocol `my-module://` such that links would have the following format: `my-module://action:some-action` and clicking on them would start the node package.
If there isn't a node API f... | 2013/08/30 | [
"https://Stackoverflow.com/questions/18534591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/568805/"
] | Its an interesting idea. I don't think there is currently a cross platform node.js solution out there. I did come across this thread of people asking for the same thing:
```
https://github.com/rogerwang/node-webkit/issues/951
```
Electron now supports it with the [`app.setAsDefaultProtocolClient`](http://electron.at... | ### Edit :
Looks like the module has changed the registration process for good:
```js
const path = require('path');
const ProtocolRegistry = require('protocol-registry');
console.log('Registering...');
// Registers the Protocol
ProtocolRegistry.register({
protocol: 'testproto', // sets protocol for your command... |
91,790 | I am working on a Magento e-commerce site.
I need to disable the Catalog Advanced Search.
I checked with source code available in the stackexchange but its not working. | 2015/11/27 | [
"https://magento.stackexchange.com/questions/91790",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/33576/"
] | To remove the link to advanced search edit `app/design/frontend/{package}/{theme}/layout/catalogsearch.xml`.
If the file does not exist in your theme, copy it from `base/default`. Then remove this from the file:
```
<action method="addLink" translate="label title" module="catalogsearch">
<label>Advanced Search... | 1. Copy below file in your theme directory
**app/design/frontend/base/default/layout/catalogsearch.xml**
2. search the layout **catalogsearch\_advanced\_index** & Just comment out the code inside that tag to hide the advance search content. |
6,350,215 | I have a split view controller in my Ipad app, in which the detail view has subviews which are UITableView's.
The functionality I am trying to implement is to get an info view at the same position of a subview when a button(info button) on the subview is pressed. I need to get this info view by animation and that anim... | 2011/06/14 | [
"https://Stackoverflow.com/questions/6350215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/621808/"
] | The basic steps of performing an animation to onscreen is as follows:
1. Create the view.
2. Move it to the initial (offscreen) position
3. Add to the view hierarchy
4. Perform the animation.
It seems like you're skipping step 3 and possibly step 2. | Did you try setting the subview frame to the frame of your superview, i.e
```
info.View.frame = self.view.frame;
``` |
53,564,926 | I am working on a WordPress site. I have two "Learn More" links on my page. When either one is clicked I would like them to revile the corresponding paragraph above. Currently clicking either or reveals both. It would also be super helpful to have the link text change from "Learn More" to "Close" on click as well.
``... | 2018/11/30 | [
"https://Stackoverflow.com/questions/53564926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2026241/"
] | Just using the mathmetical way + `numpy` `broadcast`
```
v1=df1.start.values
v2=df1.end.values
s1=df2.start.values
s2=df2.end.values
s=pd.DataFrame(((s2-v1[:,None])>0)&((s1-v2[:,None])<0)).dot(df2.name+'|').str[:-1]
s
Out[737]:
0 FOXP3
1 LOXL1
2 LOXL1|INSN
dtype: object
#df1['New']=s.values
``` | The question you need to answer, from what you already have, is whether there is anything in the `range` you know.
```
if max(start_1, start_2) <= min(end_1, end_2):
```
You might find better tools in the `interval` module; this does a variety of operations on known intervals; I'm hopeful there are vectorized tools ... |
13,482,532 | I would like to calculate sums for certain columns and then apply this summation for every row. Unfortunately, I can only get to the first step. How do I now make it happen for each row? I know that R doesn't need loops; what are good approaches?
My matrix (zscore) looks like this:
```
a b c t y
1 3 ... | 2012/11/20 | [
"https://Stackoverflow.com/questions/13482532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1807857/"
] | You could do something like this:
```
summed <- rowSums(zscore[, c(1, 2, 3, 5)])
``` | If you don't have NA you can apply this
```
suma.zscore = (zscore$a + zscore$c + zscore$t + zscore$y)
``` |
13,482,532 | I would like to calculate sums for certain columns and then apply this summation for every row. Unfortunately, I can only get to the first step. How do I now make it happen for each row? I know that R doesn't need loops; what are good approaches?
My matrix (zscore) looks like this:
```
a b c t y
1 3 ... | 2012/11/20 | [
"https://Stackoverflow.com/questions/13482532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1807857/"
] | You could do something like this:
```
summed <- rowSums(zscore[, c(1, 2, 3, 5)])
``` | The summation of all individual rows can also be done using the row-wise operations of dplyr (with `col1, col2, col3` defining three selected columns for which the row-wise sum is calculated):
```
library(tidyverse)
df <- df %>%
rowwise() %>%
mutate(rowsum = sum(c(col1, col2,col3)))
``` |
13,482,532 | I would like to calculate sums for certain columns and then apply this summation for every row. Unfortunately, I can only get to the first step. How do I now make it happen for each row? I know that R doesn't need loops; what are good approaches?
My matrix (zscore) looks like this:
```
a b c t y
1 3 ... | 2012/11/20 | [
"https://Stackoverflow.com/questions/13482532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1807857/"
] | The summation of all individual rows can also be done using the row-wise operations of dplyr (with `col1, col2, col3` defining three selected columns for which the row-wise sum is calculated):
```
library(tidyverse)
df <- df %>%
rowwise() %>%
mutate(rowsum = sum(c(col1, col2,col3)))
``` | If you don't have NA you can apply this
```
suma.zscore = (zscore$a + zscore$c + zscore$t + zscore$y)
``` |
117,716 | I am making my first GUI in unity, and I am not sure if should create the toggle buttons in the game scene by creating new UI elements or by scripting.
Creating them in the game scene gives me more options but I have trouble to manipulate the input.
Because of this I am scripting them in the monodeveloper but it see... | 2016/03/04 | [
"https://gamedev.stackexchange.com/questions/117716",
"https://gamedev.stackexchange.com",
"https://gamedev.stackexchange.com/users/76710/"
] | I am using the canvas UI in Unity 5. And to add a button to screen, I just create a UI Image under my canvas object in Hierarchy view. Change the sprite as required.
Now add "Event Trigger" as shown below.
[](https://i.stack.imgur.com/ImP7I.png)
Ne... | I prefer UI Elements...
I mostly use UI Elements for static buttons and labels..
When I need dynamic stuff going on (an inventory for example) I just script-instantiate them (using object pools) |
117,716 | I am making my first GUI in unity, and I am not sure if should create the toggle buttons in the game scene by creating new UI elements or by scripting.
Creating them in the game scene gives me more options but I have trouble to manipulate the input.
Because of this I am scripting them in the monodeveloper but it see... | 2016/03/04 | [
"https://gamedev.stackexchange.com/questions/117716",
"https://gamedev.stackexchange.com",
"https://gamedev.stackexchange.com/users/76710/"
] | I prefer the scripting way to make the GUI, though it's probably because the only thing I like about making games is scripting.
---
**Slipting way :**
One way to do it is to use the [GUI.Toggle](http://docs.unity3d.com/ScriptReference/GUI.Toggle.html) function in Unity.
---
**Non Scripting Way :**
If you still ... | I prefer UI Elements...
I mostly use UI Elements for static buttons and labels..
When I need dynamic stuff going on (an inventory for example) I just script-instantiate them (using object pools) |
117,716 | I am making my first GUI in unity, and I am not sure if should create the toggle buttons in the game scene by creating new UI elements or by scripting.
Creating them in the game scene gives me more options but I have trouble to manipulate the input.
Because of this I am scripting them in the monodeveloper but it see... | 2016/03/04 | [
"https://gamedev.stackexchange.com/questions/117716",
"https://gamedev.stackexchange.com",
"https://gamedev.stackexchange.com/users/76710/"
] | I am using the canvas UI in Unity 5. And to add a button to screen, I just create a UI Image under my canvas object in Hierarchy view. Change the sprite as required.
Now add "Event Trigger" as shown below.
[](https://i.stack.imgur.com/ImP7I.png)
Ne... | I prefer the scripting way to make the GUI, though it's probably because the only thing I like about making games is scripting.
---
**Slipting way :**
One way to do it is to use the [GUI.Toggle](http://docs.unity3d.com/ScriptReference/GUI.Toggle.html) function in Unity.
---
**Non Scripting Way :**
If you still ... |
40,203,874 | Is there a way to disable all access to a variable in a certain scope?
Its usage might be similar to this :-
```
int outerOnly=5; //primitive or class or struct, it can also be a field
outerOnly=4; //ok
{//vvv The disable command may be in a block?
disable outerOnly; //<--- I want some thing like this.
outer... | 2016/10/23 | [
"https://Stackoverflow.com/questions/40203874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3577745/"
] | Consider implementing something like this (perhaps with deleted copy constructors and assignment operators):
```
struct disable
{
private:
disable(const disable&) = delete;
disable& operator=(const disable&) = delete;
public:
disable() {}
};
```
Then, placing
```
disable outerOnly;
```
inside the inne... | Simply do a `struct Outeronly;`.
Note that the error messages can be perplexing if one is unfamiliar with them. |
40,203,874 | Is there a way to disable all access to a variable in a certain scope?
Its usage might be similar to this :-
```
int outerOnly=5; //primitive or class or struct, it can also be a field
outerOnly=4; //ok
{//vvv The disable command may be in a block?
disable outerOnly; //<--- I want some thing like this.
outer... | 2016/10/23 | [
"https://Stackoverflow.com/questions/40203874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3577745/"
] | Consider implementing something like this (perhaps with deleted copy constructors and assignment operators):
```
struct disable
{
private:
disable(const disable&) = delete;
disable& operator=(const disable&) = delete;
public:
disable() {}
};
```
Then, placing
```
disable outerOnly;
```
inside the inne... | >
> Is there a way to disable all access to a variable in a certain scope?
>
>
>
No, there is no such feature.
>
> If the answer is no, is there any feature closest to this one?
>
>
>
Instead of a simple block, you could define and call a closure that doesn't capture the undesired variable:
```
int outerOnl... |
40,203,874 | Is there a way to disable all access to a variable in a certain scope?
Its usage might be similar to this :-
```
int outerOnly=5; //primitive or class or struct, it can also be a field
outerOnly=4; //ok
{//vvv The disable command may be in a block?
disable outerOnly; //<--- I want some thing like this.
outer... | 2016/10/23 | [
"https://Stackoverflow.com/questions/40203874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3577745/"
] | Consider implementing something like this (perhaps with deleted copy constructors and assignment operators):
```
struct disable
{
private:
disable(const disable&) = delete;
disable& operator=(const disable&) = delete;
public:
disable() {}
};
```
Then, placing
```
disable outerOnly;
```
inside the inne... | Here is pretty straightforward solution:
```
int main()
{
int outerOnly=5; //primitive or class or struct, it can also be a field
outerOnly=4; //ok
#define outerOnly outerOnly_disabled
//outerOnly=4; //error outerOnly_disabled is not declared
//int c=outerOnly; //error
... |
40,203,874 | Is there a way to disable all access to a variable in a certain scope?
Its usage might be similar to this :-
```
int outerOnly=5; //primitive or class or struct, it can also be a field
outerOnly=4; //ok
{//vvv The disable command may be in a block?
disable outerOnly; //<--- I want some thing like this.
outer... | 2016/10/23 | [
"https://Stackoverflow.com/questions/40203874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3577745/"
] | >
> Is there a way to disable all access to a variable in a certain scope?
>
>
>
No, there is no such feature.
>
> If the answer is no, is there any feature closest to this one?
>
>
>
Instead of a simple block, you could define and call a closure that doesn't capture the undesired variable:
```
int outerOnl... | Simply do a `struct Outeronly;`.
Note that the error messages can be perplexing if one is unfamiliar with them. |
40,203,874 | Is there a way to disable all access to a variable in a certain scope?
Its usage might be similar to this :-
```
int outerOnly=5; //primitive or class or struct, it can also be a field
outerOnly=4; //ok
{//vvv The disable command may be in a block?
disable outerOnly; //<--- I want some thing like this.
outer... | 2016/10/23 | [
"https://Stackoverflow.com/questions/40203874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3577745/"
] | >
> Is there a way to disable all access to a variable in a certain scope?
>
>
>
No, there is no such feature.
>
> If the answer is no, is there any feature closest to this one?
>
>
>
Instead of a simple block, you could define and call a closure that doesn't capture the undesired variable:
```
int outerOnl... | Here is pretty straightforward solution:
```
int main()
{
int outerOnly=5; //primitive or class or struct, it can also be a field
outerOnly=4; //ok
#define outerOnly outerOnly_disabled
//outerOnly=4; //error outerOnly_disabled is not declared
//int c=outerOnly; //error
... |
55,988,036 | I created an apparatus maintenance board for my fire department. Each apparatus has its own tab with the name of that apparatus in cell A1.
Each row below that has room to list issues for that apparatus with column D being a drop-down list for the current progress. I want to be able to format the color of the apparatu... | 2019/05/05 | [
"https://Stackoverflow.com/questions/55988036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11453749/"
] | 1. Verify versions:
```
kubeadm version
kubeadm config view
```
2. Generate default settings for your init command to see your settings (should be modified):
```
kubeadm init --config defaults
```
3. Did you try the solution provided by the output?
```
kubeadm config migrate --old-config old.yam... | what is the kubernetes version are you using?
try below
apiVersion: kubeadm.k8s.io/v1alpha2
OR
apiVersion: kubeadm.k8s.io/v1alpha3 |
71,395,797 | I have json file with the following data in it:
```
{
"item1": "value1",
"item2": "value2",
"item3": "value3"
}
```
I also have `Items()` class in a seperate file which has the method `getItems()` method which loads the json file:
```
class Items {
Future<Map<String, dynamic>> getItems() async {
String ... | 2022/03/08 | [
"https://Stackoverflow.com/questions/71395797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12182218/"
] | The quick solution would be to replace `yield from io.BytesIO(resp.read())` with the one below (see [FastAPI documentation - `StreamingResponse`](https://fastapi.tiangolo.com/advanced/custom-response/#using-streamingresponse-with-file-like-objects) for more details).
```py
yield from resp
```
However, instead of us... | I encountered similar issues but solved all. The main idea is to create a session with requests.Session(), and yield a chunk one by one, instead of getting all the content and yield it at once. This works very nicely without making any memory issue at all.
```py
@app.get(params.api_video_route)
async def get_api_video... |
34,377,277 | Recently I came across code where DAO has an instance of DAOFactory. And DAOFactory has Connection. DAO uses Connection of DAOFactory for its operations. Basically DAO was dependent on DAOFactory. This is the code:
**DAOFactory.java:**
```
public abstract class DAOFactory {
public static final int SQL_SERVER = 1;... | 2015/12/20 | [
"https://Stackoverflow.com/questions/34377277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4339178/"
] | The DAO having a DAOFactory means that changing the connection in the factory will change the connection in every dao created from it. This allows the DAOs to be created before the connection instance is known.
It has the disadvantages of creating circular dependencies between DAOFactory and the DAOs, and causing the ... | Pros :
1. Creates objects according to the required database connection.
2. Then according to the created database creates the User.
3. Follows standard Abstract Factory Design Pattern.
Cons:
1. There is no need to have seperate UserDAOs for separate connections. Could have been done with one class. |
20,081,380 | On my windows phone 7 Mango app I use the Microsoft.Live and Microsoft.Live.Controls references to download and upload on Skydrive. Logging in and uploading files works fine but whenever I call the "client.GetAsync("/me/skydrive/files");" on the LiveConnectClient the Callback result is empty just containing the error: ... | 2013/11/19 | [
"https://Stackoverflow.com/questions/20081380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3010425/"
] | I am not sure about minitest. But in rspec, you will have to stub the initialization part as well and return a mocked scheduler object
This is how i would do it in rspec.
```
mock_scheduler = double("scheduler")
Scheduler.stub(:new).and_return(mock_scheduler)
mock_scheduler.stub(:submit_request).and_return(response)
... | As Vimsha noted you have to first stub out the class initialization. I couldn't get his code to work, but this revised test code below has the same idea:
```
def test_schedule_request
scheduler_response = 'Expected response string for RequestId X'
response = nil
scheduler = Scheduler.new
Scheduler.stub :new, s... |
30,030,601 | I need to create constant json string or a json sorted on keys. What do I mean by constant json string? Please look into following code sample, which I created.
**My Code 1:**
```
public class GsonTest
{
class DataObject {
private int data1 = 100;
private String data2 = "hello";
}
pu... | 2015/05/04 | [
"https://Stackoverflow.com/questions/30030601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3906965/"
] | First of all, the keys of a json object are **unordered** by definition, see <http://json.org/>.
If you merely want a json string with ordered keys, you can try deserializing your json into a sorted map, and then serialize the map in order to get the sorted-by-key json string.
```
GsonTest obj=new GsonTest();
DataObj... | Perhaps a work around is for your class wrap a TreeMap which maintains sort order of the keys. You can add getters and setters for convenience. When you gson the TreeMap, you'll get ordered keys. |
30,030,601 | I need to create constant json string or a json sorted on keys. What do I mean by constant json string? Please look into following code sample, which I created.
**My Code 1:**
```
public class GsonTest
{
class DataObject {
private int data1 = 100;
private String data2 = "hello";
}
pu... | 2015/05/04 | [
"https://Stackoverflow.com/questions/30030601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3906965/"
] | First of all, the keys of a json object are **unordered** by definition, see <http://json.org/>.
If you merely want a json string with ordered keys, you can try deserializing your json into a sorted map, and then serialize the map in order to get the sorted-by-key json string.
```
GsonTest obj=new GsonTest();
DataObj... | Like others have mentioned that by design JSON is not supposed to have sorted keys in itself. You can also come up with a recursive solution to do it. I won't say my solution is very efficient but it does the intended job. Please have a look at the following piece of code.
```
private static JsonObject sortAndGet(Json... |
30,030,601 | I need to create constant json string or a json sorted on keys. What do I mean by constant json string? Please look into following code sample, which I created.
**My Code 1:**
```
public class GsonTest
{
class DataObject {
private int data1 = 100;
private String data2 = "hello";
}
pu... | 2015/05/04 | [
"https://Stackoverflow.com/questions/30030601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3906965/"
] | Like others have mentioned that by design JSON is not supposed to have sorted keys in itself. You can also come up with a recursive solution to do it. I won't say my solution is very efficient but it does the intended job. Please have a look at the following piece of code.
```
private static JsonObject sortAndGet(Json... | Perhaps a work around is for your class wrap a TreeMap which maintains sort order of the keys. You can add getters and setters for convenience. When you gson the TreeMap, you'll get ordered keys. |
65,003 | My requirement is to allow a user (other than salesforce admin) to allow to add picklist values by filling a value in text field and submitting form via a visualforce page. I am using javascript remoting for this. Below is my VF code :-
```
<apex:page controller="addfieldtopicklist" showHeader="false">
<apex:form id="... | 2015/02/02 | [
"https://salesforce.stackexchange.com/questions/65003",
"https://salesforce.stackexchange.com",
"https://salesforce.stackexchange.com/users/10167/"
] | Updating metadata using the Apex wrapper to the Metadata API (which is what it appears you are using) requires the running user have `Customize Application` privileges | If this is a custom object, you should use the Delegated Administration functionality. [Delegated Administration](https://help.salesforce.com/HTViewHelpDochttps://help.salesforce.com/HTViewHelpDoc?id=admin_delegate.htm&language=en_US) |
2,133 | Obviously, the computing power necessary to create the blockchain requires access to fast hashing which requires electricity. Given that local power outages do occur, and this can cause a lack of network availability, does this act as the Achilles heel for Bitcoin?
Is it possible to conduct Bitcoin transactions in the... | 2011/12/02 | [
"https://bitcoin.stackexchange.com/questions/2133",
"https://bitcoin.stackexchange.com",
"https://bitcoin.stackexchange.com/users/117/"
] | The network is distributed, so it won't go down everywhere at once.
Locally, on one hand it is similar to debit transactions - they need to get online to be processed. One can use cellphones though, which have their own batteries to run for awhile, so it's not too bad.
Lastly, one can accept transactions offline (usi... | In theory Bitcoin could work without electricity or computers. The difficulty would be (manually) reduced so that calculating the hashes by hand (or mechanical means) was feasible. Transactions would have to propagate on paper by hand. Transaction fees would have to go up enormously. And the whole shebang would work at... |
38,608,095 | I'm making an order form and I want the user to be able to resume their order at a later time, so I create an order in an `IncompleteOrders` collection and save the `docId` of the incomplete order in the user's LocalStorage.
When the user returns to the page I want to read the `docId` stored in their LocalStorage, su... | 2016/07/27 | [
"https://Stackoverflow.com/questions/38608095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2760030/"
] | You can use c.stop() where c is a callback. Please go through code below it should help
```
instance.autorun(function(c){
let subscription = this.subscribe('incompleteOrders');
if(subscription.ready()){
console.log('IncompleteOrders subscription complete!');
Session.set('orderContents', IncompleteOrders... | Just an idea, how about doing it on router, i.e; when the router changes and the form isn't submitted but has some data than insert the available fields into incomplete collection? |
229,021 | This is a scaled down code of what I'm working with:
```
assoc1 = <|"T1" -> 1, "T2" -> 2, "T3" -> 3, "Z1" -> 4|>
lis1 = {{{"T1","T2","T1"}, {"Z1","T3","T2"}, {"T1","T1","Z1"}, {"T2","T3","T3"}}}
lis2 = lis1 /. assoc1
```
What I'm trying to do is to filter through `lis1` and make a few different lists which fit the ... | 2020/08/25 | [
"https://mathematica.stackexchange.com/questions/229021",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/74202/"
] | First and third:
```
Cases[lis1, {x_, _, x_}, {2}]
```
>
> `{{"T1", "T2", "T1"}}`
>
>
>
First two and last two:
```
Cases[lis1, {x_, x_, _}, {2}]
```
>
> `{{"T1", "T1", "Z1"}}`
>
>
>
```
Cases[lis1, {_, x_, x_}, {2}]
```
>
> `{{"T2", "T3", "T3"}}`
>
>
>
I used `Cases` out of habit, but your idea ... | Your example list *lis1* has 3 levels, but only one element at the first level. If this is always the case, you could use
```
Select[lis1 // First,
assoc1[#[[1]]] == assoc1[#[[2]]] ||
assoc1[#[[2]]] == assoc1[#[[3]]] &]
```
However, if *lis1* could have more than 1 "row", you could use something like
```
Sele... |
229,021 | This is a scaled down code of what I'm working with:
```
assoc1 = <|"T1" -> 1, "T2" -> 2, "T3" -> 3, "Z1" -> 4|>
lis1 = {{{"T1","T2","T1"}, {"Z1","T3","T2"}, {"T1","T1","Z1"}, {"T2","T3","T3"}}}
lis2 = lis1 /. assoc1
```
What I'm trying to do is to filter through `lis1` and make a few different lists which fit the ... | 2020/08/25 | [
"https://mathematica.stackexchange.com/questions/229021",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/74202/"
] | First and third:
```
Cases[lis1, {x_, _, x_}, {2}]
```
>
> `{{"T1", "T2", "T1"}}`
>
>
>
First two and last two:
```
Cases[lis1, {x_, x_, _}, {2}]
```
>
> `{{"T1", "T1", "Z1"}}`
>
>
>
```
Cases[lis1, {_, x_, x_}, {2}]
```
>
> `{{"T2", "T3", "T3"}}`
>
>
>
I used `Cases` out of habit, but your idea ... | ```
newlis1 = List /@ Cases[lis1, {a_, _, b_} /;assoc1[a] == assoc1[b], All]
```
>
>
> ```
> {{{"T1", "T2", "T1"}}}
>
> ```
>
>
```
{newlis2, newlis3} = List /@ Cases[lis1, {a_, b_, _} | {_, a_, b_} /;
assoc1[a] == assoc1[b], All]
```
>
>
> ```
> {{{"T1", "T1", "Z1"}}, {{"T2", "T3", "T3"}}}
>
> ```... |
30,866,718 | Edit: Oops my bad! I wasn't clear enough... I guess I need to explain more...
I need to create a package installer for my customers. I want them to extract and overwrite the contents only in their specific folder.
I don't want them to be able to extract the contents wherever they want to let them steal my work /or k... | 2015/06/16 | [
"https://Stackoverflow.com/questions/30866718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4442072/"
] | Just increment before, not on every substitution:
```
awk '{i++; gsub(/a/,i)}1' file
```
This way, the variable gets updated once per line, not once per record.
The same applies to the Perl script:
```
perl -pe 'BEGIN { our $i = 0; } $i++; s/a/$i/ge;' file
```
### Test
```
$ cat a
0 0 a a a
2 3 a a a
$ awk '{i+... | ```
perl -pe'$i++;s/a/$i/g'
```
or if you like to increment only for lines with any substitution
```
perl -pe'/a/&&$i++;s/a/$i/g'
```
In action:
```
$ cat a
0 0 a a a
1 2 0 0 0
2 3 a a a
$ perl -pe'$i++;s/a/$i/g' a
0 0 1 1 1
1 2 0 0 0
2 3 3 3 3
$ perl -pe'/a/&&$i++;s/a/$i/g' a
0 0 1 1 1
1 2 0 0 0
2 3 2 2 2
``` |
30,866,718 | Edit: Oops my bad! I wasn't clear enough... I guess I need to explain more...
I need to create a package installer for my customers. I want them to extract and overwrite the contents only in their specific folder.
I don't want them to be able to extract the contents wherever they want to let them steal my work /or k... | 2015/06/16 | [
"https://Stackoverflow.com/questions/30866718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4442072/"
] | Just increment before, not on every substitution:
```
awk '{i++; gsub(/a/,i)}1' file
```
This way, the variable gets updated once per line, not once per record.
The same applies to the Perl script:
```
perl -pe 'BEGIN { our $i = 0; } $i++; s/a/$i/ge;' file
```
### Test
```
$ cat a
0 0 a a a
2 3 a a a
$ awk '{i+... | You can simply replace every occurrence of `a` with the current line number
```
perl -pe 's/a/$./g' FILE > NEW_FILE
``` |
30,866,718 | Edit: Oops my bad! I wasn't clear enough... I guess I need to explain more...
I need to create a package installer for my customers. I want them to extract and overwrite the contents only in their specific folder.
I don't want them to be able to extract the contents wherever they want to let them steal my work /or k... | 2015/06/16 | [
"https://Stackoverflow.com/questions/30866718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4442072/"
] | You can simply replace every occurrence of `a` with the current line number
```
perl -pe 's/a/$./g' FILE > NEW_FILE
``` | ```
perl -pe'$i++;s/a/$i/g'
```
or if you like to increment only for lines with any substitution
```
perl -pe'/a/&&$i++;s/a/$i/g'
```
In action:
```
$ cat a
0 0 a a a
1 2 0 0 0
2 3 a a a
$ perl -pe'$i++;s/a/$i/g' a
0 0 1 1 1
1 2 0 0 0
2 3 3 3 3
$ perl -pe'/a/&&$i++;s/a/$i/g' a
0 0 1 1 1
1 2 0 0 0
2 3 2 2 2
``` |
17,924,267 | I'd like to compare Windows Azure SQL Database and SQL Server on VM. So I'd like to ask:
which SQL server edition on Windows Azure(S,M edition; Web or Standard) should I choose to compare it with Windows Azure SQL Database Web. I know that these are different concepts PaaS IaaS and so on. In my question I am referring... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17924267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2225591/"
] | Roughly, [Windows Azure SQL Database](http://www.windowsazure.com/en-us/services/data-management/) is comparable to the features of [SQL Server 2012 Standard Edition](http://msdn.microsoft.com/en-us/library/cc645993.aspx), but this comparison is only approximate, because each offer is meant for a different use case and... | Regarding Windows Azure SQL Database Web edition: Web and Business editions are identical except for storage capacity (see my detailed SO answer about this, [here](https://stackoverflow.com/a/3521506/272109)), so it doesn't matter for your comparison.
Regarding SQL Server editions, I think this is going to be primaril... |
17,924,267 | I'd like to compare Windows Azure SQL Database and SQL Server on VM. So I'd like to ask:
which SQL server edition on Windows Azure(S,M edition; Web or Standard) should I choose to compare it with Windows Azure SQL Database Web. I know that these are different concepts PaaS IaaS and so on. In my question I am referring... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17924267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2225591/"
] | I made comparison for Azure SQL and SQL Server Std hosted on Azure VM (Large (A3)) for 2GB database. I just copied DB from Azure to VM, so, basically, I had 2 Databases with identical data and was able to run same queries.
SQL Azure DB has known advantages, but when it goes to performance people starts crying:
* Gett... | Regarding Windows Azure SQL Database Web edition: Web and Business editions are identical except for storage capacity (see my detailed SO answer about this, [here](https://stackoverflow.com/a/3521506/272109)), so it doesn't matter for your comparison.
Regarding SQL Server editions, I think this is going to be primaril... |
9,731,866 | i have a password box and i want to get the input data to check for verification.
My passwordbox c# code
```
public void textBox2_TextInput(object sender, TextCompositionEventArgs e)
{
//pass = textBox2.ToString();
}
```
and the xaml code
```
<PasswordBox Name="textBox2"
PasswordCha... | 2012/03/16 | [
"https://Stackoverflow.com/questions/9731866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1151462/"
] | Putting some work on a background thread is easy: fire off your block with `dispatch_async()`, `-[NSOperationQueue addOperationWithBlock:]`, or possibly even something related to the server connection you're using, like `+[NSURLConnection sendAsynchronousRequest:queue:completionHandler:]`. (Look up any of those in the ... | The block that you're passing is an object that the server will execute at some point. If you want the block to be executed on a different thread, you'll need to change SomeServer's implementation of `-doServerCallCallback:`.
See the [*Grand Central Dispatch Reference*](https://developer.apple.com/library/mac/#documen... |
29,989,854 | I am iterating a JavaScript array object. I have written a function which iterates the array element. it works but above the result there is written 'undefined'. I don't want to see this, it would be great help to know how to solve this undefine word thing.
```js
var userlist = [{
"username": "Tom",
"Current... | 2015/05/01 | [
"https://Stackoverflow.com/questions/29989854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1080145/"
] | You need to initialize your valiable `text` to an empty string, like this:
```
var text = "";
```
Uninitialized variables in JavaScript default to the special value [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined), which is found as text in the concatenation.
... | It's because you haven't initialised your variable:
```
var text; //text is undefined at this point
for (var i = 0; i < user.length; i++)
{
//the first iteration of the loop will append to "undefined"
text+="<li>"+ user[i].username+"</li>";
};
```
Simply give it an initial value:
```
var text = '';
for (v... |
47,157,832 | I have a maxtrix data which shape is 10201\*101,and only contains 0 and 1. the codes below is same peocession by matlab/python,but it get different result,I don't know why...
```
BOUND = load('C:\Users\1\Desktop\ct06\result_data116.dat');
BOUND = reshape(BOUND,101,101,101);
BOUND(:,:,[1,101]) = 1;
BOU... | 2017/11/07 | [
"https://Stackoverflow.com/questions/47157832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8057143/"
] | Matlab uses column major ordering, while python uses row major (read <https://en.wikipedia.org/wiki/Row-_and_column-major_order> for more details on what this means). As an example, in python
```
t = np.eye(3)
t[0,1] = 3
np.reshape(t, (9, 1))
```
results in
```
array([[ 1.],
[ 3.],
[ 0.],
[ 0.],
[ 1.],... | The likely cause is that Matlab uses column-major order, so when you do
```
BOUND[:,[0,100],:] = 1
```
the behavior is different in Matlab and Python. |
59,202,279 | Given:
```
const a = () => true
const b = () => false
const t = [a, b]
```
How can I generate an additive AND:
`a() && b()`
In this case, it would return `false`. | 2019/12/05 | [
"https://Stackoverflow.com/questions/59202279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6402561/"
] | You could reduce the array by using `true` as *startValue* and perform a [logical AND `&&`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_AND) by using the result of the function call.
This approach keeps the value of the function calls.
```js
const a = () => tr... | Use [`array.every()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every):
```js
const a = () => true
const b = () => false
const t = [a, b]
console.log(t.every(f => f()));
```
This will only produce a boolean value, so if you were intending to get a different result as ... |
59,202,279 | Given:
```
const a = () => true
const b = () => false
const t = [a, b]
```
How can I generate an additive AND:
`a() && b()`
In this case, it would return `false`. | 2019/12/05 | [
"https://Stackoverflow.com/questions/59202279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6402561/"
] | Use [`array.every()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every):
```js
const a = () => true
const b = () => false
const t = [a, b]
console.log(t.every(f => f()));
```
This will only produce a boolean value, so if you were intending to get a different result as ... | Use `Array.find()` to get the 1st function with a falsy value. If none found, take the last function in the array, and if the array is empty use the fallback function that returns `undefined`. Invoke the function that you got.
```js
const fn = arr => (
arr.find(f => !f()) || arr[arr.length - 1] || (() => undefined)... |
59,202,279 | Given:
```
const a = () => true
const b = () => false
const t = [a, b]
```
How can I generate an additive AND:
`a() && b()`
In this case, it would return `false`. | 2019/12/05 | [
"https://Stackoverflow.com/questions/59202279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6402561/"
] | You could reduce the array by using `true` as *startValue* and perform a [logical AND `&&`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_AND) by using the result of the function call.
This approach keeps the value of the function calls.
```js
const a = () => tr... | In your case, using `a() && b()` will work perfectly. If you want to use the `t` array, you can do it like this: `t[0]() && t[1]()`. However, if you want multiple inputs, I think it would be good to use an array function (`Array.prototype.reduce`):
```js
t.reduce((previous, item) => previous && item(), true)
``` |
59,202,279 | Given:
```
const a = () => true
const b = () => false
const t = [a, b]
```
How can I generate an additive AND:
`a() && b()`
In this case, it would return `false`. | 2019/12/05 | [
"https://Stackoverflow.com/questions/59202279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6402561/"
] | You could reduce the array by using `true` as *startValue* and perform a [logical AND `&&`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_AND) by using the result of the function call.
This approach keeps the value of the function calls.
```js
const a = () => tr... | Use `Array.find()` to get the 1st function with a falsy value. If none found, take the last function in the array, and if the array is empty use the fallback function that returns `undefined`. Invoke the function that you got.
```js
const fn = arr => (
arr.find(f => !f()) || arr[arr.length - 1] || (() => undefined)... |
59,202,279 | Given:
```
const a = () => true
const b = () => false
const t = [a, b]
```
How can I generate an additive AND:
`a() && b()`
In this case, it would return `false`. | 2019/12/05 | [
"https://Stackoverflow.com/questions/59202279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6402561/"
] | In your case, using `a() && b()` will work perfectly. If you want to use the `t` array, you can do it like this: `t[0]() && t[1]()`. However, if you want multiple inputs, I think it would be good to use an array function (`Array.prototype.reduce`):
```js
t.reduce((previous, item) => previous && item(), true)
``` | Use `Array.find()` to get the 1st function with a falsy value. If none found, take the last function in the array, and if the array is empty use the fallback function that returns `undefined`. Invoke the function that you got.
```js
const fn = arr => (
arr.find(f => !f()) || arr[arr.length - 1] || (() => undefined)... |
22,118,546 | I'm trying to do something like this:
Input:
```
"a | b"
"a|b"
"a| b"
"a |b"
```
Output for all of above Inputs must be:
```
"a | b"
```
I tried lots of things but couldn't achieve what I meant for. | 2014/03/01 | [
"https://Stackoverflow.com/questions/22118546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1079221/"
] | I dont think you need regex for this.
```
var parts = myString.Split('|').Select(p => p.Trim());
var result = string.Join(" | ", parts);
```
As @I4V's answer shows you can split on carriage return line feed, then handle each row.
To use my answer in this way try this:
```
var splitLines = input.Split("\r\n".ToChar... | >
> this happens many times in a multi-line text (Commented on a deleted answer)
>
>
>
```
string input =
@"a | b
a|b
a| b
a |b";
var result =
String.Join(Environment.NewLine,
input.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
.Select(line => S... |
22,118,546 | I'm trying to do something like this:
Input:
```
"a | b"
"a|b"
"a| b"
"a |b"
```
Output for all of above Inputs must be:
```
"a | b"
```
I tried lots of things but couldn't achieve what I meant for. | 2014/03/01 | [
"https://Stackoverflow.com/questions/22118546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1079221/"
] | This one will do as well:
```
input = Regex.Replace(input, "\\s*\\|\\s*", " | ");
``` | I dont think you need regex for this.
```
var parts = myString.Split('|').Select(p => p.Trim());
var result = string.Join(" | ", parts);
```
As @I4V's answer shows you can split on carriage return line feed, then handle each row.
To use my answer in this way try this:
```
var splitLines = input.Split("\r\n".ToChar... |
22,118,546 | I'm trying to do something like this:
Input:
```
"a | b"
"a|b"
"a| b"
"a |b"
```
Output for all of above Inputs must be:
```
"a | b"
```
I tried lots of things but couldn't achieve what I meant for. | 2014/03/01 | [
"https://Stackoverflow.com/questions/22118546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1079221/"
] | I dont think you need regex for this.
```
var parts = myString.Split('|').Select(p => p.Trim());
var result = string.Join(" | ", parts);
```
As @I4V's answer shows you can split on carriage return line feed, then handle each row.
To use my answer in this way try this:
```
var splitLines = input.Split("\r\n".ToChar... | you can try this
```
Regex.Replace(str, "([a-zA-Z]+)(\s*)\|(\s*)([a-zA-Z]+)", "$1 | $4");
```
I may be mistaking about $1,$4 location. It may be "$4 | $5". Though it is not complete answer but may be close. |
22,118,546 | I'm trying to do something like this:
Input:
```
"a | b"
"a|b"
"a| b"
"a |b"
```
Output for all of above Inputs must be:
```
"a | b"
```
I tried lots of things but couldn't achieve what I meant for. | 2014/03/01 | [
"https://Stackoverflow.com/questions/22118546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1079221/"
] | This one will do as well:
```
input = Regex.Replace(input, "\\s*\\|\\s*", " | ");
``` | >
> this happens many times in a multi-line text (Commented on a deleted answer)
>
>
>
```
string input =
@"a | b
a|b
a| b
a |b";
var result =
String.Join(Environment.NewLine,
input.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
.Select(line => S... |
22,118,546 | I'm trying to do something like this:
Input:
```
"a | b"
"a|b"
"a| b"
"a |b"
```
Output for all of above Inputs must be:
```
"a | b"
```
I tried lots of things but couldn't achieve what I meant for. | 2014/03/01 | [
"https://Stackoverflow.com/questions/22118546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1079221/"
] | you can try this
```
Regex.Replace(str, "([a-zA-Z]+)(\s*)\|(\s*)([a-zA-Z]+)", "$1 | $4");
```
I may be mistaking about $1,$4 location. It may be "$4 | $5". Though it is not complete answer but may be close. | >
> this happens many times in a multi-line text (Commented on a deleted answer)
>
>
>
```
string input =
@"a | b
a|b
a| b
a |b";
var result =
String.Join(Environment.NewLine,
input.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
.Select(line => S... |
22,118,546 | I'm trying to do something like this:
Input:
```
"a | b"
"a|b"
"a| b"
"a |b"
```
Output for all of above Inputs must be:
```
"a | b"
```
I tried lots of things but couldn't achieve what I meant for. | 2014/03/01 | [
"https://Stackoverflow.com/questions/22118546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1079221/"
] | This one will do as well:
```
input = Regex.Replace(input, "\\s*\\|\\s*", " | ");
``` | you can try this
```
Regex.Replace(str, "([a-zA-Z]+)(\s*)\|(\s*)([a-zA-Z]+)", "$1 | $4");
```
I may be mistaking about $1,$4 location. It may be "$4 | $5". Though it is not complete answer but may be close. |
5,328 | I'm learning Sagang Textbook, and in the book has a homework like that:
"Read the following summary, find the mistakes and correct them (3 things)
>
> 지훈 씨는 서울 식당에 가 봤어요. 서울 식당은 일식집이에요. 특히 비빔밥이 아주 맛있어요. 그래서 마에코 씨한테 서울 식당을 소개해 줬어요. 미에코 씨는 비빔밥이 먹고 싶어서 서울 식당에 갔어요. 비빔밥 두 그릇을 시켰어요. 하지만 서울 식당 아저씨는 "하나 더 시키세요"라고 말했어요"
>
> ... | 2019/06/16 | [
"https://korean.stackexchange.com/questions/5328",
"https://korean.stackexchange.com",
"https://korean.stackexchange.com/users/1194/"
] | I am afraid to say this, but there are more than three mistakes.
First of all, 서울 식당 is used too many times, although it is *not* a *grammatical* mistake. Even if 서울 식당 is a name of a restaurant, the repetitive use of *proper names for places* seems clumsy. You may use 이 식당, 그 식당, 그곳, or 거기 in place of 서울 식당. Nonethel... | A partial answer to the “미에코 씨는 비빔밥(을/이) 먹고 싶어—” question.
==========================================================
>
> 이27
> ===
>
>
> ### Sense Ⅳ
>
>
> * (‘⸻고 싶다’ 구성에서 본동사의 **목적어**나 받침 있는 부사어 뒤에 붙어) 앞말을 지정하여 *강조하는 뜻*을 나타내는 보조사.
> * A postposition which (slightly) *emphasizes* what it follows, following **the ... |
5,328 | I'm learning Sagang Textbook, and in the book has a homework like that:
"Read the following summary, find the mistakes and correct them (3 things)
>
> 지훈 씨는 서울 식당에 가 봤어요. 서울 식당은 일식집이에요. 특히 비빔밥이 아주 맛있어요. 그래서 마에코 씨한테 서울 식당을 소개해 줬어요. 미에코 씨는 비빔밥이 먹고 싶어서 서울 식당에 갔어요. 비빔밥 두 그릇을 시켰어요. 하지만 서울 식당 아저씨는 "하나 더 시키세요"라고 말했어요"
>
> ... | 2019/06/16 | [
"https://korean.stackexchange.com/questions/5328",
"https://korean.stackexchange.com",
"https://korean.stackexchange.com/users/1194/"
] | I am afraid to say this, but there are more than three mistakes.
First of all, 서울 식당 is used too many times, although it is *not* a *grammatical* mistake. Even if 서울 식당 is a name of a restaurant, the repetitive use of *proper names for places* seems clumsy. You may use 이 식당, 그 식당, 그곳, or 거기 in place of 서울 식당. Nonethel... | First, `일식집` is Japanese restaurant but `비빔밥` is Korean food, so `...일식집이에요. 특히 비빔밥이 아주 맛있어요` is ridiculous.
Second, `그래서 마에코 씨에게 서울 식당을 소개해 줬어요` has no subject. I think it can be skipped, but it is still somewhat awkward. Same thing with 6th sentence.
Third, this one is most obvious : `...두 그릇을 시켰어요. 하지만 서울 식당 아저씨는... |
73,132,473 | Getting class as undefined for img tag in react.js
This is the component Header.jsx,
Here is the Header.jsx I'm using `<img>`, but the CSS properties are not not being implemented in the image, and I'm getting error as `class=undefined`
```
import React from 'react';
import classes from './header.css';
import { Box,Gr... | 2022/07/27 | [
"https://Stackoverflow.com/questions/73132473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18629021/"
] | Add properties listed below to your `application.properties` and application name will be appended to all your logs:
```
spring.application.name=my-spring-boot-application
logging.pattern.level= %5p [${spring.application.name}]
``` | In your application.properties you configured the name with:
```
spring.application.name=your-app-name
```
Then you can just Autowire it in with:
```
@Value("${spring.application.name}")
private String applicationName;
```
And then finally just log it:
```
LOGGER.info("Your application name: {}", applicationNam... |
5,870,809 | I have a django application and what I want to do is change wherever it says "Company id" in my templates. The thing it can be very tedious because I have to make this change in every template which says "Company id". So then I thought I might create another file that can store this entry, which the I can easy custom t... | 2011/05/03 | [
"https://Stackoverflow.com/questions/5870809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/512002/"
] | As Blender stated, you need to pass variables like this in as part of the context when you render the template. You might make a dictionary or a namedtuple that has common items stored in configuration loaded in a function.
You should also consider using template inheritance if many templates will be display the same ... | You could create a shared template and use [include](http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#include) to load it in to the main template. Then in the shared template you could load and call a [custom template tag](http://docs.djangoproject.com/en/dev/howto/custom-template-tags/) that p... |
5,870,809 | I have a django application and what I want to do is change wherever it says "Company id" in my templates. The thing it can be very tedious because I have to make this change in every template which says "Company id". So then I thought I might create another file that can store this entry, which the I can easy custom t... | 2011/05/03 | [
"https://Stackoverflow.com/questions/5870809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/512002/"
] | This is what [context processors](https://docs.djangoproject.com/en/1.11/ref/templates/api/#writing-your-own-context-processors) are for. Define your company name in settings.py, then write a context processor that imports it from there and returns it in a dictionary - it will then be available in every template (as lo... | You could create a shared template and use [include](http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#include) to load it in to the main template. Then in the shared template you could load and call a [custom template tag](http://docs.djangoproject.com/en/dev/howto/custom-template-tags/) that p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.