qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
15,191,103
C++ allows non-type template parameters to be of integral or enumeration type (with integral including boolean and character), as well as pointers and references to arbitrary types. I have seen integer, boolean, and enumeration parameters used widely and I appreciate their utility. I've even seen a clever use of chara...
2013/03/03
[ "https://Stackoverflow.com/questions/15191103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/141719/" ]
if you know the address of a buffer at compile time, you can make a decision (at compile time) based on its alignment, especially for things such as memcpy, this allows you to skip any run-time checking, and just jump straight to copying the data using the most efficiently sized types. (I'm guessing) You might also b...
Here is a useful example of non-integral template parameters. Some predeclarations (not all, but just enough to get the idea): ``` template <bool flag, class T, class F> struct SelectType { typedef T Result; }; template <class T, class F> struct SelectType<false, T, F> { typedef F Result; }; #define PARAMETER...
15,191,103
C++ allows non-type template parameters to be of integral or enumeration type (with integral including boolean and character), as well as pointers and references to arbitrary types. I have seen integer, boolean, and enumeration parameters used widely and I appreciate their utility. I've even seen a clever use of chara...
2013/03/03
[ "https://Stackoverflow.com/questions/15191103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/141719/" ]
Using a pointer-to-member-function as a template parameter makes it possible for the compiler to inline a call to that function. An example of this usage can be seen in my answer to this question: [How to allow templated functor work on both member and non-member functions](https://stackoverflow.com/questions/17218712/...
I think important, pointer-template-argument are *Operations.* (Where the more circumstantial way would be a function pointer, and the "easier" way a function object [which in turn is a type again.]) ``` template<typename Key, class Val, bool (*CMP)(Key const&, Key const&)> class map { }; template<typename KEY, class...
15,191,103
C++ allows non-type template parameters to be of integral or enumeration type (with integral including boolean and character), as well as pointers and references to arbitrary types. I have seen integer, boolean, and enumeration parameters used widely and I appreciate their utility. I've even seen a clever use of chara...
2013/03/03
[ "https://Stackoverflow.com/questions/15191103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/141719/" ]
I think important, pointer-template-argument are *Operations.* (Where the more circumstantial way would be a function pointer, and the "easier" way a function object [which in turn is a type again.]) ``` template<typename Key, class Val, bool (*CMP)(Key const&, Key const&)> class map { }; template<typename KEY, class...
Here is a useful example of non-integral template parameters. Some predeclarations (not all, but just enough to get the idea): ``` template <bool flag, class T, class F> struct SelectType { typedef T Result; }; template <class T, class F> struct SelectType<false, T, F> { typedef F Result; }; #define PARAMETER...
15,191,103
C++ allows non-type template parameters to be of integral or enumeration type (with integral including boolean and character), as well as pointers and references to arbitrary types. I have seen integer, boolean, and enumeration parameters used widely and I appreciate their utility. I've even seen a clever use of chara...
2013/03/03
[ "https://Stackoverflow.com/questions/15191103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/141719/" ]
Using a pointer-to-member-function as a template parameter makes it possible for the compiler to inline a call to that function. An example of this usage can be seen in my answer to this question: [How to allow templated functor work on both member and non-member functions](https://stackoverflow.com/questions/17218712/...
Here is a useful example of non-integral template parameters. Some predeclarations (not all, but just enough to get the idea): ``` template <bool flag, class T, class F> struct SelectType { typedef T Result; }; template <class T, class F> struct SelectType<false, T, F> { typedef F Result; }; #define PARAMETER...
15,191,103
C++ allows non-type template parameters to be of integral or enumeration type (with integral including boolean and character), as well as pointers and references to arbitrary types. I have seen integer, boolean, and enumeration parameters used widely and I appreciate their utility. I've even seen a clever use of chara...
2013/03/03
[ "https://Stackoverflow.com/questions/15191103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/141719/" ]
Using a pointer-to-member-function as a template parameter makes it possible for the compiler to inline a call to that function. An example of this usage can be seen in my answer to this question: [How to allow templated functor work on both member and non-member functions](https://stackoverflow.com/questions/17218712/...
I've used an intrusive (data pointers stored in the data elements) singly-linked list before, that was parameterized by a pointer to data member indicating where the list stored its links. That parameterization makes it possible to store the same data element in multiple lists if they use different link members: ``` t...
15,191,103
C++ allows non-type template parameters to be of integral or enumeration type (with integral including boolean and character), as well as pointers and references to arbitrary types. I have seen integer, boolean, and enumeration parameters used widely and I appreciate their utility. I've even seen a clever use of chara...
2013/03/03
[ "https://Stackoverflow.com/questions/15191103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/141719/" ]
I've used an intrusive (data pointers stored in the data elements) singly-linked list before, that was parameterized by a pointer to data member indicating where the list stored its links. That parameterization makes it possible to store the same data element in multiple lists if they use different link members: ``` t...
Here is a useful example of non-integral template parameters. Some predeclarations (not all, but just enough to get the idea): ``` template <bool flag, class T, class F> struct SelectType { typedef T Result; }; template <class T, class F> struct SelectType<false, T, F> { typedef F Result; }; #define PARAMETER...
20,133,837
I am trying to grab the href values from the following string: ``` <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere" class="bigger">random1</a><br/> <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere2" class="bigger">random2</a><br/> ``` In this case, I should get "/pa...
2013/11/21
[ "https://Stackoverflow.com/questions/20133837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1647763/" ]
Try a pattern like this ``` /width=\"300\"class=\"topborder\"><ahref=\"(.*?)"/ ``` `"(.*?)"` will match any character but is "lazy". That means once it finds the first `"` after the group (in this case: end of the `href` tag), the group will end [demo](http://3v4l.org/BgebB)
``` <script> $(document).ready(function(){ $("button").click(function(){ alert($("#blah").attr("href")); }); }); </script> ``` Then... ``` <a href="http://www.blah.com" id="blah">Blah</a></p> <button>Show href Value</button> ``` Is this what you mean?
20,133,837
I am trying to grab the href values from the following string: ``` <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere" class="bigger">random1</a><br/> <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere2" class="bigger">random2</a><br/> ``` In this case, I should get "/pa...
2013/11/21
[ "https://Stackoverflow.com/questions/20133837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1647763/" ]
All you need is DOM and XPath. Regular expressions were not designed for HTML parsing. ``` <?php $html = <<<HTML <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere" class="bigger">random1</a><br/> <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere2" class="bigger">random2<...
Try a pattern like this ``` /width=\"300\"class=\"topborder\"><ahref=\"(.*?)"/ ``` `"(.*?)"` will match any character but is "lazy". That means once it finds the first `"` after the group (in this case: end of the `href` tag), the group will end [demo](http://3v4l.org/BgebB)
20,133,837
I am trying to grab the href values from the following string: ``` <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere" class="bigger">random1</a><br/> <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere2" class="bigger">random2</a><br/> ``` In this case, I should get "/pa...
2013/11/21
[ "https://Stackoverflow.com/questions/20133837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1647763/" ]
Try a pattern like this ``` /width=\"300\"class=\"topborder\"><ahref=\"(.*?)"/ ``` `"(.*?)"` will match any character but is "lazy". That means once it finds the first `"` after the group (in this case: end of the `href` tag), the group will end [demo](http://3v4l.org/BgebB)
or you could try: ``` $htmlc = ' <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere" class="bigger">random1</a><br/> <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere2" class="bigger">random2</a><br/> '; preg_match_all('~(?<=<a\shref=")[^"]*~', $htmlc, $hrefvals); var_du...
20,133,837
I am trying to grab the href values from the following string: ``` <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere" class="bigger">random1</a><br/> <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere2" class="bigger">random2</a><br/> ``` In this case, I should get "/pa...
2013/11/21
[ "https://Stackoverflow.com/questions/20133837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1647763/" ]
All you need is DOM and XPath. Regular expressions were not designed for HTML parsing. ``` <?php $html = <<<HTML <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere" class="bigger">random1</a><br/> <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere2" class="bigger">random2<...
``` <script> $(document).ready(function(){ $("button").click(function(){ alert($("#blah").attr("href")); }); }); </script> ``` Then... ``` <a href="http://www.blah.com" id="blah">Blah</a></p> <button>Show href Value</button> ``` Is this what you mean?
20,133,837
I am trying to grab the href values from the following string: ``` <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere" class="bigger">random1</a><br/> <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere2" class="bigger">random2</a><br/> ``` In this case, I should get "/pa...
2013/11/21
[ "https://Stackoverflow.com/questions/20133837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1647763/" ]
or you could try: ``` $htmlc = ' <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere" class="bigger">random1</a><br/> <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere2" class="bigger">random2</a><br/> '; preg_match_all('~(?<=<a\shref=")[^"]*~', $htmlc, $hrefvals); var_du...
``` <script> $(document).ready(function(){ $("button").click(function(){ alert($("#blah").attr("href")); }); }); </script> ``` Then... ``` <a href="http://www.blah.com" id="blah">Blah</a></p> <button>Show href Value</button> ``` Is this what you mean?
20,133,837
I am trying to grab the href values from the following string: ``` <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere" class="bigger">random1</a><br/> <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere2" class="bigger">random2</a><br/> ``` In this case, I should get "/pa...
2013/11/21
[ "https://Stackoverflow.com/questions/20133837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1647763/" ]
All you need is DOM and XPath. Regular expressions were not designed for HTML parsing. ``` <?php $html = <<<HTML <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere" class="bigger">random1</a><br/> <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere2" class="bigger">random2<...
or you could try: ``` $htmlc = ' <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere" class="bigger">random1</a><br/> <td valign="top" width="300"class="topborder"><a href="/path/to/somewhere2" class="bigger">random2</a><br/> '; preg_match_all('~(?<=<a\shref=")[^"]*~', $htmlc, $hrefvals); var_du...
932,911
I would like to know if the following integral is divergent: $$\int\_{-1}^1 \frac{dx}{\sqrt{1-x^2}} = \pi $$ Wolfram alpha returned a finite answer of [$\pi$](http://www.wolframalpha.com/input/?i=Int%5B+1%2Fsqrt%281+-+x%5E2%29%2C+-1%2C1%5D). It looks like it should have poles at $x=-1,1$. Can explain? The antidervia...
2014/09/15
[ "https://math.stackexchange.com/questions/932911", "https://math.stackexchange.com", "https://math.stackexchange.com/users/4997/" ]
$$\int\_{-1}^1 \frac{dx}{x^2 - 1}=\int\_{-1}^1 \left(\frac{1}{2 x - 2}- \frac{1}{2 x + 2}\right) \, dx$$ $$\int\_{-1}^1\frac{1}{x + 1}=[\ln(x+1)]\_{-1}^1.$$ However, $\ln(x+1)$ isn't defined for $x=-1$, and $\displaystyle\lim\_{x\rightarrow-1}\ln(x+1)=-\infty$. Therefore $\int\_{-1}^1 \frac{dx}{x^2 - 1}$ is not defi...
**Hint:** Notice that, due to the [parity](http://en.wikipedia.org/wiki/Even_and_odd_functions) of the integrand, our expression becomes $I=2\displaystyle\int\_0^1\dfrac{dx}{\sqrt{1-x^2}}$. Now, let $x=1-t$. Our integral becomes $I=2\displaystyle\int\_0^1\dfrac{dt}{\sqrt{t~(2-t)}}$, whose convergence is the same as...
932,911
I would like to know if the following integral is divergent: $$\int\_{-1}^1 \frac{dx}{\sqrt{1-x^2}} = \pi $$ Wolfram alpha returned a finite answer of [$\pi$](http://www.wolframalpha.com/input/?i=Int%5B+1%2Fsqrt%281+-+x%5E2%29%2C+-1%2C1%5D). It looks like it should have poles at $x=-1,1$. Can explain? The antidervia...
2014/09/15
[ "https://math.stackexchange.com/questions/932911", "https://math.stackexchange.com", "https://math.stackexchange.com/users/4997/" ]
$$\int\_{-1}^1 \frac{dx}{x^2 - 1}=\int\_{-1}^1 \left(\frac{1}{2 x - 2}- \frac{1}{2 x + 2}\right) \, dx$$ $$\int\_{-1}^1\frac{1}{x + 1}=[\ln(x+1)]\_{-1}^1.$$ However, $\ln(x+1)$ isn't defined for $x=-1$, and $\displaystyle\lim\_{x\rightarrow-1}\ln(x+1)=-\infty$. Therefore $\int\_{-1}^1 \frac{dx}{x^2 - 1}$ is not defi...
We want $$\lim\_{(\delta,\epsilon)\to(0^+,0^+)}\int\_{-1+\delta}^{1-\epsilon} \frac{1}{\sqrt{1-x^2}}\,dx.$$ This is $$\lim\_{(\delta,\epsilon)\to(0^+,0^+)}\left(\arcsin(1-\epsilon)-\arcsin(-1+\delta)\right).$$ But $$\lim\_{\epsilon\to 0^+}\arcsin(1-\epsilon)=\frac{\pi}{2}\quad\text{and}\quad \lim\_{\delta\to 0^+}\arc...
23,049,901
I have multiple NSTextFields and other controls embedded in custom views: ``` Custom View - Image View - Custom View -- Text Field -- Text Field . . . - Custom View -- Text Field -- Text Field . . . ``` NSTextFields have assigned tooltips. These tooltips are not being displayed, mouse events are probably intercept b...
2014/04/13
[ "https://Stackoverflow.com/questions/23049901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3530139/" ]
This is invalid code - although it compiles, which is peculiar because other programming languages would flag it as an error on the spot: ``` return total_1 print total_1 # unreachable code, function ends with return on previous line ``` It should be: ``` print total_1 return total_1 ``` In other words: a `retur...
You could simplify this a bit by either using a list comprehension or keeping a running total rather than building up a second list. ``` def scrabble_score(word): return sum((score.get(x.lower(), 0) for x in word)) print scrabble_score('Hey') >>> 9 ``` Or ``` def scrabble_score2(word): total = 0 for w ...
23,049,901
I have multiple NSTextFields and other controls embedded in custom views: ``` Custom View - Image View - Custom View -- Text Field -- Text Field . . . - Custom View -- Text Field -- Text Field . . . ``` NSTextFields have assigned tooltips. These tooltips are not being displayed, mouse events are probably intercept b...
2014/04/13
[ "https://Stackoverflow.com/questions/23049901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3530139/" ]
`return` will return control of the program back to the caller. Anything past it is (essentially) unreachable code. Reverse the order of your statements, and your `print` statement will work: ``` print total_1 return total_1 ```
You could simplify this a bit by either using a list comprehension or keeping a running total rather than building up a second list. ``` def scrabble_score(word): return sum((score.get(x.lower(), 0) for x in word)) print scrabble_score('Hey') >>> 9 ``` Or ``` def scrabble_score2(word): total = 0 for w ...
15,533,456
I'm trying to use the following code on my server to estimate the length of some text fields and potentially trim them before sending them by email... ``` String.prototype.visualLength = function() { var element = document.createElement("span"); element.css({ "visibility": "hidden", "white-spac...
2013/03/20
[ "https://Stackoverflow.com/questions/15533456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1981580/" ]
This is fairly easy to create yourself just by adding classes with an onClick handler, and then styling with the classes how you see fit. They're probably not using a plugin for this but is actually a bespoke function they've created them selves with the jQuery library. For example. ``` $('.style').on('click',functi...
The example you provided is using this <http://drupal.org/project/flexslider> EDIT I'm sorry I got confused. The style switcher is custom made by Envato, the company behind themeforest you can find the code here <http://centum.envato.tabvn.com/sites/all/themes/centum/js/switcher.js>
15,533,456
I'm trying to use the following code on my server to estimate the length of some text fields and potentially trim them before sending them by email... ``` String.prototype.visualLength = function() { var element = document.createElement("span"); element.css({ "visibility": "hidden", "white-spac...
2013/03/20
[ "https://Stackoverflow.com/questions/15533456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1981580/" ]
if someone still looking here are two solutions [Blast.js](http://www.jqueryscript.net/other/Minimal-jQuery-Based-Site-Theme-Color-Scheme-Switcher-Blast-js.html) or [JTS](http://www.jqueryscript.net/other/jQuery-Plugin-To-Create-A-Theme-Skin-Switcher.html)
The example you provided is using this <http://drupal.org/project/flexslider> EDIT I'm sorry I got confused. The style switcher is custom made by Envato, the company behind themeforest you can find the code here <http://centum.envato.tabvn.com/sites/all/themes/centum/js/switcher.js>
15,533,456
I'm trying to use the following code on my server to estimate the length of some text fields and potentially trim them before sending them by email... ``` String.prototype.visualLength = function() { var element = document.createElement("span"); element.css({ "visibility": "hidden", "white-spac...
2013/03/20
[ "https://Stackoverflow.com/questions/15533456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1981580/" ]
This is fairly easy to create yourself just by adding classes with an onClick handler, and then styling with the classes how you see fit. They're probably not using a plugin for this but is actually a bespoke function they've created them selves with the jQuery library. For example. ``` $('.style').on('click',functi...
if someone still looking here are two solutions [Blast.js](http://www.jqueryscript.net/other/Minimal-jQuery-Based-Site-Theme-Color-Scheme-Switcher-Blast-js.html) or [JTS](http://www.jqueryscript.net/other/jQuery-Plugin-To-Create-A-Theme-Skin-Switcher.html)
56,904,949
I have an array which looks like this : ``` var array = [ { key : { id : 1 , pack : "pack 1"}, values : [ { item : { id : 1 , name : "item1"}, itemP : {id : 2 , name : "itemP12"} }, { item : { id : 4 , name : "item...
2019/07/05
[ "https://Stackoverflow.com/questions/56904949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10863293/" ]
As Val noticed, you cant access `_source` of documents in script queries in recent versions of Elasticsearch. But elasticsearch allow you to access this `_source` in the "score context". So a possible workaround ( but you need to be careful about the performance ) is to use a scripted score combined with a min\_scor...
> > 1 - Filter documents where size of employee array is == 3 > > > For the first problem, the best thing to do is to add another root-level field (e.g. `NbEmployees`) that contains the number of items in the `Employee` array so that you can use a `range` query and not a costly `script` query. Then, whenever you ...
4,257,098
I have a bash script, a.sh , and in it I have call a python script b.py . The python script calculates something, and I want it to return a value that will be used later in a.sh . I know I can do In a.sh: ``` var=`python b.py` ``` In b.py: ``` print x # when x is the value I want to pass ``` But this is not so c...
2010/11/23
[ "https://Stackoverflow.com/questions/4257098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/170102/" ]
I'm not sure about "better", but you *could* write the result to a file then read it back in in Bash and delete it afterwards. This is definitely ugly, but it's something to keep in mind in case nothing else does the trick.
In shell script you can use like this `python_ret=$(python b.py)`. It contains all print messages from python file b.py. Then you can search for a string which you are looking for. For example, if you are looking for 'Exception', you can lieke this ``` if [[ $python_ret == *"Exception:"* ]]; then echo "Got some e...
4,257,098
I have a bash script, a.sh , and in it I have call a python script b.py . The python script calculates something, and I want it to return a value that will be used later in a.sh . I know I can do In a.sh: ``` var=`python b.py` ``` In b.py: ``` print x # when x is the value I want to pass ``` But this is not so c...
2010/11/23
[ "https://Stackoverflow.com/questions/4257098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/170102/" ]
I believe the answer is .py ``` import sys a=['zero','one','two','three'] b = int(sys.argv[1]) ###your python script can still print to stderr if it likes to print >> sys.stderr, "I am no converting" result = a[b] print result ``` .sh ``` #!/bin/sh num=2 text=`python numtotext.py $num` echo "$num as tex...
You can write the output to a temporary file, and have the shell read and delete that file. This is even less convenient, but reserves stdout for communication with the user. Alternatively, you can use some kind of format for stdout: the first n lines are certain variables, the rest will be echoed by the parent shell ...
4,257,098
I have a bash script, a.sh , and in it I have call a python script b.py . The python script calculates something, and I want it to return a value that will be used later in a.sh . I know I can do In a.sh: ``` var=`python b.py` ``` In b.py: ``` print x # when x is the value I want to pass ``` But this is not so c...
2010/11/23
[ "https://Stackoverflow.com/questions/4257098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/170102/" ]
I would print it to a file chosen on the command line then I'd get that value in bash with something like `cat`. So you'd go: ``` python b.py tempfile.txt var=`cat tempfile.txt` rm tempfile.txt ``` **[EDIT, another idea based on other answers]** Your other option is to format your output carefully so you can use b...
In shell script you can use like this `python_ret=$(python b.py)`. It contains all print messages from python file b.py. Then you can search for a string which you are looking for. For example, if you are looking for 'Exception', you can lieke this ``` if [[ $python_ret == *"Exception:"* ]]; then echo "Got some e...
4,257,098
I have a bash script, a.sh , and in it I have call a python script b.py . The python script calculates something, and I want it to return a value that will be used later in a.sh . I know I can do In a.sh: ``` var=`python b.py` ``` In b.py: ``` print x # when x is the value I want to pass ``` But this is not so c...
2010/11/23
[ "https://Stackoverflow.com/questions/4257098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/170102/" ]
I would print it to a file chosen on the command line then I'd get that value in bash with something like `cat`. So you'd go: ``` python b.py tempfile.txt var=`cat tempfile.txt` rm tempfile.txt ``` **[EDIT, another idea based on other answers]** Your other option is to format your output carefully so you can use b...
You can write the output to a temporary file, and have the shell read and delete that file. This is even less convenient, but reserves stdout for communication with the user. Alternatively, you can use some kind of format for stdout: the first n lines are certain variables, the rest will be echoed by the parent shell ...
4,257,098
I have a bash script, a.sh , and in it I have call a python script b.py . The python script calculates something, and I want it to return a value that will be used later in a.sh . I know I can do In a.sh: ``` var=`python b.py` ``` In b.py: ``` print x # when x is the value I want to pass ``` But this is not so c...
2010/11/23
[ "https://Stackoverflow.com/questions/4257098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/170102/" ]
I would print it to a file chosen on the command line then I'd get that value in bash with something like `cat`. So you'd go: ``` python b.py tempfile.txt var=`cat tempfile.txt` rm tempfile.txt ``` **[EDIT, another idea based on other answers]** Your other option is to format your output carefully so you can use b...
On bash `backsticks works` I usualy do something like ``` PIP_PATH=`python -c "from distutils.sysconfig \ import get_python_lib; print(get_python_lib())"` POWELINE_PATH=$PIP_PATH"/powerline" echo $POWELINE_PATH ```
4,257,098
I have a bash script, a.sh , and in it I have call a python script b.py . The python script calculates something, and I want it to return a value that will be used later in a.sh . I know I can do In a.sh: ``` var=`python b.py` ``` In b.py: ``` print x # when x is the value I want to pass ``` But this is not so c...
2010/11/23
[ "https://Stackoverflow.com/questions/4257098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/170102/" ]
I believe the answer is .py ``` import sys a=['zero','one','two','three'] b = int(sys.argv[1]) ###your python script can still print to stderr if it likes to print >> sys.stderr, "I am no converting" result = a[b] print result ``` .sh ``` #!/bin/sh num=2 text=`python numtotext.py $num` echo "$num as tex...
In shell script you can use like this `python_ret=$(python b.py)`. It contains all print messages from python file b.py. Then you can search for a string which you are looking for. For example, if you are looking for 'Exception', you can lieke this ``` if [[ $python_ret == *"Exception:"* ]]; then echo "Got some e...
4,257,098
I have a bash script, a.sh , and in it I have call a python script b.py . The python script calculates something, and I want it to return a value that will be used later in a.sh . I know I can do In a.sh: ``` var=`python b.py` ``` In b.py: ``` print x # when x is the value I want to pass ``` But this is not so c...
2010/11/23
[ "https://Stackoverflow.com/questions/4257098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/170102/" ]
I'm not sure about "better", but you *could* write the result to a file then read it back in in Bash and delete it afterwards. This is definitely ugly, but it's something to keep in mind in case nothing else does the trick.
Better to forward the print value from the python script to a temp file before assigning it in a bash value. I believe there's no need to remove the file if this is the case. ``` !#/bin/bash python b.py > tempfile.txt var=`cat tempfile.txt` ``` Then, get the value: ``` echo $var ```
4,257,098
I have a bash script, a.sh , and in it I have call a python script b.py . The python script calculates something, and I want it to return a value that will be used later in a.sh . I know I can do In a.sh: ``` var=`python b.py` ``` In b.py: ``` print x # when x is the value I want to pass ``` But this is not so c...
2010/11/23
[ "https://Stackoverflow.com/questions/4257098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/170102/" ]
I would print it to a file chosen on the command line then I'd get that value in bash with something like `cat`. So you'd go: ``` python b.py tempfile.txt var=`cat tempfile.txt` rm tempfile.txt ``` **[EDIT, another idea based on other answers]** Your other option is to format your output carefully so you can use b...
Better to forward the print value from the python script to a temp file before assigning it in a bash value. I believe there's no need to remove the file if this is the case. ``` !#/bin/bash python b.py > tempfile.txt var=`cat tempfile.txt` ``` Then, get the value: ``` echo $var ```
4,257,098
I have a bash script, a.sh , and in it I have call a python script b.py . The python script calculates something, and I want it to return a value that will be used later in a.sh . I know I can do In a.sh: ``` var=`python b.py` ``` In b.py: ``` print x # when x is the value I want to pass ``` But this is not so c...
2010/11/23
[ "https://Stackoverflow.com/questions/4257098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/170102/" ]
I'm not sure about "better", but you *could* write the result to a file then read it back in in Bash and delete it afterwards. This is definitely ugly, but it's something to keep in mind in case nothing else does the trick.
You can write the output to a temporary file, and have the shell read and delete that file. This is even less convenient, but reserves stdout for communication with the user. Alternatively, you can use some kind of format for stdout: the first n lines are certain variables, the rest will be echoed by the parent shell ...
4,257,098
I have a bash script, a.sh , and in it I have call a python script b.py . The python script calculates something, and I want it to return a value that will be used later in a.sh . I know I can do In a.sh: ``` var=`python b.py` ``` In b.py: ``` print x # when x is the value I want to pass ``` But this is not so c...
2010/11/23
[ "https://Stackoverflow.com/questions/4257098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/170102/" ]
In your python script, redirect another messages to stderr, and print `x` to stdout: ``` import sys ... print >>sys.stderr, "another message" print x ``` in the bash script: ``` ... var=`python b.py 2>/dev/null` ``` Also, if x is an integer between 0,255, you can use exit code to pass it to the bash: ``` import ...
You can write the output to a temporary file, and have the shell read and delete that file. This is even less convenient, but reserves stdout for communication with the user. Alternatively, you can use some kind of format for stdout: the first n lines are certain variables, the rest will be echoed by the parent shell ...
1,861,002
Given that $a^2 + b^2 = 1$, $c^2 + d^2 = 1$, $p^2 + q^2 = 1$, where $a$, $b$, $c$, $d$, $p$, $q$ are all real numbers, prove that $ab + cd + pq\le \frac{3}{2}$.
2016/07/16
[ "https://math.stackexchange.com/questions/1861002", "https://math.stackexchange.com", "https://math.stackexchange.com/users/310685/" ]
HINT: For real $a-b,c-d,p-q;$ $$(a-b)^2+(c-d)^2+(p-q)^2\ge0$$ --- More generally for real $a,b;$ $$a^2+b^2=(a-b)^2+2ab\ge2ab\iff2ab\le a^2+b^2=?$$
Subtracting 2ab, 2cd and 2pq from the three equations gives us: $$ a^2+b^2-2ab = 1 - 2ab$$$$ c^2 + d^2 - 2cd = 1 - 2cd$$$$p^2+q^2 - 2pq = 1-2pq$$ Noting that the LHS of each of these equations is a perfect square and all perfect squares are non-negative we have:$$1-2ab≥0$$$$1-2cd≥0$$$$1-2pq≥0$$ Adding the three equa...
44,304,689
I am currently using the SQL command ``` Select * from where name='john' ``` Is it possible to return 20 no matter the query, for example ``` Select * from where name='john' or return = 20 ```
2017/06/01
[ "https://Stackoverflow.com/questions/44304689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7113481/" ]
**EDIT** If you have an oracle database you can do something like that: ``` SELECT * FROM dual WHERE 1=0 UNION SELECT '20' FROM dual; ```
check my answer ``` if exists (Select * from item where ItemName='ABC Daycare1') begin Select * from item where ItemName='ABC Daycare1' end else select '20' ```
44,304,689
I am currently using the SQL command ``` Select * from where name='john' ``` Is it possible to return 20 no matter the query, for example ``` Select * from where name='john' or return = 20 ```
2017/06/01
[ "https://Stackoverflow.com/questions/44304689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7113481/" ]
**EDIT** If you have an oracle database you can do something like that: ``` SELECT * FROM dual WHERE 1=0 UNION SELECT '20' FROM dual; ```
Try running this. This should return the top result (which is never 20 due to the custom sort) and then when the name doesn't match a value it returns 'Mark' and 20 **SQL** ``` IF OBJECT_ID('tempdb..#temp') IS NOT NULL DROP TABLE #temp CREATE TABLE #temp (id int NOT NULL, name varchar(255) NOT NULL) INSERT INTO #te...
44,304,689
I am currently using the SQL command ``` Select * from where name='john' ``` Is it possible to return 20 no matter the query, for example ``` Select * from where name='john' or return = 20 ```
2017/06/01
[ "https://Stackoverflow.com/questions/44304689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7113481/" ]
check my answer ``` if exists (Select * from item where ItemName='ABC Daycare1') begin Select * from item where ItemName='ABC Daycare1' end else select '20' ```
Try running this. This should return the top result (which is never 20 due to the custom sort) and then when the name doesn't match a value it returns 'Mark' and 20 **SQL** ``` IF OBJECT_ID('tempdb..#temp') IS NOT NULL DROP TABLE #temp CREATE TABLE #temp (id int NOT NULL, name varchar(255) NOT NULL) INSERT INTO #te...
143,084
I've got a backup script written in Python which creates the destination directory before copying the source directory to it. I've configured it to use `/external-backup` as the destination, which is where I mount an external hard drive. I just ran the script without the hard drive being turned on (or being mounted) an...
2010/05/18
[ "https://serverfault.com/questions/143084", "https://serverfault.com", "https://serverfault.com/users/13642/" ]
For a definitive answer to something only the kernel knows for sure, ask the kernel: ``` cat /proc/mounts ``` That file can be read / parsed as if it was a normal file, using any tools you like. Including Python. Quick-n-dirty example: ``` #!/usr/bin/python d = {} for l in file('/proc/mounts'): if l[0] == '/'...
The /etc/mtab file exists to tell you what is currently mounted. There is a `getmntent` call, but I don't think it's exported in the `os` module. The quick and dirty? Open /etc/mtab and split. Ensure your device is present in column 0 and the destination mount point in column 1 is correct.
143,084
I've got a backup script written in Python which creates the destination directory before copying the source directory to it. I've configured it to use `/external-backup` as the destination, which is where I mount an external hard drive. I just ran the script without the hard drive being turned on (or being mounted) an...
2010/05/18
[ "https://serverfault.com/questions/143084", "https://serverfault.com", "https://serverfault.com/users/13642/" ]
I would take a look at [`os.path.ismount()`](https://docs.python.org/3/library/os.path.html#os.path.ismount).
The easiest way to check is to invoke `mount` via `subprocess` and see if it shows up there. For extra credit, use `os.readlink()` on the contents of `/dev/disk/by-*` to figure out which device it is.
143,084
I've got a backup script written in Python which creates the destination directory before copying the source directory to it. I've configured it to use `/external-backup` as the destination, which is where I mount an external hard drive. I just ran the script without the hard drive being turned on (or being mounted) an...
2010/05/18
[ "https://serverfault.com/questions/143084", "https://serverfault.com", "https://serverfault.com/users/13642/" ]
For a definitive answer to something only the kernel knows for sure, ask the kernel: ``` cat /proc/mounts ``` That file can be read / parsed as if it was a normal file, using any tools you like. Including Python. Quick-n-dirty example: ``` #!/usr/bin/python d = {} for l in file('/proc/mounts'): if l[0] == '/'...
The easiest way to check is to invoke `mount` via `subprocess` and see if it shows up there. For extra credit, use `os.readlink()` on the contents of `/dev/disk/by-*` to figure out which device it is.
143,084
I've got a backup script written in Python which creates the destination directory before copying the source directory to it. I've configured it to use `/external-backup` as the destination, which is where I mount an external hard drive. I just ran the script without the hard drive being turned on (or being mounted) an...
2010/05/18
[ "https://serverfault.com/questions/143084", "https://serverfault.com", "https://serverfault.com/users/13642/" ]
The easiest way to check is to invoke `mount` via `subprocess` and see if it shows up there. For extra credit, use `os.readlink()` on the contents of `/dev/disk/by-*` to figure out which device it is.
The /etc/mtab file exists to tell you what is currently mounted. There is a `getmntent` call, but I don't think it's exported in the `os` module. The quick and dirty? Open /etc/mtab and split. Ensure your device is present in column 0 and the destination mount point in column 1 is correct.
143,084
I've got a backup script written in Python which creates the destination directory before copying the source directory to it. I've configured it to use `/external-backup` as the destination, which is where I mount an external hard drive. I just ran the script without the hard drive being turned on (or being mounted) an...
2010/05/18
[ "https://serverfault.com/questions/143084", "https://serverfault.com", "https://serverfault.com/users/13642/" ]
For a definitive answer to something only the kernel knows for sure, ask the kernel: ``` cat /proc/mounts ``` That file can be read / parsed as if it was a normal file, using any tools you like. Including Python. Quick-n-dirty example: ``` #!/usr/bin/python d = {} for l in file('/proc/mounts'): if l[0] == '/'...
You can try this but it won't work in every case: ``` from pathlib import Path def guess_mounted(path) -> bool: for p in [Path(path)] + list(Path(path).parents): if p == Path('/'): return False elif p.is_mount(): return True return False ``` Then later in your code yo...
143,084
I've got a backup script written in Python which creates the destination directory before copying the source directory to it. I've configured it to use `/external-backup` as the destination, which is where I mount an external hard drive. I just ran the script without the hard drive being turned on (or being mounted) an...
2010/05/18
[ "https://serverfault.com/questions/143084", "https://serverfault.com", "https://serverfault.com/users/13642/" ]
Bonus answer. If external device is not mounted data is written to root partition at path `/external-backup`. If external device is mounted data on root partition is still there but it is not reachable because `/external-backup` is now pointing to external device.
The /etc/mtab file exists to tell you what is currently mounted. There is a `getmntent` call, but I don't think it's exported in the `os` module. The quick and dirty? Open /etc/mtab and split. Ensure your device is present in column 0 and the destination mount point in column 1 is correct.
143,084
I've got a backup script written in Python which creates the destination directory before copying the source directory to it. I've configured it to use `/external-backup` as the destination, which is where I mount an external hard drive. I just ran the script without the hard drive being turned on (or being mounted) an...
2010/05/18
[ "https://serverfault.com/questions/143084", "https://serverfault.com", "https://serverfault.com/users/13642/" ]
I would take a look at [`os.path.ismount()`](https://docs.python.org/3/library/os.path.html#os.path.ismount).
Bonus answer. If external device is not mounted data is written to root partition at path `/external-backup`. If external device is mounted data on root partition is still there but it is not reachable because `/external-backup` is now pointing to external device.
143,084
I've got a backup script written in Python which creates the destination directory before copying the source directory to it. I've configured it to use `/external-backup` as the destination, which is where I mount an external hard drive. I just ran the script without the hard drive being turned on (or being mounted) an...
2010/05/18
[ "https://serverfault.com/questions/143084", "https://serverfault.com", "https://serverfault.com/users/13642/" ]
I would take a look at [`os.path.ismount()`](https://docs.python.org/3/library/os.path.html#os.path.ismount).
The /etc/mtab file exists to tell you what is currently mounted. There is a `getmntent` call, but I don't think it's exported in the `os` module. The quick and dirty? Open /etc/mtab and split. Ensure your device is present in column 0 and the destination mount point in column 1 is correct.
143,084
I've got a backup script written in Python which creates the destination directory before copying the source directory to it. I've configured it to use `/external-backup` as the destination, which is where I mount an external hard drive. I just ran the script without the hard drive being turned on (or being mounted) an...
2010/05/18
[ "https://serverfault.com/questions/143084", "https://serverfault.com", "https://serverfault.com/users/13642/" ]
Old question, but I thought I'd contribute my solution (based on [Dennis Williamson's](https://serverfault.com/questions/143084/how-can-i-check-whether-a-volume-is-mounted-where-it-is-supposed-to-be-using-pyt/143094#143094) and [Ignacio Vazquez-Abrams's](https://serverfault.com/questions/143084/how-can-i-check-whether-...
The /etc/mtab file exists to tell you what is currently mounted. There is a `getmntent` call, but I don't think it's exported in the `os` module. The quick and dirty? Open /etc/mtab and split. Ensure your device is present in column 0 and the destination mount point in column 1 is correct.
143,084
I've got a backup script written in Python which creates the destination directory before copying the source directory to it. I've configured it to use `/external-backup` as the destination, which is where I mount an external hard drive. I just ran the script without the hard drive being turned on (or being mounted) an...
2010/05/18
[ "https://serverfault.com/questions/143084", "https://serverfault.com", "https://serverfault.com/users/13642/" ]
For a definitive answer to something only the kernel knows for sure, ask the kernel: ``` cat /proc/mounts ``` That file can be read / parsed as if it was a normal file, using any tools you like. Including Python. Quick-n-dirty example: ``` #!/usr/bin/python d = {} for l in file('/proc/mounts'): if l[0] == '/'...
Bonus answer. If external device is not mounted data is written to root partition at path `/external-backup`. If external device is mounted data on root partition is still there but it is not reachable because `/external-backup` is now pointing to external device.
5,014,871
Does anybody know is there any open source program or web app for file tracking (not version control, much simpler, add name of new file, add user, add users to some file, set privileges to user,track revision of file, notify user for change - most of time it will work with .doc files) writen in Java, Python, C# or Has...
2011/02/16
[ "https://Stackoverflow.com/questions/5014871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/619391/" ]
It sounds like you want both version control and a web interface to it. One approach would be something like gitit/darcsit, a wiki/cms system with a git or darcs backend: <http://gitit.net/>
Im not exactly sure what you mean by it, but there are tools/utilitys such as [git](http://git-scm.com/) that can be used for tracking changes in files and restoring if needed. I wonderful compliment to git is [github](https://github.com/) that can be used for collaborative project work
5,014,871
Does anybody know is there any open source program or web app for file tracking (not version control, much simpler, add name of new file, add user, add users to some file, set privileges to user,track revision of file, notify user for change - most of time it will work with .doc files) writen in Java, Python, C# or Has...
2011/02/16
[ "https://Stackoverflow.com/questions/5014871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/619391/" ]
It sounds like you want both version control and a web interface to it. One approach would be something like gitit/darcsit, a wiki/cms system with a git or darcs backend: <http://gitit.net/>
You are asking about version control such as CVS,CM Synergy .But if you want to keep track on a file then , there is an API for this > > JNotify java API JNotify is a java > library that allow java application to > listen to file system events, such as: > > > > ``` > * File created > * File modified > * File re...
59,699,576
> > The function Celsius2Fahrenheit will convert Celsius to Fahrenheit to be used later, and the range is supposed to go up each time by .5, and stop at 101, but you cant use a float value in range, (I am a beginner at python), can someone please help. > > > ``` def Celsius2Fahrenheit(c): """ This will Convert c C...
2020/01/11
[ "https://Stackoverflow.com/questions/59699576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12696534/" ]
Here are two possibilities: 1) Multiply your range by 10 so that the values become integers you can use with `range()`. Then you would divide the index variable by 10 to get back the float values you are after, like this: ``` for ix in range(0, 1010, 5): x = ix / 10 <...rest of your code...> ``` 2) You can ...
Because you can increment range like you that. Try this, ``` import numpy as np def Celsius2Fahrenheit(c): #This will Convert c Celsius to its Fahrenheit equivalent""" return c * 9 / 5 + 32 ``` Use numpy [arange](https://docs.scipy.org/doc/numpy/reference/generated/numpy.arange.html), ``` for x in np.arange(0...
59,699,576
> > The function Celsius2Fahrenheit will convert Celsius to Fahrenheit to be used later, and the range is supposed to go up each time by .5, and stop at 101, but you cant use a float value in range, (I am a beginner at python), can someone please help. > > > ``` def Celsius2Fahrenheit(c): """ This will Convert c C...
2020/01/11
[ "https://Stackoverflow.com/questions/59699576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12696534/" ]
Here are two possibilities: 1) Multiply your range by 10 so that the values become integers you can use with `range()`. Then you would divide the index variable by 10 to get back the float values you are after, like this: ``` for ix in range(0, 1010, 5): x = ix / 10 <...rest of your code...> ``` 2) You can ...
There are two basic ways you could do this, by using a while loop and modifying a value yourself, or changing the bounds for the range function. The first method is likely preferred as it will be more accurate and easy to code. ``` def Celsius2Fahrenheit(c): """ This will Convert c Celsius to its Fahrenheit equiv...
59,699,576
> > The function Celsius2Fahrenheit will convert Celsius to Fahrenheit to be used later, and the range is supposed to go up each time by .5, and stop at 101, but you cant use a float value in range, (I am a beginner at python), can someone please help. > > > ``` def Celsius2Fahrenheit(c): """ This will Convert c C...
2020/01/11
[ "https://Stackoverflow.com/questions/59699576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12696534/" ]
Here are two possibilities: 1) Multiply your range by 10 so that the values become integers you can use with `range()`. Then you would divide the index variable by 10 to get back the float values you are after, like this: ``` for ix in range(0, 1010, 5): x = ix / 10 <...rest of your code...> ``` 2) You can ...
try this ``` def Celsius2Fahrenheit(c): return c * 9 / 5 + 32 for x in map(lambda x: x/10.0, range(0, 1005, 5)): # This will print the values using new style formatting e = Celsius2Fahrenheit(x) if (e > 0): print(" {:3.1f} (C) | {:6.2f} (F) ".format(x,e)) else: print(" {:3.1f} (C) | {:...
23,989,096
I have some jQuery that does something on screen size. The problem is that I want to do that on event resize window. Here is what I have for now: ``` if ($(window).width() >= 1000) { jQuery('ul.nav li.dropdown').hover(function () { jQuery(this).find('.dropdown-menu').stop(true, true).delay(200).fadeIn(); ...
2014/06/02
[ "https://Stackoverflow.com/questions/23989096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3165604/" ]
From the command line or from within `top`? If you're already in `top`, press `f` and toggle the columns you want to see. Alternatively, you can use `ps`: ``` ps -eo %cpu,pid --sort -%cpu ```
``` top -stats "cpu,command" ``` If you want, extend it with PID or any other details. top -stats "pid, command,cpu"
26,493,388
I am doing my homework which is about a chat program. It has two interfaces, one is for server and the second one is for client. Program flow is as the following: 1. Server starts a connection on a certain port 2. Client starts and tries to connect to server 3. If everything is OK, they start chatting 4. One of the te...
2014/10/21
[ "https://Stackoverflow.com/questions/26493388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1494102/" ]
The issue is that you are using `SwingUtilities.invokeLater`. As [this answer](https://stackoverflow.com/a/6568120/2479481) explains, `invokeLater` executes the `run` body inside the application's primary `Thread`. Since your UI is also operating in this `Thread`, you'll need to use another method. You'll want to put ...
Your infinite cycle is a busy wait, which prevents your UI from refreshing. You have two problems: * busy wait is not the best approach * waiting prevents UI actualization and event-handling Instead of busy waiting, please, look for [alternatives](https://stackoverflow.com/questions/18866115/alternate-to-busy-wait). ...
5,057
I was wondering if someone has successfully implemented both Facebook Connect and Zoo Visitor on a single site. Are there any issues I should be aware of? Does creating an account through Facebook also trigger the creation of a Zoo Visitor member-channel entry? Client has requested a quote on this functionality and I d...
2013/01/18
[ "https://expressionengine.stackexchange.com/questions/5057", "https://expressionengine.stackexchange.com", "https://expressionengine.stackexchange.com/users/195/" ]
Steven, I would recommend using Yuri’s addon, Social Login PRO, if only for the fact that he and the EE Zoo team have worked to make them work well together. To that extent though, the documentation on ensuring a sync is a little sparse for my tastes. I do see this link: [Integration with Zoo Visitor](http://devot-ee.c...
I've done it on a site I worked on a while back. My memory isn't fresh, since it's been handed off to the client and my hands are completely off it, but I can tell you that it does work — it's just a bit tricky. As powerful and awesome as Zoo Visitor is, you have to remember that you are basically duplicating data fro...
23,016,816
The compiler gives me an error: "Invalid conversion from 'int' to 'const char\*'. The offending line is: ``` change[j]=oper[integer(A[i][j]+A[i][j+1])][0]; ``` Where is my trouble? ``` #include <iostream> #include <sstream> #include <vector> using namespace std; string mas[10000000],oper[100]; int integer(string...
2014/04/11
[ "https://Stackoverflow.com/questions/23016816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3524337/" ]
`integer` converts a `string` to `int`. But you are passing in a `char`, not a `string`.
A is vector<std::string>, so A[j] is string, so A[j][i] is character of the string. Without trying to understand what is the purpose, I can say that A[j][i] + A[j][i+1] sums the character **values**, so if both characters are 'A' and as 'A' is represented by 65, the result value would be 130 ->'é' Then you take this ...
53,233
I've seen a similar question on BSE about entering foreign languages into 3D Text, but it doesn't help. I've tried using two different fonts (both of which support Russian). I've tried enabling International Fonts in Blender's User Preferences, but it doesn't work as well. It either types English text with Greek letter...
2016/05/23
[ "https://blender.stackexchange.com/questions/53233", "https://blender.stackexchange.com", "https://blender.stackexchange.com/users/15366/" ]
Select your text object and under it's data change the font to use: [![enter image description here](https://i.stack.imgur.com/3TArQ.png)](https://i.stack.imgur.com/3TArQ.png) Use a *[Unicode](https://en.wikipedia.org/wiki/Unicode)* font file or a file that has all the symbols you need. On windows machine you can fin...
Have you tried a different font file? You probably have to find a font family that has glyphs for your character set, in this case Russian characters, I am not sure the font shipped by default with Blender default (BFont) has the characters you need. Try downloading a new one from, say [Google Fonts](https://www.goog...
6,866,555
I created a Windows Forms application using Visual Studio Professional in C#. In my program I prompt the user to input the number of rolls he/she wants and then they press enter to get the numbers. The numbers are shown in the same form under a label and get tallied up. I know how to tally the numbers know but I can'...
2011/07/28
[ "https://Stackoverflow.com/questions/6866555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/868412/" ]
Try something like this: ``` Random randGen = new Random(); var rolls = new List<int>(); int sum = 0; for (int i = 0; i < numberOfRolls; i++) { int randomNum1 = randGen.Next(1,7); int randomNum2 = randGen.Next(1,7); sum += randomNum1 + randomNum2; rolls.Add(randomNum1); rolls.Add(randomNum2); } ``...
Your code is totally wrong... ``` Random randGen = new Random(DateTime.Now.Ticks); // unique seed, mostly int result = 0; for (int i = 0; i < number_of_rolls_the_user_wants; i++) result += randGen.Next(2, 14); // (1 - 7) + (1 - 7) = 2 - 14 lol... >.> ``` Replace `number_of_rolls_the_user_wants` with the number ...
6,866,555
I created a Windows Forms application using Visual Studio Professional in C#. In my program I prompt the user to input the number of rolls he/she wants and then they press enter to get the numbers. The numbers are shown in the same form under a label and get tallied up. I know how to tally the numbers know but I can'...
2011/07/28
[ "https://Stackoverflow.com/questions/6866555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/868412/" ]
``` int rolls = Console.ReadLine(); int total = 0; Random randGen = new Random(System.DateTime.Now.Millisecond); for(int i =0; i<rolls; i++) { int oneRoll = randGen.Next(1,7) + randGen.Next(1, 7); Console.WriteLine("Rolled " + oneRoll); total += oneRoll; } Console.WriteLine("Total " + total); ``` NB. you don't need...
Your code is totally wrong... ``` Random randGen = new Random(DateTime.Now.Ticks); // unique seed, mostly int result = 0; for (int i = 0; i < number_of_rolls_the_user_wants; i++) result += randGen.Next(2, 14); // (1 - 7) + (1 - 7) = 2 - 14 lol... >.> ``` Replace `number_of_rolls_the_user_wants` with the number ...
6,866,555
I created a Windows Forms application using Visual Studio Professional in C#. In my program I prompt the user to input the number of rolls he/she wants and then they press enter to get the numbers. The numbers are shown in the same form under a label and get tallied up. I know how to tally the numbers know but I can'...
2011/07/28
[ "https://Stackoverflow.com/questions/6866555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/868412/" ]
Make sure you create the Random Number generator just once. Do NOT create it in each loop iteration. Or, the numbers may not be random because the loop is so tight it will use the same time as the seed in the internal generator.
Your code is totally wrong... ``` Random randGen = new Random(DateTime.Now.Ticks); // unique seed, mostly int result = 0; for (int i = 0; i < number_of_rolls_the_user_wants; i++) result += randGen.Next(2, 14); // (1 - 7) + (1 - 7) = 2 - 14 lol... >.> ``` Replace `number_of_rolls_the_user_wants` with the number ...
4,572,717
I am trying to map the caps lock key to do an action in MacVIM, but I cannot figure out how to map that key.
2010/12/31
[ "https://Stackoverflow.com/questions/4572717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/134482/" ]
No, not using the framework APIs and not without a modified device. You'd need to construct a userdata.img file, which is essentially a block-level copy of the device's user-writable storage. However, you do not have block-level access to the filesystem. On top of that, your application wouldn't have permission to re...
I'm not sure but if it isn't in Googles docs then it probably isn't possible <http://developer.android.com/guide/developing/tools/avd.html> Seems like you'll have to do it all manually. although if you have a phone at your disposal that you wish to copy, the best decision would be to debug directly on the phone itself
4,572,717
I am trying to map the caps lock key to do an action in MacVIM, but I cannot figure out how to map that key.
2010/12/31
[ "https://Stackoverflow.com/questions/4572717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/134482/" ]
No, not using the framework APIs and not without a modified device. You'd need to construct a userdata.img file, which is essentially a block-level copy of the device's user-writable storage. However, you do not have block-level access to the filesystem. On top of that, your application wouldn't have permission to re...
You mean, an Android app being executed on a device (or in the emulator), can it create another instance of the emulator on the host PC? I'd do it in a desktop program, then find a way to invoke it from Android.
4,572,717
I am trying to map the caps lock key to do an action in MacVIM, but I cannot figure out how to map that key.
2010/12/31
[ "https://Stackoverflow.com/questions/4572717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/134482/" ]
No, not using the framework APIs and not without a modified device. You'd need to construct a userdata.img file, which is essentially a block-level copy of the device's user-writable storage. However, you do not have block-level access to the filesystem. On top of that, your application wouldn't have permission to re...
I don't get what you're trying to do. An AVD is useful with an emulator, but there is no emulator that runs on Android hardware. Perhaps you're thinking of making a complete copy of the "disk" that is the Android device? For that you'd need root access, and somewhere to write it to. Something like dd that writes to the...
1,264,781
> > **Possible Duplicates:** > > [(0 == variable) or (null == obj): An outdated practice in C#?](https://stackoverflow.com/questions/655657/0-variable-or-null-obj-an-outdated-practice-in-c) > > [Why does one often see “null != variable” instead of “variable != null” in C#?](https://stackoverflow.com/questions/27...
2009/08/12
[ "https://Stackoverflow.com/questions/1264781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/139357/" ]
No, both are equal
They achieve the same. Personally I have never seen null == user in any of my projects, but if I should render a guess, I'd say it's connected to how you read your every day language. If you are from Europe, odds are you read from left to right, but some languages read from right to left, that may be where it comes fro...
1,264,781
> > **Possible Duplicates:** > > [(0 == variable) or (null == obj): An outdated practice in C#?](https://stackoverflow.com/questions/655657/0-variable-or-null-obj-an-outdated-practice-in-c) > > [Why does one often see “null != variable” instead of “variable != null” in C#?](https://stackoverflow.com/questions/27...
2009/08/12
[ "https://Stackoverflow.com/questions/1264781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/139357/" ]
if(user==null) is easier to read
No, both are equal
1,264,781
> > **Possible Duplicates:** > > [(0 == variable) or (null == obj): An outdated practice in C#?](https://stackoverflow.com/questions/655657/0-variable-or-null-obj-an-outdated-practice-in-c) > > [Why does one often see “null != variable” instead of “variable != null” in C#?](https://stackoverflow.com/questions/27...
2009/08/12
[ "https://Stackoverflow.com/questions/1264781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/139357/" ]
As far as I know... null == object would be a reference comparison. object == null may be overloaded.
No deference between the two statements, they are equal. And that's related to the way that the developer used to write the code.
1,264,781
> > **Possible Duplicates:** > > [(0 == variable) or (null == obj): An outdated practice in C#?](https://stackoverflow.com/questions/655657/0-variable-or-null-obj-an-outdated-practice-in-c) > > [Why does one often see “null != variable” instead of “variable != null” in C#?](https://stackoverflow.com/questions/27...
2009/08/12
[ "https://Stackoverflow.com/questions/1264781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/139357/" ]
it comes from C You could easily write if(user=null) by mistake with only one = sign which instead of comparing assigns null to user and then tests the value of null. If you wrote it as "if (NULL == user)" then you got a compiler error if you accidentally only wrote one = I never liked it, it was as mistake I rarel...
No deference between the two statements, they are equal. And that's related to the way that the developer used to write the code.
1,264,781
> > **Possible Duplicates:** > > [(0 == variable) or (null == obj): An outdated practice in C#?](https://stackoverflow.com/questions/655657/0-variable-or-null-obj-an-outdated-practice-in-c) > > [Why does one often see “null != variable” instead of “variable != null” in C#?](https://stackoverflow.com/questions/27...
2009/08/12
[ "https://Stackoverflow.com/questions/1264781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/139357/" ]
if(user==null) is easier to read
It just makes more logical sense to do: if (user == null) as it is the user you are evaluating, you are just using null as a comparison.
1,264,781
> > **Possible Duplicates:** > > [(0 == variable) or (null == obj): An outdated practice in C#?](https://stackoverflow.com/questions/655657/0-variable-or-null-obj-an-outdated-practice-in-c) > > [Why does one often see “null != variable” instead of “variable != null” in C#?](https://stackoverflow.com/questions/27...
2009/08/12
[ "https://Stackoverflow.com/questions/1264781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/139357/" ]
`user == null` is human speak. `null == user` is Yoda speak. To the compiler they are the same, so pick the one you are most comfortable with.
it comes from C You could easily write if(user=null) by mistake with only one = sign which instead of comparing assigns null to user and then tests the value of null. If you wrote it as "if (NULL == user)" then you got a compiler error if you accidentally only wrote one = I never liked it, it was as mistake I rarel...
1,264,781
> > **Possible Duplicates:** > > [(0 == variable) or (null == obj): An outdated practice in C#?](https://stackoverflow.com/questions/655657/0-variable-or-null-obj-an-outdated-practice-in-c) > > [Why does one often see “null != variable” instead of “variable != null” in C#?](https://stackoverflow.com/questions/27...
2009/08/12
[ "https://Stackoverflow.com/questions/1264781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/139357/" ]
As far as I know... null == object would be a reference comparison. object == null may be overloaded.
No, both are equal
1,264,781
> > **Possible Duplicates:** > > [(0 == variable) or (null == obj): An outdated practice in C#?](https://stackoverflow.com/questions/655657/0-variable-or-null-obj-an-outdated-practice-in-c) > > [Why does one often see “null != variable” instead of “variable != null” in C#?](https://stackoverflow.com/questions/27...
2009/08/12
[ "https://Stackoverflow.com/questions/1264781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/139357/" ]
if(user==null) is easier to read
They achieve the same. Personally I have never seen null == user in any of my projects, but if I should render a guess, I'd say it's connected to how you read your every day language. If you are from Europe, odds are you read from left to right, but some languages read from right to left, that may be where it comes fro...
1,264,781
> > **Possible Duplicates:** > > [(0 == variable) or (null == obj): An outdated practice in C#?](https://stackoverflow.com/questions/655657/0-variable-or-null-obj-an-outdated-practice-in-c) > > [Why does one often see “null != variable” instead of “variable != null” in C#?](https://stackoverflow.com/questions/27...
2009/08/12
[ "https://Stackoverflow.com/questions/1264781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/139357/" ]
I think that `null == user` is an best practice in C/C++ world. It prevents typos like: ``` if (user = null) { ``` to happening, since they pass silently and they are very dangerous. Using `null = user` is safer in C/C++ (but not in C# since the compiler will complain) since the compiler cannot compile it.
It just makes more logical sense to do: if (user == null) as it is the user you are evaluating, you are just using null as a comparison.
1,264,781
> > **Possible Duplicates:** > > [(0 == variable) or (null == obj): An outdated practice in C#?](https://stackoverflow.com/questions/655657/0-variable-or-null-obj-an-outdated-practice-in-c) > > [Why does one often see “null != variable” instead of “variable != null” in C#?](https://stackoverflow.com/questions/27...
2009/08/12
[ "https://Stackoverflow.com/questions/1264781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/139357/" ]
`user == null` is human speak. `null == user` is Yoda speak. To the compiler they are the same, so pick the one you are most comfortable with.
No, both are equal
7,884,070
Office for Mac 2011 has better support for Pivot Tables in Excel, including external data. I need an ODBC connection on a Mac to SQL Server 2008. Microsoft recommends using a JDBC driver, but the documentation for it is very, very, very weak. Here is the link to the JDBC driver: <http://msdn.microsoft.com/en-us/sql...
2011/10/25
[ "https://Stackoverflow.com/questions/7884070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/854739/" ]
Just to help those who stumble across this problem: `Control` + `Click` to edit both Keyword and Value fields in Mac OS X ODBC Administrator. Alternatively, `Command` + `Return` `Tab`-bing through the fields work as well.
I'm not sure where you found the recommendation to use a JDBC driver with MS Office 2011. I am sure it won't work out. However -- ODBC drivers for Mac do exist, for MS SQL Server and other DBMS, and these are fully compatible with MS Office 2011. My employer makes [a number of these drivers](http://uda.openlinksw.com/...
36,213
I am studying the effects of tetrodotoxin and its symptoms when consumed. Numbness is one of the first sensations reported. But I googled numbness and I couldn't find information about whether this means all touch sensations (e.g. thermal, mechano, etc) have to be absent for numbness or just one specific kind. **My...
2015/07/19
[ "https://biology.stackexchange.com/questions/36213", "https://biology.stackexchange.com", "https://biology.stackexchange.com/users/11652/" ]
The definition of numbness has been answered by yourself, and I will focus on the second part of the question. In terms of the underlying physiological mechanism behind numbness I think it's good to narrow the question down and focus on **local anesthetics**, which numb a local area of the body for minor surgical proc...
An Initial clarification of what "loss of sensation" means: > > The history in the patient with “numbness” is extremely important. First of all, as with most neurologic complaints, you must determine what the patient means by “numbness.” Some patients are describing loss of sensitivity (anesthesia or hypesthesia) or ...
41,730,353
I wrote this @keyframes animation to change the background after a few seconds. ``` @keyframes banner{ 0% {background-image: url(../img/1.jpg);} 18% {background-image: url(../img/2.jpg);} 36% {background-image: url(../img/3.jpg);} 54% {background-image: url(../img/4.jpg);} 72% {background-image: url(../img/5.jpg);} 10...
2017/01/18
[ "https://Stackoverflow.com/questions/41730353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5066946/" ]
The animation flickers the first time, because each background image has to be requested separately over the network. Depending on how large each of your background images is, it might be best to combine them into one like a sprite image, then animate the position change. Here is an example: ``` @keyframes banner{ 0%...
First iteration is the problem, so why don't you simply run the same animation with: ``` animation-duration: 1s; animation-iteration-count: 1; ``` on a different layer, of course hidden. Apparently layer must be same class as the one you're using and can't be `display: none;` so you should hide it with `z-index` att...
41,730,353
I wrote this @keyframes animation to change the background after a few seconds. ``` @keyframes banner{ 0% {background-image: url(../img/1.jpg);} 18% {background-image: url(../img/2.jpg);} 36% {background-image: url(../img/3.jpg);} 54% {background-image: url(../img/4.jpg);} 72% {background-image: url(../img/5.jpg);} 10...
2017/01/18
[ "https://Stackoverflow.com/questions/41730353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5066946/" ]
The animation flickers the first time, because each background image has to be requested separately over the network. Depending on how large each of your background images is, it might be best to combine them into one like a sprite image, then animate the position change. Here is an example: ``` @keyframes banner{ 0%...
I had a similar problem and negative value for 'animation-delay' property fixed it. The animation will start as if it had already been playing for 3 seconds and only the first iteration with flicker is hidden. In my case I had 3 background images. ``` animation-duration: 10s; animation-delay: -3s; animation-iteratio...
41,730,353
I wrote this @keyframes animation to change the background after a few seconds. ``` @keyframes banner{ 0% {background-image: url(../img/1.jpg);} 18% {background-image: url(../img/2.jpg);} 36% {background-image: url(../img/3.jpg);} 54% {background-image: url(../img/4.jpg);} 72% {background-image: url(../img/5.jpg);} 10...
2017/01/18
[ "https://Stackoverflow.com/questions/41730353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5066946/" ]
The animation flickers the first time, because each background image has to be requested separately over the network. Depending on how large each of your background images is, it might be best to combine them into one like a sprite image, then animate the position change. Here is an example: ``` @keyframes banner{ 0%...
Also i found something really simple too that worked for me: ``` let images = []; for (let i = 1; i <= 6; i++) { images.push(new Image()); } for (let i = 1; i <= 6; i++) { images[i].src = `../img/${i}.png`; } ``` The Image object creates an img tag that you can then set it's src to the image's file path. Aft...
41,730,353
I wrote this @keyframes animation to change the background after a few seconds. ``` @keyframes banner{ 0% {background-image: url(../img/1.jpg);} 18% {background-image: url(../img/2.jpg);} 36% {background-image: url(../img/3.jpg);} 54% {background-image: url(../img/4.jpg);} 72% {background-image: url(../img/5.jpg);} 10...
2017/01/18
[ "https://Stackoverflow.com/questions/41730353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5066946/" ]
If size doesn't matter for you. You should try `Data URI` <https://css-tricks.com/data-uris/> ``` @keyframes banner{ 0% {background-image: url(data:image/png;base64,iVB......gg==);} 18% {background-image: url(data:image/png;base64,iVB......gg==);} 36% {background-image: url(data:image/png;base64,iVB......gg==);} 5...
First iteration is the problem, so why don't you simply run the same animation with: ``` animation-duration: 1s; animation-iteration-count: 1; ``` on a different layer, of course hidden. Apparently layer must be same class as the one you're using and can't be `display: none;` so you should hide it with `z-index` att...
41,730,353
I wrote this @keyframes animation to change the background after a few seconds. ``` @keyframes banner{ 0% {background-image: url(../img/1.jpg);} 18% {background-image: url(../img/2.jpg);} 36% {background-image: url(../img/3.jpg);} 54% {background-image: url(../img/4.jpg);} 72% {background-image: url(../img/5.jpg);} 10...
2017/01/18
[ "https://Stackoverflow.com/questions/41730353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5066946/" ]
If size doesn't matter for you. You should try `Data URI` <https://css-tricks.com/data-uris/> ``` @keyframes banner{ 0% {background-image: url(data:image/png;base64,iVB......gg==);} 18% {background-image: url(data:image/png;base64,iVB......gg==);} 36% {background-image: url(data:image/png;base64,iVB......gg==);} 5...
I had a similar problem and negative value for 'animation-delay' property fixed it. The animation will start as if it had already been playing for 3 seconds and only the first iteration with flicker is hidden. In my case I had 3 background images. ``` animation-duration: 10s; animation-delay: -3s; animation-iteratio...
41,730,353
I wrote this @keyframes animation to change the background after a few seconds. ``` @keyframes banner{ 0% {background-image: url(../img/1.jpg);} 18% {background-image: url(../img/2.jpg);} 36% {background-image: url(../img/3.jpg);} 54% {background-image: url(../img/4.jpg);} 72% {background-image: url(../img/5.jpg);} 10...
2017/01/18
[ "https://Stackoverflow.com/questions/41730353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5066946/" ]
If size doesn't matter for you. You should try `Data URI` <https://css-tricks.com/data-uris/> ``` @keyframes banner{ 0% {background-image: url(data:image/png;base64,iVB......gg==);} 18% {background-image: url(data:image/png;base64,iVB......gg==);} 36% {background-image: url(data:image/png;base64,iVB......gg==);} 5...
Also i found something really simple too that worked for me: ``` let images = []; for (let i = 1; i <= 6; i++) { images.push(new Image()); } for (let i = 1; i <= 6; i++) { images[i].src = `../img/${i}.png`; } ``` The Image object creates an img tag that you can then set it's src to the image's file path. Aft...
51,064,876
I was following a brief [tutorial on LinkedIn regarding multiindexed pandas dataframes](https://www.linkedin.com/learning/python-data-analysis/using-multilevel-indices) where I was unable to reproduce a seemingly very basic operation (at 3:00). You DO NOT have to watch the video to grasp the problem. The following sni...
2018/06/27
[ "https://Stackoverflow.com/questions/51064876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3437787/" ]
Change: ``` flights_unstack = flights_indexed.unstack() ``` to: ``` flights_unstack = flights_indexed['passengers'].unstack() ``` for remove `Multiindex` in columns. --- And last is necessary [`add_categories`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.CategoricalIndex.add_categories.html) by...
I know this is kind of late but I found the answer to your problem in the FAQs section of the course. Here's what it says: "Q. What are the issues with Pandas categorical data? A. Since version 0.6, seaborn.load\_dataset converts certain columns to Pandas categorical data (see <http://pandas.pydata.org/pandas-docs/s...
51,064,876
I was following a brief [tutorial on LinkedIn regarding multiindexed pandas dataframes](https://www.linkedin.com/learning/python-data-analysis/using-multilevel-indices) where I was unable to reproduce a seemingly very basic operation (at 3:00). You DO NOT have to watch the video to grasp the problem. The following sni...
2018/06/27
[ "https://Stackoverflow.com/questions/51064876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3437787/" ]
Change: ``` flights_unstack = flights_indexed.unstack() ``` to: ``` flights_unstack = flights_indexed['passengers'].unstack() ``` for remove `Multiindex` in columns. --- And last is necessary [`add_categories`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.CategoricalIndex.add_categories.html) by...
You can use the following: ``` df = pd.concat([flights_unstack.sum(axis = 'columns').rename('Total'), flights_unstack], axis = 'columns') ``` [Results](https://i.stack.imgur.com/0r7ne.png) Then you can reset to multi-index using: ``` df.columns = pd.MultiIndex.from_tuples(('passangers', column) for column in df....
51,064,876
I was following a brief [tutorial on LinkedIn regarding multiindexed pandas dataframes](https://www.linkedin.com/learning/python-data-analysis/using-multilevel-indices) where I was unable to reproduce a seemingly very basic operation (at 3:00). You DO NOT have to watch the video to grasp the problem. The following sni...
2018/06/27
[ "https://Stackoverflow.com/questions/51064876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3437787/" ]
I know this is kind of late but I found the answer to your problem in the FAQs section of the course. Here's what it says: "Q. What are the issues with Pandas categorical data? A. Since version 0.6, seaborn.load\_dataset converts certain columns to Pandas categorical data (see <http://pandas.pydata.org/pandas-docs/s...
You can use the following: ``` df = pd.concat([flights_unstack.sum(axis = 'columns').rename('Total'), flights_unstack], axis = 'columns') ``` [Results](https://i.stack.imgur.com/0r7ne.png) Then you can reset to multi-index using: ``` df.columns = pd.MultiIndex.from_tuples(('passangers', column) for column in df....
38,427,165
I have used MongoDB but new to Cassandra. I have worked on applications which are using MongoDB and are not very large applications. Read and Write operations are not very much intensive. MongoDB worked well for me in that scenario. Now I am building a new application(w/ some feature like Stack Overflow[voting, totals ...
2016/07/18
[ "https://Stackoverflow.com/questions/38427165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4593335/" ]
Picking a database is very subjective. I'd say that modern MongoDB 3.2+ using the new WiredTiger Storage Engine handles concurrency pretty well. When selecting a distributed NoSQL (or SQL) datastore, you can generally only pick two of these three: * [Consistency](https://en.wikipedia.org/wiki/Consistency_(database_sy...
It only depends on what your application is for. For extensive write apps it is way better to go with Cassandra
413,021
I'm trying to get into the habit of making sure that each `master` commit to a repository I work on does not break any existent tests. In my current flawed workflow, there are some intermediate commits on `master` that do not pass all tests, and I'm trying to adopt a solution to this. From [About Continuous Integratio...
2020/07/23
[ "https://softwareengineering.stackexchange.com/questions/413021", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/232447/" ]
There is no relationship between Continuous Integration and Git Hooks. Or, to put it more precisely: the relationship between CI and Git Hooks is the same as the relationship between CI and your keyboard: CI needs to run code, and your keyboard can be used to run code by typing it into a shell, therefore your keyboard...
First, lets make definition of Continuous Integration clear, originally, CI meant > > Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily - leading to multiple integrations per day. Each integration is verifie...
33,719
What sets does MTGO randomly chooses cards from for the Momir Basic format? I'm pretty sure things like Unglued and Unhinged are out, but what about Commander? Also how are banned cards dealt with? An example would Stoneforge Mystic, this card is banned in Modern, but is legal in Legacy. Could I have this be a two d...
2017/01/04
[ "https://boardgames.stackexchange.com/questions/33719", "https://boardgames.stackexchange.com", "https://boardgames.stackexchange.com/users/14181/" ]
As far as actual legality goes, the only cards legal to have in your deck are [Momir Vig, Simic Visionary](http://magiccards.info/extra/other/vanguard-mtgo-3/momir-vig-simic-visionary.html), as well as [Plains](http://gatherer.wizards.com/Pages/Search/Default.aspx?name=%2b%5bPlains%5d), [Island](http://gatherer.wizards...
Momir Basic does not have a ban list of any kind. However, your card pool is limited to creatures that has been put on Magic Online - and since un-sets have never been printed online, those cards can't show up. Most (if not all - I'm genuinely not sure) of the Commander products have been printed online, so those cards...
44,502,581
I'm looking for a way to turn a string like `1 hello there 6 foo 37 bar` to an array like: ``` Array ( [1] => "hello there", [6] => "foo", [37] => "bar" ) ``` Each number will be the index of a string that comes after it. I would like to get so help with it. Thanks! :)
2017/06/12
[ "https://Stackoverflow.com/questions/44502581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6340965/" ]
The solution using `preg_match_all` and `array_combine` functions: ``` $str = '1 hello there 6 foo 37 bar'; preg_match_all('/(\d+) +(\D*[^\s\d])/', $str, $m); $result = array_combine($m[1], $m[2]); print_r($result); ``` The output: ``` Array ( [1] => hello there [6] => foo [37] => bar ) ```
This should work, you will have the array on $out. Maybe you should consider using regular expressions. ``` $str = '1 hello there 6 foo 37 bar'; $temp = explode(' ', $str); $out = []; $key = -1; foreach ($temp as $word) { if (is_numeric($word)) { $key = $word; $out[$key] = ''; } else if ($key ...
44,502,581
I'm looking for a way to turn a string like `1 hello there 6 foo 37 bar` to an array like: ``` Array ( [1] => "hello there", [6] => "foo", [37] => "bar" ) ``` Each number will be the index of a string that comes after it. I would like to get so help with it. Thanks! :)
2017/06/12
[ "https://Stackoverflow.com/questions/44502581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6340965/" ]
This should work, you will have the array on $out. Maybe you should consider using regular expressions. ``` $str = '1 hello there 6 foo 37 bar'; $temp = explode(' ', $str); $out = []; $key = -1; foreach ($temp as $word) { if (is_numeric($word)) { $key = $word; $out[$key] = ''; } else if ($key ...
You can use regex, [live demo](https://eval.in/815853). ``` <?php $string = '1 hello there 6 foo 37 bar'; preg_match_all('/([\d]+)[\s]+([\D]+)/', $string, $matches); print_r(array_combine($matches[1], $matches[2])); ```
44,502,581
I'm looking for a way to turn a string like `1 hello there 6 foo 37 bar` to an array like: ``` Array ( [1] => "hello there", [6] => "foo", [37] => "bar" ) ``` Each number will be the index of a string that comes after it. I would like to get so help with it. Thanks! :)
2017/06/12
[ "https://Stackoverflow.com/questions/44502581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6340965/" ]
The solution using `preg_match_all` and `array_combine` functions: ``` $str = '1 hello there 6 foo 37 bar'; preg_match_all('/(\d+) +(\D*[^\s\d])/', $str, $m); $result = array_combine($m[1], $m[2]); print_r($result); ``` The output: ``` Array ( [1] => hello there [6] => foo [37] => bar ) ```
You can use regex, [live demo](https://eval.in/815853). ``` <?php $string = '1 hello there 6 foo 37 bar'; preg_match_all('/([\d]+)[\s]+([\D]+)/', $string, $matches); print_r(array_combine($matches[1], $matches[2])); ```
1,383,544
i have a text like this .... ``` ======== 1079.tif Image Description : Vexcel-UCD-Level-3 ------------------ CAM_ID: UCD-SU-1-0018 [5] RECORD_GUID: 64763E99-3573-43AD-995B-8A07E3FE2BE3 IMG_NO: 1079 CAPTURE_TIME: 2004/03/15 02:07:17.641 IMG_TYPE: ...
2009/09/05
[ "https://Stackoverflow.com/questions/1383544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Those ".." sections probably are CR,LF line endings that got lost in translation somewhere. The obvious answer is to use Regular Expressions (RegEx), but you may want to pre-process a little by restoring the lines and extract stuff from certain lines only. I gather that it is a condition that your result groups are fr...
Regex are probably a good way to do this, but since i'm not ver good at it, try this: I'm asuming that this is what you want. ``` public ObjectOfMyFile ParseFile(string fileContent) { ObjectOfMyFile objectOfMyFile = new ObjectOfMyFile(); string[] contentLines = fileContent.Split(new[] { Environ...
47,972,200
I have seen this issue talked about on the FirebaseUI documentation but for the life of me I cannot understand the solution. I want to use the latest version of Firebase Auth and Firestore, as well as the latest version of FirebaseUI. Is this possible? Please do not just link me to the documentation of dependency issue...
2017/12/25
[ "https://Stackoverflow.com/questions/47972200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6058412/" ]
You can exclude a dependencies' dependency with the `exclude` keyword. ``` implementation('com.firebaseui:firebase-ui-auth:3.1.2') { exclude group: 'com.google.android.gms' exclude group: 'com.google.firebase' } ```
Firebase SDK Version 11.8.0 released December 18, 2017, and there is no officially released FirebaseUI version for that release for now. You can see the corresponding versions of Firebase UI - Firebase Services at <https://github.com/firebase/FirebaseUI-Android> Corresponding FirebaseUI Version and Firebase/Play Servi...
47,972,200
I have seen this issue talked about on the FirebaseUI documentation but for the life of me I cannot understand the solution. I want to use the latest version of Firebase Auth and Firestore, as well as the latest version of FirebaseUI. Is this possible? Please do not just link me to the documentation of dependency issue...
2017/12/25
[ "https://Stackoverflow.com/questions/47972200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6058412/" ]
You can exclude a dependencies' dependency with the `exclude` keyword. ``` implementation('com.firebaseui:firebase-ui-auth:3.1.2') { exclude group: 'com.google.android.gms' exclude group: 'com.google.firebase' } ```
Check if your ``` compile 'com.android.support:appcompat-v7:**26**.1.0' ``` version is same as your ``` targetSdkVersion **26** ``` Mine was different and changing this resolved the problem.
36,043,539
``` table 1 id name value activ 1 abc 5 1 2 def 6 1 3 ghi 10 0 4 jkl 15 1 table 2 id name value table1_id 1 abc 100 1 2 jkl 200 4 ``` i want to return all records from table 1 where active = 1 and the records from table 2 where table1\_id refer...
2016/03/16
[ "https://Stackoverflow.com/questions/36043539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5058321/" ]
**[SQL Fiddle Demo](http://sqlfiddle.com/#!9/ae959/2)** ``` SELECT T1.name, COALESCE(T2.value, T1.value) as value FROM Table1 as T1 LEFT JOIN Table2 as T2 ON T1.id = T2.table1_id WHERE T1.active = 1 ``` **OUTPUT** ``` | name | value | |------|-------| | abc | 100 | | jkl | 200 | | def | 6 ...
``` SELECT a.name, NVL(b.value, a.value) FROM table1 a LEFT OUTER JOIN table2 b ON a.id =b.table1_id WHERE a.activ=1; ```
36,043,539
``` table 1 id name value activ 1 abc 5 1 2 def 6 1 3 ghi 10 0 4 jkl 15 1 table 2 id name value table1_id 1 abc 100 1 2 jkl 200 4 ``` i want to return all records from table 1 where active = 1 and the records from table 2 where table1\_id refer...
2016/03/16
[ "https://Stackoverflow.com/questions/36043539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5058321/" ]
**[SQL Fiddle Demo](http://sqlfiddle.com/#!9/ae959/2)** ``` SELECT T1.name, COALESCE(T2.value, T1.value) as value FROM Table1 as T1 LEFT JOIN Table2 as T2 ON T1.id = T2.table1_id WHERE T1.active = 1 ``` **OUTPUT** ``` | name | value | |------|-------| | abc | 100 | | jkl | 200 | | def | 6 ...
You can use [COALESCE](http://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html#function_coalesce). ``` SELECT table_1.name, COALESCE(table_2.value, table_1.value) as value FROM table_1 LEFT JOIN table_2 ON table_1.id = table_2.id WHERE table_1.active = 1 ```
132,885
In tonight's session, the party came across a Leomund's Tiny Hut. The party's bard chose to cast Dimension Door into it. This caused a bit of a (friendly) disagreement among the party, and none of us had an answer that solidly convinced the other side. [Leomund's Tiny Hut](https://www.dndbeyond.com/spells/tiny-hut) st...
2018/10/03
[ "https://rpg.stackexchange.com/questions/132885", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/39799/" ]
You *can* teleport into the Tiny Hut. ===================================== Spells that restrict or block teleportation make specific reference to teleportation. In particular this one: * (PHB 252) *Imprisonment (Burial)*: > > ...Nothing can pass through the sphere, nor can any creature teleport or use planar trave...
You *can not* teleport into the Tiny Hut. ========================================= While spells that restrict or block teleportation make specific reference to teleportation. Leomund's Tiny Hut restricts "Spells and Magical Effects". Is "Dimension Door" a spell or magical effect? Yes, Dimension Door is a spell. Is it...
132,885
In tonight's session, the party came across a Leomund's Tiny Hut. The party's bard chose to cast Dimension Door into it. This caused a bit of a (friendly) disagreement among the party, and none of us had an answer that solidly convinced the other side. [Leomund's Tiny Hut](https://www.dndbeyond.com/spells/tiny-hut) st...
2018/10/03
[ "https://rpg.stackexchange.com/questions/132885", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/39799/" ]
You *Cannot* Teleport Into the Tiny Hut ======================================= A key, though subtle point to this opinion is a statement on *Range* in the PHB (203) > > Once a spell is cast, its effects aren’t limited by its range, unless the spell’s description says otherwise. > > > The suggestion is that ***d...
You *can* teleport into the Tiny Hut. ===================================== Spells that restrict or block teleportation make specific reference to teleportation. In particular this one: * (PHB 252) *Imprisonment (Burial)*: > > ...Nothing can pass through the sphere, nor can any creature teleport or use planar trave...
132,885
In tonight's session, the party came across a Leomund's Tiny Hut. The party's bard chose to cast Dimension Door into it. This caused a bit of a (friendly) disagreement among the party, and none of us had an answer that solidly convinced the other side. [Leomund's Tiny Hut](https://www.dndbeyond.com/spells/tiny-hut) st...
2018/10/03
[ "https://rpg.stackexchange.com/questions/132885", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/39799/" ]
You *Cannot* Teleport Into the Tiny Hut ======================================= A key, though subtle point to this opinion is a statement on *Range* in the PHB (203) > > Once a spell is cast, its effects aren’t limited by its range, unless the spell’s description says otherwise. > > > The suggestion is that ***d...
You *can not* teleport into the Tiny Hut. ========================================= While spells that restrict or block teleportation make specific reference to teleportation. Leomund's Tiny Hut restricts "Spells and Magical Effects". Is "Dimension Door" a spell or magical effect? Yes, Dimension Door is a spell. Is it...
32,192
written a test class to test the callout that is using SOAP. I have generated class using WSDL. The response line in the generated class not covered though i tried several ways. Given below is the generated class. Since it is not returning a response the code coverage is very low which is 29%. What should i return as a...
2014/04/08
[ "https://salesforce.stackexchange.com/questions/32192", "https://salesforce.stackexchange.com", "https://salesforce.stackexchange.com/users/4195/" ]
At a minimum: ``` public class MyMock implements WebServiceMock { public void doInvoke( Object stub, Object request, Map<String, Object> response, String endpoint, String soapAction, String requestName, String responseNS, String...
In your HttpCalloutMock class, simply construct the expected Response elements. Your WSDL 2 Apex code contains lots of getters / setters, so if you construct the response element and any of the nested inner classes, you should reach close to 100% code coverage quickly. Additionally as an FYI, if you have any exception...
318,590
I'm refactoring a 500-lines of C++ code in main() for solving a differential equation. I'd like to encapsulate the big ideas of our solver into smaller functions (i.e. "SolvePotential(...)" instead of 50 lines of numerics code). Should I code this sequentially with a bunch of functions taking **very long** parameters...
2008/11/25
[ "https://Stackoverflow.com/questions/318590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40785/" ]
Since you mention that one of your goals is encapsulation, I'd point you towards the OO approach. In your example code, I think your class name is a little off. I'd first apply the refactoring that you are doing ([Extract Method](http://www.refactoring.com/catalog/extractMethod.html) into smaller functions). After tha...
Since you're using an object-oriented language, you should go for objects, assuming you could **reuse** those in the future. Just one advice: try to design a good class diagram. What are the entities of you program? I'd see an "equation" class with a derived "differentialEquation" one, and so on.
318,590
I'm refactoring a 500-lines of C++ code in main() for solving a differential equation. I'd like to encapsulate the big ideas of our solver into smaller functions (i.e. "SolvePotential(...)" instead of 50 lines of numerics code). Should I code this sequentially with a bunch of functions taking **very long** parameters...
2008/11/25
[ "https://Stackoverflow.com/questions/318590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40785/" ]
"SolvePotential" is a verb, and classes tend to be nouns with verbs attached. I don't know a lot about the details of your problem, but this may be a sign that a procedural approach would be clearer than OO here. In any case, it certainly seems like if you did create this class, it would be little more than packaging f...
Since you're not expecting to reuse the code elsewhere at this point, I'd focus on making the code readable and clean. That way you can figure out what it does a year from now when you need to solve the differential equations again or when you find out you actually do want to reuse the code. IMHO, the functions with pa...
318,590
I'm refactoring a 500-lines of C++ code in main() for solving a differential equation. I'd like to encapsulate the big ideas of our solver into smaller functions (i.e. "SolvePotential(...)" instead of 50 lines of numerics code). Should I code this sequentially with a bunch of functions taking **very long** parameters...
2008/11/25
[ "https://Stackoverflow.com/questions/318590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40785/" ]
Neither. "Move all my code from one single function to one single class" is not OOP. One of the fundamental rules of OOP is that a class should have *one single area of responsibility*. This is not a single responsibility, it is around 15: ``` SolverPotential::solve(){ SolvePotential::interpolate() SolverPotential::co...
Actually C++ is not just an OO language, it mixes other paradigms, including the procedural one. Being able to use classes don't make them more suitable for any problem. In my opinion, functions make much more sense here since you are implementing mathematical **procedures** that are not based on a state and dont need...
318,590
I'm refactoring a 500-lines of C++ code in main() for solving a differential equation. I'd like to encapsulate the big ideas of our solver into smaller functions (i.e. "SolvePotential(...)" instead of 50 lines of numerics code). Should I code this sequentially with a bunch of functions taking **very long** parameters...
2008/11/25
[ "https://Stackoverflow.com/questions/318590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40785/" ]
Neither. "Move all my code from one single function to one single class" is not OOP. One of the fundamental rules of OOP is that a class should have *one single area of responsibility*. This is not a single responsibility, it is around 15: ``` SolverPotential::solve(){ SolvePotential::interpolate() SolverPotential::co...
Since you mention that one of your goals is encapsulation, I'd point you towards the OO approach. In your example code, I think your class name is a little off. I'd first apply the refactoring that you are doing ([Extract Method](http://www.refactoring.com/catalog/extractMethod.html) into smaller functions). After tha...