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 |
|---|---|---|---|---|---|
18,794,793 | How can I compare a single character from a string, and another string (which may or may not be greater than one character)
This program gives me almost 300 lines of random errors. The errors don't reference a specific line number either, just a lot of stuff about "char\* ", "", or "std::to\_string".
```
#include <io... | 2013/09/13 | [
"https://Stackoverflow.com/questions/18794793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1521753/"
] | `str[4]` is a `char` type, which will not compare with a `string`.
Compare apples with apples.
Use
```
test[0] == str[4]
```
instead. | You're mixing types. It doesn't know how to compare a string (`test`) to a char (`str[4]`).
If you change test to a `char` that will work fine. Or reference the specific character within test you want to compare such as `if (test[0] == str[4])` it should compile and run.
However, as this is merely an example and not... |
18,794,793 | How can I compare a single character from a string, and another string (which may or may not be greater than one character)
This program gives me almost 300 lines of random errors. The errors don't reference a specific line number either, just a lot of stuff about "char\* ", "", or "std::to\_string".
```
#include <io... | 2013/09/13 | [
"https://Stackoverflow.com/questions/18794793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1521753/"
] | You're comparing a char to a std::string, this is not a valid comparison.
You're looking for std::string::find, as follows:
```
if( test.find( str[4] ) != std::string::npos ) cout << test << "\n";
```
Note that this will return true if test *contains* `str[4]`. | Also you need `"D"` to be a char value not a string value if you are comparing it like that.
```
std::string myString = "Hello World";
const char *myStringChars = myString.c_str();
```
You have to turn it into a char array before can access it. Unless you do.
```
str.at(i);
```
which you can also write as
`str[... |
18,794,793 | How can I compare a single character from a string, and another string (which may or may not be greater than one character)
This program gives me almost 300 lines of random errors. The errors don't reference a specific line number either, just a lot of stuff about "char\* ", "", or "std::to\_string".
```
#include <io... | 2013/09/13 | [
"https://Stackoverflow.com/questions/18794793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1521753/"
] | You need to convert str[4] (which is a char) to a string before you can compare it to another string. Here's a simple way to do this
```
if (test == string(1, str[4])) {
``` | You're comparing a char to a std::string, this is not a valid comparison.
You're looking for std::string::find, as follows:
```
if( test.find( str[4] ) != std::string::npos ) cout << test << "\n";
```
Note that this will return true if test *contains* `str[4]`. |
18,794,793 | How can I compare a single character from a string, and another string (which may or may not be greater than one character)
This program gives me almost 300 lines of random errors. The errors don't reference a specific line number either, just a lot of stuff about "char\* ", "", or "std::to\_string".
```
#include <io... | 2013/09/13 | [
"https://Stackoverflow.com/questions/18794793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1521753/"
] | You need to convert str[4] (which is a char) to a string before you can compare it to another string. Here's a simple way to do this
```
if (test == string(1, str[4])) {
``` | Also you need `"D"` to be a char value not a string value if you are comparing it like that.
```
std::string myString = "Hello World";
const char *myStringChars = myString.c_str();
```
You have to turn it into a char array before can access it. Unless you do.
```
str.at(i);
```
which you can also write as
`str[... |
30,127 | I've pored over the PHBs, the Rules Compendium, and similar questions at this site and other forums and I'm still confused about how magical weapons enhancements/properties interact with character powers and proficiency. Specifically, I've got two circumstances I need advice on.
**First case**: An invoker in my group ... | 2013/11/14 | [
"https://rpg.stackexchange.com/questions/30127",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/9816/"
] | Here are the two things to remember:
* An enhancement bonus is an enhancement bonus is an enhancement bonus.
* Proficiency only applies to `weapon` attacks.
So for your first example, the invoker would get her staff's enhancement bonus (even if it's an enchanted quarterstaff (with a weapon enchantment) rather than an... | **First case**
*An invoker in my group has a +1 Staff of Earthen Might. Since her class is proficient with staffs, I know that any implement power she uses this with will apply the +1 to her attack and damage rolls with such powers. I get that.*
That is correct.
*Am I correct, though, that the +2 proficiency bonus f... |
30,127 | I've pored over the PHBs, the Rules Compendium, and similar questions at this site and other forums and I'm still confused about how magical weapons enhancements/properties interact with character powers and proficiency. Specifically, I've got two circumstances I need advice on.
**First case**: An invoker in my group ... | 2013/11/14 | [
"https://rpg.stackexchange.com/questions/30127",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/9816/"
] | There are three issues here, I think: Keywords, the two different kinds of proficiency, and permission by omission.
But before I go into those, a word: As always there are explicit features/feats/enchantments which break the rules, and that's why we call D&D an "exception-based" system: it deals in rules which apply u... | Here are the two things to remember:
* An enhancement bonus is an enhancement bonus is an enhancement bonus.
* Proficiency only applies to `weapon` attacks.
So for your first example, the invoker would get her staff's enhancement bonus (even if it's an enchanted quarterstaff (with a weapon enchantment) rather than an... |
30,127 | I've pored over the PHBs, the Rules Compendium, and similar questions at this site and other forums and I'm still confused about how magical weapons enhancements/properties interact with character powers and proficiency. Specifically, I've got two circumstances I need advice on.
**First case**: An invoker in my group ... | 2013/11/14 | [
"https://rpg.stackexchange.com/questions/30127",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/9816/"
] | There are three issues here, I think: Keywords, the two different kinds of proficiency, and permission by omission.
But before I go into those, a word: As always there are explicit features/feats/enchantments which break the rules, and that's why we call D&D an "exception-based" system: it deals in rules which apply u... | **First case**
*An invoker in my group has a +1 Staff of Earthen Might. Since her class is proficient with staffs, I know that any implement power she uses this with will apply the +1 to her attack and damage rolls with such powers. I get that.*
That is correct.
*Am I correct, though, that the +2 proficiency bonus f... |
39,973 | I know the differences between a **rangefinder** and a **SLR/DSLR** but what is the real reason to put a mirror in front of a lens to reflect light into the viewfinder?
It raises lens prooduction price when you put extra distance between lens and sensor. So why do that? Does it improve image quality somehow? Isn't it... | 2013/06/09 | [
"https://photo.stackexchange.com/questions/39973",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/17818/"
] | Simple, it allows you to see exactly what the camera will "see" when you expose the shot.
Nir has given you a part of the argument as well which is accuracy.
In the "middle ground" of anything around mabye 20-100mm, building a rangefinder is not too difficult and Leica had adapters for longer and wider lenses if I am ... | Simple — you can't make an exchangeable lens rangefinder where the viewfinder is even remotely accurate. (Well, you can't without digital technology and live view — and then the mirrorless cameras makes more sense than rangefinders.) |
39,973 | I know the differences between a **rangefinder** and a **SLR/DSLR** but what is the real reason to put a mirror in front of a lens to reflect light into the viewfinder?
It raises lens prooduction price when you put extra distance between lens and sensor. So why do that? Does it improve image quality somehow? Isn't it... | 2013/06/09 | [
"https://photo.stackexchange.com/questions/39973",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/17818/"
] | Simple, it allows you to see exactly what the camera will "see" when you expose the shot.
Nir has given you a part of the argument as well which is accuracy.
In the "middle ground" of anything around mabye 20-100mm, building a rangefinder is not too difficult and Leica had adapters for longer and wider lenses if I am ... | Its tradition. When we had film cameras, a mirror system was used to give the photographer an accurate image of what the lens was seeing irrespective of which lens was attached. Obviously one could have a system with a live viewer. Old time photographers are used to looking in a view finder and composing an image. |
2,862,698 | I'm still learning undergraduate probability. I was asked this probability puzzle in a recent quantitative developer interview. I solved the first part of the question, using brute-force. I think, brute-force very quickly becomes unwieldy for the sequence ending $THH$ - not sure if my answer is correct.
>
> A coin i... | 2018/07/25 | [
"https://math.stackexchange.com/questions/2862698",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/247892/"
] | Note: the only way you can possibly get $HHT$ before $THH$ is if the first two tosses are $HH$.
Pf: Suppose you get $HHT$ first. Then look at the first occurrence of $HHT$. Go back through the sequence. If you ever encounter a $T$, you must have $THH$ starting with the first $T$ you find. Thus, you can never find a $... | >
> A coin is flipped infinitely until you or I win. If at any point, the last three tosses in the sequence are $HHT$, I win. If at any point, the last three tosses in the sequence are $THH$, you win. Which sequence is more likely?
>
>
>
Hint: if and only if the first two tosses are $HH$, player 1 wins. In all oth... |
36,123,740 | Tensorflow tends to preallocate the entire available memory on it's GPUs. For debugging, is there a way of telling how much of that memory is actually in use? | 2016/03/21 | [
"https://Stackoverflow.com/questions/36123740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/349760/"
] | Here's a practical solution that worked well for me:
Disable GPU memory pre-allocation using TF session configuration:
```
config = tf.ConfigProto()
config.gpu_options.allow_growth=True
sess = tf.Session(config=config)
```
run **nvidia-smi -l** (or some other utility) to monitor GPU memory consumption.
Ste... | The TensorFlow profiler has improved memory timeline that is based on real gpu memory allocator information
<https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler#visualize-time-and-memory> |
36,123,740 | Tensorflow tends to preallocate the entire available memory on it's GPUs. For debugging, is there a way of telling how much of that memory is actually in use? | 2016/03/21 | [
"https://Stackoverflow.com/questions/36123740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/349760/"
] | (1) There is some limited support with [Timeline](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/client/timeline.py) for logging memory allocations. Here is an example for its usage:
```
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
... | ```
tf.config.experimental.get_memory_info('GPU:0')
```
Currently returns the following keys:
```
'current': The current memory used by the device, in bytes.
'peak': The peak memory used by the device across the run of the program, in bytes.
``` |
36,123,740 | Tensorflow tends to preallocate the entire available memory on it's GPUs. For debugging, is there a way of telling how much of that memory is actually in use? | 2016/03/21 | [
"https://Stackoverflow.com/questions/36123740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/349760/"
] | There's some code in `tensorflow.contrib.memory_stats` that will help with this:
```
from tensorflow.contrib.memory_stats.python.ops.memory_stats_ops import BytesInUse
with tf.device('/device:GPU:0'): # Replace with device you are interested in
bytes_in_use = BytesInUse()
with tf.Session() as sess:
print(sess.run... | The TensorFlow profiler has improved memory timeline that is based on real gpu memory allocator information
<https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler#visualize-time-and-memory> |
36,123,740 | Tensorflow tends to preallocate the entire available memory on it's GPUs. For debugging, is there a way of telling how much of that memory is actually in use? | 2016/03/21 | [
"https://Stackoverflow.com/questions/36123740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/349760/"
] | (1) There is some limited support with [Timeline](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/client/timeline.py) for logging memory allocations. Here is an example for its usage:
```
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
... | The TensorFlow profiler has improved memory timeline that is based on real gpu memory allocator information
<https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler#visualize-time-and-memory> |
36,123,740 | Tensorflow tends to preallocate the entire available memory on it's GPUs. For debugging, is there a way of telling how much of that memory is actually in use? | 2016/03/21 | [
"https://Stackoverflow.com/questions/36123740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/349760/"
] | (1) There is some limited support with [Timeline](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/client/timeline.py) for logging memory allocations. Here is an example for its usage:
```
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
... | Here's a practical solution that worked well for me:
Disable GPU memory pre-allocation using TF session configuration:
```
config = tf.ConfigProto()
config.gpu_options.allow_growth=True
sess = tf.Session(config=config)
```
run **nvidia-smi -l** (or some other utility) to monitor GPU memory consumption.
Ste... |
36,123,740 | Tensorflow tends to preallocate the entire available memory on it's GPUs. For debugging, is there a way of telling how much of that memory is actually in use? | 2016/03/21 | [
"https://Stackoverflow.com/questions/36123740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/349760/"
] | The TensorFlow profiler has improved memory timeline that is based on real gpu memory allocator information
<https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler#visualize-time-and-memory> | as @V.M previously mentioned, a solution that works well is using: `tf.config.experimental.get_memory_info('DEVICE_NAME')`
This function returns a dictionary with two keys:
* **'current'**: The current memory used by the device, in bytes
* **'peak'**: The peak memory used by the device across the run of the program, ... |
36,123,740 | Tensorflow tends to preallocate the entire available memory on it's GPUs. For debugging, is there a way of telling how much of that memory is actually in use? | 2016/03/21 | [
"https://Stackoverflow.com/questions/36123740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/349760/"
] | Here's a practical solution that worked well for me:
Disable GPU memory pre-allocation using TF session configuration:
```
config = tf.ConfigProto()
config.gpu_options.allow_growth=True
sess = tf.Session(config=config)
```
run **nvidia-smi -l** (or some other utility) to monitor GPU memory consumption.
Ste... | as @V.M previously mentioned, a solution that works well is using: `tf.config.experimental.get_memory_info('DEVICE_NAME')`
This function returns a dictionary with two keys:
* **'current'**: The current memory used by the device, in bytes
* **'peak'**: The peak memory used by the device across the run of the program, ... |
36,123,740 | Tensorflow tends to preallocate the entire available memory on it's GPUs. For debugging, is there a way of telling how much of that memory is actually in use? | 2016/03/21 | [
"https://Stackoverflow.com/questions/36123740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/349760/"
] | There's some code in `tensorflow.contrib.memory_stats` that will help with this:
```
from tensorflow.contrib.memory_stats.python.ops.memory_stats_ops import BytesInUse
with tf.device('/device:GPU:0'): # Replace with device you are interested in
bytes_in_use = BytesInUse()
with tf.Session() as sess:
print(sess.run... | as @V.M previously mentioned, a solution that works well is using: `tf.config.experimental.get_memory_info('DEVICE_NAME')`
This function returns a dictionary with two keys:
* **'current'**: The current memory used by the device, in bytes
* **'peak'**: The peak memory used by the device across the run of the program, ... |
36,123,740 | Tensorflow tends to preallocate the entire available memory on it's GPUs. For debugging, is there a way of telling how much of that memory is actually in use? | 2016/03/21 | [
"https://Stackoverflow.com/questions/36123740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/349760/"
] | (1) There is some limited support with [Timeline](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/client/timeline.py) for logging memory allocations. Here is an example for its usage:
```
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
... | as @V.M previously mentioned, a solution that works well is using: `tf.config.experimental.get_memory_info('DEVICE_NAME')`
This function returns a dictionary with two keys:
* **'current'**: The current memory used by the device, in bytes
* **'peak'**: The peak memory used by the device across the run of the program, ... |
36,123,740 | Tensorflow tends to preallocate the entire available memory on it's GPUs. For debugging, is there a way of telling how much of that memory is actually in use? | 2016/03/21 | [
"https://Stackoverflow.com/questions/36123740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/349760/"
] | Here's a practical solution that worked well for me:
Disable GPU memory pre-allocation using TF session configuration:
```
config = tf.ConfigProto()
config.gpu_options.allow_growth=True
sess = tf.Session(config=config)
```
run **nvidia-smi -l** (or some other utility) to monitor GPU memory consumption.
Ste... | ```
tf.config.experimental.get_memory_info('GPU:0')
```
Currently returns the following keys:
```
'current': The current memory used by the device, in bytes.
'peak': The peak memory used by the device across the run of the program, in bytes.
``` |
36,501,768 | At our .NET front-end we are using ticks to handle time localization and at the database we are storing all values in UTC. Today we came across an odd rounding error when storing records to the database, we are using the following formula to convert Ticks to a datetime.
```
CAST((@ticks - 599266080000000000) / 1000000... | 2016/04/08 | [
"https://Stackoverflow.com/questions/36501768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3048845/"
] | If you capture your calculation in a sql\_variant you can determine what type it is. In your case the calculation uses a numeric type which is not an exact datatype and this is where the rounding is occurring:
```
DECLARE @myVar sql_variant = (@Ticks - 599266080000000000) / 10000000 / 24 / 60 / 60
SELECT SQL_VARIANT... | I found the following works:
```
DECLARE @ticks bigint = 635953248000000000; -- 2016-04-04 00:00:00.000
SELECT DATEADD(s,(@ticks %CONVERT(BIGINT,864000000000))/CONVERT(BIGINT,10000000),DATEADD(d,@ticks /CONVERT(BIGINT,864000000000)-CONVERT(BIGINT,639905),CONVERT(DATETIME,'1/1/1753')))
-- Results in 2016-04-04 00:0... |
36,501,768 | At our .NET front-end we are using ticks to handle time localization and at the database we are storing all values in UTC. Today we came across an odd rounding error when storing records to the database, we are using the following formula to convert Ticks to a datetime.
```
CAST((@ticks - 599266080000000000) / 1000000... | 2016/04/08 | [
"https://Stackoverflow.com/questions/36501768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3048845/"
] | If you capture your calculation in a sql\_variant you can determine what type it is. In your case the calculation uses a numeric type which is not an exact datatype and this is where the rounding is occurring:
```
DECLARE @myVar sql_variant = (@Ticks - 599266080000000000) / 10000000 / 24 / 60 / 60
SELECT SQL_VARIANT... | The problem comes about because `datetime` does not have the precision to store values down to the millisecond:
>
> datetime values are rounded to increments of .000, .003, or .007 seconds
>
>
>
[Source](https://msdn.microsoft.com/en-gb/library/ms187819.aspx)
Your value comes out as `42462.000000000000000000` wh... |
66,389 | Let $G$ be an ample $\mathbb{Q}$-divisor on a smooth variety $X$. Let $D$ be a $\mathbb{Q}$-divisor linearly equivalent to $G$. Let $f: Y\to X$ be a common log resolution of $G$ and $D$. We define the multiplier ideal of a divisor $G$ as $I(G)=f\_\*O\_Y(K\_{Y/X}-[f^\*G])$. Are the multiplier ideals $I(G)$ and $I((1-t)G... | 2011/05/29 | [
"https://mathoverflow.net/questions/66389",
"https://mathoverflow.net",
"https://mathoverflow.net/users/2348/"
] | I don't think so. Take for example $X=\mathbb{P}^2$, and $G$ and $D$ to be distinct lines.
then $I(G)=\mathcal{O}\_X(-G)$ while $I((1-t)g+tD)=\mathcal{O}\_X$ for every small $t>0$.
Maybe you might want to look at the multiplier ideal associated to the linear series $|G|$. | Think about it this way: The co-support of the multiplier ideal of $G$ is the locus where the pair $(X,G)$ has worse than klt singularities. If $(X,G)$ has non-klt singularities, say because some of its coefficients are at least $1$, and $(X,D)$ is dlt, then some of the small perturbations will likely be still klt, so ... |
66,389 | Let $G$ be an ample $\mathbb{Q}$-divisor on a smooth variety $X$. Let $D$ be a $\mathbb{Q}$-divisor linearly equivalent to $G$. Let $f: Y\to X$ be a common log resolution of $G$ and $D$. We define the multiplier ideal of a divisor $G$ as $I(G)=f\_\*O\_Y(K\_{Y/X}-[f^\*G])$. Are the multiplier ideals $I(G)$ and $I((1-t)G... | 2011/05/29 | [
"https://mathoverflow.net/questions/66389",
"https://mathoverflow.net",
"https://mathoverflow.net/users/2348/"
] | I don't think so. Take for example $X=\mathbb{P}^2$, and $G$ and $D$ to be distinct lines.
then $I(G)=\mathcal{O}\_X(-G)$ while $I((1-t)g+tD)=\mathcal{O}\_X$ for every small $t>0$.
Maybe you might want to look at the multiplier ideal associated to the linear series $|G|$. | However, I should point out that one always has the multiplier ideal containment
$$I((1−t)G+tD) \supseteq I(G)$$ for $t > 0$ sufficiently small.
In particular, the singularities of $(X, (1-t)G + tD)$ can only be epsilon more severe than the singularities of the pair $(X, G)$, thus the multiplier ideal won't get smalle... |
44,200,737 | I need to remove all occurring patterns except 1, but I haven't been able to get this working in a Bash script.
I tried
```
sed -e 's/ /\\ /g' -e 's/\\ / /1'
```
and
```
sed ':a;s/\([^ ]* .*[^\\]\) \(.*\)/\1\\ \2/;ta'
```
but neither do have the desired effect unfortunately.
Is someone able to help me out?
T... | 2017/05/26 | [
"https://Stackoverflow.com/questions/44200737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7487227/"
] | **Plain Mockito library**
```
import org.mockito.Mock;
...
@Mock
MyService myservice;
```
and
```
import org.mockito.Mockito;
...
MyService myservice = Mockito.mock(MyService.class);
```
come from the Mockito library and are functionally equivalent.
They allow to mock a class or an interface and to record a... | At the end its easy to explain. If you just look into the javadocs of the annotations you will see the differences:
@Mock: (`org.mockito.Mock`)
>
> Mark a field as a mock.
>
>
>
>
> * Allows shorthand mock creation.
> * Minimizes repetitive mock creation code.
> * Makes the test class more readable.
> * Makes t... |
44,200,737 | I need to remove all occurring patterns except 1, but I haven't been able to get this working in a Bash script.
I tried
```
sed -e 's/ /\\ /g' -e 's/\\ / /1'
```
and
```
sed ':a;s/\([^ ]* .*[^\\]\) \(.*\)/\1\\ \2/;ta'
```
but neither do have the desired effect unfortunately.
Is someone able to help me out?
T... | 2017/05/26 | [
"https://Stackoverflow.com/questions/44200737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7487227/"
] | At the end its easy to explain. If you just look into the javadocs of the annotations you will see the differences:
@Mock: (`org.mockito.Mock`)
>
> Mark a field as a mock.
>
>
>
>
> * Allows shorthand mock creation.
> * Minimizes repetitive mock creation code.
> * Makes the test class more readable.
> * Makes t... | Mocktio.mock() :-
1. Will create a mock object of either class or interface. We can use
this mock to stub the return values and verify if they are called.
2. We must use the `when(..)` and `thenReturn(..)` methods for mock objects
whose class methods will be invoked during test case execution.
`@Mock` :-
1. This is ... |
44,200,737 | I need to remove all occurring patterns except 1, but I haven't been able to get this working in a Bash script.
I tried
```
sed -e 's/ /\\ /g' -e 's/\\ / /1'
```
and
```
sed ':a;s/\([^ ]* .*[^\\]\) \(.*\)/\1\\ \2/;ta'
```
but neither do have the desired effect unfortunately.
Is someone able to help me out?
T... | 2017/05/26 | [
"https://Stackoverflow.com/questions/44200737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7487227/"
] | **Plain Mockito library**
```
import org.mockito.Mock;
...
@Mock
MyService myservice;
```
and
```
import org.mockito.Mockito;
...
MyService myservice = Mockito.mock(MyService.class);
```
come from the Mockito library and are functionally equivalent.
They allow to mock a class or an interface and to record a... | Mocktio.mock() :-
1. Will create a mock object of either class or interface. We can use
this mock to stub the return values and verify if they are called.
2. We must use the `when(..)` and `thenReturn(..)` methods for mock objects
whose class methods will be invoked during test case execution.
`@Mock` :-
1. This is ... |
28,022,091 | I never wrote any complex regular expression before, and what I need seems to be (at least) a bit complicated.
I need a Regex to find matches for the following:
```
"On Fri, Jan 16, 2015 at 4:39 PM"
```
Where `On` will always be there;
then 3 characters for week day;
`,` is always there;
space is always there;
... | 2015/01/19 | [
"https://Stackoverflow.com/questions/28022091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1772830/"
] | You could try the below regex and it won't check for the month name or day name or date.
```
^On\s[A-Z][a-z]{2},\s[A-Z][a-z]{2}\s\d{1,2},\s\d{4}\sat\s(?:10|4):39\s[AP]M$
```
[DEMO](http://www.rubular.com/r/yQcktbdo8t) | You can use [Rubular](http://rubular.com) to construct and test Ruby Regular Expressions.
I have put together an Example: <http://rubular.com/r/45RIiwheqs>
Since it looks you try to parse dates, you should use [Date.strptime](http://ruby-doc.org/stdlib-2.2.0/libdoc/date/rdoc/Date.html#method-c-strptime). |
28,022,091 | I never wrote any complex regular expression before, and what I need seems to be (at least) a bit complicated.
I need a Regex to find matches for the following:
```
"On Fri, Jan 16, 2015 at 4:39 PM"
```
Where `On` will always be there;
then 3 characters for week day;
`,` is always there;
space is always there;
... | 2015/01/19 | [
"https://Stackoverflow.com/questions/28022091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1772830/"
] | Try this:
```
On\s+(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (?:Jan|Feb|Mar|Apr|May|June|July|Aug|Sept|Oct|Nov|Dec) \d{1,2}, \d{4} at \d{1,2}:\d{2} (?:AM|PM)
```
 | /On [A-Za-z]{3}, [A-Za-z]{3} \d{1,2}, \d{4} at \d{1,2}:\d{1,2}/g |
28,022,091 | I never wrote any complex regular expression before, and what I need seems to be (at least) a bit complicated.
I need a Regex to find matches for the following:
```
"On Fri, Jan 16, 2015 at 4:39 PM"
```
Where `On` will always be there;
then 3 characters for week day;
`,` is always there;
space is always there;
... | 2015/01/19 | [
"https://Stackoverflow.com/questions/28022091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1772830/"
] | Try this:
```
On\s+(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (?:Jan|Feb|Mar|Apr|May|June|July|Aug|Sept|Oct|Nov|Dec) \d{1,2}, \d{4} at \d{1,2}:\d{2} (?:AM|PM)
```
 | ```
/On \w{3}, \w{3} \d{1,2}, \d{4} at \d{1,2}:\d{1,2} [A-Z]{2}/
# \w{3} for 3 charecters
# \d{1,2} for a or 2 digits
# \d{4} for 4 digits
# [A-Z]{2} for 2 capital leters
``` |
28,022,091 | I never wrote any complex regular expression before, and what I need seems to be (at least) a bit complicated.
I need a Regex to find matches for the following:
```
"On Fri, Jan 16, 2015 at 4:39 PM"
```
Where `On` will always be there;
then 3 characters for week day;
`,` is always there;
space is always there;
... | 2015/01/19 | [
"https://Stackoverflow.com/questions/28022091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1772830/"
] | ```
/On \w{3}, \w{3} \d{1,2}, \d{4} at \d{1,2}:\d{1,2} [A-Z]{2}/
# \w{3} for 3 charecters
# \d{1,2} for a or 2 digits
# \d{4} for 4 digits
# [A-Z]{2} for 2 capital leters
``` | You can use [Rubular](http://rubular.com) to construct and test Ruby Regular Expressions.
I have put together an Example: <http://rubular.com/r/45RIiwheqs>
Since it looks you try to parse dates, you should use [Date.strptime](http://ruby-doc.org/stdlib-2.2.0/libdoc/date/rdoc/Date.html#method-c-strptime). |
28,022,091 | I never wrote any complex regular expression before, and what I need seems to be (at least) a bit complicated.
I need a Regex to find matches for the following:
```
"On Fri, Jan 16, 2015 at 4:39 PM"
```
Where `On` will always be there;
then 3 characters for week day;
`,` is always there;
space is always there;
... | 2015/01/19 | [
"https://Stackoverflow.com/questions/28022091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1772830/"
] | You could try the below regex and it won't check for the month name or day name or date.
```
^On\s[A-Z][a-z]{2},\s[A-Z][a-z]{2}\s\d{1,2},\s\d{4}\sat\s(?:10|4):39\s[AP]M$
```
[DEMO](http://www.rubular.com/r/yQcktbdo8t) | The way you are describing the problem makes me thing that the format will always be preserved.
I would then in your case use the `Time.parse` function, passing the format string
```
format = "On %a, %b"On Fri, Jan 16, 2015 at 4:39 PM", format)
```
which is more readable than a regexp (in my opinion) and has the ad... |
28,022,091 | I never wrote any complex regular expression before, and what I need seems to be (at least) a bit complicated.
I need a Regex to find matches for the following:
```
"On Fri, Jan 16, 2015 at 4:39 PM"
```
Where `On` will always be there;
then 3 characters for week day;
`,` is always there;
space is always there;
... | 2015/01/19 | [
"https://Stackoverflow.com/questions/28022091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1772830/"
] | ```
/On \w{3}, \w{3} \d{1,2}, \d{4} at \d{1,2}:\d{1,2} [A-Z]{2}/
# \w{3} for 3 charecters
# \d{1,2} for a or 2 digits
# \d{4} for 4 digits
# [A-Z]{2} for 2 capital leters
``` | The way you are describing the problem makes me thing that the format will always be preserved.
I would then in your case use the `Time.parse` function, passing the format string
```
format = "On %a, %b"On Fri, Jan 16, 2015 at 4:39 PM", format)
```
which is more readable than a regexp (in my opinion) and has the ad... |
28,022,091 | I never wrote any complex regular expression before, and what I need seems to be (at least) a bit complicated.
I need a Regex to find matches for the following:
```
"On Fri, Jan 16, 2015 at 4:39 PM"
```
Where `On` will always be there;
then 3 characters for week day;
`,` is always there;
space is always there;
... | 2015/01/19 | [
"https://Stackoverflow.com/questions/28022091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1772830/"
] | Here's a very simple and readable one:
```
/On \w{3}, \w{3} \d{1,2}, \d{4} at \d{1,2}:\d{2} [AP]M/
```
[See it on rubular](http://rubular.com/r/CxkKy6h4Y9) | The way you are describing the problem makes me thing that the format will always be preserved.
I would then in your case use the `Time.parse` function, passing the format string
```
format = "On %a, %b"On Fri, Jan 16, 2015 at 4:39 PM", format)
```
which is more readable than a regexp (in my opinion) and has the ad... |
28,022,091 | I never wrote any complex regular expression before, and what I need seems to be (at least) a bit complicated.
I need a Regex to find matches for the following:
```
"On Fri, Jan 16, 2015 at 4:39 PM"
```
Where `On` will always be there;
then 3 characters for week day;
`,` is always there;
space is always there;
... | 2015/01/19 | [
"https://Stackoverflow.com/questions/28022091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1772830/"
] | ```
/On \w{3}, \w{3} \d{1,2}, \d{4} at \d{1,2}:\d{1,2} [A-Z]{2}/
# \w{3} for 3 charecters
# \d{1,2} for a or 2 digits
# \d{4} for 4 digits
# [A-Z]{2} for 2 capital leters
``` | /On [A-Za-z]{3}, [A-Za-z]{3} \d{1,2}, \d{4} at \d{1,2}:\d{1,2}/g |
28,022,091 | I never wrote any complex regular expression before, and what I need seems to be (at least) a bit complicated.
I need a Regex to find matches for the following:
```
"On Fri, Jan 16, 2015 at 4:39 PM"
```
Where `On` will always be there;
then 3 characters for week day;
`,` is always there;
space is always there;
... | 2015/01/19 | [
"https://Stackoverflow.com/questions/28022091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1772830/"
] | You could try the below regex and it won't check for the month name or day name or date.
```
^On\s[A-Z][a-z]{2},\s[A-Z][a-z]{2}\s\d{1,2},\s\d{4}\sat\s(?:10|4):39\s[AP]M$
```
[DEMO](http://www.rubular.com/r/yQcktbdo8t) | /On [A-Za-z]{3}, [A-Za-z]{3} \d{1,2}, \d{4} at \d{1,2}:\d{1,2}/g |
28,022,091 | I never wrote any complex regular expression before, and what I need seems to be (at least) a bit complicated.
I need a Regex to find matches for the following:
```
"On Fri, Jan 16, 2015 at 4:39 PM"
```
Where `On` will always be there;
then 3 characters for week day;
`,` is always there;
space is always there;
... | 2015/01/19 | [
"https://Stackoverflow.com/questions/28022091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1772830/"
] | Try this:
```
On\s+(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (?:Jan|Feb|Mar|Apr|May|June|July|Aug|Sept|Oct|Nov|Dec) \d{1,2}, \d{4} at \d{1,2}:\d{2} (?:AM|PM)
```
 | You can use [Rubular](http://rubular.com) to construct and test Ruby Regular Expressions.
I have put together an Example: <http://rubular.com/r/45RIiwheqs>
Since it looks you try to parse dates, you should use [Date.strptime](http://ruby-doc.org/stdlib-2.2.0/libdoc/date/rdoc/Date.html#method-c-strptime). |
24,283 | Reading Matthew 12:26
If Satan drives out Satan, he is divided against himself. How then can his kingdom stand?
I cant seem to pin point where is his kingdom? Evil men dont seem to be united? | 2013/12/31 | [
"https://christianity.stackexchange.com/questions/24283",
"https://christianity.stackexchange.com",
"https://christianity.stackexchange.com/users/6506/"
] | Let's take a long look at the Scriptures around your referenced Scripture:
Matthew 12:25 through 28 KJV
>
> 25 And Jesus knew their thoughts, and said unto them, Every kingdom divided against itself is brought to desolation; and every city or house divided against itself shall not stand:
>
>
> 26 And if Satan cast... | I see three questions plus the question in the quote.
**Is Satan's kingdom here on earth?** Yes, the adversary is here on earth. He was cast out when Jesus was "snatched up to God and to his throne" (Rev 12:5). Most likely his "Ascension into Heaven" (Acts 1:9-11) but possibly at his death on the Cross.
**I cant se... |
24,283 | Reading Matthew 12:26
If Satan drives out Satan, he is divided against himself. How then can his kingdom stand?
I cant seem to pin point where is his kingdom? Evil men dont seem to be united? | 2013/12/31 | [
"https://christianity.stackexchange.com/questions/24283",
"https://christianity.stackexchange.com",
"https://christianity.stackexchange.com/users/6506/"
] | Let's take a long look at the Scriptures around your referenced Scripture:
Matthew 12:25 through 28 KJV
>
> 25 And Jesus knew their thoughts, and said unto them, Every kingdom divided against itself is brought to desolation; and every city or house divided against itself shall not stand:
>
>
> 26 And if Satan cast... | This question is about spiritual world. How it is reflected within humanity? How it manifests? How a spiritual world stands?
To understand how a man can become evil man, or a good man, I will quote from Holy Tradition of Orthodoxy, where many mysteries about humanity and God where revealed to us through Holy Spirit an... |
23,032,889 | i need help, i am trying to replicate this kind of progress indicator, but i can't figure it out.
What i want:
[](https://i.stack.imgur.com/d0Ypc.png)
What i have: <http://jsfiddle.net/AQWdM/>
```css
body {
font-family: 'Segoe UI';
font-size:... | 2014/04/12 | [
"https://Stackoverflow.com/questions/23032889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3527152/"
] | You should use one pseudo rotated element and draw it on the far left side. *the first will be out of sight, so no need to worry about last `li`, set `overflow` on `ul` to hide `overflow`ing parts :).*
**[DEMO](http://codepen.io/gc-nomade/pen/FnKim/)** and CSS
```css
body {
font-family: 'Segoe UI';
font-size: 1... | [Check this out](http://jsfiddle.net/8D2Ss/1/)
Please check this and see is this what you were looking for
```
<ul class="progress">
<li><a href="">✔ Qualify</a></li>
<li class="beforeactive"><a href=""> ✔ Develop</a></li>
<li class="active"><a href="">Propose</a></li>
<li><a href="">Close</a></li>
</... |
16,214,205 | Lets say, I have Product and Score tables.
```
Product
-------
id
name
Score
-----
id
ProductId
ScoreValue
```
I want to get the top 10 Products with the highest AVERAGE scores, how do I get the average and select the top 10 products in one select statement?
here is mine which selects unexpected rows
```
SELECT ... | 2013/04/25 | [
"https://Stackoverflow.com/questions/16214205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2091346/"
] | Give this a try,
```
WITH records
AS
(
SELECT a.ID, a.Name, AVG(b.ScoreValue) avg_score,
DENSE_RANK() OVER (ORDER BY AVG(b.ScoreValue) DESC) rn
FROM Product a
INNER JOIN Score b
ON a.ID = b.ProductID
GROUP BY a.ID, a.Name
)
SELECT ID, Name, Avg_Score
FROM r... | Please try:
```
declare @Product as table (id int, name nvarchar(20))
declare @Score as table (id int, ProductID int, ScoreValue decimal(23, 5))
insert into @Product values (1, 'a'), (2, 'b'), (3, 'c')
insert into @Score values (1, 1, 25), (2, 1, 30), (3, 2, 40), (4, 2, 45), (5, 3, 3)
select
distinct top 2 nam... |
16,214,205 | Lets say, I have Product and Score tables.
```
Product
-------
id
name
Score
-----
id
ProductId
ScoreValue
```
I want to get the top 10 Products with the highest AVERAGE scores, how do I get the average and select the top 10 products in one select statement?
here is mine which selects unexpected rows
```
SELECT ... | 2013/04/25 | [
"https://Stackoverflow.com/questions/16214205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2091346/"
] | Give this a try,
```
WITH records
AS
(
SELECT a.ID, a.Name, AVG(b.ScoreValue) avg_score,
DENSE_RANK() OVER (ORDER BY AVG(b.ScoreValue) DESC) rn
FROM Product a
INNER JOIN Score b
ON a.ID = b.ProductID
GROUP BY a.ID, a.Name
)
SELECT ID, Name, Avg_Score
FROM r... | This might do it
```
SELECT TOP 10 p.ProductName, avg( s.Score ) as avg_score
FROM Product p
inner join Score s on s.product_id = p.product_id
group by p.ProductName, p.product_id
order by avg_score desc
``` |
27,470,505 | I'm using webapi2 and Castle Windsor. I'm trying to intercept calls to the ApiController to make some logging, but I can't find in the parameter the method called, url, parameters, etc. The method name returned is ExecuteAsync.
This is my interceptor call (which is hit)
```
public class LoggingInterceptor : IInte... | 2014/12/14 | [
"https://Stackoverflow.com/questions/27470505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/723059/"
] | ```
if (invocation.Method.Name == "ExecuteAsync")
{
var ctx = (HttpControllerContext) invocation.Arguments[0];
Console.WriteLine("Controller name: {0}", ctx.ControllerDescriptor.ControllerName);
Console.WriteLine("Request Uri: {0}", ctx.Request.RequestUri);
}
invocation.Proceed();
```
Intercepting the Exe... | While using ASP.NET MVC framework is possible to get the action caller from LoginInterceptor (check [this link](https://cangencer.wordpress.com/2011/06/02/asp-net-mvc-3-aspect-oriented-programming-with-castle-interceptors/)), in ASP.NET Web Api I haven't found a proper way to achieve it using interceptors with Castle W... |
207,341 | Assume this city is relatively large by late medieval standards, around 200,000 people. The city is mainly a site for trade due to its geographically central position and being on a river. Also, because it is geographically central, it also means the city is important for the government to project power.
**What might ... | 2021/07/17 | [
"https://worldbuilding.stackexchange.com/questions/207341",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/43517/"
] | ### To punish them.
Looking at your situation from a modern lens - Politicians love spending money on those who voted for them, and also those who could be plausibly convinced to vote for them. They don't like spending money on those who voted strongly against them. Dishing out favour in this way is known as [pork bar... | Instead of government-sanctioned crime, what about a small area with a different government or no government? It could be an independent city where three or more large countries meet, and none of the countries can take it over because the others wouldn't let them. This also gives a good explanation for why there would ... |
207,341 | Assume this city is relatively large by late medieval standards, around 200,000 people. The city is mainly a site for trade due to its geographically central position and being on a river. Also, because it is geographically central, it also means the city is important for the government to project power.
**What might ... | 2021/07/17 | [
"https://worldbuilding.stackexchange.com/questions/207341",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/43517/"
] | I wonder if you have a too modern view of the state -- by the people, for the people. Over much of history it was by *some* people, for *some* people.
* **Illicit substances**
Very much in the eye of the beholder. In much of the West, alcohol is legal (and taxed) and cannabis is not. Say you have strong merchant gu... | Instead of government-sanctioned crime, what about a small area with a different government or no government? It could be an independent city where three or more large countries meet, and none of the countries can take it over because the others wouldn't let them. This also gives a good explanation for why there would ... |
207,341 | Assume this city is relatively large by late medieval standards, around 200,000 people. The city is mainly a site for trade due to its geographically central position and being on a river. Also, because it is geographically central, it also means the city is important for the government to project power.
**What might ... | 2021/07/17 | [
"https://worldbuilding.stackexchange.com/questions/207341",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/43517/"
] | Nonsense. If something is allowed by the law, then it is not a crime. The very definition of a crime is breaking the law.
The proper question would be why the law in this city is more lenient than elsewhere. Consider for example the US, which is probably the country with the most legally heterogeneous country in the w... | Hollywood will show you many - prolly dozens - of stories in which "governments" sanction crime for their own devious ends… most often to justify increasing the security budget or beefing up security powers.
That and any other Answer uses "government" in a rather loose sense. Even in today's Communist China and the hi... |
207,341 | Assume this city is relatively large by late medieval standards, around 200,000 people. The city is mainly a site for trade due to its geographically central position and being on a river. Also, because it is geographically central, it also means the city is important for the government to project power.
**What might ... | 2021/07/17 | [
"https://worldbuilding.stackexchange.com/questions/207341",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/43517/"
] | I wonder if you have a too modern view of the state -- by the people, for the people. Over much of history it was by *some* people, for *some* people.
* **Illicit substances**
Very much in the eye of the beholder. In much of the West, alcohol is legal (and taxed) and cannabis is not. Say you have strong merchant gu... | >
> What might be the benefits for [a] government to sanction certain crime within [an] important trade city?
>
>
>
There are already excellent answers to this question, but to add some more real world details that have been overlooked:
### Strengthening Colonial Rule
The most famous real-world example is [**Hon... |
207,341 | Assume this city is relatively large by late medieval standards, around 200,000 people. The city is mainly a site for trade due to its geographically central position and being on a river. Also, because it is geographically central, it also means the city is important for the government to project power.
**What might ... | 2021/07/17 | [
"https://worldbuilding.stackexchange.com/questions/207341",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/43517/"
] | **Crime keeps people scared. Scared people want governments that are tough on crime. To demonstrate you are tough, you need criminals to punish.**
<https://www.foxnews.com/us/san-diego-homeless-attacks-help>
>
> San Diegans beg city to curb violence by homeless: 'like you’re in the
> 'Walking Dead''
>
>
>
What a... | >
> What might be the benefits for [a] government to sanction certain crime within [an] important trade city?
>
>
>
There are already excellent answers to this question, but to add some more real world details that have been overlooked:
### Strengthening Colonial Rule
The most famous real-world example is [**Hon... |
207,341 | Assume this city is relatively large by late medieval standards, around 200,000 people. The city is mainly a site for trade due to its geographically central position and being on a river. Also, because it is geographically central, it also means the city is important for the government to project power.
**What might ... | 2021/07/17 | [
"https://worldbuilding.stackexchange.com/questions/207341",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/43517/"
] | Crime is allowed in the central city because it symbolically reinforces the government's claim to power.
* The current rulers are not nobles whose authority to lead flows down from their heritage.
* They are not great businessmen whose authority comes from their wealth and the employment opportunities they bring to th... | **All of that is already legal to some extent in some places**
Legal in lots of jurisdictions, some of them even real democracies:
* Killing humans, for example in self defense, in war, as capital punishment, to save the mother of an unborn, abortion or euthanasia.
* Substance trading and consumption: Drinking alcoho... |
207,341 | Assume this city is relatively large by late medieval standards, around 200,000 people. The city is mainly a site for trade due to its geographically central position and being on a river. Also, because it is geographically central, it also means the city is important for the government to project power.
**What might ... | 2021/07/17 | [
"https://worldbuilding.stackexchange.com/questions/207341",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/43517/"
] | **Crime keeps people scared. Scared people want governments that are tough on crime. To demonstrate you are tough, you need criminals to punish.**
<https://www.foxnews.com/us/san-diego-homeless-attacks-help>
>
> San Diegans beg city to curb violence by homeless: 'like you’re in the
> 'Walking Dead''
>
>
>
What a... | We have good historical examples where this occurred because of jurisdictional confusion.
For example, the tangled relationship of royal and Church prerogatives in Europe in the medieval and early Modern period often allowed Church leaders to exempt people from royal laws while on their lands. For example, in an area ... |
207,341 | Assume this city is relatively large by late medieval standards, around 200,000 people. The city is mainly a site for trade due to its geographically central position and being on a river. Also, because it is geographically central, it also means the city is important for the government to project power.
**What might ... | 2021/07/17 | [
"https://worldbuilding.stackexchange.com/questions/207341",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/43517/"
] | Nonsense. If something is allowed by the law, then it is not a crime. The very definition of a crime is breaking the law.
The proper question would be why the law in this city is more lenient than elsewhere. Consider for example the US, which is probably the country with the most legally heterogeneous country in the w... | Some governments [pork barrel](https://en.wikipedia.org/wiki/Pork_barrel): they favor the electorates that voted for them with money for projects that will benefit those communities - better roads, park lands, new hospital or extension to an existing one, etc.
There is also an element of divide and conquer. If the com... |
207,341 | Assume this city is relatively large by late medieval standards, around 200,000 people. The city is mainly a site for trade due to its geographically central position and being on a river. Also, because it is geographically central, it also means the city is important for the government to project power.
**What might ... | 2021/07/17 | [
"https://worldbuilding.stackexchange.com/questions/207341",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/43517/"
] | **In the real world, we sanction crime already**
Many countries allowed crime. Prostitution is illegal in many areas and has been at many times. It was and is often *tolerated*. Reasonings like, "if we don't tolerate it, the sailors will grab our woman of high social standing" were used to justify this. It was certain... | Hollywood will show you many - prolly dozens - of stories in which "governments" sanction crime for their own devious ends… most often to justify increasing the security budget or beefing up security powers.
That and any other Answer uses "government" in a rather loose sense. Even in today's Communist China and the hi... |
207,341 | Assume this city is relatively large by late medieval standards, around 200,000 people. The city is mainly a site for trade due to its geographically central position and being on a river. Also, because it is geographically central, it also means the city is important for the government to project power.
**What might ... | 2021/07/17 | [
"https://worldbuilding.stackexchange.com/questions/207341",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/43517/"
] | **In the real world, we sanction crime already**
Many countries allowed crime. Prostitution is illegal in many areas and has been at many times. It was and is often *tolerated*. Reasonings like, "if we don't tolerate it, the sailors will grab our woman of high social standing" were used to justify this. It was certain... | We have good historical examples where this occurred because of jurisdictional confusion.
For example, the tangled relationship of royal and Church prerogatives in Europe in the medieval and early Modern period often allowed Church leaders to exempt people from royal laws while on their lands. For example, in an area ... |
28,731 | Sometimes, package updates from MELPA can break some part of emacs and when that happens I'd like to be able to revert back to using an older version of the package.
Right now, I can do it in two ways:
* I've set emacs to delete files by moving to trash and when I update a package, the older version is trashed. I can... | 2016/11/18 | [
"https://emacs.stackexchange.com/questions/28731",
"https://emacs.stackexchange.com",
"https://emacs.stackexchange.com/users/12247/"
] | When you update your packages through the `M-x list-packages` interface, after the successful installation of the package, you'll get asked if you want to remove the old package. Don't delete them so they stay in place and you could then later remove the newer package through this interface.
My current package list sh... | Lots of people elect not to commit ELPA packages to version control, but this is an example of why I believe you should do so.
Reverting *anything* is trivial if it's all committed.
Depending on the state of the upstream ELPA packages is a risk. |
28,731 | Sometimes, package updates from MELPA can break some part of emacs and when that happens I'd like to be able to revert back to using an older version of the package.
Right now, I can do it in two ways:
* I've set emacs to delete files by moving to trash and when I update a package, the older version is trashed. I can... | 2016/11/18 | [
"https://emacs.stackexchange.com/questions/28731",
"https://emacs.stackexchange.com",
"https://emacs.stackexchange.com/users/12247/"
] | The "nuclear option", as it were, would be to ditch `package.el` entirely and instead use the package manager that I wrote, [`straight.el`](https://github.com/raxod502/straight.el). The advantage would be that `straight.el` installs packages by cloning their Git repositories, thereby making it trivial to use whichever ... | Lots of people elect not to commit ELPA packages to version control, but this is an example of why I believe you should do so.
Reverting *anything* is trivial if it's all committed.
Depending on the state of the upstream ELPA packages is a risk. |
28,731 | Sometimes, package updates from MELPA can break some part of emacs and when that happens I'd like to be able to revert back to using an older version of the package.
Right now, I can do it in two ways:
* I've set emacs to delete files by moving to trash and when I update a package, the older version is trashed. I can... | 2016/11/18 | [
"https://emacs.stackexchange.com/questions/28731",
"https://emacs.stackexchange.com",
"https://emacs.stackexchange.com/users/12247/"
] | I find an easy way to downgrade: managing your own melpa archive.
1. Clone [melpa](https://github.com/melpa/melpa) repo.
2. Follow [melpa's custom melpa archive wiki page](https://github.com/melpa/melpa/wiki/Custom-Melpa-Archive) to remove all recipes.
3. Find the commit of the package you want to down grade to, and c... | Lots of people elect not to commit ELPA packages to version control, but this is an example of why I believe you should do so.
Reverting *anything* is trivial if it's all committed.
Depending on the state of the upstream ELPA packages is a risk. |
28,731 | Sometimes, package updates from MELPA can break some part of emacs and when that happens I'd like to be able to revert back to using an older version of the package.
Right now, I can do it in two ways:
* I've set emacs to delete files by moving to trash and when I update a package, the older version is trashed. I can... | 2016/11/18 | [
"https://emacs.stackexchange.com/questions/28731",
"https://emacs.stackexchange.com",
"https://emacs.stackexchange.com/users/12247/"
] | When you update your packages through the `M-x list-packages` interface, after the successful installation of the package, you'll get asked if you want to remove the old package. Don't delete them so they stay in place and you could then later remove the newer package through this interface.
My current package list sh... | The "nuclear option", as it were, would be to ditch `package.el` entirely and instead use the package manager that I wrote, [`straight.el`](https://github.com/raxod502/straight.el). The advantage would be that `straight.el` installs packages by cloning their Git repositories, thereby making it trivial to use whichever ... |
28,731 | Sometimes, package updates from MELPA can break some part of emacs and when that happens I'd like to be able to revert back to using an older version of the package.
Right now, I can do it in two ways:
* I've set emacs to delete files by moving to trash and when I update a package, the older version is trashed. I can... | 2016/11/18 | [
"https://emacs.stackexchange.com/questions/28731",
"https://emacs.stackexchange.com",
"https://emacs.stackexchange.com/users/12247/"
] | When you update your packages through the `M-x list-packages` interface, after the successful installation of the package, you'll get asked if you want to remove the old package. Don't delete them so they stay in place and you could then later remove the newer package through this interface.
My current package list sh... | I find an easy way to downgrade: managing your own melpa archive.
1. Clone [melpa](https://github.com/melpa/melpa) repo.
2. Follow [melpa's custom melpa archive wiki page](https://github.com/melpa/melpa/wiki/Custom-Melpa-Archive) to remove all recipes.
3. Find the commit of the package you want to down grade to, and c... |
28,731 | Sometimes, package updates from MELPA can break some part of emacs and when that happens I'd like to be able to revert back to using an older version of the package.
Right now, I can do it in two ways:
* I've set emacs to delete files by moving to trash and when I update a package, the older version is trashed. I can... | 2016/11/18 | [
"https://emacs.stackexchange.com/questions/28731",
"https://emacs.stackexchange.com",
"https://emacs.stackexchange.com/users/12247/"
] | When you update your packages through the `M-x list-packages` interface, after the successful installation of the package, you'll get asked if you want to remove the old package. Don't delete them so they stay in place and you could then later remove the newer package through this interface.
My current package list sh... | I download the package from github(the package home page) and build it, and recover files to `.emacs.d/elpa`.
for example:
If I want to downgrade package - [hl-todo](https://github.com/tarsius/hl-todo/tree/3bba4591c54951d2abab113ec5e58a6319808ca9) to version `3bba4591`, I can download the specific version package, the... |
28,731 | Sometimes, package updates from MELPA can break some part of emacs and when that happens I'd like to be able to revert back to using an older version of the package.
Right now, I can do it in two ways:
* I've set emacs to delete files by moving to trash and when I update a package, the older version is trashed. I can... | 2016/11/18 | [
"https://emacs.stackexchange.com/questions/28731",
"https://emacs.stackexchange.com",
"https://emacs.stackexchange.com/users/12247/"
] | The "nuclear option", as it were, would be to ditch `package.el` entirely and instead use the package manager that I wrote, [`straight.el`](https://github.com/raxod502/straight.el). The advantage would be that `straight.el` installs packages by cloning their Git repositories, thereby making it trivial to use whichever ... | I find an easy way to downgrade: managing your own melpa archive.
1. Clone [melpa](https://github.com/melpa/melpa) repo.
2. Follow [melpa's custom melpa archive wiki page](https://github.com/melpa/melpa/wiki/Custom-Melpa-Archive) to remove all recipes.
3. Find the commit of the package you want to down grade to, and c... |
28,731 | Sometimes, package updates from MELPA can break some part of emacs and when that happens I'd like to be able to revert back to using an older version of the package.
Right now, I can do it in two ways:
* I've set emacs to delete files by moving to trash and when I update a package, the older version is trashed. I can... | 2016/11/18 | [
"https://emacs.stackexchange.com/questions/28731",
"https://emacs.stackexchange.com",
"https://emacs.stackexchange.com/users/12247/"
] | The "nuclear option", as it were, would be to ditch `package.el` entirely and instead use the package manager that I wrote, [`straight.el`](https://github.com/raxod502/straight.el). The advantage would be that `straight.el` installs packages by cloning their Git repositories, thereby making it trivial to use whichever ... | I download the package from github(the package home page) and build it, and recover files to `.emacs.d/elpa`.
for example:
If I want to downgrade package - [hl-todo](https://github.com/tarsius/hl-todo/tree/3bba4591c54951d2abab113ec5e58a6319808ca9) to version `3bba4591`, I can download the specific version package, the... |
28,731 | Sometimes, package updates from MELPA can break some part of emacs and when that happens I'd like to be able to revert back to using an older version of the package.
Right now, I can do it in two ways:
* I've set emacs to delete files by moving to trash and when I update a package, the older version is trashed. I can... | 2016/11/18 | [
"https://emacs.stackexchange.com/questions/28731",
"https://emacs.stackexchange.com",
"https://emacs.stackexchange.com/users/12247/"
] | I find an easy way to downgrade: managing your own melpa archive.
1. Clone [melpa](https://github.com/melpa/melpa) repo.
2. Follow [melpa's custom melpa archive wiki page](https://github.com/melpa/melpa/wiki/Custom-Melpa-Archive) to remove all recipes.
3. Find the commit of the package you want to down grade to, and c... | I download the package from github(the package home page) and build it, and recover files to `.emacs.d/elpa`.
for example:
If I want to downgrade package - [hl-todo](https://github.com/tarsius/hl-todo/tree/3bba4591c54951d2abab113ec5e58a6319808ca9) to version `3bba4591`, I can download the specific version package, the... |
7,338,824 | I have a log line that I am pulling from bash like:
```
There are 5 apples and 7 oranges
```
And I want to get the 5 and 7 into bash variables and am having problems doing so.
awk '{ print $3, $6 }' won't work due to the fact that their position might change, if there are bananas. Bonus points if the digits can be ... | 2011/09/07 | [
"https://Stackoverflow.com/questions/7338824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/884881/"
] | and to get the fruits:
```
echo 'There are 5 apples and 7 oranges' | grep -o -E '[[:digit:]]+ [[:alpha:]]+'
``` | Grep will do this:
```
echo 'There are 5 apples and 7 oranges' | grep -o -E '[[:digit:]]+'
``` |
7,338,824 | I have a log line that I am pulling from bash like:
```
There are 5 apples and 7 oranges
```
And I want to get the 5 and 7 into bash variables and am having problems doing so.
awk '{ print $3, $6 }' won't work due to the fact that their position might change, if there are bananas. Bonus points if the digits can be ... | 2011/09/07 | [
"https://Stackoverflow.com/questions/7338824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/884881/"
] | A bash-only method, tested with bash v4:
```
str=" There are 5 apples, 12 bananas and 7 oranges"
i=0
while [[ "$str" =~ ([0-9]+)" "([a-z]+)(.*) ]] ; do
num[$i]=${BASH_REMATCH[1]}
type[$i]=${BASH_REMATCH[2]}
str=${BASH_REMATCH[3]}
(( i++ ))
done
for (( i=0; i<${#num[@]}; i++ )); do
printf "%4d\t%s... | Grep will do this:
```
echo 'There are 5 apples and 7 oranges' | grep -o -E '[[:digit:]]+'
``` |
7,338,824 | I have a log line that I am pulling from bash like:
```
There are 5 apples and 7 oranges
```
And I want to get the 5 and 7 into bash variables and am having problems doing so.
awk '{ print $3, $6 }' won't work due to the fact that their position might change, if there are bananas. Bonus points if the digits can be ... | 2011/09/07 | [
"https://Stackoverflow.com/questions/7338824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/884881/"
] | and to get the fruits:
```
echo 'There are 5 apples and 7 oranges' | grep -o -E '[[:digit:]]+ [[:alpha:]]+'
``` | Slightly more compact version:
`echo 'There are 5 apples and 7 oranges' | egrep -o '[0-9]+ \w+'`
Note however that `\w` is synonymous with `[:alnum:]`, and will thus match "appl3s" as well, for example. |
7,338,824 | I have a log line that I am pulling from bash like:
```
There are 5 apples and 7 oranges
```
And I want to get the 5 and 7 into bash variables and am having problems doing so.
awk '{ print $3, $6 }' won't work due to the fact that their position might change, if there are bananas. Bonus points if the digits can be ... | 2011/09/07 | [
"https://Stackoverflow.com/questions/7338824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/884881/"
] | and to get the fruits:
```
echo 'There are 5 apples and 7 oranges' | grep -o -E '[[:digit:]]+ [[:alpha:]]+'
``` | Well, shell is a strange language, and you can do nice things. For example:
```
a="there are 7 apples"
for i in $a; do
case $i in
[0-9]*)
value=$i
expectname=1
;;
*)
test -n "$expectname" && name=$i
expectname=
;;
esac
done
echo $value
echo $name
```
If you have more than... |
7,338,824 | I have a log line that I am pulling from bash like:
```
There are 5 apples and 7 oranges
```
And I want to get the 5 and 7 into bash variables and am having problems doing so.
awk '{ print $3, $6 }' won't work due to the fact that their position might change, if there are bananas. Bonus points if the digits can be ... | 2011/09/07 | [
"https://Stackoverflow.com/questions/7338824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/884881/"
] | and to get the fruits:
```
echo 'There are 5 apples and 7 oranges' | grep -o -E '[[:digit:]]+ [[:alpha:]]+'
``` | A bash-only method, tested with bash v4:
```
str=" There are 5 apples, 12 bananas and 7 oranges"
i=0
while [[ "$str" =~ ([0-9]+)" "([a-z]+)(.*) ]] ; do
num[$i]=${BASH_REMATCH[1]}
type[$i]=${BASH_REMATCH[2]}
str=${BASH_REMATCH[3]}
(( i++ ))
done
for (( i=0; i<${#num[@]}; i++ )); do
printf "%4d\t%s... |
7,338,824 | I have a log line that I am pulling from bash like:
```
There are 5 apples and 7 oranges
```
And I want to get the 5 and 7 into bash variables and am having problems doing so.
awk '{ print $3, $6 }' won't work due to the fact that their position might change, if there are bananas. Bonus points if the digits can be ... | 2011/09/07 | [
"https://Stackoverflow.com/questions/7338824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/884881/"
] | A bash-only method, tested with bash v4:
```
str=" There are 5 apples, 12 bananas and 7 oranges"
i=0
while [[ "$str" =~ ([0-9]+)" "([a-z]+)(.*) ]] ; do
num[$i]=${BASH_REMATCH[1]}
type[$i]=${BASH_REMATCH[2]}
str=${BASH_REMATCH[3]}
(( i++ ))
done
for (( i=0; i<${#num[@]}; i++ )); do
printf "%4d\t%s... | Slightly more compact version:
`echo 'There are 5 apples and 7 oranges' | egrep -o '[0-9]+ \w+'`
Note however that `\w` is synonymous with `[:alnum:]`, and will thus match "appl3s" as well, for example. |
7,338,824 | I have a log line that I am pulling from bash like:
```
There are 5 apples and 7 oranges
```
And I want to get the 5 and 7 into bash variables and am having problems doing so.
awk '{ print $3, $6 }' won't work due to the fact that their position might change, if there are bananas. Bonus points if the digits can be ... | 2011/09/07 | [
"https://Stackoverflow.com/questions/7338824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/884881/"
] | A bash-only method, tested with bash v4:
```
str=" There are 5 apples, 12 bananas and 7 oranges"
i=0
while [[ "$str" =~ ([0-9]+)" "([a-z]+)(.*) ]] ; do
num[$i]=${BASH_REMATCH[1]}
type[$i]=${BASH_REMATCH[2]}
str=${BASH_REMATCH[3]}
(( i++ ))
done
for (( i=0; i<${#num[@]}; i++ )); do
printf "%4d\t%s... | Well, shell is a strange language, and you can do nice things. For example:
```
a="there are 7 apples"
for i in $a; do
case $i in
[0-9]*)
value=$i
expectname=1
;;
*)
test -n "$expectname" && name=$i
expectname=
;;
esac
done
echo $value
echo $name
```
If you have more than... |
65,263,049 | I am using this logic in my button i.e if login the buynow class is working else login modal is open.
& code here.
```
<button class="ps-btn ps-btn--sm @if(session()->has('name')){{'buy_now'}}"@else {{data-toggle="modal" data-target="#loginModal"}}@endif>Buy Now<i class="ps-icon-next"></i></button>
``` | 2020/12/12 | [
"https://Stackoverflow.com/questions/65263049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14724522/"
] | You can use below code
```
<button class="ps-btn ps-btn--sm
@if(session()->has('name')) buy_now"
@else " data-toggle='modal' data-target='#loginModal'
@endif>Buy Now<i class="ps-icon-next"></i>
</button>
```
**Notice:** We use `{{ $variable }}` for echoing a php variable. It is equivalent to `<?php echo... | **Try this:**
```
<button session()->has('name') ? class="ps-btn ps-btn--sm buy_now' : "data-
toggle="modal" data-target="#loginModal">Buy Now<i class="ps-icon-next"></i>
</button>
``` |
40,193,491 | I am working on a project, where I have a domain `xyz.com`, I have been requested that a subdomain example `abc.xyz.com` should point to website which has ipaddress
example `http://199.152.57.120/client/` and when a visitor browse `abc.xyz.com` it should open the website hosted on `http://199.152.57.120/client/` but by... | 2016/10/22 | [
"https://Stackoverflow.com/questions/40193491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7057429/"
] | Here's the solution for [image2](http://genxcoders.in/demo/TDirectory/2.png)
`echo '<select>';`
`structureTree(0,0);`
`echo '</select>';`
`function structureTree($deptParentId, $level){`
```
$result = getDataFromDb($deptParentId); // change this into SQL
foreach($result as $result){
echo '<option value="'.$dep... | recursion is the solution for this problem. While the parent still has a child then it keeps querying until there's no child left.
e.g
One
.One1
.One2
.One3
Here's the php application
`function structureTree($depParentId = 0){`
```
$result = queryFunction("SELECT *FROM
tddept WHE... |
2,318 | We would like to get rid of the Tridion Broker as part of a project and publish content directly to a repository as part of a Storage Extension.
My question is, is there any deep dependency that Tridion has on the Broker that might mean things work in a sub-optimal way, or gotchas that I should be aware of?
Update -... | 2013/07/25 | [
"https://tridion.stackexchange.com/questions/2318",
"https://tridion.stackexchange.com",
"https://tridion.stackexchange.com/users/315/"
] | I will assume that what you mean with the Broker is the Tridion Broker database.
It is possible to publish everything to the file system, it includes, content, linking info, metadata and references, however this functionality is deprecated and will be removed in future releases, having said that, in future releases, l... | 1. Dynamic Linking is the big one as Rob mentions.
2. any DCPs embedded on Pages will render
UCs/Tags.
3. Any code that queries CPs using Criteria/Query API will need to be gutted/replaced.
4. If you use P&P, then any personalized content will be rendered and filtered via User Controls/Tags, and this will need replaci... |
2,318 | We would like to get rid of the Tridion Broker as part of a project and publish content directly to a repository as part of a Storage Extension.
My question is, is there any deep dependency that Tridion has on the Broker that might mean things work in a sub-optimal way, or gotchas that I should be aware of?
Update -... | 2013/07/25 | [
"https://tridion.stackexchange.com/questions/2318",
"https://tridion.stackexchange.com",
"https://tridion.stackexchange.com/users/315/"
] | 1. Dynamic Linking is the big one as Rob mentions.
2. any DCPs embedded on Pages will render
UCs/Tags.
3. Any code that queries CPs using Criteria/Query API will need to be gutted/replaced.
4. If you use P&P, then any personalized content will be rendered and filtered via User Controls/Tags, and this will need replaci... | This sounds like an unusual implementation.
It might be worth blueprinting your website to allow you to localize the templates to render the json. The new child publication could be used with a new deployer for you to test if this gives you the output you need without any missing functionality. |
2,318 | We would like to get rid of the Tridion Broker as part of a project and publish content directly to a repository as part of a Storage Extension.
My question is, is there any deep dependency that Tridion has on the Broker that might mean things work in a sub-optimal way, or gotchas that I should be aware of?
Update -... | 2013/07/25 | [
"https://tridion.stackexchange.com/questions/2318",
"https://tridion.stackexchange.com",
"https://tridion.stackexchange.com/users/315/"
] | I will assume that what you mean with the Broker is the Tridion Broker database.
It is possible to publish everything to the file system, it includes, content, linking info, metadata and references, however this functionality is deprecated and will be removed in future releases, having said that, in future releases, l... | This sounds like an unusual implementation.
It might be worth blueprinting your website to allow you to localize the templates to render the json. The new child publication could be used with a new deployer for you to test if this gives you the output you need without any missing functionality. |
2,318 | We would like to get rid of the Tridion Broker as part of a project and publish content directly to a repository as part of a Storage Extension.
My question is, is there any deep dependency that Tridion has on the Broker that might mean things work in a sub-optimal way, or gotchas that I should be aware of?
Update -... | 2013/07/25 | [
"https://tridion.stackexchange.com/questions/2318",
"https://tridion.stackexchange.com",
"https://tridion.stackexchange.com/users/315/"
] | I will assume that what you mean with the Broker is the Tridion Broker database.
It is possible to publish everything to the file system, it includes, content, linking info, metadata and references, however this functionality is deprecated and will be removed in future releases, having said that, in future releases, l... | I would be vary wary of any approach that removes all Content Delivery functionality, or the ability to hook into it. Customers I have seen that take this approach due to whatever requirements, tend to become very dissatisfied in the long term. Usually they bought Tridion for the whole package of functionality, CM + CD... |
2,318 | We would like to get rid of the Tridion Broker as part of a project and publish content directly to a repository as part of a Storage Extension.
My question is, is there any deep dependency that Tridion has on the Broker that might mean things work in a sub-optimal way, or gotchas that I should be aware of?
Update -... | 2013/07/25 | [
"https://tridion.stackexchange.com/questions/2318",
"https://tridion.stackexchange.com",
"https://tridion.stackexchange.com/users/315/"
] | I would be vary wary of any approach that removes all Content Delivery functionality, or the ability to hook into it. Customers I have seen that take this approach due to whatever requirements, tend to become very dissatisfied in the long term. Usually they bought Tridion for the whole package of functionality, CM + CD... | This sounds like an unusual implementation.
It might be worth blueprinting your website to allow you to localize the templates to render the json. The new child publication could be used with a new deployer for you to test if this gives you the output you need without any missing functionality. |
32,869,080 | I've a class A like that:
```
public class A
{
private String id; // Generated on server
private DateTime timestamp;
private int trash;
private Humanity.FeedTypeEnum feedType
private List<Property> properties;
// ...
```
where `Property` is:
```
public class Property
{
private H... | 2015/09/30 | [
"https://Stackoverflow.com/questions/32869080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3227319/"
] | You can do what you want extending `DynamicObject` class:
```
class A : System.Dynamic.DynamicObject
{
// Other members
public List<Property> properties;
private readonly Dictionary<string, object> _membersDict = new Dictionary<string, object>();
public override bool TryGetMember(System.Dynamic.GetMe... | This method just overrides the square bracket operator. Not as slick as what you wanted but simpler and workable.
You definitely can't have design time (when you write code) features like you described.
You could make it work with reflection at run-time but surely not the way you showed right?
```
using System;
using... |
64,018,695 | My program always outpout test which should not happen. Its like the program is skipping the case to go to default right away. I don't understand why it does that. I've spent 30 mins to find a solution but I can't understand why it does that.
Thanks for helping me !
```
var ani;
let ans;
let prix;
var total;
var arm1... | 2020/09/22 | [
"https://Stackoverflow.com/questions/64018695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14323955/"
] | You are doing `ani.toLowerCase`. It should be `ani.toLowerCase()`. Also remove the return 1. | You didn't call the lowerCase function, invoke it.
Also, remove the return statement,
Now if you try to enter 'l' or 'c' letter it will work
```js
var ani;
let ans;
let prix;
var total;
var arm1;
var arm2;
let nombrearmure;
nombrearmure = 0;
ani = prompt("Entrez votre type d'animal : ");
switch (ani.toLowerCase()) {
... |
59,973 | I want to register a sidebar but I am a little confused about the uses of the `id` argument in [`register_sidebar`](http://codex.wordpress.org/Function_Reference/register_sidebar) function.
>
> Codex says: id - Sidebar id - Must be all in lowercase, with no spaces
> (default is a numeric auto-incremented ID).
>
>
... | 2012/07/28 | [
"https://wordpress.stackexchange.com/questions/59973",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11125/"
] | John Landells’ answer is good and correct.
I want to add a **List of forbidden or reserved IDs** – these IDs may appear on the widget config page `/wp-admin/widgets.php`. If you use one of these … strange things will happen due to duplicated IDs. Drag and drop will probably not work anymore. See [Ticket #14466](http:... | The sidebar ID is used to uniquely identify this specific sidebar. If you don't set it and something creates another, you could find that your sidebar moves somewhere unexpected!
It doesn't need to be numeric - you can use strings, too. |
59,973 | I want to register a sidebar but I am a little confused about the uses of the `id` argument in [`register_sidebar`](http://codex.wordpress.org/Function_Reference/register_sidebar) function.
>
> Codex says: id - Sidebar id - Must be all in lowercase, with no spaces
> (default is a numeric auto-incremented ID).
>
>
... | 2012/07/28 | [
"https://wordpress.stackexchange.com/questions/59973",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11125/"
] | The sidebar ID is used to uniquely identify this specific sidebar. If you don't set it and something creates another, you could find that your sidebar moves somewhere unexpected!
It doesn't need to be numeric - you can use strings, too. | You have to avoid multiple `-` characters, like `test1---test2` |
59,973 | I want to register a sidebar but I am a little confused about the uses of the `id` argument in [`register_sidebar`](http://codex.wordpress.org/Function_Reference/register_sidebar) function.
>
> Codex says: id - Sidebar id - Must be all in lowercase, with no spaces
> (default is a numeric auto-incremented ID).
>
>
... | 2012/07/28 | [
"https://wordpress.stackexchange.com/questions/59973",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11125/"
] | The sidebar ID is used to uniquely identify this specific sidebar. If you don't set it and something creates another, you could find that your sidebar moves somewhere unexpected!
It doesn't need to be numeric - you can use strings, too. | Apparently, you have to avoid IDs that include prefixes from the above list as well:
e.g.:
```
#footer-xxx
#footer-yyy
```
The following setup initially worked, but resulted in errors (using the monsoon theme):
```
register_sidebar( array(
'name' => esc_html__( 'Footer Area', 'monsoon' ),
'id' ... |
59,973 | I want to register a sidebar but I am a little confused about the uses of the `id` argument in [`register_sidebar`](http://codex.wordpress.org/Function_Reference/register_sidebar) function.
>
> Codex says: id - Sidebar id - Must be all in lowercase, with no spaces
> (default is a numeric auto-incremented ID).
>
>
... | 2012/07/28 | [
"https://wordpress.stackexchange.com/questions/59973",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11125/"
] | John Landells’ answer is good and correct.
I want to add a **List of forbidden or reserved IDs** – these IDs may appear on the widget config page `/wp-admin/widgets.php`. If you use one of these … strange things will happen due to duplicated IDs. Drag and drop will probably not work anymore. See [Ticket #14466](http:... | You have to avoid multiple `-` characters, like `test1---test2` |
59,973 | I want to register a sidebar but I am a little confused about the uses of the `id` argument in [`register_sidebar`](http://codex.wordpress.org/Function_Reference/register_sidebar) function.
>
> Codex says: id - Sidebar id - Must be all in lowercase, with no spaces
> (default is a numeric auto-incremented ID).
>
>
... | 2012/07/28 | [
"https://wordpress.stackexchange.com/questions/59973",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11125/"
] | John Landells’ answer is good and correct.
I want to add a **List of forbidden or reserved IDs** – these IDs may appear on the widget config page `/wp-admin/widgets.php`. If you use one of these … strange things will happen due to duplicated IDs. Drag and drop will probably not work anymore. See [Ticket #14466](http:... | Apparently, you have to avoid IDs that include prefixes from the above list as well:
e.g.:
```
#footer-xxx
#footer-yyy
```
The following setup initially worked, but resulted in errors (using the monsoon theme):
```
register_sidebar( array(
'name' => esc_html__( 'Footer Area', 'monsoon' ),
'id' ... |
17,435,950 | I am trying to improve the performance of a hammered wordpress DB by adding indexes to queries that appear in the slow query log.
In MS SQL you can use query hints to force a query to use an index but it is usually quite easy to get a query to use an index if you cover the columns correctly etc.
I have this query tha... | 2013/07/02 | [
"https://Stackoverflow.com/questions/17435950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1037545/"
] | >
> Does MySQL have query hints to force an index to be used for speed/performance tests or is there something else I need to do to see why this index is being ignored.
>
>
>
[The documentation](http://dev.mysql.com/doc/refman/5.0/en/index-hints.html) answers this question in some detail:
>
> By specifying `USE ... | Try changing the order of your index definition to
```
post_type, post_status, post_date, post_id
```
or
```
post_date desc, post_type, post_status, post_id
``` |
17,435,950 | I am trying to improve the performance of a hammered wordpress DB by adding indexes to queries that appear in the slow query log.
In MS SQL you can use query hints to force a query to use an index but it is usually quite easy to get a query to use an index if you cover the columns correctly etc.
I have this query tha... | 2013/07/02 | [
"https://Stackoverflow.com/questions/17435950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1037545/"
] | MySQL 5.6 has support for a new format of EXPLAIN, which the [MySQL Workbench](http://www.mysql.com/products/workbench/) GUI can visualize in a more appealing way. But that doesn't help you if you're stuck on MySQL 5.5 or earlier.
MySQL does have hints as @AirThomas mentions, but you should really use them sparingly. ... | Try changing the order of your index definition to
```
post_type, post_status, post_date, post_id
```
or
```
post_date desc, post_type, post_status, post_id
``` |
17,435,950 | I am trying to improve the performance of a hammered wordpress DB by adding indexes to queries that appear in the slow query log.
In MS SQL you can use query hints to force a query to use an index but it is usually quite easy to get a query to use an index if you cover the columns correctly etc.
I have this query tha... | 2013/07/02 | [
"https://Stackoverflow.com/questions/17435950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1037545/"
] | Try changing the order of your index definition to
```
post_type, post_status, post_date, post_id
```
or
```
post_date desc, post_type, post_status, post_id
``` | Just to let you know I am on a different PC so my username has changed but I did write the original question.
What I think would be very helpful is a conversion guide to help people from MS SQL backgrounds covert to MySQL as it seems there's some difference in the index tuning I didn't realise especially that differen... |
17,435,950 | I am trying to improve the performance of a hammered wordpress DB by adding indexes to queries that appear in the slow query log.
In MS SQL you can use query hints to force a query to use an index but it is usually quite easy to get a query to use an index if you cover the columns correctly etc.
I have this query tha... | 2013/07/02 | [
"https://Stackoverflow.com/questions/17435950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1037545/"
] | >
> Does MySQL have query hints to force an index to be used for speed/performance tests or is there something else I need to do to see why this index is being ignored.
>
>
>
[The documentation](http://dev.mysql.com/doc/refman/5.0/en/index-hints.html) answers this question in some detail:
>
> By specifying `USE ... | MySQL 5.6 has support for a new format of EXPLAIN, which the [MySQL Workbench](http://www.mysql.com/products/workbench/) GUI can visualize in a more appealing way. But that doesn't help you if you're stuck on MySQL 5.5 or earlier.
MySQL does have hints as @AirThomas mentions, but you should really use them sparingly. ... |
17,435,950 | I am trying to improve the performance of a hammered wordpress DB by adding indexes to queries that appear in the slow query log.
In MS SQL you can use query hints to force a query to use an index but it is usually quite easy to get a query to use an index if you cover the columns correctly etc.
I have this query tha... | 2013/07/02 | [
"https://Stackoverflow.com/questions/17435950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1037545/"
] | >
> Does MySQL have query hints to force an index to be used for speed/performance tests or is there something else I need to do to see why this index is being ignored.
>
>
>
[The documentation](http://dev.mysql.com/doc/refman/5.0/en/index-hints.html) answers this question in some detail:
>
> By specifying `USE ... | Just to let you know I am on a different PC so my username has changed but I did write the original question.
What I think would be very helpful is a conversion guide to help people from MS SQL backgrounds covert to MySQL as it seems there's some difference in the index tuning I didn't realise especially that differen... |
17,435,950 | I am trying to improve the performance of a hammered wordpress DB by adding indexes to queries that appear in the slow query log.
In MS SQL you can use query hints to force a query to use an index but it is usually quite easy to get a query to use an index if you cover the columns correctly etc.
I have this query tha... | 2013/07/02 | [
"https://Stackoverflow.com/questions/17435950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1037545/"
] | MySQL 5.6 has support for a new format of EXPLAIN, which the [MySQL Workbench](http://www.mysql.com/products/workbench/) GUI can visualize in a more appealing way. But that doesn't help you if you're stuck on MySQL 5.5 or earlier.
MySQL does have hints as @AirThomas mentions, but you should really use them sparingly. ... | Just to let you know I am on a different PC so my username has changed but I did write the original question.
What I think would be very helpful is a conversion guide to help people from MS SQL backgrounds covert to MySQL as it seems there's some difference in the index tuning I didn't realise especially that differen... |
51,384,796 | I have a table that have logins in one column and phone numbers in another. I need to copy all phone numbers of each login and paste them to another sheet. But i need only unique phone numbers as one login may contain many records with the same phone number. What i have tried and what failed
```
For Each rCell In Shee... | 2018/07/17 | [
"https://Stackoverflow.com/questions/51384796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5874458/"
] | you can add this
```
onFocus={useTheOnFocus ? onFocusHandler : undefined}
```
or set a handler
```
onFocus={onFocusHandler}
```
and check a condition in a handler
```
onFocusHandler = (ev) => {
if(!condition) {
return null;
}
// your code
}
``` | You can give event handlers a value of `undefined` if you don't want them to be active.
**Example**
```js
class App extends React.Component {
state = { useTheOnFocus: false };
componentDidMount() {
setInterval(() => {
this.setState(prevState => ({
useTheOnFocus: !prevState.useTheOnFocus
... |
24,440,216 | I have line like this
and I am searching for how the input works when the code is executed
```
scanf("%d, %f",&withdrawal ,&balance );
```
I use Cygwin to compile the code and afterwards I am asked for inputs.
Does it mean that I have to write two numbers separated by space
```
60 120
```
or there is some tr... | 2014/06/26 | [
"https://Stackoverflow.com/questions/24440216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3460161/"
] | scanf(), or scan formatted, expects input in the format you specified. scanf("%d, %f") simply means you expect input in this exact format, for example: 62, 2.15 . | scanf expects an input as specified in quotes, as Matt Phillips mentioned.
so, whether change a scanf to:
`scanf("%d %f", &withdrawal, &balance);` and then input `60 120` or just input `60, 120` |
24,440,216 | I have line like this
and I am searching for how the input works when the code is executed
```
scanf("%d, %f",&withdrawal ,&balance );
```
I use Cygwin to compile the code and afterwards I am asked for inputs.
Does it mean that I have to write two numbers separated by space
```
60 120
```
or there is some tr... | 2014/06/26 | [
"https://Stackoverflow.com/questions/24440216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3460161/"
] | scanf(), or scan formatted, expects input in the format you specified. scanf("%d, %f") simply means you expect input in this exact format, for example: 62, 2.15 . | On encountering non-white-space character (`,` in your case) in a format string (`"%d, %f"`), `scanf` compares it with the next input character.
>
> * If the two characters match, `scanf` discards the input character and continues processing the format string.
> * If the character doesn't match, `scanf` puts the off... |
42,461,533 | i'm developing a java program that shows area and perimeter of two rectangle with fixed width&length, current date and reads input from user to solve a linear equation. I was able to ask a user if they want to re-run the program or not. the problem is that if they input y or Y, the program runs, but if the user enters ... | 2017/02/25 | [
"https://Stackoverflow.com/questions/42461533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2066392/"
] | You can add a `do while` when you asks the user whether if he wants to repeat the program.
Besides, instead of specifying both uppercase and lowercase in statement : `while(ch == 'y' || ch == 'Y');` you can use `Character.toLowerCase()` method to reduce the number of tests to perform.
```
do {
System.ou... | At the end of your loop (but still IN your loop), you could do something like
```
ch = 'x'; // Just a dummy value
while (ch != 'y' && ch != 'n') {
System.out.prinln("Enter y or n:");
ch = input.next().charAt(0);
}
if (ch == 'n') {
break;
}
``` |
34,778,041 | I want to know what `[=]` does? Here's a short example
```
template <typename T>
std::function<T (T)> makeConverter(T factor, T offset) {
return [=] (T input) -> T { return (offset + input) * factor; };
}
auto milesToKm = makeConverter(1.60936, 0.0);
```
How would the code work with `[]` instead of `[=]`?
I as... | 2016/01/13 | [
"https://Stackoverflow.com/questions/34778041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4503737/"
] | The `[=]` you're referring to is part of the *capture list* for the lambda expression. This tells C++ that the code inside the lambda expression is initialized so that the lambda gets a copy of all the local variables it uses when it's created. This is necessary for the lambda expression to be able to refer to `factor`... | It's a [lambda](http://en.cppreference.com/w/cpp/language/lambda) capture list. Makes variables available for the lambda. You can use `[=]` which copies by value, or `[&]` which passes by reference. |
51,206,456 | I have restructured my project folders. I see that i lost commit history before restructuring of files in my remote repository.
I have the history before restructuring locally.
Right now everyone who clone the repository doesn't have the commit history before restructuring.
Is there anyway i can rebuild the commit h... | 2018/07/06 | [
"https://Stackoverflow.com/questions/51206456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1057347/"
] | The only way to lose history in Git is to remove commits. This is because the commits *are* the history. There is no file history; there are only commits.
When you use `git log --follow pom.xml`, you are telling Git to *synthesize* a file history, by wandering through the commit history and noting when a file named `p... | Finally i found out thats an issue only on Bitbucket and Eclipse.
Bitbucket shows all commits to the repository but can not show the sinbgle file log with the command --follow.
The same issue is with Eclipse.
Intellij works fine. |
7,515,167 | What I want is when checkbox1 is selected both checkbox labelled 1 will get selected and background will be removed
[here is the fiddle](http://jsfiddle.net/rigids/D2vCf/)
for eg if i select checkbox1 it should select both checkbox labelled checkbox1 | 2011/09/22 | [
"https://Stackoverflow.com/questions/7515167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/791441/"
] | The problem is that searching for ID $("#somethin") is not possible to select more than one element. IF you search for class, then your example works.. well, with [some minor changes](http://jsfiddle.net/D2vCf/11/) :)
```
$(document).ready(function() {
$('input[type=checkbox]').change(function(){
var pos;
... | You can't have multiple DOM elements with the same id.
See [this fiddle](http://jsfiddle.net/PL6MW/1/) for a working example, but it's not as generic as you may need. |
7,515,167 | What I want is when checkbox1 is selected both checkbox labelled 1 will get selected and background will be removed
[here is the fiddle](http://jsfiddle.net/rigids/D2vCf/)
for eg if i select checkbox1 it should select both checkbox labelled checkbox1 | 2011/09/22 | [
"https://Stackoverflow.com/questions/7515167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/791441/"
] | The problem is that searching for ID $("#somethin") is not possible to select more than one element. IF you search for class, then your example works.. well, with [some minor changes](http://jsfiddle.net/D2vCf/11/) :)
```
$(document).ready(function() {
$('input[type=checkbox]').change(function(){
var pos;
... | Select multiple elements using class. You can try this..
```
<script language="javascript" type="text/javascript">
$(function () {
$("#checkbox1").click(function () {
$('.case').attr('checked', this.checked);
});
});
</script>
```
and your html code will be like below
```
<d... |
4,195,726 | I want to create a custom TableViewCell on which I want to have UITextField with editing possibility.
So I created new class with xib. Add TableViewCell element. Drag on it UITextField. Added outlets in my class and connect them all together. In my TableView method cellForRowAtIndexPath I create my custom cells, BUT t... | 2010/11/16 | [
"https://Stackoverflow.com/questions/4195726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/449007/"
] | Do not use UITableViewCell's initializer, but make the cell load from your nib:
```
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"EditCell";
EditCell *cell = (EditCell*) [tableView dequeueReusableCellWithIdentifier... | You need to load your xib and retrieve your custom cell:
```
NSArray *uiObjects = [[NSBundle mainBundle] loadNibNamed:@"yourNib"
owner:self
options:nil];
for (id uiObject in uiObjects) {
if ([uiObject isKindOfCla... |
4,195,726 | I want to create a custom TableViewCell on which I want to have UITextField with editing possibility.
So I created new class with xib. Add TableViewCell element. Drag on it UITextField. Added outlets in my class and connect them all together. In my TableView method cellForRowAtIndexPath I create my custom cells, BUT t... | 2010/11/16 | [
"https://Stackoverflow.com/questions/4195726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/449007/"
] | Do not use UITableViewCell's initializer, but make the cell load from your nib:
```
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"EditCell";
EditCell *cell = (EditCell*) [tableView dequeueReusableCellWithIdentifier... | You can load custom UITableViewCells from NIB files without creating a subclass of UITableViewCell first, but with a subclass you can configure more about the cell.
**First solution, without subclass:**
**In ViewController:**
• Define cell ivar as IBOutlet
```
UITableViewCell *tableViewCell;
@property (nonatomic, ... |
4,195,726 | I want to create a custom TableViewCell on which I want to have UITextField with editing possibility.
So I created new class with xib. Add TableViewCell element. Drag on it UITextField. Added outlets in my class and connect them all together. In my TableView method cellForRowAtIndexPath I create my custom cells, BUT t... | 2010/11/16 | [
"https://Stackoverflow.com/questions/4195726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/449007/"
] | You can load custom UITableViewCells from NIB files without creating a subclass of UITableViewCell first, but with a subclass you can configure more about the cell.
**First solution, without subclass:**
**In ViewController:**
• Define cell ivar as IBOutlet
```
UITableViewCell *tableViewCell;
@property (nonatomic, ... | You need to load your xib and retrieve your custom cell:
```
NSArray *uiObjects = [[NSBundle mainBundle] loadNibNamed:@"yourNib"
owner:self
options:nil];
for (id uiObject in uiObjects) {
if ([uiObject isKindOfCla... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.