qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
34,140
I have met the following HTML code: ``` <a rel="douche" href="...">blah</a> ``` And I am wondering what is the effect of the "douche" attribute.
2012/09/03
[ "https://webmasters.stackexchange.com/questions/34140", "https://webmasters.stackexchange.com", "https://webmasters.stackexchange.com/users/18164/" ]
It's just "commentary." In this case, whoever created that link apparently thinks the person on the other end is a douche. The `rel` attribute defines the relationship between the current document and the target(`href`) document. Consider this a more…aggressive version of the [Vote Links microformat](http://microf...
It has no meaning assigned to it in any published specification. It may have been agreed on in some community, or it may have special meaning to some software, or it may be just someone’s idea of a joke. There are various `rel` values around, but anything that is not listed in the Microformats Microformats Wiki [existi...
59,922,784
Currently I use the following command to export the environment variable `FOO`: ``` export FOO=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done) ``` This results in the string: ``` uops_dispatched_port.port_0|p0,uops_dispatched_port.port_1|p1,uops_dispatched_port.port_2|p2,uops_dispatched_por...
2020/01/26
[ "https://Stackoverflow.com/questions/59922784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/149138/" ]
Would you please try the following: ``` export FOO=$(a=(); for i in {0..7}; do a+=("uops_dispatched_port.port_$i|p$i"); done; IFS=,; echo "${a[*]}") ``` The assignment to `IFS` is limited within the subshell and does not affect the following statements.
Another one is using read and PE directly inside the command substituion. ``` export foo=$(read -r var < <(for i in {0..7}; do printf '%s' "uops_dispatched_port.port_$i|p$i,"; done); printf '%s' "${var%,}" ) ``` Or use the good ol pipe with command grouping using braces `{ }` ``` export foo=$(for i in {0..7}; do p...
59,922,784
Currently I use the following command to export the environment variable `FOO`: ``` export FOO=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done) ``` This results in the string: ``` uops_dispatched_port.port_0|p0,uops_dispatched_port.port_1|p1,uops_dispatched_port.port_2|p2,uops_dispatched_por...
2020/01/26
[ "https://Stackoverflow.com/questions/59922784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/149138/" ]
You can use the parameter expansion to remove the trailing comma eg.: ``` foo=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done) export FOO=${foo%,} ``` Below is the fragment from [the Bash manual](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html) that describes...
You could pipe the for-loop output to `head -c-1` to delete the trailing comma: ``` export FOO=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done | head -c-1) ```
59,922,784
Currently I use the following command to export the environment variable `FOO`: ``` export FOO=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done) ``` This results in the string: ``` uops_dispatched_port.port_0|p0,uops_dispatched_port.port_1|p1,uops_dispatched_port.port_2|p2,uops_dispatched_por...
2020/01/26
[ "https://Stackoverflow.com/questions/59922784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/149138/" ]
You could pipe the for-loop output to `head -c-1` to delete the trailing comma: ``` export FOO=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done | head -c-1) ```
Another one is using read and PE directly inside the command substituion. ``` export foo=$(read -r var < <(for i in {0..7}; do printf '%s' "uops_dispatched_port.port_$i|p$i,"; done); printf '%s' "${var%,}" ) ``` Or use the good ol pipe with command grouping using braces `{ }` ``` export foo=$(for i in {0..7}; do p...
59,922,784
Currently I use the following command to export the environment variable `FOO`: ``` export FOO=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done) ``` This results in the string: ``` uops_dispatched_port.port_0|p0,uops_dispatched_port.port_1|p1,uops_dispatched_port.port_2|p2,uops_dispatched_por...
2020/01/26
[ "https://Stackoverflow.com/questions/59922784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/149138/" ]
You could pipe the for-loop output to `head -c-1` to delete the trailing comma: ``` export FOO=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done | head -c-1) ```
Also you can mark it as the last one and remove precisely ``` export FOO=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done; printf "_LAST_") echo ${FOO//,_LAST_/} ```
59,922,784
Currently I use the following command to export the environment variable `FOO`: ``` export FOO=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done) ``` This results in the string: ``` uops_dispatched_port.port_0|p0,uops_dispatched_port.port_1|p1,uops_dispatched_port.port_2|p2,uops_dispatched_por...
2020/01/26
[ "https://Stackoverflow.com/questions/59922784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/149138/" ]
Would you please try the following: ``` export FOO=$(a=(); for i in {0..7}; do a+=("uops_dispatched_port.port_$i|p$i"); done; IFS=,; echo "${a[*]}") ``` The assignment to `IFS` is limited within the subshell and does not affect the following statements.
Instead of printing the comma at the end of each `echo` string (and then removing the last one), print the comma at the beginning of the `echo` string for the 2nd thru 7th passes through the loop ... * remove comma (`,`) from `echo` command * set variable `dl=""` for first pass through loop * print `${dl}` at beginnin...
59,922,784
Currently I use the following command to export the environment variable `FOO`: ``` export FOO=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done) ``` This results in the string: ``` uops_dispatched_port.port_0|p0,uops_dispatched_port.port_1|p1,uops_dispatched_port.port_2|p2,uops_dispatched_por...
2020/01/26
[ "https://Stackoverflow.com/questions/59922784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/149138/" ]
Me too! ``` export FOO=$(seq 0 7 | xargs -I{} echo "uops_dispatched_port.port_{}|p{}" | paste -sd,) ``` * `seq` generates numbers from 0 to 7 * `xargs -I{}` outputs the number in the strange format requested. * `paste -sd,` joins the lines with the comma.
Also you can mark it as the last one and remove precisely ``` export FOO=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done; printf "_LAST_") echo ${FOO//,_LAST_/} ```
59,922,784
Currently I use the following command to export the environment variable `FOO`: ``` export FOO=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done) ``` This results in the string: ``` uops_dispatched_port.port_0|p0,uops_dispatched_port.port_1|p1,uops_dispatched_port.port_2|p2,uops_dispatched_por...
2020/01/26
[ "https://Stackoverflow.com/questions/59922784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/149138/" ]
Would you please try the following: ``` export FOO=$(a=(); for i in {0..7}; do a+=("uops_dispatched_port.port_$i|p$i"); done; IFS=,; echo "${a[*]}") ``` The assignment to `IFS` is limited within the subshell and does not affect the following statements.
Also you can mark it as the last one and remove precisely ``` export FOO=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done; printf "_LAST_") echo ${FOO//,_LAST_/} ```
59,922,784
Currently I use the following command to export the environment variable `FOO`: ``` export FOO=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done) ``` This results in the string: ``` uops_dispatched_port.port_0|p0,uops_dispatched_port.port_1|p1,uops_dispatched_port.port_2|p2,uops_dispatched_por...
2020/01/26
[ "https://Stackoverflow.com/questions/59922784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/149138/" ]
You can use the parameter expansion to remove the trailing comma eg.: ``` foo=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done) export FOO=${foo%,} ``` Below is the fragment from [the Bash manual](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html) that describes...
Give this a try: ``` export foo=$(awk 'BEGIN{for(i=1;i<=7;i++)printf "%suops_dispatched_port.port_%d|p%d",(i>1?",":""),i,i}') ```
59,922,784
Currently I use the following command to export the environment variable `FOO`: ``` export FOO=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done) ``` This results in the string: ``` uops_dispatched_port.port_0|p0,uops_dispatched_port.port_1|p1,uops_dispatched_port.port_2|p2,uops_dispatched_por...
2020/01/26
[ "https://Stackoverflow.com/questions/59922784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/149138/" ]
Would you please try the following: ``` export FOO=$(a=(); for i in {0..7}; do a+=("uops_dispatched_port.port_$i|p$i"); done; IFS=,; echo "${a[*]}") ``` The assignment to `IFS` is limited within the subshell and does not affect the following statements.
Give this a try: ``` export foo=$(awk 'BEGIN{for(i=1;i<=7;i++)printf "%suops_dispatched_port.port_%d|p%d",(i>1?",":""),i,i}') ```
59,922,784
Currently I use the following command to export the environment variable `FOO`: ``` export FOO=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done) ``` This results in the string: ``` uops_dispatched_port.port_0|p0,uops_dispatched_port.port_1|p1,uops_dispatched_port.port_2|p2,uops_dispatched_por...
2020/01/26
[ "https://Stackoverflow.com/questions/59922784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/149138/" ]
You can use the parameter expansion to remove the trailing comma eg.: ``` foo=$(for i in {0..7}; do echo -n "uops_dispatched_port.port_$i|p$i,"; done) export FOO=${foo%,} ``` Below is the fragment from [the Bash manual](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html) that describes...
Would you please try the following: ``` export FOO=$(a=(); for i in {0..7}; do a+=("uops_dispatched_port.port_$i|p$i"); done; IFS=,; echo "${a[*]}") ``` The assignment to `IFS` is limited within the subshell and does not affect the following statements.
33,063,263
I have the following PHP to loop through images in my WordPres ``` function marty_get_images($post_id) { global $post; $thumbnail_ID = get_post_thumbnail_id(); $images = get_children( array('post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'AS...
2015/10/11
[ "https://Stackoverflow.com/questions/33063263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/644978/" ]
You can use the [`break`](http://php.net/manual/en/control-structures.break.php) statement: ``` <?php endif; ?> <?php break; ?> <?php endforeach; ?> ```
Add `break;` after your HTML link. This will break out of the `foreach` loop and continue executing any other code which may be after the loop. <http://php.net/manual/en/control-structures.break.php> ``` <?php break; ?> ```
33,063,263
I have the following PHP to loop through images in my WordPres ``` function marty_get_images($post_id) { global $post; $thumbnail_ID = get_post_thumbnail_id(); $images = get_children( array('post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'AS...
2015/10/11
[ "https://Stackoverflow.com/questions/33063263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/644978/" ]
You can use the [`break`](http://php.net/manual/en/control-structures.break.php) statement: ``` <?php endif; ?> <?php break; ?> <?php endforeach; ?> ```
> > For only one iteration you can use "LIMIT" on query which will return only one record from database > > > ``` $images = get_children( array('post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID', 'limit' =>...
33,063,263
I have the following PHP to loop through images in my WordPres ``` function marty_get_images($post_id) { global $post; $thumbnail_ID = get_post_thumbnail_id(); $images = get_children( array('post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'AS...
2015/10/11
[ "https://Stackoverflow.com/questions/33063263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/644978/" ]
You can use the [`break`](http://php.net/manual/en/control-structures.break.php) statement: ``` <?php endif; ?> <?php break; ?> <?php endforeach; ?> ```
Better to use array\_slice and run the loop once ``` foreach (array_slice($images,0,1 )as $attachment_id => $image) { } ``` here, 0 = index form where loop start, 1 = run the loop once
6,036,217
I have this php function in wordpress ``` function includePosts ($content = '') { preg_match_all('/(?<=\\[\\[)\\d+?(?=\\]\\])/', $content, $matches, PREG_PATTERN_ORDER); $numMatches = count($matches[0]); for ($i = 0; $i < $numMatches; $i++) { $postId = $matches[0][$i]; $post= get_post($pos...
2011/05/17
[ "https://Stackoverflow.com/questions/6036217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/760476/" ]
Just a shot in the dark. If you replace your return statement with the one below, does it accomplish what you would like? ``` return "<ul>$content</ul>"; ```
Something like this might work: ``` function includePosts ($content = '') { preg_match_all('/(?<=\\[\\[)\\d+?(?=\\]\\])/', $content, $matches, PREG_PATTERN_ORDER); $numMatches = count($matches[0]); for ($i = 0; $i < $numMatches; $i++) { $postId = $matches[0][$i]; $post= get_post($postId); ...
41,308,057
I am pretty new to TestNG framework. I did download TestNG from the link <http://beust.com/eclipse>. Post this I created a new Java Project named as MyProject and a new TestNG class file "NewTest". I did write a small piece of Code with @Test annotation to launch Firefox browser and navigate to Google. I tried searchin...
2016/12/23
[ "https://Stackoverflow.com/questions/41308057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7323737/" ]
You just need to append an `'m'` to each time and the `strptime` will parse it. Oneliner -------- ``` list(map(lambda s: datetime.strptime(s+'m', '%I:%M%p'), s) for s in (s.strip().split('-') for s in l) ``` Output (*redacted for clarity*): ``` [[datetime(…, 06, 0), datetime(…, 11, 0)], [datetime(…, 19, 0), datet...
It's a bit clunky, but basically, you can take each string and examine the last character. If it's an `a`, just discard it. If it's a `p`, add 12 to the number before the colon: ``` def translate_times(s): # Remove space at the begining and split according to the - each = s[1:].split('-') for i in range(le...
41,308,057
I am pretty new to TestNG framework. I did download TestNG from the link <http://beust.com/eclipse>. Post this I created a new Java Project named as MyProject and a new TestNG class file "NewTest". I did write a small piece of Code with @Test annotation to launch Firefox browser and navigate to Google. I tried searchin...
2016/12/23
[ "https://Stackoverflow.com/questions/41308057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7323737/" ]
You just need to append an `'m'` to each time and the `strptime` will parse it. Oneliner -------- ``` list(map(lambda s: datetime.strptime(s+'m', '%I:%M%p'), s) for s in (s.strip().split('-') for s in l) ``` Output (*redacted for clarity*): ``` [[datetime(…, 06, 0), datetime(…, 11, 0)], [datetime(…, 19, 0), datet...
This may not be the quickest solution, but gives the output you requested: ``` old = [' 06:00a-11:00a', ' 07:00p-11:00p', ' 09:00a-04:00p', ' 09:00a-04:00p', ' 10:00a-04:00p', ' 10:00a-03:00p'] import time ``` Fix am/pm issue: ``` am = list(map(lambda x:x.replace('a','am'),old)) pm = list(map(lambda x:x.replace('...
500,545
I read an essay about prime numbers. In it the author suggests that a natural first question to ask is, > > What is the probability of a random natural number being prime? > > > but proceeds to dismiss it as "not making sense". I wonder what's wrong with the question. Is its meaninglessness related to the fact t...
2013/09/21
[ "https://math.stackexchange.com/questions/500545", "https://math.stackexchange.com", "https://math.stackexchange.com/users/93671/" ]
There's no uniform random distribution on the natural numbers, so the problem is with the phrase "random natural number". One cannot, for example, "pick a natural number at random", a fact which can be illustrated by the following thought experiment: How many digits should a natural number picked at random have? On th...
The main issue with the question is that the density of primes decreases over increasing upper-limit interval subsets of $\mathbb N$. In fact, taking the density of the primes over the entire set of natural numbers evaluates to zero, therefore the probability would technically be zero. It does makes sense to say, for a...
500,545
I read an essay about prime numbers. In it the author suggests that a natural first question to ask is, > > What is the probability of a random natural number being prime? > > > but proceeds to dismiss it as "not making sense". I wonder what's wrong with the question. Is its meaninglessness related to the fact t...
2013/09/21
[ "https://math.stackexchange.com/questions/500545", "https://math.stackexchange.com", "https://math.stackexchange.com/users/93671/" ]
The main issue with the question is that the density of primes decreases over increasing upper-limit interval subsets of $\mathbb N$. In fact, taking the density of the primes over the entire set of natural numbers evaluates to zero, therefore the probability would technically be zero. It does makes sense to say, for a...
The probability that a random number n is prime is either 0 or 1; it will take us some time to find out which. In that sense probabilities make little sense. But let’s take some large n, then count the primes p with n - n^1/2 < p < n + n^1/2, and calculate the probability that a random p in that range is a prime. The ...
500,545
I read an essay about prime numbers. In it the author suggests that a natural first question to ask is, > > What is the probability of a random natural number being prime? > > > but proceeds to dismiss it as "not making sense". I wonder what's wrong with the question. Is its meaninglessness related to the fact t...
2013/09/21
[ "https://math.stackexchange.com/questions/500545", "https://math.stackexchange.com", "https://math.stackexchange.com/users/93671/" ]
There's no uniform random distribution on the natural numbers, so the problem is with the phrase "random natural number". One cannot, for example, "pick a natural number at random", a fact which can be illustrated by the following thought experiment: How many digits should a natural number picked at random have? On th...
As in the other answers, indeed, there is difficulty in defining probabilities on somewhat-sparse subsets of infinite sets. Nevertheless, in practice, there is a version of this question that has some substance, namely, to ask the "probability" that a number chosen "near" a given large-ish integer $N$ is prime, giving...
500,545
I read an essay about prime numbers. In it the author suggests that a natural first question to ask is, > > What is the probability of a random natural number being prime? > > > but proceeds to dismiss it as "not making sense". I wonder what's wrong with the question. Is its meaninglessness related to the fact t...
2013/09/21
[ "https://math.stackexchange.com/questions/500545", "https://math.stackexchange.com", "https://math.stackexchange.com/users/93671/" ]
There's no uniform random distribution on the natural numbers, so the problem is with the phrase "random natural number". One cannot, for example, "pick a natural number at random", a fact which can be illustrated by the following thought experiment: How many digits should a natural number picked at random have? On th...
There is a sense in which the probability of a random natural number being prime approximates to $\frac{1}{log N}$, as Paul and Daniel each get to, and subject to Daniel's elegant exposition of the measure issue. It's worth bearing in mind that for most of the twentieth century, a lot of mathematicians (and in particu...
500,545
I read an essay about prime numbers. In it the author suggests that a natural first question to ask is, > > What is the probability of a random natural number being prime? > > > but proceeds to dismiss it as "not making sense". I wonder what's wrong with the question. Is its meaninglessness related to the fact t...
2013/09/21
[ "https://math.stackexchange.com/questions/500545", "https://math.stackexchange.com", "https://math.stackexchange.com/users/93671/" ]
There's no uniform random distribution on the natural numbers, so the problem is with the phrase "random natural number". One cannot, for example, "pick a natural number at random", a fact which can be illustrated by the following thought experiment: How many digits should a natural number picked at random have? On th...
The probability that a random number n is prime is either 0 or 1; it will take us some time to find out which. In that sense probabilities make little sense. But let’s take some large n, then count the primes p with n - n^1/2 < p < n + n^1/2, and calculate the probability that a random p in that range is a prime. The ...
500,545
I read an essay about prime numbers. In it the author suggests that a natural first question to ask is, > > What is the probability of a random natural number being prime? > > > but proceeds to dismiss it as "not making sense". I wonder what's wrong with the question. Is its meaninglessness related to the fact t...
2013/09/21
[ "https://math.stackexchange.com/questions/500545", "https://math.stackexchange.com", "https://math.stackexchange.com/users/93671/" ]
As in the other answers, indeed, there is difficulty in defining probabilities on somewhat-sparse subsets of infinite sets. Nevertheless, in practice, there is a version of this question that has some substance, namely, to ask the "probability" that a number chosen "near" a given large-ish integer $N$ is prime, giving...
The probability that a random number n is prime is either 0 or 1; it will take us some time to find out which. In that sense probabilities make little sense. But let’s take some large n, then count the primes p with n - n^1/2 < p < n + n^1/2, and calculate the probability that a random p in that range is a prime. The ...
500,545
I read an essay about prime numbers. In it the author suggests that a natural first question to ask is, > > What is the probability of a random natural number being prime? > > > but proceeds to dismiss it as "not making sense". I wonder what's wrong with the question. Is its meaninglessness related to the fact t...
2013/09/21
[ "https://math.stackexchange.com/questions/500545", "https://math.stackexchange.com", "https://math.stackexchange.com/users/93671/" ]
There is a sense in which the probability of a random natural number being prime approximates to $\frac{1}{log N}$, as Paul and Daniel each get to, and subject to Daniel's elegant exposition of the measure issue. It's worth bearing in mind that for most of the twentieth century, a lot of mathematicians (and in particu...
The probability that a random number n is prime is either 0 or 1; it will take us some time to find out which. In that sense probabilities make little sense. But let’s take some large n, then count the primes p with n - n^1/2 < p < n + n^1/2, and calculate the probability that a random p in that range is a prime. The ...
44,018,389
I have converted a JSON file to a map and I need to modify multiple values of different keys at once using JAVA. Following is the map converted JSON file: ``` { "name": "", "numberID": null, "StartDate": "", "EndDate": "", "count": null, "level": null, "discipline": null, "paymentModel...
2017/05/17
[ "https://Stackoverflow.com/questions/44018389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3531010/" ]
You can re-use your `merge` function, by dereferencing the boxes inside the `boxed_merge` function. Note that this will not re-use the allocations but instead create a new one ``` fn boxed_merge(a1: Box<A>, a2: Box<A>) -> Box<A> { Box::new(merge(*a1, *a2)) } ```
You can access the contents of boxed arguments by dereferencing them and combine them in a new `Box`. For example: ``` fn merge(a1: Box<usize>, a2: Box<usize>) -> Box<usize> { Box::new(*a1 + *a2) } fn main() { let a1 = Box::new(1); let a2 = Box::new(2); println!("{}", merge(a1, a2)); } ```
44,018,389
I have converted a JSON file to a map and I need to modify multiple values of different keys at once using JAVA. Following is the map converted JSON file: ``` { "name": "", "numberID": null, "StartDate": "", "EndDate": "", "count": null, "level": null, "discipline": null, "paymentModel...
2017/05/17
[ "https://Stackoverflow.com/questions/44018389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3531010/" ]
You can re-use your `merge` function, by dereferencing the boxes inside the `boxed_merge` function. Note that this will not re-use the allocations but instead create a new one ``` fn boxed_merge(a1: Box<A>, a2: Box<A>) -> Box<A> { Box::new(merge(*a1, *a2)) } ```
I would advocate that a by-value `merge` should *not* be your base implementation. Instead, a mutating method provides more flexibility. You can then build on that for by-value and by-boxed-value methods: ``` struct A(u8); impl A { fn merge_ref(&mut self, other: &A) { self.0 += other.0 } } fn merge(m...
69,882,538
I need to send frequently a lot of files to a multiple hosts and is crucial to be fast and I want it to do it in parallel. how can I run in a bash script a parallel rsync to multiple hosts? now the script looks like this ``` for i in ${listofhosts[*]} do rsync -rv --checksum folder/ -e "ssh -i rsa_key -o ...
2021/11/08
[ "https://Stackoverflow.com/questions/69882538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3909755/" ]
This is happening because MSAL automatically refreshes your token after expiration. When user opens your app it checks if that token is already present and valid. So you can remove the token from the Android KeyStore in onStop(). So yes you also need to remove the cache as well to remove the account from the cache, fi...
On Android we basically don't have any control on the cookies because they are shared with external Chrome app and because of that it is not accessible. If you want the user to enter the password again then you should do this: `AcquireTokenInteractive(scopes).WithPrompt(Prompt.ForceLogin);`
18,976,302
I am trying to return html via and Ajax call and I have the following snippet of code in my view ``` if request.is_ajax(): t = loader.get_template('frontend/scroll.html') html = t.render(RequestContext({'dishes': dishes}) return HttpResponse(json.dumps({'html': html})) ``` and my Ajax ``` $.ajax({ typ...
2013/09/24
[ "https://Stackoverflow.com/questions/18976302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2758219/" ]
The first argument of RequestContext is a request object. You could either add the request object or use the Context class instead.
First parameter to `RequestContext()` should be `request`, so update line in your code as ``` html = t.render(RequestContext(request, {'dishes': dishes}) ```
18,976,302
I am trying to return html via and Ajax call and I have the following snippet of code in my view ``` if request.is_ajax(): t = loader.get_template('frontend/scroll.html') html = t.render(RequestContext({'dishes': dishes}) return HttpResponse(json.dumps({'html': html})) ``` and my Ajax ``` $.ajax({ typ...
2013/09/24
[ "https://Stackoverflow.com/questions/18976302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2758219/" ]
There are a few issues with your code: You need to use [`render_to_string`](https://docs.djangoproject.com/en/3.2/topics/templates/#django.template.loader.render_to_string). You also don't need to convert your HTML into json because you are replacing the contents directly. Putting all this together you have: ``` fr...
The first argument of RequestContext is a request object. You could either add the request object or use the Context class instead.
18,976,302
I am trying to return html via and Ajax call and I have the following snippet of code in my view ``` if request.is_ajax(): t = loader.get_template('frontend/scroll.html') html = t.render(RequestContext({'dishes': dishes}) return HttpResponse(json.dumps({'html': html})) ``` and my Ajax ``` $.ajax({ typ...
2013/09/24
[ "https://Stackoverflow.com/questions/18976302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2758219/" ]
There are a few issues with your code: You need to use [`render_to_string`](https://docs.djangoproject.com/en/3.2/topics/templates/#django.template.loader.render_to_string). You also don't need to convert your HTML into json because you are replacing the contents directly. Putting all this together you have: ``` fr...
First parameter to `RequestContext()` should be `request`, so update line in your code as ``` html = t.render(RequestContext(request, {'dishes': dishes}) ```
49,833
How can you have a Gmail account or any e mail account with a different name? For example `123@anothername.com` instead of `123@gmail.com`? I have already tried going to the account settings and tried using Outlook but all of them require their ending after the `@` sign. I just want to know how to change that because I...
2013/09/22
[ "https://webapps.stackexchange.com/questions/49833", "https://webapps.stackexchange.com", "https://webapps.stackexchange.com/users/48160/" ]
You need to purchase your own domain name, e.g. `anothername.com`, from a [domain registrar](https://en.wikipedia.org/wiki/Domain_registrar). Once you've done so, you need to find an email/web hosting service that will enable you to set up email addresses at your domain. As far as I know, any web hosting company will p...
Having a custom domain for you email addresses requires that you own a custom domain. You could buy it directly to a domain registrar but you should be prepared to manage it properly. IMHO small business should consider to get the domain from a provider that could help with the domain management tasks. Regarding Gmail...
16,233,500
I recently came across this code which uses a way, which I've never used before, to position 3 columns on a page. I have included this method in my code below in GROUP 2. I use GROUP 1 to achieve the same task myself. Now I know writing mark-up such as CSS and HTML, much like programming, is mostly up to the programmer...
2013/04/26
[ "https://Stackoverflow.com/questions/16233500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1004665/" ]
GCC has two [attributes](http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html), `pure` and `const`, that may be used to mark such function. If the function has no side-effect and its result depends only on its arguments, the function should be declared `const`, if the results may also depend on some global variab...
I think, yes. If you get compiler disassembly output you can see that, sin is called in another label than the loop label for 'for': (compiled with g++ -O1 -O2 -O3) ``` Leh_func_begin1: pushq %rbp Ltmp0: movq %rsp, %rbp Ltmp1: pushq %rbx subq $8, %rsp Ltmp2: testl %e...
16,233,500
I recently came across this code which uses a way, which I've never used before, to position 3 columns on a page. I have included this method in my code below in GROUP 2. I use GROUP 1 to achieve the same task myself. Now I know writing mark-up such as CSS and HTML, much like programming, is mostly up to the programmer...
2013/04/26
[ "https://Stackoverflow.com/questions/16233500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1004665/" ]
GCC has two [attributes](http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html), `pure` and `const`, that may be used to mark such function. If the function has no side-effect and its result depends only on its arguments, the function should be declared `const`, if the results may also depend on some global variab...
As a matter of fact, todays common compilers will perform the kind of [loop-invariant code motion](https://en.wikipedia.org/wiki/Loop-invariant_code_motion) optimisation you're asking about. For a demonstration of this, see the second exercise within [this article entitled "Will it Optimize?"](http://ridiculousfish.com...
16,233,500
I recently came across this code which uses a way, which I've never used before, to position 3 columns on a page. I have included this method in my code below in GROUP 2. I use GROUP 1 to achieve the same task myself. Now I know writing mark-up such as CSS and HTML, much like programming, is mostly up to the programmer...
2013/04/26
[ "https://Stackoverflow.com/questions/16233500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1004665/" ]
GCC has two [attributes](http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html), `pure` and `const`, that may be used to mark such function. If the function has no side-effect and its result depends only on its arguments, the function should be declared `const`, if the results may also depend on some global variab...
What is needed to permit hoisting this subexpression outside the loop is not purity, but [idempotence](https://stackoverflow.com/q/1077412/103167). Idempotence means that a function will have the same side-effects and result if it is called once as if it is called many times with the same arguments. Therefore, the com...
16,233,500
I recently came across this code which uses a way, which I've never used before, to position 3 columns on a page. I have included this method in my code below in GROUP 2. I use GROUP 1 to achieve the same task myself. Now I know writing mark-up such as CSS and HTML, much like programming, is mostly up to the programmer...
2013/04/26
[ "https://Stackoverflow.com/questions/16233500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1004665/" ]
As a matter of fact, todays common compilers will perform the kind of [loop-invariant code motion](https://en.wikipedia.org/wiki/Loop-invariant_code_motion) optimisation you're asking about. For a demonstration of this, see the second exercise within [this article entitled "Will it Optimize?"](http://ridiculousfish.com...
I think, yes. If you get compiler disassembly output you can see that, sin is called in another label than the loop label for 'for': (compiled with g++ -O1 -O2 -O3) ``` Leh_func_begin1: pushq %rbp Ltmp0: movq %rsp, %rbp Ltmp1: pushq %rbx subq $8, %rsp Ltmp2: testl %e...
16,233,500
I recently came across this code which uses a way, which I've never used before, to position 3 columns on a page. I have included this method in my code below in GROUP 2. I use GROUP 1 to achieve the same task myself. Now I know writing mark-up such as CSS and HTML, much like programming, is mostly up to the programmer...
2013/04/26
[ "https://Stackoverflow.com/questions/16233500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1004665/" ]
As a matter of fact, todays common compilers will perform the kind of [loop-invariant code motion](https://en.wikipedia.org/wiki/Loop-invariant_code_motion) optimisation you're asking about. For a demonstration of this, see the second exercise within [this article entitled "Will it Optimize?"](http://ridiculousfish.com...
What is needed to permit hoisting this subexpression outside the loop is not purity, but [idempotence](https://stackoverflow.com/q/1077412/103167). Idempotence means that a function will have the same side-effects and result if it is called once as if it is called many times with the same arguments. Therefore, the com...
2,906,375
So i have 6 different flavours. I intend to mix these flavours together where the total amount would be 100 % when all the 6 different flavours has been counted. This means for example that one combination can look like this flavour 1 can have 20 % in there, flavour 2 = 40 %, flavour 3 = 15 %, flavour 4 = 15 %, flav...
2018/09/05
[ "https://math.stackexchange.com/questions/2906375", "https://math.stackexchange.com", "https://math.stackexchange.com/users/435374/" ]
The answer depends on whether you require each of the six flavours to be present (that is, at least 1%). Assuming that you do indeed intend each flavour to be present: Consider 100 little cups waiting to take their flavour portion, representing 1% each. Now insert marks between the cups to show where to change to the ...
In case you need a proof for the binomial stated in the comment above or in the answer above you may consider the following sketch: Suppose you have $100$ spoons in a row represented here by the letter "o", namely something like this ooooooooooooooooooooooooooooooooooooooo........ooo then in how many ways can we sepa...
2,299,139
What do you think is the most optimal way to retrieve all attributes for all the associations an AR model has? i.e: let's say we have the model `Target`. ``` class Target < ActiveRecord::Base has_many :countries has_many :cities has_many :towns has_many :colleges has_many :tags accepts_nested_attributes_...
2010/02/19
[ "https://Stackoverflow.com/questions/2299139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/217956/" ]
I'm not clear on what you mean with iterating on all associations. Are you already using reflections? Still curious if there's a neater way, but this is what I could come up with, which more or less results in the hash you're showing in your example: ``` class Target < ActiveRecord::Base has_many :tags def assoc...
try this with exception handling: ``` class Target < ActiveRecord::Base def associations_attributes tmp = {} self.class.reflections.symbolize_keys.keys.each do |key| begin data = self.send(key) || {} if data.is_a?(ActiveRecord::Base) tmp[key] = data.attributes.symbolize_keys!...
2,299,139
What do you think is the most optimal way to retrieve all attributes for all the associations an AR model has? i.e: let's say we have the model `Target`. ``` class Target < ActiveRecord::Base has_many :countries has_many :cities has_many :towns has_many :colleges has_many :tags accepts_nested_attributes_...
2010/02/19
[ "https://Stackoverflow.com/questions/2299139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/217956/" ]
I'm not clear on what you mean with iterating on all associations. Are you already using reflections? Still curious if there's a neater way, but this is what I could come up with, which more or less results in the hash you're showing in your example: ``` class Target < ActiveRecord::Base has_many :tags def assoc...
This is updated version of **Stéphan Kochen**'s code for Rails 4.2 ``` def associations_attributes association_names = self.class.reflect_on_all_associations.collect { |r| r.name } me = self.class.includes(association_names).find self.id pairs = association_names.collect do |association_name...
68,888,792
I'm trying to send a simple post request in 3 different ways, first two are failing with 400 Bad Request, only RestSharp works. I would say the body of the request and the headers are set in the same way, so I don't understand what's wrong. ### Using `HttpWebRequest` ``` var httpRequest = (HttpWebRequest) WebRequest....
2021/08/23
[ "https://Stackoverflow.com/questions/68888792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16730939/" ]
Here you have all the keys handled by ursina with the values associated. <https://github.com/pokepetter/ursina/blob/master/ursina/input_handler.py> So for the right shift key it's : ```py # On the lib right_shift = 'right shift' right_shift_up = 'right shift up' right_shift_down = 'right shift down' ``` ```py # For...
I will provide code for a **class** and for **input function** For the **input function**: ```py def update(): if held_keys['shift']: player.speed=10 print("Shift is Hold") def input(key): if key == 'shift': print("Shift Pressed") if key == 'w' ...
68,888,792
I'm trying to send a simple post request in 3 different ways, first two are failing with 400 Bad Request, only RestSharp works. I would say the body of the request and the headers are set in the same way, so I don't understand what's wrong. ### Using `HttpWebRequest` ``` var httpRequest = (HttpWebRequest) WebRequest....
2021/08/23
[ "https://Stackoverflow.com/questions/68888792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16730939/" ]
You have to do this: ``` from ursina import * #importing everything from ursina app = Ursina() #Creating window def input(key): # checking for a key input if key == 'shift': # checking particular key print('pressed right shift button') # printing if shift key pressed app.run() # launching the window ``...
I will provide code for a **class** and for **input function** For the **input function**: ```py def update(): if held_keys['shift']: player.speed=10 print("Shift is Hold") def input(key): if key == 'shift': print("Shift Pressed") if key == 'w' ...
1,907,594
For the ellipse $4x^2 + 9y^2 = 36$ and the function $2x + 3y = k$ find the values of $k$ that are a tangent to the ellipse. I squared the function and got $ 4x^2 + 9y^2 = k^2$ When I solve it I get $k = \pm\sqrt 6$ don't know where I went wrong, as the answer key says it's $\pm2\sqrt6$ . Any help for why I am missi...
2016/08/29
[ "https://math.stackexchange.com/questions/1907594", "https://math.stackexchange.com", "https://math.stackexchange.com/users/364737/" ]
$u = 2x, v = 3y\\ u^2 + v^2 = 36\\ u + v = k$ Now we have a circle and not an ellipse, and circles are easier to work with. the tangent to the circle is perpendicular to the radius. the point of tangency is then on the line $u = v$ $u,v = \pm 6\frac {\sqrt{2}}{2}\\ k = \pm 6{\sqrt{2}}$ Now that doesn't fit your ans...
The given line is $y=-\frac 23 x+\frac k3$, substitute this in original and you will get the point of intersection of line and ellipse, but for any line to be tangent only one point of intersection is there thus the discriminant of quadratic you will get should be $0$.
1,907,594
For the ellipse $4x^2 + 9y^2 = 36$ and the function $2x + 3y = k$ find the values of $k$ that are a tangent to the ellipse. I squared the function and got $ 4x^2 + 9y^2 = k^2$ When I solve it I get $k = \pm\sqrt 6$ don't know where I went wrong, as the answer key says it's $\pm2\sqrt6$ . Any help for why I am missi...
2016/08/29
[ "https://math.stackexchange.com/questions/1907594", "https://math.stackexchange.com", "https://math.stackexchange.com/users/364737/" ]
$u = 2x, v = 3y\\ u^2 + v^2 = 36\\ u + v = k$ Now we have a circle and not an ellipse, and circles are easier to work with. the tangent to the circle is perpendicular to the radius. the point of tangency is then on the line $u = v$ $u,v = \pm 6\frac {\sqrt{2}}{2}\\ k = \pm 6{\sqrt{2}}$ Now that doesn't fit your ans...
$$(a+b)^2=a^2+b^2+2ab$$ As [Jonathan Richard Lombardy](https://math.stackexchange.com/users/345851/jonathan-richard-lombardy) already stated this is what you're missing.
14,636,312
Is there an easy howto on writing C++ app for Samsung Smart TV that should be able to run in background (so not an HTML/JS applet) and access /dev/ttyUSBx device plugged in the TV? Do they have some API to access /dev/ttyUSBx or it will be a simple Linux app? Do they allow to load such apps? Is there a toolchain to co...
2013/01/31
[ "https://Stackoverflow.com/questions/14636312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/363297/" ]
At least according to Samsung, "No." > > > > > > > > > > > > Q: Do you support C++ in the SDK? > > > > > > > > > A: No, Samsung platform only supports web technologies based apps (JS, CSS, HTML, FLASH) > > > > > > > > > > > > > > > > > > <http://www.samsungdforum.com/Support/FAQList?page=1&faqCateID=2...
For Samsung SmartTVs you cannot use C++, the only allowed language/technology is HTML/JavaScript/CSS and Flash (not used much). Majority of the applications are JavaScript based. Might be you can have some exclusive agreement with the Samsung, since e.g. Skype is most probably not developed in JavaScript and the Angr...
14,636,312
Is there an easy howto on writing C++ app for Samsung Smart TV that should be able to run in background (so not an HTML/JS applet) and access /dev/ttyUSBx device plugged in the TV? Do they have some API to access /dev/ttyUSBx or it will be a simple Linux app? Do they allow to load such apps? Is there a toolchain to co...
2013/01/31
[ "https://Stackoverflow.com/questions/14636312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/363297/" ]
At least according to Samsung, "No." > > > > > > > > > > > > Q: Do you support C++ in the SDK? > > > > > > > > > A: No, Samsung platform only supports web technologies based apps (JS, CSS, HTML, FLASH) > > > > > > > > > > > > > > > > > > <http://www.samsungdforum.com/Support/FAQList?page=1&faqCateID=2...
In the SDK 4.5 will include Native Client technology, NaCl, Currently supported languages ​​are C and C + +. For more information: <http://www.samsungdforum.com/Guide/d17/index.html>
14,636,312
Is there an easy howto on writing C++ app for Samsung Smart TV that should be able to run in background (so not an HTML/JS applet) and access /dev/ttyUSBx device plugged in the TV? Do they have some API to access /dev/ttyUSBx or it will be a simple Linux app? Do they allow to load such apps? Is there a toolchain to co...
2013/01/31
[ "https://Stackoverflow.com/questions/14636312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/363297/" ]
In the SDK 4.5 will include Native Client technology, NaCl, Currently supported languages ​​are C and C + +. For more information: <http://www.samsungdforum.com/Guide/d17/index.html>
For Samsung SmartTVs you cannot use C++, the only allowed language/technology is HTML/JavaScript/CSS and Flash (not used much). Majority of the applications are JavaScript based. Might be you can have some exclusive agreement with the Samsung, since e.g. Skype is most probably not developed in JavaScript and the Angr...
16,024,969
I am new to R and most of my experience is in Java. I am trying to do the following: ``` clusterWeeks <- function() { kmV = list() #a list of kmeans objects from each week for(i in 1:5) { windows() kmV.append(clusterData(i)) #clusterData(i) returns a kmeans object } } ``` For some r...
2013/04/15
[ "https://Stackoverflow.com/questions/16024969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1104823/" ]
You need to create a list to hold each separate object. Otherwise you are just overwriting and returning only the last one: ``` clusterWeeks <- function() { kmV = vector("list", 5) # a 5 element list of empty items for(i in 1:5) { windows() kmV[[i]] <- clusterData(i) #clusterData(i) returns a ...
Based on your code, here is what I would do: ``` clusterWeeks <- function(){ kmV <- c() for(i in 1:5) { kmV <- c(kmV, i) } return(kmV) } ``` small example: ``` test <- clusterWeeks() test[2] 2 ```
27,357,618
I have done some research on line and noticed that the apps you write in apple swift language would be working on OS X 10.9 and higher only. In order to make apps that work on earlier versions of OS X like 10.6 you would have to write them in objective C. [Here](https://developer.apple.com/library/prerelease/ios/doc...
2014/12/08
[ "https://Stackoverflow.com/questions/27357618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4327809/" ]
If you want it to run on an earlier version of OSX, then just have to write it in Objective-C. You need to bundle a run-time library with swift code, and this library will not work correctly on releases earlier than 10.9 and usually crashes. In addition, if you try to target an earlier release of OSX with your swift ...
According to Apple Swift blog, Mavericks is the lowest [compatible](https://developer.apple.com/swift/blog/?id=2) version: > > Simply put, if you write a Swift app today and submit it to the App Store this Fall when iOS 8 and OS X Yosemite are released, you can trust that your app will work well into the future. > ...
1,418
We're treading down a wrong path here, there needs to be some quality control in terms of answers. Just treating everything as "it's creative, don't hate" is such a bad way to regulate question and answer quality. For example, this question: <https://puzzling.stackexchange.com/questions/3911/a-man-pushes-his-car> An ...
2014/11/12
[ "https://puzzling.meta.stackexchange.com/questions/1418", "https://puzzling.meta.stackexchange.com", "https://puzzling.meta.stackexchange.com/users/4425/" ]
I blame the questions. If “solve this riddle” is a valid question, then those are decent answers. [These puzzles are officially off-topic](https://puzzling.meta.stackexchange.com/questions/1254/why-are-questions-off-topic-if-they-invite-answers-which-are-not-demonstrably-co), but pretty much nobody appears to be enfo...
That is actually a good answer by StackExchange standards. The answerer provided a link to a reputable source (Wikipedia) as well as summarizing the condition in his own words. Then he explained how it answered the question. There's some debate here as to whether we want to include well-known puzzles like these that a...
1,418
We're treading down a wrong path here, there needs to be some quality control in terms of answers. Just treating everything as "it's creative, don't hate" is such a bad way to regulate question and answer quality. For example, this question: <https://puzzling.stackexchange.com/questions/3911/a-man-pushes-his-car> An ...
2014/11/12
[ "https://puzzling.meta.stackexchange.com/questions/1418", "https://puzzling.meta.stackexchange.com", "https://puzzling.meta.stackexchange.com/users/4425/" ]
One reason for this is the way the 'hotness' scores are calculated. Questions with high 'hotness' can reach the SE home page and the multi-collider-thingy, which gives them a big boost in visitors and rep. The hotness formula gives a big advantage to questions with plenty of answers, specifically `MIN(AnswerCount, 10...
That is actually a good answer by StackExchange standards. The answerer provided a link to a reputable source (Wikipedia) as well as summarizing the condition in his own words. Then he explained how it answered the question. There's some debate here as to whether we want to include well-known puzzles like these that a...
1,418
We're treading down a wrong path here, there needs to be some quality control in terms of answers. Just treating everything as "it's creative, don't hate" is such a bad way to regulate question and answer quality. For example, this question: <https://puzzling.stackexchange.com/questions/3911/a-man-pushes-his-car> An ...
2014/11/12
[ "https://puzzling.meta.stackexchange.com/questions/1418", "https://puzzling.meta.stackexchange.com", "https://puzzling.meta.stackexchange.com/users/4425/" ]
It's not just you. The problems you've mentioned here are the main reason I stopped participating in this site several months ago. I have no intent to return in the future unless they are worked out (which I'm not hopeful of). I decided to describe what I expected this site would be and compare to what it actually beca...
That is actually a good answer by StackExchange standards. The answerer provided a link to a reputable source (Wikipedia) as well as summarizing the condition in his own words. Then he explained how it answered the question. There's some debate here as to whether we want to include well-known puzzles like these that a...
1,418
We're treading down a wrong path here, there needs to be some quality control in terms of answers. Just treating everything as "it's creative, don't hate" is such a bad way to regulate question and answer quality. For example, this question: <https://puzzling.stackexchange.com/questions/3911/a-man-pushes-his-car> An ...
2014/11/12
[ "https://puzzling.meta.stackexchange.com/questions/1418", "https://puzzling.meta.stackexchange.com", "https://puzzling.meta.stackexchange.com/users/4425/" ]
I blame the questions. If “solve this riddle” is a valid question, then those are decent answers. [These puzzles are officially off-topic](https://puzzling.meta.stackexchange.com/questions/1254/why-are-questions-off-topic-if-they-invite-answers-which-are-not-demonstrably-co), but pretty much nobody appears to be enfo...
One reason for this is the way the 'hotness' scores are calculated. Questions with high 'hotness' can reach the SE home page and the multi-collider-thingy, which gives them a big boost in visitors and rep. The hotness formula gives a big advantage to questions with plenty of answers, specifically `MIN(AnswerCount, 10...
1,418
We're treading down a wrong path here, there needs to be some quality control in terms of answers. Just treating everything as "it's creative, don't hate" is such a bad way to regulate question and answer quality. For example, this question: <https://puzzling.stackexchange.com/questions/3911/a-man-pushes-his-car> An ...
2014/11/12
[ "https://puzzling.meta.stackexchange.com/questions/1418", "https://puzzling.meta.stackexchange.com", "https://puzzling.meta.stackexchange.com/users/4425/" ]
I blame the questions. If “solve this riddle” is a valid question, then those are decent answers. [These puzzles are officially off-topic](https://puzzling.meta.stackexchange.com/questions/1254/why-are-questions-off-topic-if-they-invite-answers-which-are-not-demonstrably-co), but pretty much nobody appears to be enfo...
It's not just you. The problems you've mentioned here are the main reason I stopped participating in this site several months ago. I have no intent to return in the future unless they are worked out (which I'm not hopeful of). I decided to describe what I expected this site would be and compare to what it actually beca...
37,780,815
I have finding on internet about how to center the text on fpdf or one way to center my text but I didnt find it. by the way it's just the title I need to center ``` <?php require('../fpdf/fpdf.php'); class Ticket extends FPDF{ private $conexion; public function __construct(){...
2016/06/13
[ "https://Stackoverflow.com/questions/37780815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6088251/" ]
The `Cell` method includes optional var for alignment <http://www.fpdf.org/en/doc/cell.htm> You can include the additional options variables and define the alignment as center. ``` $pdf->Cell(0,0,'StoreLTE',0,1,'C'); ```
``` $pdf->MultiCell(0,0, $user_name , $border=0, $align='C', $fill=false); ``` Just give `$align='C'`. This works for me.
19,297,209
The code: ``` $gmc = new GearmanClient(); $gmc->addServer(); $gmc->setCompleteCallback(function(GearmanTask $task){ echo 'Complete: Task ' . $task->unique() . PHP_EOL; }); for ($i=0; $i<10; $i++) { $gmc->addTask('queryShard', json_encode($taskData), null, 'Job:' . $i); } if (!$gmc->runTasks()) { echo "ER...
2013/10/10
[ "https://Stackoverflow.com/questions/19297209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/84626/" ]
*runTasks* will block execution of the calling thread until all added foreground tasks complete. See fiskfisk [answer](https://stackoverflow.com/questions/10397923/parallelization-with-gearman) for more details. However the fact that the all tasks completed does not imply that all tasks successfully completed. Gearma...
You can use the following: ``` $taskset = $gmc->new_task_set(); while(...) { $taskset->addTask(...); } $taskset->wait(); ``` to wait until all jobs has been finished.
9,997,587
Is it possible that the data of a QRCode could contain an image and text? I am not talking about an image placed on top of the QRCode, but when you scan the QRCode that it would contain the data of an image to display along with some text? Basically when I scan my QRCode, I would like for it to show my photo name and ...
2012/04/03
[ "https://Stackoverflow.com/questions/9997587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/775414/" ]
Not really. The maximum amount of data you can store in a QR code is ~4KB. That's not really enough for any image files.
**Yes**, it can be possible by compressing an image to near about 1.5kb and then convert it into BASE64 format by following whatever you text want to place into QR code.However, you might require more than 10mp camera to fetch information from QR Code.[This is the example of Qr Code with image and text.](https://i.stac...
61,159,177
I have created a simple Spark application in Scala which is running fine locally. I have used Maven as a build tool and am packaging the JAR file using shade plugin. The directory structure looks like this: [![Project Structure](https://i.stack.imgur.com/iKxFv.png)](https://i.stack.imgur.com/iKxFv.png) I am using th...
2020/04/11
[ "https://Stackoverflow.com/questions/61159177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7429624/" ]
You are using `json4s-native_2.11 3.6.6` but `spark-core 2.4.4` which is core of Spark framework uses [json4s](https://mvnrepository.com/artifact/org.apache.spark/spark-core_2.11/2.4.4) in version `3.5.3` which makes `json4s core` incompatible. I recommend switching to json4s version `3.5.3`
Your plugin for dependencies might be wrong set. Mine has some differences and works perfectly. ``` <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals> <goal>single</goa...
1,482,226
I'm worried that this will be a spanner in the works when I'm using a calculator in an exam , I know that $-2^2= 4$ since $(-2) \cdot (-2) = 4 $. So why does my calculator show it as negative 4 ? Does anyone know if there is a way to reset my calculator so it doesn't do this? The make and model is Casio fx-83ES.
2015/10/15
[ "https://math.stackexchange.com/questions/1482226", "https://math.stackexchange.com", "https://math.stackexchange.com/users/276596/" ]
$ax +be^x +c\sin(x) =0$, $x=0$ implies $b=0$, $ax+c\sin(x) = 0$, $x=\pi$, $a=0$ thus $c=0$
Since $x$, $e^x$, and $\sin x$ are analytic, then their non-vanishing [Wronskian](https://en.wikipedia.org/wiki/Wronskian#The_Wronskian_and_linear_independence) is sufficient to conclude that the set is linearly independent. The Wronskian is equal to the determinant $W$ of the matrix given by $$\begin{bmatrix} x & ...
1,482,226
I'm worried that this will be a spanner in the works when I'm using a calculator in an exam , I know that $-2^2= 4$ since $(-2) \cdot (-2) = 4 $. So why does my calculator show it as negative 4 ? Does anyone know if there is a way to reset my calculator so it doesn't do this? The make and model is Casio fx-83ES.
2015/10/15
[ "https://math.stackexchange.com/questions/1482226", "https://math.stackexchange.com", "https://math.stackexchange.com/users/276596/" ]
$ax +be^x +c\sin(x) =0$, $x=0$ implies $b=0$, $ax+c\sin(x) = 0$, $x=\pi$, $a=0$ thus $c=0$
Suppose $ax +be^x +c\sin(x) =0 $. If $b \ne 0$, then, for large enough $x$, $b e^x$ is much larger than the other two terms, which is a contradiction. Therefore $b = 0$, so we have $ax+c\sin(x) = 0 $. Again, if $a \ne 0$, we can choose $x$ large enough so that $|ax| > |c|$. Since $|\sin(x)| \le 1$, this can not hold...
1,482,226
I'm worried that this will be a spanner in the works when I'm using a calculator in an exam , I know that $-2^2= 4$ since $(-2) \cdot (-2) = 4 $. So why does my calculator show it as negative 4 ? Does anyone know if there is a way to reset my calculator so it doesn't do this? The make and model is Casio fx-83ES.
2015/10/15
[ "https://math.stackexchange.com/questions/1482226", "https://math.stackexchange.com", "https://math.stackexchange.com/users/276596/" ]
Since $x$, $e^x$, and $\sin x$ are analytic, then their non-vanishing [Wronskian](https://en.wikipedia.org/wiki/Wronskian#The_Wronskian_and_linear_independence) is sufficient to conclude that the set is linearly independent. The Wronskian is equal to the determinant $W$ of the matrix given by $$\begin{bmatrix} x & ...
Suppose $ax +be^x +c\sin(x) =0 $. If $b \ne 0$, then, for large enough $x$, $b e^x$ is much larger than the other two terms, which is a contradiction. Therefore $b = 0$, so we have $ax+c\sin(x) = 0 $. Again, if $a \ne 0$, we can choose $x$ large enough so that $|ax| > |c|$. Since $|\sin(x)| \le 1$, this can not hold...
28,414,080
I am following this tutorial <https://www.youtube.com/watch?v=rdYQOqxq9F0> Building Eclipse Maven project for Web App, using Spring-MVC and Hibernate with MySQL. Using Apache Tomcat 8 as server. After many hours trying to solve this, I am stuck. Please help, thank you. I am getting this error. Error: [EDITED] ``` ...
2015/02/09
[ "https://Stackoverflow.com/questions/28414080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3686580/" ]
Add this to your Adapter: ``` public void addItem(ItemListView item){ items.add(item); notifyDatasetChanged(); } public void removeItem(int positionToRemove){ items.remove(positionToRemove); notifyDatasetChanged(); } ``` To further explain whats happening, the adapter is the controller, the middle step between ...
You can use a simple methods like this in your activity : ``` private void addItemToList(ItemListView item){ if(item != null){ itens.add(item) } } ``` (to remove cells use list.remove()) Add this in your adapter : ``` public void loadNewList(List<ItemListView> list){ if(itens != null){ ...
28,414,080
I am following this tutorial <https://www.youtube.com/watch?v=rdYQOqxq9F0> Building Eclipse Maven project for Web App, using Spring-MVC and Hibernate with MySQL. Using Apache Tomcat 8 as server. After many hours trying to solve this, I am stuck. Please help, thank you. I am getting this error. Error: [EDITED] ``` ...
2015/02/09
[ "https://Stackoverflow.com/questions/28414080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3686580/" ]
Add this to your Adapter: ``` public void addItem(ItemListView item){ items.add(item); notifyDatasetChanged(); } public void removeItem(int positionToRemove){ items.remove(positionToRemove); notifyDatasetChanged(); } ``` To further explain whats happening, the adapter is the controller, the middle step between ...
In your activity you have `listView` attribut. In `onCreate()` method you can do this: ``` listView.setOnItemLongClickListener(new OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { final ItemListView i...
49,454,858
I'm trying to perform an action when the playback reaches a certain time. I can't find any delegate methods or examples of how to do this. How can I call a method when the playback reaches a certain point?
2018/03/23
[ "https://Stackoverflow.com/questions/49454858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48523/" ]
Console wraps your text. Set heigher column number in console settings
The problem is that java treats your text as a single line and cmd wraps it, so it becomes unreadable. To make a new line, use the newline character `\n`.
14,652,332
i have a list of posts on a page with a search bar at the top of the page. is there a way to get the contents of the search bar when the user hits enter? i don't want to submit a form but i want to get the contents of the search bar without leaving the page. i think i'd be able to get the contents of the field using ...
2013/02/01
[ "https://Stackoverflow.com/questions/14652332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1082281/" ]
Seems i've solved it ... Short story: Recompiled PHP with `--enable-zend-multibyte`. Long story: I tried everything imaginable ... checked source files byte-by-byte and there were no issues to be found. I've tried getting file contents inside php and echoing byte array from insidde php and in this case too, no ...
If you are using APC probabily you don't have updated the previous byte code. Try `apc_clear_cache();`
1,841,093
Is it possible to load an ActionScript 3 SWF and interact with it, for example by replacing some of its functions or editing variables? Similar to how it's possible in .NET using reflection and code generation. I'm looking to add an extra layer of functionality over an existing 3rd-party AS3 app.
2009/12/03
[ "https://Stackoverflow.com/questions/1841093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If you are loading it to another AS3 SWF, yes, you can access the public properties of the loaded SWF. You cannot replace functions - you can call functions, public ones, that is. ``` var ldr:Loader = new Loader(); ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad); ldr.load(new URLRequest("filename.swf")...
Well, you could could control the things(clips and other swf components) that are publicly available by digging in through the hierarchy of objects, just basic stuff. The other choice is you could decompile the loaded swf at runtime. This [library](http://code.google.com/p/as3swf/) sounds pretty interesting for that ta...
1,841,093
Is it possible to load an ActionScript 3 SWF and interact with it, for example by replacing some of its functions or editing variables? Similar to how it's possible in .NET using reflection and code generation. I'm looking to add an extra layer of functionality over an existing 3rd-party AS3 app.
2009/12/03
[ "https://Stackoverflow.com/questions/1841093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If you are loading it to another AS3 SWF, yes, you can access the public properties of the loaded SWF. You cannot replace functions - you can call functions, public ones, that is. ``` var ldr:Loader = new Loader(); ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad); ldr.load(new URLRequest("filename.swf")...
Aspose.Flash can help you with editing variables since it has support for the action script byte code decompilation, however it's not free and can't emit new functions unless you use an external as3 compiler(e.g. the one from Adobe that's free and open source)
18,233,946
I know that I need to pass through google to search etc, I did but they don't offer what I need 90% of this sites give the same example and even sometimes the same explanation, If there someone who have for example links from university or school or may be in his dropbox, I will be very thankfull.
2013/08/14
[ "https://Stackoverflow.com/questions/18233946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2529175/" ]
Unfortunately it seems that the best resources for learning Standard ML are various paper books (e.g. [Introduction to Programming using SML](https://rads.stackoverflow.com/amzn/click/com/0201398206) by Hansen & Rischel, [ML for the Working Programmer](https://rads.stackoverflow.com/amzn/click/com/052156543X) by Larry ...
I am using the book Programming in Standard ML by Colin Meyers,Chris Clark,Ellen Poon and ML for the working Programmer by L C Paulson.The former is really a great book as it always puts types in function declarations..this way you will master the underlying types in sml
18,233,946
I know that I need to pass through google to search etc, I did but they don't offer what I need 90% of this sites give the same example and even sometimes the same explanation, If there someone who have for example links from university or school or may be in his dropbox, I will be very thankfull.
2013/08/14
[ "https://Stackoverflow.com/questions/18233946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2529175/" ]
I took the [Programming Languages Course](https://www.coursera.org/course/proglang) at Coursera and it was superb. Most of the course is based on SML. The first first four weeks are entirely about SML. The material distributed in the course is great and every week there are plenty of interesting exercises to solve. T...
I am using the book Programming in Standard ML by Colin Meyers,Chris Clark,Ellen Poon and ML for the working Programmer by L C Paulson.The former is really a great book as it always puts types in function declarations..this way you will master the underlying types in sml
31,880,569
I want to use the new ItemTouchHelper from the v7 design library. I use it inside of a SwipeRefreshLayout. The problem is that with the SwipeRefreshLayout the animation for the swipe to dismiss is wrong and buggy. Anyone knows how to fix this?
2015/08/07
[ "https://Stackoverflow.com/questions/31880569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1047461/" ]
You could disable your SwipeRefreshLayout as long as you are swiping. ``` final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.Callback() { @Override public int getMovementFlags(RecyclerView recyclerView, ViewHolder viewHolder) { return makeMovementFlags(0, ItemTouchHelper.ST...
**one of many:** ``` /** * Notify the widget that refresh state has changed. * method to avoid bug in setRefreshing(boolean) * Do not call this when refresh is triggered by a swipe gesture. * @param swipeRefreshLayout - layout, take care not to pass null parameter * @param isRefreshing - whether or not the...
67,871,652
I'm getting this exact crash/error message from logcat for my Android app. ``` A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 9500 (com.schonell), pid 9500 ``` No more crash log details only this message showing. This happened every time when my video calling app end the calls and cra...
2021/06/07
[ "https://Stackoverflow.com/questions/67871652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9651355/" ]
> > Is this the correct approach in validation a selected record? If not, what is the correct approach? > > > Not. You are doing wrong. It is impossible to give a complete answer - it requires more code of your implementation. Therefore, I am writing what I could understand from your explanations and partial c...
activate the cell\_click event handler for the DataGrid. Then ``` private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex]; TextBox1.text = row.Cells["id_number"].V...
55,383
I'm a wanna-be indie developer, and I am working on my first flash game. But, before I even start with the code, I want to know this: When determining the title of my game, how can I decide if it is copyrighted or not? For example, at first I thought about "Into the Void" for the title. When I Googled it, I found out...
2013/05/12
[ "https://gamedev.stackexchange.com/questions/55383", "https://gamedev.stackexchange.com", "https://gamedev.stackexchange.com/users/30604/" ]
Short answer: you can use that name for your game legally, as long as you abide by the copyright laws and the name is not [trademarked](https://en.wikipedia.org/wiki/Trademark). For the long answer, we refer to [Wikipedia](https://en.wikipedia.org/wiki/Copyright_infringement): > > **Copyright infringement** is the ...
If you want proper legal advice speak to a lawyer. However, as far as I know copyright isn't a big issue with titles for games, especially when it clashes with something that's not a game. Trademarks are something you should avoid though. However if you want people to be able to find your game on a search engine, hav...
55,383
I'm a wanna-be indie developer, and I am working on my first flash game. But, before I even start with the code, I want to know this: When determining the title of my game, how can I decide if it is copyrighted or not? For example, at first I thought about "Into the Void" for the title. When I Googled it, I found out...
2013/05/12
[ "https://gamedev.stackexchange.com/questions/55383", "https://gamedev.stackexchange.com", "https://gamedev.stackexchange.com/users/30604/" ]
If you want proper legal advice speak to a lawyer. However, as far as I know copyright isn't a big issue with titles for games, especially when it clashes with something that's not a game. Trademarks are something you should avoid though. However if you want people to be able to find your game on a search engine, hav...
The title of a game isn't copyrighted - it is trademarked. Trademark law and copyright law are related but entirely different areas. While registration of a copyright is optional, a trademark must be registred to be enforceable (there are exceptions, like claiming an unregistred trademark through notoriety, but these ...
55,383
I'm a wanna-be indie developer, and I am working on my first flash game. But, before I even start with the code, I want to know this: When determining the title of my game, how can I decide if it is copyrighted or not? For example, at first I thought about "Into the Void" for the title. When I Googled it, I found out...
2013/05/12
[ "https://gamedev.stackexchange.com/questions/55383", "https://gamedev.stackexchange.com", "https://gamedev.stackexchange.com/users/30604/" ]
Short answer: you can use that name for your game legally, as long as you abide by the copyright laws and the name is not [trademarked](https://en.wikipedia.org/wiki/Trademark). For the long answer, we refer to [Wikipedia](https://en.wikipedia.org/wiki/Copyright_infringement): > > **Copyright infringement** is the ...
The title of a game isn't copyrighted - it is trademarked. Trademark law and copyright law are related but entirely different areas. While registration of a copyright is optional, a trademark must be registred to be enforceable (there are exceptions, like claiming an unregistred trademark through notoriety, but these ...
45,310,487
I am setting up a Spring hibernate H2 application. When the server starts everything works but after an update (rebuild project in eclipse without restarting Tomcat) I get the following error messages saying that the database file can't be accessed. Error Messages: ``` java.lang.IllegalStateException: The file is lo...
2017/07/25
[ "https://Stackoverflow.com/questions/45310487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4779728/" ]
Try `DB_CLOSE_ON_EXIT=FALSE`, from the Spring [docs](https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-sql.html#boot-features-embedded-database-support) > > If, for whatever reason, you do configure the connection URL for an embedded database, care should be taken to ensure that the databas...
if need to create multipul connecation then you need to use below code : ``` <property name="javax.persistence.jdbc.url" value="jdbc:h2:tcp://localhost/C:\Database\Data\production;"/> ```
41,438,419
I have function for serialization to jsonObject in swift: ``` func JSONWork() -> Any { let file = Bundle.main.path(forResource: "file", ofType: "json")! let url = URL(fileURLWithPath: file) let jsonData = NSData(contentsOf: url)! let json = try! JSONSerialization.jsonOb...
2017/01/03
[ "https://Stackoverflow.com/questions/41438419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5928311/" ]
You can use on of frameworks for JSON mapping. Read about pros and cons of popular solutions [here](https://github.com/bwhiteley/JSONShootout) and choose best for you. Also, you can read [Working with JSON in Swift](https://developer.apple.com/swift/blog/?id=37) article from Swift blog, it's a recommendation by Apple t...
``` if let data = NSData(contentsOfFile: file) { let jsonObj = JSON(data: data) let array = jsonObj.arrayValue } ``` [Use Swifty JSON](https://github.com/SwiftyJSON/SwiftyJSON)
21,775,894
I'm using async library(the browser version) . I am stuck at the point where I see a fail in the normal(read 'expected') behavior of [async series](https://github.com/caolan/async#seriestasks-callback) when i nest async calls inside one another. Here are some fiddles producing wrong outputs [fiddle 1](http://jsfiddl...
2014/02/14
[ "https://Stackoverflow.com/questions/21775894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1525202/" ]
With asynchronous functions, invoking the callback is analogous to returning from a normal function in the sense that it resumes execution of the rest of the program. In function `f1`, invoking `cb` causes `f2` to be executed (which eventually prints `Hello from f2` and `Done all`). To make sure `f2` is executed after...
The answer as per EDITs from @tom. It was a mistake to call cb(null) early in the code -- corrected code has been edited above in the question itself.
47,129,959
I am trying to load multiple csv files from a hdfs directory into spark DataSet using Spark 2.1.0 APIs: ``` val csvData = spark.read.option("header", "true").csv("csvdatatest/") ``` Inside the "csvdatatest" folder there are multiple csv files. Spark is picking header only from the first file and generating this as S...
2017/11/06
[ "https://Stackoverflow.com/questions/47129959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2919849/" ]
There are no ways to read the data correctly without iterating over the files in some way. In big data, file-based data sources are directory-based and the assumption for CSV is that all files in a directory have the same schema. There is no equivalent to `.read.option("mergeSchema", true)` that exists for JSON sources...
It automatically merges, and show the latest schema. For data missing columns is shown as nulls. I am using spark version 2.3.1
29,370,415
I heard somewhere that `NSManagedObjectContext` is a transactional log, so context stores operations with date when they were performed. Is it right? Am I able to get back this log?
2015/03/31
[ "https://Stackoverflow.com/questions/29370415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239219/" ]
Change the `sep` parameter so that `print` doesn't implicitly insert a space: ``` for i in range(18): print("sfo-router",(i), sep='') ``` Alternatively, you can convert your number to a string with `str` and concatenate: ``` for i in range(18): print("sfo-router" + str(i)) ``` **Outputs: (*in both cases*)...
Use format: ``` for i in range(18): print("sfo-router{}".format(i)) ```
29,370,415
I heard somewhere that `NSManagedObjectContext` is a transactional log, so context stores operations with date when they were performed. Is it right? Am I able to get back this log?
2015/03/31
[ "https://Stackoverflow.com/questions/29370415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239219/" ]
Change the `sep` parameter so that `print` doesn't implicitly insert a space: ``` for i in range(18): print("sfo-router",(i), sep='') ``` Alternatively, you can convert your number to a string with `str` and concatenate: ``` for i in range(18): print("sfo-router" + str(i)) ``` **Outputs: (*in both cases*)...
I'm new at python as well, and a quick google search did this one: Just use `str.replace()`: ``` string = 'hey man' string.replace(" ","") # String is now 'heyman' ``` Source: [Python remove all whitespace in a string](https://stackoverflow.com/questions/8270092/python-remove-all-whitespace-in-a-string)
29,370,415
I heard somewhere that `NSManagedObjectContext` is a transactional log, so context stores operations with date when they were performed. Is it right? Am I able to get back this log?
2015/03/31
[ "https://Stackoverflow.com/questions/29370415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239219/" ]
Use format: ``` for i in range(18): print("sfo-router{}".format(i)) ```
I'm new at python as well, and a quick google search did this one: Just use `str.replace()`: ``` string = 'hey man' string.replace(" ","") # String is now 'heyman' ``` Source: [Python remove all whitespace in a string](https://stackoverflow.com/questions/8270092/python-remove-all-whitespace-in-a-string)
971,810
In Silverlight I got the following problem. If you fire multiple requests to the web service, the responses might not return in an ordered sequence. Meaning if the first request takes longer than the following ones, its response will return at last: ``` 1. Sending request A.. (takes longer for some reason) 2. Sending ...
2009/06/09
[ "https://Stackoverflow.com/questions/971810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50430/" ]
I take a similar approach in my non-WCF ASP.NET web services, though I use the `DateTime` of the request instead and then just store the `DateTime` of the most recent request. This way I can do a direct less than comparison to determine if the returning service is the most recent or not. I did look into canceling old ...
Both of these approaches are what I took when I worked on a real time system with a lot of service calls. Basically just have some way to keep track of order ( incrementing variable, timestamp, etc. ) then keep track of highest received response. If the current response is lower than the highest, drop it.
23,792,284
I have the following code: ``` char* p; void func1() { p = "hello world"; } int main() { func1(); printf(p); return 0; } ``` This code works fine here, but I'd like to know if it is correct or if there is an "undefined behavior" here. Will the "hello world" still exist outside the func1()?
2014/05/21
[ "https://Stackoverflow.com/questions/23792284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1122858/" ]
String literals are character arrays with static storage duration (cf. C11 6.4.5/6), and thus their lifetime extends to the end of the entire program. Your code is fine.
The answer is "yes" -- "hello world" will still exist outside of `func1()`. That's because the string literal is not actually being stored in `func1`'s stack, but instead (usually) in a global table of such literals. Two notes, however: 1) It is bad practice to do `printf(str)` even for a constant str -- if the stri...
15,661,170
I’m trying to figure out how to add the menu class (optional field in admin) to the `body_class`, as I want to use the menu item's color on other elements of the page: ``` /** Add nav menu css class to body class */ function add_nav_menu_css( $classes ) { $classes[] = ‘optional-menu-class’; return $classes; } ...
2013/03/27
[ "https://Stackoverflow.com/questions/15661170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2215937/" ]
The only way i could find is to use `wp_get_nav_menu_items($menuID)` i tested it below with my menu `id` of `7` ``` $items = wp_get_nav_menu_items( 7 ); foreach ($items as $i) { echo $i->classes[0]; } ``` outputs `sample-page-class` which I inputed on the appearance menu page. All of the menu classes are stor...
if you want to add a custom class to the body tag simply use the body class, ``` <body <?php body_class('class-name'); ?>> ``` where 'class-name' is your custom class, if you want this to change based on or page/post, simply add this to your header.php ``` <?php if(is_page('your-page-name')){// or post $body_cla...
11,576,360
I am trying to refresh a jQuery mobile list view after an ajax post, I have been trying to use the .trigger("create") to do this like so: ``` <div data-role="content"> <div id="linksHolder" data-role="controlgroup" data-type="horizontal"> <a id="most-played" href="#" data-role="button" data-mode="mostplayed">Most...
2012/07/20
[ "https://Stackoverflow.com/questions/11576360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/926699/" ]
Solution to this was that DrawPageContent() was not being called when the document was ready. Once this was changed I could use .listview("refresh"): ``` <script type="text/javascript"> $(function () { DrawPageContent(); }); $(document).on("click", "#linksHolder a", function () { var mode = $(this).attr("data...
I think you can use id instead of class because you can use this class in multiple control so try id of your tag as per given below ``` <ul id="vdo_list" class="video-list" data-role="listview" data-divider-theme="a" data-inset="true"></ul> $("#vdo_list").listview('refresh'); ```
21,301,918
I want to trigger some script when new calendar event is created in Google Calendar (say calling some rest API that enters event information to my database). I do not want any kind of UI that triggers the script. Is it possible to achieve this using Google gadget since I do not want any UI? I would really appreciat...
2014/01/23
[ "https://Stackoverflow.com/questions/21301918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/737406/" ]
[Calendar API](https://developers.google.com/google-apps/calendar/) has something like notifications. See this link: [Push Notifications](https://developers.google.com/google-apps/calendar/v3/push). From documentation: > > The Google Calendar API provides push notifications that let you watch > for changes to resour...
Google Calendar API ([relevant docs](https://developers.google.com/calendar/v3/reference/events/watch)) provides a `watch` endpoint that allows you to specify a webhook upon certain events. To set up the webhook, you can call the Calendar API endpoint a POST request to `https://www.googleapis.com/calendar/v3/calendars...
22,389
If a wise person was unsure about which commercial cryptography standards are [truly secure](http://www.spiegel.de/international/germany/bild-1010361-793640.html) from [the fascist powers that be](https://en.wikipedia.org/wiki/Five_Eyes), it would seem the obvious option for companies and individuals is to now use two ...
2015/01/14
[ "https://crypto.stackexchange.com/questions/22389", "https://crypto.stackexchange.com", "https://crypto.stackexchange.com/users/21330/" ]
While the way that Robert showed can work if $e$ is small (and if $e \cdot d \equiv 1 \pmod{\phi(n)}$ (which is not necessarily true), there is a slightly more complicated method which will work in any case. What we do is compute $\lambda = (e \cdot d - 1)/ 2^k$ odd (and $k$ is the integer that makes $\lambda$ odd. Th...
Generally the public exponent is small. then if you know the public and private key, then you can compute $e.d=1+k.\phi(n)$. k is smaller than e and $\phi(n)$ is in the range of n. A direct method allow to make an exhaustive search on the small k which divide ed-1 in such a way that $\frac{e.d-1}{k}$ is an integer. Th...
19,045,739
I've try to implement RadioGroup view and put it inside a DialogFragment, but something gone wrong. I've follow this tutorial <http://developer.android.com/guide/topics/ui/controls/radiobutton.html> but instead Activity, view is initialized in a DialogFragment: ``` public class MenuDialog extends DialogFragment { ...
2013/09/27
[ "https://Stackoverflow.com/questions/19045739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246746/" ]
I'd rather implement the click handler inside of the fragment and add the listener dynamically (via java instead of XML). So I would do something like this: ``` public class MenuDialog extends DialogFragment implements OnClickListener{ [...] @Override public View onCreateView(LayoutInflater inflater, ViewGroup con...
The problem is that if you specify [`onClick`](http://developer.android.com/reference/android/R.attr.html#onClick) callback attribute for any `View` in xml file it should be located inside an `Activity` code but not in fragment code
19,045,739
I've try to implement RadioGroup view and put it inside a DialogFragment, but something gone wrong. I've follow this tutorial <http://developer.android.com/guide/topics/ui/controls/radiobutton.html> but instead Activity, view is initialized in a DialogFragment: ``` public class MenuDialog extends DialogFragment { ...
2013/09/27
[ "https://Stackoverflow.com/questions/19045739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246746/" ]
The problem is that if you specify [`onClick`](http://developer.android.com/reference/android/R.attr.html#onClick) callback attribute for any `View` in xml file it should be located inside an `Activity` code but not in fragment code
Implement RadioButton.OnCheckedChangeListener for your fragment. setOnCheckedChangeListener according to your radio buttons. ``` public class MenuDialog extends DialogFragment implements RadioButton.OnCheckedChangeListener{ //.. @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle...
19,045,739
I've try to implement RadioGroup view and put it inside a DialogFragment, but something gone wrong. I've follow this tutorial <http://developer.android.com/guide/topics/ui/controls/radiobutton.html> but instead Activity, view is initialized in a DialogFragment: ``` public class MenuDialog extends DialogFragment { ...
2013/09/27
[ "https://Stackoverflow.com/questions/19045739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246746/" ]
The problem is that if you specify [`onClick`](http://developer.android.com/reference/android/R.attr.html#onClick) callback attribute for any `View` in xml file it should be located inside an `Activity` code but not in fragment code
maybe I am a little bit late, but discovered this solution. Works on API 23 **YourDialogFragment.kt** ``` override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return requireActivity().let { AlertDialog.Builder(it) .setTitle("Your title here") .setSingleChoiceItems( ...
19,045,739
I've try to implement RadioGroup view and put it inside a DialogFragment, but something gone wrong. I've follow this tutorial <http://developer.android.com/guide/topics/ui/controls/radiobutton.html> but instead Activity, view is initialized in a DialogFragment: ``` public class MenuDialog extends DialogFragment { ...
2013/09/27
[ "https://Stackoverflow.com/questions/19045739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246746/" ]
I'd rather implement the click handler inside of the fragment and add the listener dynamically (via java instead of XML). So I would do something like this: ``` public class MenuDialog extends DialogFragment implements OnClickListener{ [...] @Override public View onCreateView(LayoutInflater inflater, ViewGroup con...
You need to link the listener with the radio group, you can do it this way ``` @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.menu_layout, container); this.getDialog().setTitle("title"); view.findViewById(R...
19,045,739
I've try to implement RadioGroup view and put it inside a DialogFragment, but something gone wrong. I've follow this tutorial <http://developer.android.com/guide/topics/ui/controls/radiobutton.html> but instead Activity, view is initialized in a DialogFragment: ``` public class MenuDialog extends DialogFragment { ...
2013/09/27
[ "https://Stackoverflow.com/questions/19045739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246746/" ]
I'd rather implement the click handler inside of the fragment and add the listener dynamically (via java instead of XML). So I would do something like this: ``` public class MenuDialog extends DialogFragment implements OnClickListener{ [...] @Override public View onCreateView(LayoutInflater inflater, ViewGroup con...
Implement RadioButton.OnCheckedChangeListener for your fragment. setOnCheckedChangeListener according to your radio buttons. ``` public class MenuDialog extends DialogFragment implements RadioButton.OnCheckedChangeListener{ //.. @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle...
19,045,739
I've try to implement RadioGroup view and put it inside a DialogFragment, but something gone wrong. I've follow this tutorial <http://developer.android.com/guide/topics/ui/controls/radiobutton.html> but instead Activity, view is initialized in a DialogFragment: ``` public class MenuDialog extends DialogFragment { ...
2013/09/27
[ "https://Stackoverflow.com/questions/19045739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246746/" ]
I'd rather implement the click handler inside of the fragment and add the listener dynamically (via java instead of XML). So I would do something like this: ``` public class MenuDialog extends DialogFragment implements OnClickListener{ [...] @Override public View onCreateView(LayoutInflater inflater, ViewGroup con...
maybe I am a little bit late, but discovered this solution. Works on API 23 **YourDialogFragment.kt** ``` override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return requireActivity().let { AlertDialog.Builder(it) .setTitle("Your title here") .setSingleChoiceItems( ...
19,045,739
I've try to implement RadioGroup view and put it inside a DialogFragment, but something gone wrong. I've follow this tutorial <http://developer.android.com/guide/topics/ui/controls/radiobutton.html> but instead Activity, view is initialized in a DialogFragment: ``` public class MenuDialog extends DialogFragment { ...
2013/09/27
[ "https://Stackoverflow.com/questions/19045739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246746/" ]
You need to link the listener with the radio group, you can do it this way ``` @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.menu_layout, container); this.getDialog().setTitle("title"); view.findViewById(R...
Implement RadioButton.OnCheckedChangeListener for your fragment. setOnCheckedChangeListener according to your radio buttons. ``` public class MenuDialog extends DialogFragment implements RadioButton.OnCheckedChangeListener{ //.. @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle...
19,045,739
I've try to implement RadioGroup view and put it inside a DialogFragment, but something gone wrong. I've follow this tutorial <http://developer.android.com/guide/topics/ui/controls/radiobutton.html> but instead Activity, view is initialized in a DialogFragment: ``` public class MenuDialog extends DialogFragment { ...
2013/09/27
[ "https://Stackoverflow.com/questions/19045739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246746/" ]
You need to link the listener with the radio group, you can do it this way ``` @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.menu_layout, container); this.getDialog().setTitle("title"); view.findViewById(R...
maybe I am a little bit late, but discovered this solution. Works on API 23 **YourDialogFragment.kt** ``` override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return requireActivity().let { AlertDialog.Builder(it) .setTitle("Your title here") .setSingleChoiceItems( ...
233,038
Assume that $X\_n$ is a sequence of a zero-mean and unit variance random variables (and maybe having density w.r.t. to Lebesgue). Can we conclude that $ P(X\_n \in [0,R\_n]) $ is bounded away from zero eventually, say $$\liminf\_{n \to \infty} P(X\_n \in [0,R\_n]) > 0$$ assuming that $R\_n \to \infty$. Intuitively, $X\...
2016/03/07
[ "https://mathoverflow.net/questions/233038", "https://mathoverflow.net", "https://mathoverflow.net/users/36687/" ]
Here's a proof if a third moment condition is satisfied. Suppose that $\mathbb EX=0$, $\mathbb EX^2=1$ and $\mathbb E|X|^3\le K$. Then let $Z=|X|$. We use Cauchy-Schwarz: $Z^2=Z^{1/2}Z^{3/2}$, so that $(\mathbb EZ^2)^2\le \mathbb EZ\cdot \mathbb EZ^3$. This gives $\mathbb EZ\ge \frac 1K$. Hence $\mathbb EX\mathbf 1\...
Filling in the details for Anthony's argument: Assume that $\mathbb E |X|^3 \le c$ for numerical constant $c > 0$. Let $X^+ = X \mathbf 1\_{X > 0}$ and $X^- = (-X) \mathbf 1\_{X < 0}$. Then, $X = X^+ - X^-$. Let $\mu = \mathbb E X^+ = \mathbb E X^-$. Then, by Anthony's argument $2 \mu = \mathbb E |X| \ge 1/c$. For ...
233,038
Assume that $X\_n$ is a sequence of a zero-mean and unit variance random variables (and maybe having density w.r.t. to Lebesgue). Can we conclude that $ P(X\_n \in [0,R\_n]) $ is bounded away from zero eventually, say $$\liminf\_{n \to \infty} P(X\_n \in [0,R\_n]) > 0$$ assuming that $R\_n \to \infty$. Intuitively, $X\...
2016/03/07
[ "https://mathoverflow.net/questions/233038", "https://mathoverflow.net", "https://mathoverflow.net/users/36687/" ]
Here's a proof if a third moment condition is satisfied. Suppose that $\mathbb EX=0$, $\mathbb EX^2=1$ and $\mathbb E|X|^3\le K$. Then let $Z=|X|$. We use Cauchy-Schwarz: $Z^2=Z^{1/2}Z^{3/2}$, so that $(\mathbb EZ^2)^2\le \mathbb EZ\cdot \mathbb EZ^3$. This gives $\mathbb EZ\ge \frac 1K$. Hence $\mathbb EX\mathbf 1\...
A standard technique to lower-bound $\mathbb P(0 < X < r)$ as a function of $\mathbb E[|X|^3]$ subject to $\mathbb E[X] = 0$ and $\mathbb E[X^2] = 1$ is to consider a suitable linear combination of $|X|^3$, $X$, $X^2$ and $1$ that is negative on $(0,r)$ and nonnegative outside that interval and has a negative expected ...
233,038
Assume that $X\_n$ is a sequence of a zero-mean and unit variance random variables (and maybe having density w.r.t. to Lebesgue). Can we conclude that $ P(X\_n \in [0,R\_n]) $ is bounded away from zero eventually, say $$\liminf\_{n \to \infty} P(X\_n \in [0,R\_n]) > 0$$ assuming that $R\_n \to \infty$. Intuitively, $X\...
2016/03/07
[ "https://mathoverflow.net/questions/233038", "https://mathoverflow.net", "https://mathoverflow.net/users/36687/" ]
A standard technique to lower-bound $\mathbb P(0 < X < r)$ as a function of $\mathbb E[|X|^3]$ subject to $\mathbb E[X] = 0$ and $\mathbb E[X^2] = 1$ is to consider a suitable linear combination of $|X|^3$, $X$, $X^2$ and $1$ that is negative on $(0,r)$ and nonnegative outside that interval and has a negative expected ...
Filling in the details for Anthony's argument: Assume that $\mathbb E |X|^3 \le c$ for numerical constant $c > 0$. Let $X^+ = X \mathbf 1\_{X > 0}$ and $X^- = (-X) \mathbf 1\_{X < 0}$. Then, $X = X^+ - X^-$. Let $\mu = \mathbb E X^+ = \mathbb E X^-$. Then, by Anthony's argument $2 \mu = \mathbb E |X| \ge 1/c$. For ...
67,923,424
[Here](https://codesandbox.io/s/react-spring-v9-page-transition-forked-3vrk8) I reproduced a simple snippet with a page transition made using `react-spring`. Is there a way to restore the previous page scroll position when clicking on the browser back button? There are many related QAs around, but I couldn't find any...
2021/06/10
[ "https://Stackoverflow.com/questions/67923424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11895568/" ]
It's not so easy to restore scrollY position while navigating. We might need a context for storing y positions for pages. Below is my solution. **custom hook for listening scroll event(hooks/scroll.js)** ``` import { useEffect, useState } from 'react'; import { useLocation } from 'react-router-dom'; export const use...
You can call the below method when unmounting a component and preserve it. ``` export const getScrollPage = (): number => { let docScrollTop = 0; if (document.documentElement && document.documentElement !== null) { docScrollTop = document.documentElement.scrollTop; } return window.pageYOffset || docScrollT...
24,688,897
Apologies for the confusing question title, I wasn't sure how to describe the problem. Background and objectives: I have a large dataset in Excel, near 1 Million rows. I have a key field (not primary cause there's duplicates). The key field will become the primary key field in a new table. For every row with the same ...
2014/07/11
[ "https://Stackoverflow.com/questions/24688897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3448738/" ]
i had the same issue, try this : open a new file and check the color mode at the beginning. then open up your file again!
When you save a file it gives you various colour management profiles depending on your set up (or needs). If you save without any colour management profile then the colours will be true
24,688,897
Apologies for the confusing question title, I wasn't sure how to describe the problem. Background and objectives: I have a large dataset in Excel, near 1 Million rows. I have a key field (not primary cause there's duplicates). The key field will become the primary key field in a new table. For every row with the same ...
2014/07/11
[ "https://Stackoverflow.com/questions/24688897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3448738/" ]
i had the same issue, try this : open a new file and check the color mode at the beginning. then open up your file again!
May be you are using CMYK color mode. try to change it. go to image then mode and click RGB color. RGB use for displaying purpose while CMYK Mode use for Printing purpose. Since this is web site item design, select RGB Color mode.