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 |
|---|---|---|---|---|---|
454,414 | Noise-canceling headphones can reduce a lot of ambient sound, but they are not 100% perfect. (Especially in the human vocal range.)
1. Is there any physical principle preventing the creation of perfect sound-canceling headphones? In other words, headphones that can cancel or block 100% of all external sound before it ... | 2019/01/15 | [
"https://physics.stackexchange.com/questions/454414",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/134671/"
] | The scattering of light by light is a very tiny quantum effect that was first observed in 2016 with high-energy photons at the Large Hadron Collider.
<https://en.wikipedia.org/wiki/Two-photon_physics>
Most of the time, photons do not interact with each other. When they occasionally do, they do not do so directly but ... | TLDR: no, photons do not normally react with each other.
All of the answers above are technically correct (*the best kind of correct*), but I'm not sure they really explain what's going on if I'm reading your post correctly. I'll try using a toy model to illustrate some of the main features.
Particles with electrical... |
24,904,552 | I want to use BeautifulSoup to pick up the ‘Model Type’ values on company’s webpages which from codes like below:
it forms 2 tables shown on the webpage, side by side.
**updated source code of the webpage**
```
<TR class=tableheader>
<TD width="12%"> </TD>
<TD style="TEXT-ALIGN: left" width="12%">Group </TD>
<T... | 2014/07/23 | [
"https://Stackoverflow.com/questions/24904552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2998077/"
] | Your alert box is empty, because the variable course has no value!
**Why?**
Your page gets reloaded, when you click on a link. The course variable is then empty, because variable values won't be stored for the next request. HTTP is stateless!
**What to do?**
Your page should not get reloaded.
Try something like:
``... | ```
course = $(this).find("a").text();
``` |
24,904,552 | I want to use BeautifulSoup to pick up the ‘Model Type’ values on company’s webpages which from codes like below:
it forms 2 tables shown on the webpage, side by side.
**updated source code of the webpage**
```
<TR class=tableheader>
<TD width="12%"> </TD>
<TD style="TEXT-ALIGN: left" width="12%">Group </TD>
<T... | 2014/07/23 | [
"https://Stackoverflow.com/questions/24904552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2998077/"
] | Your alert box is empty, because the variable course has no value!
**Why?**
Your page gets reloaded, when you click on a link. The course variable is then empty, because variable values won't be stored for the next request. HTTP is stateless!
**What to do?**
Your page should not get reloaded.
Try something like:
``... | You can use "this" to get the correct reference.
```
$(function(){
$('li').click(function(e){
alert($(this).text());
});
});
```
jsfiddle:
<http://jsfiddle.net/CMt9h/3/>
you can also use the event argument to get the target:
```
$(function(){
$('li').click(function(e){
alert($(e.target)... |
24,904,552 | I want to use BeautifulSoup to pick up the ‘Model Type’ values on company’s webpages which from codes like below:
it forms 2 tables shown on the webpage, side by side.
**updated source code of the webpage**
```
<TR class=tableheader>
<TD width="12%"> </TD>
<TD style="TEXT-ALIGN: left" width="12%">Group </TD>
<T... | 2014/07/23 | [
"https://Stackoverflow.com/questions/24904552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2998077/"
] | Your alert box is empty, because the variable course has no value!
**Why?**
Your page gets reloaded, when you click on a link. The course variable is then empty, because variable values won't be stored for the next request. HTTP is stateless!
**What to do?**
Your page should not get reloaded.
Try something like:
``... | As AndiPower said the course variable is empty due to the page reload. If you want this page reload, but still want to display the selected value on the next page you can do:
* Submit the value to the server and load it in js ready
* Add it as an url parameter to the `href` and read it in js ready
* Store it in a cook... |
35,353 | I am a Windows administrator standing up an Ubuntu Server for some intranet LAMP applications. I have read through some of the Ubuntu documentation but am not clear on a good way to get backups of the system. Obviously what I would like to do is be able restore the application data (and perhaps applications) if an issu... | 2011/04/15 | [
"https://askubuntu.com/questions/35353",
"https://askubuntu.com",
"https://askubuntu.com/users/13733/"
] | It really depends upon what your backup requirements are. Are you considering backup of entire machine, just userdata, perhaps app data, maybe mySQL data, etc?
Linux admins commonly use tools like Rsync with combination or ssh, at times for added security to do file level backups. Of course, if you have a virtual envi... | You say this is for LAMP applications (only?). In that case, you probably just need to backup the MySQL database(s), and the contents of /etc. The former should be backed up with a script specific to MySQL (backing up the MySQL data directory directly risks backing up an inconsistent database state), while for the latt... |
114,142 | I have my Stack Overflow account and [this](https://webmasters.stackexchange.com/questions/22660/how-do-i-set-starting-at-12-value-for-a-grouped-product-in-magento) question was migrated to Pro webmasters
Why was this question migrated? | 2011/11/30 | [
"https://meta.stackexchange.com/questions/114142",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/173856/"
] | I'm a little surprised there isn't an FAQ question about this. (Maybe this could be it?) A question is migrated when it is off topic for Stack Overflow, but is on topic for the destination site.
In this case, your question was migrated because it was not about programming specifically, but was about higher-level tasks... | Because there are a wealth of people on that site who know about Magento - and, best I can tell, your question wasn't programming-related - and fits within the scope of the other site more aptly. |
114,142 | I have my Stack Overflow account and [this](https://webmasters.stackexchange.com/questions/22660/how-do-i-set-starting-at-12-value-for-a-grouped-product-in-magento) question was migrated to Pro webmasters
Why was this question migrated? | 2011/11/30 | [
"https://meta.stackexchange.com/questions/114142",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/173856/"
] | I'm a little surprised there isn't an FAQ question about this. (Maybe this could be it?) A question is migrated when it is off topic for Stack Overflow, but is on topic for the destination site.
In this case, your question was migrated because it was not about programming specifically, but was about higher-level tasks... | As the migrator in question, I'll second what David has said. It was not programming related, and therefore off topic for StackOverflow.
There is not much traffic for managing Magento website configurations on Webmasters, unfortunately for you, but it is on topic there.
Perhaps you should check out this [Magento pro... |
1,508,516 | Prove that $(1+\sqrt2)^{2n} + (1-\sqrt2)^{2n}$ is an even integer.
I'm not sure how to prove that it is an even integer. What would I do for the Inductive Step? And for the basic step, can I plug in zero and prove something from that? | 2015/11/01 | [
"https://math.stackexchange.com/questions/1508516",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/286002/"
] | **Hint:** Prove by induction on $k$ that $(1+\sqrt2)^k = a+b\sqrt2$ for some integers $a$ and $b$ such that $(1-\sqrt2)^k = a-b\sqrt2$.
Then set $k=2n$.
You can choose either $k=0$ or $k=1$ to be the base case.
---
**Alternatively:** Use the binomial theorem on each of $(1+\sqrt2)^{2n}$ and $(1-\sqrt2)^{2n}$. Note ... | For the basic step, yes, you can plug $n=0$ (and also $n=1$, if you want) and do some computations.
On the other hand, for the inductive step you can always use the following equality:
$$x^{2n} + y^{2n} = (x^2+y^2)\cdot (x^{2(n-1)} + y^{2(n-1)}) - x^2y^2\cdot (x^{2(n-2)} + y^{2(n-2)})$$
and use *complete induction* (a... |
1,508,516 | Prove that $(1+\sqrt2)^{2n} + (1-\sqrt2)^{2n}$ is an even integer.
I'm not sure how to prove that it is an even integer. What would I do for the Inductive Step? And for the basic step, can I plug in zero and prove something from that? | 2015/11/01 | [
"https://math.stackexchange.com/questions/1508516",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/286002/"
] | **Hint:** Prove by induction on $k$ that $(1+\sqrt2)^k = a+b\sqrt2$ for some integers $a$ and $b$ such that $(1-\sqrt2)^k = a-b\sqrt2$.
Then set $k=2n$.
You can choose either $k=0$ or $k=1$ to be the base case.
---
**Alternatively:** Use the binomial theorem on each of $(1+\sqrt2)^{2n}$ and $(1-\sqrt2)^{2n}$. Note ... | Note that
$(1+\sqrt2)(1-\sqrt2)
=-1
$
and
$(1+\sqrt2)^2
=3+2\sqrt{2}
$.
Therefore,
if $a
=3+2\sqrt{2}
$,
then
$1/a = 3-2\sqrt{2}
$,
so that
$a+1/a
=6
$
and
$(1+\sqrt2)^{2n} + (1-\sqrt2)^{2n}
=a^n+1/a^n
$.
We now use the identity
true for any $a$
that
$a^{n+1}+1/a^{n+1}
=(a+1/a)(a^n+1/a^n)-(a^{n-1}+a^{n-1})
$.
Theref... |
1,508,516 | Prove that $(1+\sqrt2)^{2n} + (1-\sqrt2)^{2n}$ is an even integer.
I'm not sure how to prove that it is an even integer. What would I do for the Inductive Step? And for the basic step, can I plug in zero and prove something from that? | 2015/11/01 | [
"https://math.stackexchange.com/questions/1508516",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/286002/"
] | Base case: $P(0)$
$$ (1 + \sqrt{2})^0 + (1 - \sqrt{2})^0 = 1 + 1 = 2 $$
which is even since $2 = 2\cdot 1$ and of course $1 \in \mathbb{Z}$.
Inductive step: Assume true for $P(k)$, i.e.
$$ (1 + \sqrt{2})^{2k} + (1 - \sqrt{2})^{2k} $$
is true. Show that $P(k+1)$ is true. | For the basic step, yes, you can plug $n=0$ (and also $n=1$, if you want) and do some computations.
On the other hand, for the inductive step you can always use the following equality:
$$x^{2n} + y^{2n} = (x^2+y^2)\cdot (x^{2(n-1)} + y^{2(n-1)}) - x^2y^2\cdot (x^{2(n-2)} + y^{2(n-2)})$$
and use *complete induction* (a... |
1,508,516 | Prove that $(1+\sqrt2)^{2n} + (1-\sqrt2)^{2n}$ is an even integer.
I'm not sure how to prove that it is an even integer. What would I do for the Inductive Step? And for the basic step, can I plug in zero and prove something from that? | 2015/11/01 | [
"https://math.stackexchange.com/questions/1508516",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/286002/"
] | Base case: $P(0)$
$$ (1 + \sqrt{2})^0 + (1 - \sqrt{2})^0 = 1 + 1 = 2 $$
which is even since $2 = 2\cdot 1$ and of course $1 \in \mathbb{Z}$.
Inductive step: Assume true for $P(k)$, i.e.
$$ (1 + \sqrt{2})^{2k} + (1 - \sqrt{2})^{2k} $$
is true. Show that $P(k+1)$ is true. | Note that
$(1+\sqrt2)(1-\sqrt2)
=-1
$
and
$(1+\sqrt2)^2
=3+2\sqrt{2}
$.
Therefore,
if $a
=3+2\sqrt{2}
$,
then
$1/a = 3-2\sqrt{2}
$,
so that
$a+1/a
=6
$
and
$(1+\sqrt2)^{2n} + (1-\sqrt2)^{2n}
=a^n+1/a^n
$.
We now use the identity
true for any $a$
that
$a^{n+1}+1/a^{n+1}
=(a+1/a)(a^n+1/a^n)-(a^{n-1}+a^{n-1})
$.
Theref... |
161,346 | and now i stuck in using node override with content type.
I followed these step.
1. Create new content type name post (machine name: post)
2. Copy node.tpl.php from module to
my\_theme/templates/node/node--post.tpl.php
3. Go to admin-configuration-performance and click "Clear all caches"
Well, it did not work.
Sorry... | 2015/06/10 | [
"https://drupal.stackexchange.com/questions/161346",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/48129/"
] | Views comes with a (initially disabled) page that will display your taxonomy terms for you. If you look for "Taxonomy Term" in your views overview you should find it. It will display all of your taxonomy terms through a view.
It is recommended that you enable the view, clone it, disable the original and work with the... | You simply follow the following steps in order to make it work.

Now add your dynamic field value say i.e year and pass the argument value as shown below.
 |
48,740,493 | The table has 3 fields and sample data.
```
customerid ordertype countoforders
1 APP 10
1 WEB 20
2 APP 10
3 WEB 10
4 APP 30
5 APP 40
5 WEB 10
```
I want to retrieve only APP order customer... | 2018/02/12 | [
"https://Stackoverflow.com/questions/48740493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7825252/"
] | Changing the `outputMode` to `complete` solved the issue.
```
val query = theGroupedDF.writeStream
.outputMode("complete")
.format("console")
.start()
query.awaitTermination()
``` | adding this would solve the problem:
```
val theGroupedDF = theDF
.multiplyYieldByHundred
.explodeDates
.aggregateByValue
//code bellow
.withColumn("timestamp", current_timestamp())
.withWatermark("timestamp", "10 minutes")
``` |
1,004,739 | ***Do not ask me to read the similar questions because I already did and my question is different***
There is an idea about saving the current machine stat in a virtual machine *(virtualizing a physical machine)* and save it in an external storage then install 64 Bit system and install the virtual machine to reinstall... | 2015/11/24 | [
"https://superuser.com/questions/1004739",
"https://superuser.com",
"https://superuser.com/users/515264/"
] | No, that can't possibly work. The 64-bit versions of those programs and their components *aren't installed on your 32-bit system*. So you have to install them all.
When you run an installer on a 32-bit operating system, it installs the 32-bit versions of the program's components in the correct locations for a 32-bit o... | You could use [this](https://technet.microsoft.com/en-us/sysinternals/ee656415.aspx) Microsoft Sysinternals tool to capture a VHD of your Hard Drive(s), which you could then mount onto a virtualisation software ([VMWare Player](https://my.vmware.com/web/vmware/downloads), [Virtualbox](https://www.virtualbox.org/)) to u... |
10,611,362 | I am trying to use a `UISearchBar` to query multiple properties of a `NSManagedObject`
I have a `NSManagedObject` called `Person`, every person has a `name` and `socialSecurity` property. Right now my code can perform a search (fetch) for one of those properties or the other, but not both at the same time.
```
- (void... | 2012/05/16 | [
"https://Stackoverflow.com/questions/10611362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225266/"
] | Addition to @Matthias's answer, you can also use NSCompoundPredicate for your AND operations like this.
**Obj-C - AND**
```
NSPredicate *predicate1 = [NSPredicate predicateWithFormat:@"X == 1"];
NSPredicate *predicate2 = [NSPredicate predicateWithFormat:@"X == 2"];
NSPredicate *predicate = [NSCompoundPredicate andPre... | This is may be useful if you want to search multiple properties for anything that matches (eg UISearchControllerDelegate):
```
NSString *searchFor = @"foo";
NSArray *fields = @[@"Surname", @"FirstName", @"AKA", @"Nickname"]; // OR'd dictionary fields to search
NSMutableArray *predicates = NSMutableArray.new;
for (NSSt... |
10,611,362 | I am trying to use a `UISearchBar` to query multiple properties of a `NSManagedObject`
I have a `NSManagedObject` called `Person`, every person has a `name` and `socialSecurity` property. Right now my code can perform a search (fetch) for one of those properties or the other, but not both at the same time.
```
- (void... | 2012/05/16 | [
"https://Stackoverflow.com/questions/10611362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225266/"
] | You can append multiple search terms in an `NSPredicate` using the usual boolean operands such as AND/OR.
Something like this should do the trick.
```
[NSPredicate predicateWithFormat:@"name contains[cd] %@ OR ssid contains[cd] %@", query, query];
```
Hope that helps :) | To avoid the warning **Incompatible pointer types initializing 'NSCompoundPredicate \*\_strong' with an expression of type 'NSPredicate \*'**, replace the following:
```
NSCompoundPredicate * predicate = [NSCompoundPredicate orPredicateWithSubPredicates:subPredicates];
```
with this:
```
NSPredicate * predicate = [... |
10,611,362 | I am trying to use a `UISearchBar` to query multiple properties of a `NSManagedObject`
I have a `NSManagedObject` called `Person`, every person has a `name` and `socialSecurity` property. Right now my code can perform a search (fetch) for one of those properties or the other, but not both at the same time.
```
- (void... | 2012/05/16 | [
"https://Stackoverflow.com/questions/10611362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225266/"
] | Complete solution for Swift2
```
let request = NSFetchRequest(entityName: "Location")
let subPredicate1 = NSPredicate(format: "(name = %@)", searchString)
let subPredicate2 = NSPredicate(format: "(street = %@)", searchString)
let subPredicate3 = NSPredicate(format: "(city = %@)", searchString)
request.predicate = NSC... | This is may be useful if you want to search multiple properties for anything that matches (eg UISearchControllerDelegate):
```
NSString *searchFor = @"foo";
NSArray *fields = @[@"Surname", @"FirstName", @"AKA", @"Nickname"]; // OR'd dictionary fields to search
NSMutableArray *predicates = NSMutableArray.new;
for (NSSt... |
10,611,362 | I am trying to use a `UISearchBar` to query multiple properties of a `NSManagedObject`
I have a `NSManagedObject` called `Person`, every person has a `name` and `socialSecurity` property. Right now my code can perform a search (fetch) for one of those properties or the other, but not both at the same time.
```
- (void... | 2012/05/16 | [
"https://Stackoverflow.com/questions/10611362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225266/"
] | To avoid the warning **Incompatible pointer types initializing 'NSCompoundPredicate \*\_strong' with an expression of type 'NSPredicate \*'**, replace the following:
```
NSCompoundPredicate * predicate = [NSCompoundPredicate orPredicateWithSubPredicates:subPredicates];
```
with this:
```
NSPredicate * predicate = [... | For Swift:
```
var predicate = NSCompoundPredicate(
type: .AndPredicateType,
subpredicates: [predicate1, predicate2]
)
``` |
10,611,362 | I am trying to use a `UISearchBar` to query multiple properties of a `NSManagedObject`
I have a `NSManagedObject` called `Person`, every person has a `name` and `socialSecurity` property. Right now my code can perform a search (fetch) for one of those properties or the other, but not both at the same time.
```
- (void... | 2012/05/16 | [
"https://Stackoverflow.com/questions/10611362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225266/"
] | Addition to @Matthias's answer, you can also use NSCompoundPredicate for your AND operations like this.
**Obj-C - AND**
```
NSPredicate *predicate1 = [NSPredicate predicateWithFormat:@"X == 1"];
NSPredicate *predicate2 = [NSPredicate predicateWithFormat:@"X == 2"];
NSPredicate *predicate = [NSCompoundPredicate andPre... | Fraser Hess over at CISMGF.com has a great search example. You can read the post at <http://www.cimgf.com/2008/11/25/adding-itunes-style-search-to-your-core-data-application/>
My code based off the post is:
```
NSArray *searchTerms = [searchText componentsSeparatedByString:@" "];
if ([searchTerms count] == 1) { // Se... |
10,611,362 | I am trying to use a `UISearchBar` to query multiple properties of a `NSManagedObject`
I have a `NSManagedObject` called `Person`, every person has a `name` and `socialSecurity` property. Right now my code can perform a search (fetch) for one of those properties or the other, but not both at the same time.
```
- (void... | 2012/05/16 | [
"https://Stackoverflow.com/questions/10611362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225266/"
] | Complete solution for Swift2
```
let request = NSFetchRequest(entityName: "Location")
let subPredicate1 = NSPredicate(format: "(name = %@)", searchString)
let subPredicate2 = NSPredicate(format: "(street = %@)", searchString)
let subPredicate3 = NSPredicate(format: "(city = %@)", searchString)
request.predicate = NSC... | Fraser Hess over at CISMGF.com has a great search example. You can read the post at <http://www.cimgf.com/2008/11/25/adding-itunes-style-search-to-your-core-data-application/>
My code based off the post is:
```
NSArray *searchTerms = [searchText componentsSeparatedByString:@" "];
if ([searchTerms count] == 1) { // Se... |
10,611,362 | I am trying to use a `UISearchBar` to query multiple properties of a `NSManagedObject`
I have a `NSManagedObject` called `Person`, every person has a `name` and `socialSecurity` property. Right now my code can perform a search (fetch) for one of those properties or the other, but not both at the same time.
```
- (void... | 2012/05/16 | [
"https://Stackoverflow.com/questions/10611362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225266/"
] | Complete solution for Swift2
```
let request = NSFetchRequest(entityName: "Location")
let subPredicate1 = NSPredicate(format: "(name = %@)", searchString)
let subPredicate2 = NSPredicate(format: "(street = %@)", searchString)
let subPredicate3 = NSPredicate(format: "(city = %@)", searchString)
request.predicate = NSC... | To avoid the warning **Incompatible pointer types initializing 'NSCompoundPredicate \*\_strong' with an expression of type 'NSPredicate \*'**, replace the following:
```
NSCompoundPredicate * predicate = [NSCompoundPredicate orPredicateWithSubPredicates:subPredicates];
```
with this:
```
NSPredicate * predicate = [... |
10,611,362 | I am trying to use a `UISearchBar` to query multiple properties of a `NSManagedObject`
I have a `NSManagedObject` called `Person`, every person has a `name` and `socialSecurity` property. Right now my code can perform a search (fetch) for one of those properties or the other, but not both at the same time.
```
- (void... | 2012/05/16 | [
"https://Stackoverflow.com/questions/10611362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225266/"
] | Complete solution for Swift2
```
let request = NSFetchRequest(entityName: "Location")
let subPredicate1 = NSPredicate(format: "(name = %@)", searchString)
let subPredicate2 = NSPredicate(format: "(street = %@)", searchString)
let subPredicate3 = NSPredicate(format: "(city = %@)", searchString)
request.predicate = NSC... | For Swift:
```
var predicate = NSCompoundPredicate(
type: .AndPredicateType,
subpredicates: [predicate1, predicate2]
)
``` |
10,611,362 | I am trying to use a `UISearchBar` to query multiple properties of a `NSManagedObject`
I have a `NSManagedObject` called `Person`, every person has a `name` and `socialSecurity` property. Right now my code can perform a search (fetch) for one of those properties or the other, but not both at the same time.
```
- (void... | 2012/05/16 | [
"https://Stackoverflow.com/questions/10611362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225266/"
] | You can append multiple search terms in an `NSPredicate` using the usual boolean operands such as AND/OR.
Something like this should do the trick.
```
[NSPredicate predicateWithFormat:@"name contains[cd] %@ OR ssid contains[cd] %@", query, query];
```
Hope that helps :) | Complete solution for Swift2
```
let request = NSFetchRequest(entityName: "Location")
let subPredicate1 = NSPredicate(format: "(name = %@)", searchString)
let subPredicate2 = NSPredicate(format: "(street = %@)", searchString)
let subPredicate3 = NSPredicate(format: "(city = %@)", searchString)
request.predicate = NSC... |
10,611,362 | I am trying to use a `UISearchBar` to query multiple properties of a `NSManagedObject`
I have a `NSManagedObject` called `Person`, every person has a `name` and `socialSecurity` property. Right now my code can perform a search (fetch) for one of those properties or the other, but not both at the same time.
```
- (void... | 2012/05/16 | [
"https://Stackoverflow.com/questions/10611362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225266/"
] | You can append multiple search terms in an `NSPredicate` using the usual boolean operands such as AND/OR.
Something like this should do the trick.
```
[NSPredicate predicateWithFormat:@"name contains[cd] %@ OR ssid contains[cd] %@", query, query];
```
Hope that helps :) | You could use a [`NSCompoundPredicate`](https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSCompoundPredicate_Class/Reference/Reference.html).
Like this:
```
NSPredicate *predicateName = [NSPredicate predicateWithFormat:@"name contains[cd] %@", query];
NSPredicate *predicateSSI... |
19,994,709 | I am making application related to images. I have multiple images on my screen. I had take screen shot of that. But it should not provide my whole screen.
Little part of the top most & bottom most part need not be shown in that.
I have navigation bar on top. And some buttons at bottom. I don't want to capture that but... | 2013/11/15 | [
"https://Stackoverflow.com/questions/19994709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2862205/"
] | the easiest way to achieve this would be to add a UIView which holds all the content you want to take a screenshot of and then call `drawViewHierarchyInRect` from that UIView instead of the main UIView.
Something like this:
```
-(UIImage *) screenshot {
UIGraphicsBeginImageContextWithOptions(contentView.bounds.si... | You can use my below code to take screen shot of a view.
I have put the condition to check the size of a screenshot.
With this code image is saved in your documents folder and from there you can use your image to share on Facebook or anywhere you want to share.
```
CGSize size = self.view.bounds.size;
CGRect cro... |
19,994,709 | I am making application related to images. I have multiple images on my screen. I had take screen shot of that. But it should not provide my whole screen.
Little part of the top most & bottom most part need not be shown in that.
I have navigation bar on top. And some buttons at bottom. I don't want to capture that but... | 2013/11/15 | [
"https://Stackoverflow.com/questions/19994709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2862205/"
] | the easiest way to achieve this would be to add a UIView which holds all the content you want to take a screenshot of and then call `drawViewHierarchyInRect` from that UIView instead of the main UIView.
Something like this:
```
-(UIImage *) screenshot {
UIGraphicsBeginImageContextWithOptions(contentView.bounds.si... | use this code
```
-(IBAction)captureScreen:(id)sender
{
UIGraphicsBeginImageContext(webview.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImag... |
19,994,709 | I am making application related to images. I have multiple images on my screen. I had take screen shot of that. But it should not provide my whole screen.
Little part of the top most & bottom most part need not be shown in that.
I have navigation bar on top. And some buttons at bottom. I don't want to capture that but... | 2013/11/15 | [
"https://Stackoverflow.com/questions/19994709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2862205/"
] | the easiest way to achieve this would be to add a UIView which holds all the content you want to take a screenshot of and then call `drawViewHierarchyInRect` from that UIView instead of the main UIView.
Something like this:
```
-(UIImage *) screenshot {
UIGraphicsBeginImageContextWithOptions(contentView.bounds.si... | snapshotViewAfterScreenUpdates
but it is only Available in **iOS 7.0 and later**.
```
- (UIView *)snapshotViewAfterScreenUpdates:(BOOL)afterUpdates
```
This method captures the current visual contents of the screen from the render server and uses them to build a new snapshot view. You can use the returned snapshot ... |
65,361,194 | I'm doing some requests through some proxy servers. The function that defines which proxy url to use will choose randomly from a list of proxies. I would like to know for a given request, which proxy url is being used. As far as I know, when using a proxy server the http headers remain the same, but the tcp headers are... | 2020/12/18 | [
"https://Stackoverflow.com/questions/65361194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11518830/"
] | Some HTTP proxies add a `Via` header that tell who they are.
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Via> | The request which contains the target URI is given as argument `request` to `chooseProxy`. So you can have the correct mapping already inside your `chooseProxy` function, all you need to to is check `proxyToUse` vs. `request.URL` there.
If you don't really trust the code that this mapping is actually done, then you ne... |
65,361,194 | I'm doing some requests through some proxy servers. The function that defines which proxy url to use will choose randomly from a list of proxies. I would like to know for a given request, which proxy url is being used. As far as I know, when using a proxy server the http headers remain the same, but the tcp headers are... | 2020/12/18 | [
"https://Stackoverflow.com/questions/65361194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11518830/"
] | You can modify your chooseProxy function so that it saves the proxy selected.
To do that, you can transform the chooseProxy func into a method of a type that will be used as storage for the information you want to keep:
```
type proxySelector string
func (sel *proxySelector) chooseProxy(request *http.Request) (*url.U... | The request which contains the target URI is given as argument `request` to `chooseProxy`. So you can have the correct mapping already inside your `chooseProxy` function, all you need to to is check `proxyToUse` vs. `request.URL` there.
If you don't really trust the code that this mapping is actually done, then you ne... |
12,971,280 | In my application i set some animations in View1's view load() ,At first launch its working propely,if im pushed into otherview ,and while pop into view1 its not animating,What shoud i do for animate while pop view from other view?here my view did load code,
```
- (void)viewDidLoad
{
artext=[[NSMutableArray alloc] in... | 2012/10/19 | [
"https://Stackoverflow.com/questions/12971280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1656298/"
] | try another way to integerate twitter in your app
1. Using auth & webview(Twitter4j library)
<http://davidcrowley.me/?p=410>
<http://www.mokasocial.com/2011/07/writing-an-android-twitter-client-with-image-upload-using-twitter4j/>
code(url open in web view)
```
twitter = new TwitterFactory().getInstance();
t... | Please put following permission in your Manifest file
```
<uses-permission android:name="android.permission.INTERNET"/>
```
also check this link....
<http://www.android10.org/index.php/articleslibraries/291-twitter-integration-in-your-android-application> |
304,459 | I have a Dissemination Areas boundaries shapefile with has an attribute table full of data needed for lowest quartile analysis and I have a neighborhood shapefile which has lowest income data which also needs to be considered but am not sure how I can combine these shapefiles so I can consider both the lowest income ne... | 2018/11/29 | [
"https://gis.stackexchange.com/questions/304459",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/92028/"
] | This depends of course completely on your data.
Let's take into account the following 4 topologies (<https://pro.arcgis.com/de/pro-app/tool-reference/data-management/select-by-location-graphical-examples.htm>):
1. Distinct
2. Dissemination COMPLETELY\_CONTAINS neighborhood
3. Dissemination INTERSECT neighborhood
4. D... | I don't think you can spatial join if your geometries do not overlap somewhere.
The way I would do it is to convert your boundaries (lines) to polygons, merge them and then you would have your data merged as well. Just check if your boundaries are closed and isolate them before. |
26,076 | A search finds no words to the copyrighted song title. | 2017/01/15 | [
"https://writers.stackexchange.com/questions/26076",
"https://writers.stackexchange.com",
"https://writers.stackexchange.com/users/23016/"
] | This is not a copyright question, it is a contract question. You signed a contract with them. The terms of the contract tell you what you can and can't do. No one here can tell you what your contract says. Find it and read it. If you are uncertain how to interpret it, ask a lawyer. | Vanity presses make money from authors, not from selling copies, so there's at least a decent chance you've kept or can get back your copyright. Unfortunately, if you didn't study your contract to begin with, and they've proven so very poor, they're probably optimized mostly to wring more money out of you :-/
You need... |
58,943 | I have a web application where (among other things) customers can upload files and administrators can then download those files. The uploaded files are stored on `ServerA` and the web application used to upload/download those files runs on `ServerB`.
I would like to make it so that while the files are stored on `Serve... | 2014/05/28 | [
"https://security.stackexchange.com/questions/58943",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/5169/"
] | The most effective method is to use secure hardware to store the key. You can get SSL accelerators that will securely store and process keys onboard so that they never leave the secure hardware module. Relatively expensive and requires you to have physical access to the hardware (so no VPS or cloud solutions). | You can use public key/asymmetric encryption, for example using the gnupg program. The administrator generates a public/private key pair, and stores the private key somewhere safe (possibly on neither ServerA nor ServerB). You can store the public key anywhere, and in particular on the web server, where it will be used... |
58,943 | I have a web application where (among other things) customers can upload files and administrators can then download those files. The uploaded files are stored on `ServerA` and the web application used to upload/download those files runs on `ServerB`.
I would like to make it so that while the files are stored on `Serve... | 2014/05/28 | [
"https://security.stackexchange.com/questions/58943",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/5169/"
] | You can use public key/asymmetric encryption, for example using the gnupg program. The administrator generates a public/private key pair, and stores the private key somewhere safe (possibly on neither ServerA nor ServerB). You can store the public key anywhere, and in particular on the web server, where it will be used... | A way you can tie user credentials to the key is by having one key for the encrypted file, and encrypting that key multiple times with key based on each user's credentials. You'll have a ton of small key files (one per user), and each user who has access can decrypt the key to use in order to decrypt the final file. |
58,943 | I have a web application where (among other things) customers can upload files and administrators can then download those files. The uploaded files are stored on `ServerA` and the web application used to upload/download those files runs on `ServerB`.
I would like to make it so that while the files are stored on `Serve... | 2014/05/28 | [
"https://security.stackexchange.com/questions/58943",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/5169/"
] | You can use public key/asymmetric encryption, for example using the gnupg program. The administrator generates a public/private key pair, and stores the private key somewhere safe (possibly on neither ServerA nor ServerB). You can store the public key anywhere, and in particular on the web server, where it will be used... | Let's say that users A, B, C and D want to share files with each other on a remote location.
Each user generates a pair of public and private keys (let's say RSA1024/2048 bit).
Each user publishes his public key on the remote server.
Now let's say that A wants to share a file with B and C, but not with D.
A will cr... |
58,943 | I have a web application where (among other things) customers can upload files and administrators can then download those files. The uploaded files are stored on `ServerA` and the web application used to upload/download those files runs on `ServerB`.
I would like to make it so that while the files are stored on `Serve... | 2014/05/28 | [
"https://security.stackexchange.com/questions/58943",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/5169/"
] | The most effective method is to use secure hardware to store the key. You can get SSL accelerators that will securely store and process keys onboard so that they never leave the secure hardware module. Relatively expensive and requires you to have physical access to the hardware (so no VPS or cloud solutions). | A way you can tie user credentials to the key is by having one key for the encrypted file, and encrypting that key multiple times with key based on each user's credentials. You'll have a ton of small key files (one per user), and each user who has access can decrypt the key to use in order to decrypt the final file. |
58,943 | I have a web application where (among other things) customers can upload files and administrators can then download those files. The uploaded files are stored on `ServerA` and the web application used to upload/download those files runs on `ServerB`.
I would like to make it so that while the files are stored on `Serve... | 2014/05/28 | [
"https://security.stackexchange.com/questions/58943",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/5169/"
] | The most effective method is to use secure hardware to store the key. You can get SSL accelerators that will securely store and process keys onboard so that they never leave the secure hardware module. Relatively expensive and requires you to have physical access to the hardware (so no VPS or cloud solutions). | Let's say that users A, B, C and D want to share files with each other on a remote location.
Each user generates a pair of public and private keys (let's say RSA1024/2048 bit).
Each user publishes his public key on the remote server.
Now let's say that A wants to share a file with B and C, but not with D.
A will cr... |
24,497,571 | I have two applications. The first is used as an internal user management application that was developed to for multiple applications to use as a central authentication service. It is placed in an IFrame inside the second application. The second application is the application users are logging into after they have been... | 2014/06/30 | [
"https://Stackoverflow.com/questions/24497571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2166672/"
] | As of XML 3.98-1.4 and R 3.1 on Win7, this problem can be solved perfectly by using the function `free()`. But it does not work with `readHTMLTable()`. The following code works perfectly.
```
library(XML)
a = readLines("http://en.wikipedia.org/wiki/2014_FIFA_World_Cup")
while(TRUE){
b = xmlParse(paste(a, collapse ... | I had a lot of problems with memory leaks in the XML pakackage too (under both windows and linux), but the way I solved it eventually was to remove the object at the end of each processing step, i.e. add a rm(b) and a gc() at the end of each iteration. Let me know if this works for you too. |
24,497,571 | I have two applications. The first is used as an internal user management application that was developed to for multiple applications to use as a central authentication service. It is placed in an IFrame inside the second application. The second application is the application users are logging into after they have been... | 2014/06/30 | [
"https://Stackoverflow.com/questions/24497571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2166672/"
] | As of XML 3.98-1.4 and R 3.1 on Win7, this problem can be solved perfectly by using the function `free()`. But it does not work with `readHTMLTable()`. The following code works perfectly.
```
library(XML)
a = readLines("http://en.wikipedia.org/wiki/2014_FIFA_World_Cup")
while(TRUE){
b = xmlParse(paste(a, collapse ... | Same problem here, even doing nothing more than reading in the document with `doc <- xmlParse(...); root <- xmlRoot(doc)`, the memory allocated to `doc` is just never released to the O/S (as monitored in Windows' Task Manager).
A crazy idea that we might try is to employ `system("Rscript ...")` to perform the XML pars... |
12,577,851 | Please help to resolve this error illegal string offset 'tittle'
here goes the jquery
```
data:{option:'catapply',sr:$(":input").serialize()},
```
and the catapply php data
```
if($_REQUEST['option']=='catapply'){
$sc = serialize($_POST['sr']);
mysql_query("insert into user_data(uid,mid,cid,scid,data) v... | 2012/09/25 | [
"https://Stackoverflow.com/questions/12577851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1393355/"
] | Try this
```
dtpTime.Format = DateTimePickerFormat.Custom
dtpTime.CustomFormat = "hh:mm tt"
``` | try this:
```
Private Sub mainform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label7.Text = DateTime.Now.ToString("MMM dd yyyy... |
12,577,851 | Please help to resolve this error illegal string offset 'tittle'
here goes the jquery
```
data:{option:'catapply',sr:$(":input").serialize()},
```
and the catapply php data
```
if($_REQUEST['option']=='catapply'){
$sc = serialize($_POST['sr']);
mysql_query("insert into user_data(uid,mid,cid,scid,data) v... | 2012/09/25 | [
"https://Stackoverflow.com/questions/12577851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1393355/"
] | Try this
```
dtpTime.Format = DateTimePickerFormat.Custom
dtpTime.CustomFormat = "hh:mm tt"
``` | Make sure that in Windows settings you also have set time format properly to display AM/PM. Time format in Windows should be also set to H:mm tt to display your result properly. |
12,577,851 | Please help to resolve this error illegal string offset 'tittle'
here goes the jquery
```
data:{option:'catapply',sr:$(":input").serialize()},
```
and the catapply php data
```
if($_REQUEST['option']=='catapply'){
$sc = serialize($_POST['sr']);
mysql_query("insert into user_data(uid,mid,cid,scid,data) v... | 2012/09/25 | [
"https://Stackoverflow.com/questions/12577851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1393355/"
] | Try this
```
dtpTime.Format = DateTimePickerFormat.Custom
dtpTime.CustomFormat = "hh:mm tt"
``` | I have the same issue. This for the "Why" :
Actually according to MS : <https://support2.microsoft.com/Default.aspx?scid=kb%3ben-us%3b889834&x=18&y=19>
Date picker don't use the current thread culture : it uses the user regional settings.
SO if you force the date picker custom format something containing "tt", and if t... |
12,577,851 | Please help to resolve this error illegal string offset 'tittle'
here goes the jquery
```
data:{option:'catapply',sr:$(":input").serialize()},
```
and the catapply php data
```
if($_REQUEST['option']=='catapply'){
$sc = serialize($_POST['sr']);
mysql_query("insert into user_data(uid,mid,cid,scid,data) v... | 2012/09/25 | [
"https://Stackoverflow.com/questions/12577851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1393355/"
] | I have the same issue. This for the "Why" :
Actually according to MS : <https://support2.microsoft.com/Default.aspx?scid=kb%3ben-us%3b889834&x=18&y=19>
Date picker don't use the current thread culture : it uses the user regional settings.
SO if you force the date picker custom format something containing "tt", and if t... | try this:
```
Private Sub mainform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label7.Text = DateTime.Now.ToString("MMM dd yyyy... |
12,577,851 | Please help to resolve this error illegal string offset 'tittle'
here goes the jquery
```
data:{option:'catapply',sr:$(":input").serialize()},
```
and the catapply php data
```
if($_REQUEST['option']=='catapply'){
$sc = serialize($_POST['sr']);
mysql_query("insert into user_data(uid,mid,cid,scid,data) v... | 2012/09/25 | [
"https://Stackoverflow.com/questions/12577851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1393355/"
] | I have the same issue. This for the "Why" :
Actually according to MS : <https://support2.microsoft.com/Default.aspx?scid=kb%3ben-us%3b889834&x=18&y=19>
Date picker don't use the current thread culture : it uses the user regional settings.
SO if you force the date picker custom format something containing "tt", and if t... | Make sure that in Windows settings you also have set time format properly to display AM/PM. Time format in Windows should be also set to H:mm tt to display your result properly. |
3,118,985 | Ive been learning MVC2 and MVVM lately and I think it works like this.
ASP.NET MVC2 - Can test the whole web site using unit tests
ASP.NET MVC2 + jquery web service calls - Can no longer just use MSTest unit test. What is the MS product to test the javascript side?
ASP.NET Webforms - Unit Tests are near impossible ... | 2010/06/25 | [
"https://Stackoverflow.com/questions/3118985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/193189/"
] | Rather than specifying the reasons why you should use MVC over Webforms, I'd take a step back and sell the management team on why you should use unit tests. After that's sold you have a case of saying that MVC would allow you to do this more efficiently than webforms.
Are you looking at going the full TDD route, or ju... | I don't know about other technologies, but I can talk about using Silverlight with MVVM pattern. Using MVVM pattern along with command pattern, we have been able to unit test all of our C# code. I mean barring xaml code, we have a very high code coverage for our C# code. We actually use a modified version of MVVM where... |
48,820,207 | I want to know that is there any way in the git by which we can pull a particular folder or a particular file from the git.
Thanks in advance. | 2018/02/16 | [
"https://Stackoverflow.com/questions/48820207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7305772/"
] | For now, you have to fetch everything, and:
* either do a [shallow clone](https://git-scm.com/docs/git-clone#git-clone---depthltdepthgt)
* or copy what you need from the cloned repo in another working folder.
But that won't always be the case.
A future 2.16.x/2.17 Q2 2018 Git will introduce what is called a partia... | If you want to update particular file to `origin` state do:
```
git fetch origin
git checkout origin/[yourbranch] -- [path_to_your_files]
``` |
18,992,790 | I have a piece of code like this:
```
public class UserCache
{
private Dictionary<int, User> _users = new Dictionary<int, User>();
public User GetUser(int id)
{
User u = null;
lock (_users)
{
if (_users.containsKey(id))
return _users[id];
}
... | 2013/09/24 | [
"https://Stackoverflow.com/questions/18992790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/336749/"
] | No, it's not thread-safe. Imagine it's called twice at the same time with the same ID, which isn't previously present.
Both threads would get as far as `RetrieveUser`, and they'd *both* call `_users.Add(id, u)`. The second call would fail because the key would already exist in the dictionary.
(As an aside, I'd strong... | It is threadsafe in the sense that it will not corrupt any data structures. It is not thread-safe in the sense that the entire method behaves atomically. Two threads might find the item to be missing, then create it then add it. One of the adders will fail. |
18,992,790 | I have a piece of code like this:
```
public class UserCache
{
private Dictionary<int, User> _users = new Dictionary<int, User>();
public User GetUser(int id)
{
User u = null;
lock (_users)
{
if (_users.containsKey(id))
return _users[id];
}
... | 2013/09/24 | [
"https://Stackoverflow.com/questions/18992790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/336749/"
] | No, it's not thread-safe. Imagine it's called twice at the same time with the same ID, which isn't previously present.
Both threads would get as far as `RetrieveUser`, and they'd *both* call `_users.Add(id, u)`. The second call would fail because the key would already exist in the dictionary.
(As an aside, I'd strong... | I think you must apply the singleton pattern to have a really thread safe code. In this moment you can have 2 instances of your class. |
18,992,790 | I have a piece of code like this:
```
public class UserCache
{
private Dictionary<int, User> _users = new Dictionary<int, User>();
public User GetUser(int id)
{
User u = null;
lock (_users)
{
if (_users.containsKey(id))
return _users[id];
}
... | 2013/09/24 | [
"https://Stackoverflow.com/questions/18992790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/336749/"
] | No, it's not thread-safe. Imagine it's called twice at the same time with the same ID, which isn't previously present.
Both threads would get as far as `RetrieveUser`, and they'd *both* call `_users.Add(id, u)`. The second call would fail because the key would already exist in the dictionary.
(As an aside, I'd strong... | Idon't think you have more choice here because the result of \_users.Add(id,u) depend on RetrieveUser you have to lock all method to make it thread safe. may be john skeet can confirm this
the solution may look like this
```
public class UserCache
{
private Dictionary<int, User> _users = new Dictionary<int, Use... |
18,992,790 | I have a piece of code like this:
```
public class UserCache
{
private Dictionary<int, User> _users = new Dictionary<int, User>();
public User GetUser(int id)
{
User u = null;
lock (_users)
{
if (_users.containsKey(id))
return _users[id];
}
... | 2013/09/24 | [
"https://Stackoverflow.com/questions/18992790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/336749/"
] | It is threadsafe in the sense that it will not corrupt any data structures. It is not thread-safe in the sense that the entire method behaves atomically. Two threads might find the item to be missing, then create it then add it. One of the adders will fail. | I think you must apply the singleton pattern to have a really thread safe code. In this moment you can have 2 instances of your class. |
18,992,790 | I have a piece of code like this:
```
public class UserCache
{
private Dictionary<int, User> _users = new Dictionary<int, User>();
public User GetUser(int id)
{
User u = null;
lock (_users)
{
if (_users.containsKey(id))
return _users[id];
}
... | 2013/09/24 | [
"https://Stackoverflow.com/questions/18992790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/336749/"
] | It is threadsafe in the sense that it will not corrupt any data structures. It is not thread-safe in the sense that the entire method behaves atomically. Two threads might find the item to be missing, then create it then add it. One of the adders will fail. | Idon't think you have more choice here because the result of \_users.Add(id,u) depend on RetrieveUser you have to lock all method to make it thread safe. may be john skeet can confirm this
the solution may look like this
```
public class UserCache
{
private Dictionary<int, User> _users = new Dictionary<int, Use... |
18,992,790 | I have a piece of code like this:
```
public class UserCache
{
private Dictionary<int, User> _users = new Dictionary<int, User>();
public User GetUser(int id)
{
User u = null;
lock (_users)
{
if (_users.containsKey(id))
return _users[id];
}
... | 2013/09/24 | [
"https://Stackoverflow.com/questions/18992790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/336749/"
] | Idon't think you have more choice here because the result of \_users.Add(id,u) depend on RetrieveUser you have to lock all method to make it thread safe. may be john skeet can confirm this
the solution may look like this
```
public class UserCache
{
private Dictionary<int, User> _users = new Dictionary<int, Use... | I think you must apply the singleton pattern to have a really thread safe code. In this moment you can have 2 instances of your class. |
31,579,781 | I'm pretty new to regex, but I did some study.
I got into a problem that might turn out impossible to be solved by regex, so I need a piece of advice.
I have the following string:
```
some text key 12, 32, 311 ,465 and 345. some other text dog 612,
12, 32, 9 and 10. some text key 1, 2.
```
I'm trying to figure if ... | 2015/07/23 | [
"https://Stackoverflow.com/questions/31579781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/577035/"
] | You can do it in `2` steps.
```
(?<=key\\s)\\d+(?:\\s*(?:,|and)\\s*\\d+)*
```
Grab all the numbers.See demo.
<https://regex101.com/r/uK9cD8/6>
Then `split` or `extract \\d+` from it.See demo.
<https://regex101.com/r/uK9cD8/7> | You can use a positive look behind which ensure that your sequence doesn't precede by any word except `key` :
```
(?<=key)\s(?:\d+[\s,]+)+(?:and )?\d+
```
Note that here you don't need to use a negative look behind for `dog` because this regex will just match if your sequence precede by `key`.
See demo <https://reg... |
31,579,781 | I'm pretty new to regex, but I did some study.
I got into a problem that might turn out impossible to be solved by regex, so I need a piece of advice.
I have the following string:
```
some text key 12, 32, 311 ,465 and 345. some other text dog 612,
12, 32, 9 and 10. some text key 1, 2.
```
I'm trying to figure if ... | 2015/07/23 | [
"https://Stackoverflow.com/questions/31579781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/577035/"
] | In Java, you can make use of a constrained width look-behind that accepts `{n,m}` limiting quantifier.
So, you can use
```
(?<=key(?:(?!dog)[^.]){0,100})[0-9]+
```
Or, if `key` and `dog` are whole words, use `\b` word boundary:
```
String pattern = "(?<=\\bkey\\b(?:(?!\\bdog\\b)[^.]){0,100})[0-9]+";
```
The only... | You can use a positive look behind which ensure that your sequence doesn't precede by any word except `key` :
```
(?<=key)\s(?:\d+[\s,]+)+(?:and )?\d+
```
Note that here you don't need to use a negative look behind for `dog` because this regex will just match if your sequence precede by `key`.
See demo <https://reg... |
31,579,781 | I'm pretty new to regex, but I did some study.
I got into a problem that might turn out impossible to be solved by regex, so I need a piece of advice.
I have the following string:
```
some text key 12, 32, 311 ,465 and 345. some other text dog 612,
12, 32, 9 and 10. some text key 1, 2.
```
I'm trying to figure if ... | 2015/07/23 | [
"https://Stackoverflow.com/questions/31579781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/577035/"
] | I wouldn't recommend using code that you can't understand and customize, but here is my one-pass solution, using [the method described in this answer of mine](https://stackoverflow.com/questions/15268504/collapse-and-capture-a-repeating-pattern-in-a-single-regex-expression/15418942#15418942). If you want to understand ... | You can use a positive look behind which ensure that your sequence doesn't precede by any word except `key` :
```
(?<=key)\s(?:\d+[\s,]+)+(?:and )?\d+
```
Note that here you don't need to use a negative look behind for `dog` because this regex will just match if your sequence precede by `key`.
See demo <https://reg... |
70,734,540 | Let say I have below code:
```
import pandas as pd
import numpy as np
import random
import string
data = ['DF1', 'DF2', 'DF2']
for i in data :
DF = pd.DataFrame([random.choices(string.ascii_lowercase,k=5), [10, 11, 12, 13, 14]]).T
DF.columns = ['col1', 'col2']
DF['i'] = i
```
So for each `i`, I have di... | 2022/01/16 | [
"https://Stackoverflow.com/questions/70734540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1867328/"
] | IIUC, try:
```
df1 = pd.DataFrame({'col1':[*'adrtg']
,'col2':[10,11,12,13,14]
,'data':['DF1']*5})
df2 = pd.DataFrame({'col1':[*'adspq']
,'col2':[10,11,12,13,14]
,'data':['DF2']*5})
df3 = pd.DataFrame({'col1':[*'dcxyz']
,'col... | you can use `merge` and actually you will be `cross join`ing the dataframes :
```
import pandas as pd
import random
import string
data = ['DF1', 'DF2', 'DF2']
df = pd.DataFrame([random.choices(string.ascii_lowercase,k=5), [10, 11, 12, 13, 14]], ).T
df.columns = ['col1', 'col2']
da = pd.DataFrame(data, columns=['data'... |
56,936,636 | I want to build an auto login bot or something. It has two parts:
1.login
2.verify login
The last line of the login part finds and clicks on a button(Log In).
When I run only the login part it works, but when I add verifying lines
it doesn't work and can't find the button to click.
Then I use Explicit Waits but it c... | 2019/07/08 | [
"https://Stackoverflow.com/questions/56936636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I think the issue comes from the fact that you defined your `replaceTransaction` method as generic, but you're not using `T` at all in that method, so type inference doesn't know what type to use in place of `T`.
To give you a simpler example, this will cause the same error:
```
fun <T> foo() {
println("Hello, wo... | Instead of using `t:Fragment`, change the type of `t` to `T`, not `Fragment`
Try to write your extension function this way:
```
fun <T : Fragment> FragmentTransaction.replaceTransaction(layout: Int, t:
T): FragmentTransaction {
return this.replace(layout, t)
}
``` |
9,488,891 | I'm making a WPF application making use of the MVVM light framework.
What I'm trying to do is have a login form in a view, when the user presses a button within that view it launches a LoginCommand for the attached ViewModel. From there I either want to launch a new window which holds the rest of the application, or s... | 2012/02/28 | [
"https://Stackoverflow.com/questions/9488891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1226583/"
] | Usually I do this one of two ways:
If the login window is a one-time thing required before starting the application, I will put it in the `OnStartup()` method of the `Application` object
```
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
// Login
var login = new LoginDialog();... | Put your views inside `Page` elements, inside your `MainWindow` create a Frame and point it's source to your first page.
From then on you can use the frame's `NavigationService` to navigate your frame to another view, much like a web browser. |
53,155,105 | I have a console program which sends async HTTP requests to an external web API. (`HttpClient.GetAsync());`)
These tasks can take several minutes to complete - during which I'd like to be able to show to the user that the app is still running - for example by sending `Console.WriteLine("I ain't dead - yet")` every 1... | 2018/11/05 | [
"https://Stackoverflow.com/questions/53155105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2892378/"
] | Let me tidy this code up a bit for you
```
async Task Main()
{
var reporter = new ConsoleProgress();
var result = await WeatherWaxProgressWrapper(() => GetAsync("foo"), reporter);
Console.WriteLine(result);
}
public async Task<int> GetAsync(string uri)
{
await Task.Delay(TimeSpan.FromSeconds(10));
... | You are looking for `System.Progress<T>`, a wonderful implementation of `IProgress`.
<https://learn.microsoft.com/en-us/dotnet/api/system.progress-1>
You create an object of this class on the "UI thread" or the main thread in your case, and it captures the `SynchronizationContext` for you. Pass it to your worker thre... |
53,155,105 | I have a console program which sends async HTTP requests to an external web API. (`HttpClient.GetAsync());`)
These tasks can take several minutes to complete - during which I'd like to be able to show to the user that the app is still running - for example by sending `Console.WriteLine("I ain't dead - yet")` every 1... | 2018/11/05 | [
"https://Stackoverflow.com/questions/53155105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2892378/"
] | Let me tidy this code up a bit for you
```
async Task Main()
{
var reporter = new ConsoleProgress();
var result = await WeatherWaxProgressWrapper(() => GetAsync("foo"), reporter);
Console.WriteLine(result);
}
public async Task<int> GetAsync(string uri)
{
await Task.Delay(TimeSpan.FromSeconds(10));
... | You could have a never-ending `Task` as a beacon that signals every 10 sec, and cancel it after the completion of the long running I/O operation:
```
var beaconCts = new CancellationTokenSource();
var beaconTask = Task.Run(async () =>
{
while (true)
{
await Task.Delay(TimeSpan.FromSeconds(10), beaconCt... |
53,155,105 | I have a console program which sends async HTTP requests to an external web API. (`HttpClient.GetAsync());`)
These tasks can take several minutes to complete - during which I'd like to be able to show to the user that the app is still running - for example by sending `Console.WriteLine("I ain't dead - yet")` every 1... | 2018/11/05 | [
"https://Stackoverflow.com/questions/53155105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2892378/"
] | You could have a never-ending `Task` as a beacon that signals every 10 sec, and cancel it after the completion of the long running I/O operation:
```
var beaconCts = new CancellationTokenSource();
var beaconTask = Task.Run(async () =>
{
while (true)
{
await Task.Delay(TimeSpan.FromSeconds(10), beaconCt... | You are looking for `System.Progress<T>`, a wonderful implementation of `IProgress`.
<https://learn.microsoft.com/en-us/dotnet/api/system.progress-1>
You create an object of this class on the "UI thread" or the main thread in your case, and it captures the `SynchronizationContext` for you. Pass it to your worker thre... |
61,189,365 | I have two lists in a list:
```
t = [['this','is','a','sentence'],['Hello','I','am','Daniel']]
```
I want to combine them in order to get two sentences:
```
'this is a sentence. Hello I am Daniel.'
```
I quickly came up with the following solution:
```
text = ''
for sent in t:
text = text + ' '.join(sent) + '.... | 2020/04/13 | [
"https://Stackoverflow.com/questions/61189365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12347331/"
] | You can shorten it to a single list comprehension, with another "." at the end:
```py
text = '. '.join(' '.join(sent) for sent in t) + '.'
``` | You could also use `list comprehensions`:
```
In [584]: ''.join([' '+ ' '.join(sent) + '. ' for sent in t])
Out[584]: ' this is a sentence. Hello I am Daniel. '
``` |
43,844,260 | Does Jenkins by default keeps all the builds and artifacts generated in each build. Or it deletes them after a certain period of time. I know I can configure the "Discard Old builds" option, but I want to know the Jenkins default behavior. | 2017/05/08 | [
"https://Stackoverflow.com/questions/43844260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2947158/"
] | Default is to keep all builds and artifacts. Might add that i don't know of any plugin which alters this default behavior. | Jenkins doesn't keep the artifacts. Jenkins only keeps the build history, means the log of the build and meta information like buildumber, time etc.
If you want that jenkins keeps your artifacts, you have to archive them.
You do this by using the archive step in your job config or by using the <https://jenkins.io/d... |
43,844,260 | Does Jenkins by default keeps all the builds and artifacts generated in each build. Or it deletes them after a certain period of time. I know I can configure the "Discard Old builds" option, but I want to know the Jenkins default behavior. | 2017/05/08 | [
"https://Stackoverflow.com/questions/43844260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2947158/"
] | Default is to keep all builds and artifacts. Might add that i don't know of any plugin which alters this default behavior. | As far I can determine with current Jenkins, default is:
* keep the build logs forever.
* assuming you have an "archive artifacts" post-build step, keep artifacts for one month.
* keep artifacts even if build failed or was aborted. |
43,844,260 | Does Jenkins by default keeps all the builds and artifacts generated in each build. Or it deletes them after a certain period of time. I know I can configure the "Discard Old builds" option, but I want to know the Jenkins default behavior. | 2017/05/08 | [
"https://Stackoverflow.com/questions/43844260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2947158/"
] | Jenkins doesn't keep the artifacts. Jenkins only keeps the build history, means the log of the build and meta information like buildumber, time etc.
If you want that jenkins keeps your artifacts, you have to archive them.
You do this by using the archive step in your job config or by using the <https://jenkins.io/d... | As far I can determine with current Jenkins, default is:
* keep the build logs forever.
* assuming you have an "archive artifacts" post-build step, keep artifacts for one month.
* keep artifacts even if build failed or was aborted. |
6,421,871 | I'm wondering if it would be possible to send an email from a lua script. I am using linux so I do have the `mail` command, but I can't work out how to use it.
Any help would be much appreciated. | 2011/06/21 | [
"https://Stackoverflow.com/questions/6421871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/363606/"
] | [LuaSocket](http://w3.impa.br/~diego/software/luasocket) offers support for sending email:
<http://w3.impa.br/~diego/software/luasocket/smtp.html> | You've probably already found a solution, but since this question still shows up in google, here's another answer that works on linux:
```
mail = io.popen("mail -s 'SUBJECT' user@example.com", "w")
mail:write("testing some stuff\n\4")
-- tested with lua 5.2 on ubuntu server
```
io.popen opens the mail program as a f... |
44,716,242 | For a school project I have been trying to make a very very simple encryptor, however I am struggling with the encryption part. Basically I would like to have the encryption be every other letter starting from the first at the beginning and every other character at the end.
So 123456 would return as 135246
I am havi... | 2017/06/23 | [
"https://Stackoverflow.com/questions/44716242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4796098/"
] | You could tweak your method a little as follows:
```
def encrypt(message):
return "%s%s" % (message[::2],message[1::2])
print(encrypt("123456")) # 135246
``` | Use `slicing` and `indexing`
```
msg = [1, 2, 3, 4, 5, 6]
In [30]: msg[::2] + msg[1::2]
Out[30]: [1, 3, 5, 2, 4, 6]
```
and for your function
```
def encrypt(message):
return "%s%s" % (message[::2],message[1::2])
print(encrypt("123456"))
``` |
44,716,242 | For a school project I have been trying to make a very very simple encryptor, however I am struggling with the encryption part. Basically I would like to have the encryption be every other letter starting from the first at the beginning and every other character at the end.
So 123456 would return as 135246
I am havi... | 2017/06/23 | [
"https://Stackoverflow.com/questions/44716242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4796098/"
] | use following code
```
def encrypt(message):
return "%s%s" % (message[::2],message[1::2])
``` | You could tweak your method a little as follows:
```
def encrypt(message):
return "%s%s" % (message[::2],message[1::2])
print(encrypt("123456")) # 135246
``` |
44,716,242 | For a school project I have been trying to make a very very simple encryptor, however I am struggling with the encryption part. Basically I would like to have the encryption be every other letter starting from the first at the beginning and every other character at the end.
So 123456 would return as 135246
I am havi... | 2017/06/23 | [
"https://Stackoverflow.com/questions/44716242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4796098/"
] | You could tweak your method a little as follows:
```
def encrypt(message):
return "%s%s" % (message[::2],message[1::2])
print(encrypt("123456")) # 135246
``` | When you use `message[::-1]` you are actually commanding to display all the values in reverse.
So expected output for `message[::-1]` will be **654321**
So use
```
(message[::2],message[1::2])
```
This should work like a charm. |
44,716,242 | For a school project I have been trying to make a very very simple encryptor, however I am struggling with the encryption part. Basically I would like to have the encryption be every other letter starting from the first at the beginning and every other character at the end.
So 123456 would return as 135246
I am havi... | 2017/06/23 | [
"https://Stackoverflow.com/questions/44716242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4796098/"
] | use following code
```
def encrypt(message):
return "%s%s" % (message[::2],message[1::2])
``` | Use `slicing` and `indexing`
```
msg = [1, 2, 3, 4, 5, 6]
In [30]: msg[::2] + msg[1::2]
Out[30]: [1, 3, 5, 2, 4, 6]
```
and for your function
```
def encrypt(message):
return "%s%s" % (message[::2],message[1::2])
print(encrypt("123456"))
``` |
44,716,242 | For a school project I have been trying to make a very very simple encryptor, however I am struggling with the encryption part. Basically I would like to have the encryption be every other letter starting from the first at the beginning and every other character at the end.
So 123456 would return as 135246
I am havi... | 2017/06/23 | [
"https://Stackoverflow.com/questions/44716242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4796098/"
] | use following code
```
def encrypt(message):
return "%s%s" % (message[::2],message[1::2])
``` | When you use `message[::-1]` you are actually commanding to display all the values in reverse.
So expected output for `message[::-1]` will be **654321**
So use
```
(message[::2],message[1::2])
```
This should work like a charm. |
58,714,978 | I've started using `FluentValidation` on a WPF project, till now I used it in a simple way checking if a field has been filled or less then n character.
Now I've to check if the value inserted (which is a string...damn old code) is greater then 0. Is there a simple way I can convert it using
```
RuleFor(x=>x.MyString... | 2019/11/05 | [
"https://Stackoverflow.com/questions/58714978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1278204/"
] | Just write a custom validator like this
```
public class Validator : AbstractValidator<Test>
{
public Validator()
{
RuleFor(x => x.MyString)
.Custom((x, context) =>
{
if ((!(int.TryParse(x, out int value)) || value < 0))
... | Another solution:
```
RuleFor(a => a.MyStringField).Must(x => int.TryParse(x, out var val) && val > 0)
.WithMessage("Invalid Number.");
``` |
58,714,978 | I've started using `FluentValidation` on a WPF project, till now I used it in a simple way checking if a field has been filled or less then n character.
Now I've to check if the value inserted (which is a string...damn old code) is greater then 0. Is there a simple way I can convert it using
```
RuleFor(x=>x.MyString... | 2019/11/05 | [
"https://Stackoverflow.com/questions/58714978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1278204/"
] | Just write a custom validator like this
```
public class Validator : AbstractValidator<Test>
{
public Validator()
{
RuleFor(x => x.MyString)
.Custom((x, context) =>
{
if ((!(int.TryParse(x, out int value)) || value < 0))
... | You can use **transformation**: <https://docs.fluentvalidation.net/en/latest/transform.html>
```
Transform(from: x => x.SomeStringProperty, to: value => int.TryParse(value, out int val) ? (int?) val : null)
.GreaterThan(0);
``` |
58,714,978 | I've started using `FluentValidation` on a WPF project, till now I used it in a simple way checking if a field has been filled or less then n character.
Now I've to check if the value inserted (which is a string...damn old code) is greater then 0. Is there a simple way I can convert it using
```
RuleFor(x=>x.MyString... | 2019/11/05 | [
"https://Stackoverflow.com/questions/58714978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1278204/"
] | Another solution:
```
RuleFor(a => a.MyStringField).Must(x => int.TryParse(x, out var val) && val > 0)
.WithMessage("Invalid Number.");
``` | You can use **transformation**: <https://docs.fluentvalidation.net/en/latest/transform.html>
```
Transform(from: x => x.SomeStringProperty, to: value => int.TryParse(value, out int val) ? (int?) val : null)
.GreaterThan(0);
``` |
41 | There is lots of evidence that I have seen showing **correlation** between human activities and climate change but what evidence is there to support **causation**? | 2011/02/25 | [
"https://skeptics.stackexchange.com/questions/41",
"https://skeptics.stackexchange.com",
"https://skeptics.stackexchange.com/users/25/"
] | The [IPCC report](http://www.ipcc.ch/publications_and_data/publications_ipcc_fourth_assessment_report_wg1_report_the_physical_science_basis.htm) gives the following probabilities:
>
> The total radiative forcing of the Earth’s climate
> due to increases in the concentrations of the LLGHGs
> CO2, CH4 and N2O, and ... | There is an overwhelming amount of evidence that, while humans didn't like CAUSE climate change, we are indeed accelerating it. A couple of excellent links of research to explain this are here:
[Is Current Warming Natural?](http://earthobservatory.nasa.gov/Features/GlobalWarming/page4.php)
[How do Human Activities Co... |
41 | There is lots of evidence that I have seen showing **correlation** between human activities and climate change but what evidence is there to support **causation**? | 2011/02/25 | [
"https://skeptics.stackexchange.com/questions/41",
"https://skeptics.stackexchange.com",
"https://skeptics.stackexchange.com/users/25/"
] | Humans affect the weather in mainly the following ways:
Direct emissions of various gasses
==================================
Typically CO2 is considered, but also other greenhouse gasses. The greenhouse effect of carbon dioxide was first measured in 1859.

... | There is an overwhelming amount of evidence that, while humans didn't like CAUSE climate change, we are indeed accelerating it. A couple of excellent links of research to explain this are here:
[Is Current Warming Natural?](http://earthobservatory.nasa.gov/Features/GlobalWarming/page4.php)
[How do Human Activities Co... |
41 | There is lots of evidence that I have seen showing **correlation** between human activities and climate change but what evidence is there to support **causation**? | 2011/02/25 | [
"https://skeptics.stackexchange.com/questions/41",
"https://skeptics.stackexchange.com",
"https://skeptics.stackexchange.com/users/25/"
] | **Trends in solar radiation don't match up with trends in temperature.** One of the arguments from skeptics of climate change is that rising global temperatures are a natural phenomenon caused by the Sun. However, most measures of total solar irradiance (also known as solar radiation, the electromagnetic energy inciden... | There is an overwhelming amount of evidence that, while humans didn't like CAUSE climate change, we are indeed accelerating it. A couple of excellent links of research to explain this are here:
[Is Current Warming Natural?](http://earthobservatory.nasa.gov/Features/GlobalWarming/page4.php)
[How do Human Activities Co... |
41 | There is lots of evidence that I have seen showing **correlation** between human activities and climate change but what evidence is there to support **causation**? | 2011/02/25 | [
"https://skeptics.stackexchange.com/questions/41",
"https://skeptics.stackexchange.com",
"https://skeptics.stackexchange.com/users/25/"
] | **Trends in solar radiation don't match up with trends in temperature.** One of the arguments from skeptics of climate change is that rising global temperatures are a natural phenomenon caused by the Sun. However, most measures of total solar irradiance (also known as solar radiation, the electromagnetic energy inciden... | Yes, humans contribute to climate change, but there is significant disagreement regarding to what degree humans contribute.
Climate change happens, and it has been happening for billions of years. That industrialized human existence is but an insignificant blip on the geological time scale undermines the ***frequentis... |
41 | There is lots of evidence that I have seen showing **correlation** between human activities and climate change but what evidence is there to support **causation**? | 2011/02/25 | [
"https://skeptics.stackexchange.com/questions/41",
"https://skeptics.stackexchange.com",
"https://skeptics.stackexchange.com/users/25/"
] | Yes, humans cause climate change (each doubling of CO2 causes about [1C increase](http://www.forbes.com/sites/warrenmeyer/2012/02/09/understanding-the-global-warming-debate/2/)). It's really a meaningless question. [Any input to any chaos system will cause some effect on that system](http://en.wikipedia.org/wiki/Chaos_... | I can’t answer the question directly.
However, there has been [at least one large-scale review](http://www.sciencemag.org/content/306/5702/1686.full) on the scientific consensus. And it can safely be said that the scientific consensus is **overwhelmingly** that the current trend in global warming is caused by mankind.... |
41 | There is lots of evidence that I have seen showing **correlation** between human activities and climate change but what evidence is there to support **causation**? | 2011/02/25 | [
"https://skeptics.stackexchange.com/questions/41",
"https://skeptics.stackexchange.com",
"https://skeptics.stackexchange.com/users/25/"
] | I can’t answer the question directly.
However, there has been [at least one large-scale review](http://www.sciencemag.org/content/306/5702/1686.full) on the scientific consensus. And it can safely be said that the scientific consensus is **overwhelmingly** that the current trend in global warming is caused by mankind.... | Yes, humans contribute to climate change, but there is significant disagreement regarding to what degree humans contribute.
Climate change happens, and it has been happening for billions of years. That industrialized human existence is but an insignificant blip on the geological time scale undermines the ***frequentis... |
41 | There is lots of evidence that I have seen showing **correlation** between human activities and climate change but what evidence is there to support **causation**? | 2011/02/25 | [
"https://skeptics.stackexchange.com/questions/41",
"https://skeptics.stackexchange.com",
"https://skeptics.stackexchange.com/users/25/"
] | Humans affect the weather in mainly the following ways:
Direct emissions of various gasses
==================================
Typically CO2 is considered, but also other greenhouse gasses. The greenhouse effect of carbon dioxide was first measured in 1859.

... | The [IPCC report](http://www.ipcc.ch/publications_and_data/publications_ipcc_fourth_assessment_report_wg1_report_the_physical_science_basis.htm) gives the following probabilities:
>
> The total radiative forcing of the Earth’s climate
> due to increases in the concentrations of the LLGHGs
> CO2, CH4 and N2O, and ... |
41 | There is lots of evidence that I have seen showing **correlation** between human activities and climate change but what evidence is there to support **causation**? | 2011/02/25 | [
"https://skeptics.stackexchange.com/questions/41",
"https://skeptics.stackexchange.com",
"https://skeptics.stackexchange.com/users/25/"
] | Yes, humans cause climate change (each doubling of CO2 causes about [1C increase](http://www.forbes.com/sites/warrenmeyer/2012/02/09/understanding-the-global-warming-debate/2/)). It's really a meaningless question. [Any input to any chaos system will cause some effect on that system](http://en.wikipedia.org/wiki/Chaos_... | Yes, humans contribute to climate change, but there is significant disagreement regarding to what degree humans contribute.
Climate change happens, and it has been happening for billions of years. That industrialized human existence is but an insignificant blip on the geological time scale undermines the ***frequentis... |
41 | There is lots of evidence that I have seen showing **correlation** between human activities and climate change but what evidence is there to support **causation**? | 2011/02/25 | [
"https://skeptics.stackexchange.com/questions/41",
"https://skeptics.stackexchange.com",
"https://skeptics.stackexchange.com/users/25/"
] | Yes, humans cause climate change (each doubling of CO2 causes about [1C increase](http://www.forbes.com/sites/warrenmeyer/2012/02/09/understanding-the-global-warming-debate/2/)). It's really a meaningless question. [Any input to any chaos system will cause some effect on that system](http://en.wikipedia.org/wiki/Chaos_... | The [IPCC report](http://www.ipcc.ch/publications_and_data/publications_ipcc_fourth_assessment_report_wg1_report_the_physical_science_basis.htm) gives the following probabilities:
>
> The total radiative forcing of the Earth’s climate
> due to increases in the concentrations of the LLGHGs
> CO2, CH4 and N2O, and ... |
41 | There is lots of evidence that I have seen showing **correlation** between human activities and climate change but what evidence is there to support **causation**? | 2011/02/25 | [
"https://skeptics.stackexchange.com/questions/41",
"https://skeptics.stackexchange.com",
"https://skeptics.stackexchange.com/users/25/"
] | Humans affect the weather in mainly the following ways:
Direct emissions of various gasses
==================================
Typically CO2 is considered, but also other greenhouse gasses. The greenhouse effect of carbon dioxide was first measured in 1859.

... | Yes, humans contribute to climate change, but there is significant disagreement regarding to what degree humans contribute.
Climate change happens, and it has been happening for billions of years. That industrialized human existence is but an insignificant blip on the geological time scale undermines the ***frequentis... |
199,197 | We have integrated our Salesforce and Marketing Cloud instances via the Marketing Cloud Connector. Our Marketing Cloud instance has 4 business units. We recently set up a synchronized data source between Salesforce and the Marketing Cloud at the parent business unit. However, we need to access the synchronized data ext... | 2017/11/16 | [
"https://salesforce.stackexchange.com/questions/199197",
"https://salesforce.stackexchange.com",
"https://salesforce.stackexchange.com/users/28171/"
] | In my experience, you can manage this through a combination of queries, date extensions, and automations to populate children business units (BUs).
1. Create as many regular Data Extensions (DEs) in the parent BU as you need to populate from the Synchronized Data Source (SDS) DEs.
2. Create your queries to push from ... | You can't access synchronised DEs in child BU, I recommend below steps:
1. In Shared Data Extension folder, create folder for each business unit, for example if you have two BUs: Home Service and Business Service, the folder structure looks like:
>
> Shared Data Extension
>
>
> * Home Service
> * Business Service
... |
57,740 | Sometimes I want a special font for the word "true", use it in mathmode as well as outside, and have a correct space afterwords if I am not in mathmode. Using
```
\newcommand{\tru}{\ifmmode {\text{\upshape \bfseries true}}%
\else {{\upshape \bfseries true}\@\xspace}\fi}%
```
xspace sometimes does not put a s... | 2012/05/29 | [
"https://tex.stackexchange.com/questions/57740",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/7635/"
] | `\xspace` looks ahead to the next token to see if it should add space or not, you have extra brace groups in your definition which will defeat that. The outer brace groups in both your true and false branch are not doing much, `{\text{\upshape \bfseries true}}` is more or less the same as `\text{\upshape \bfseries true... | In this particular case I don't see why doing all that work:
```
\newcommand{\tru}{\textbf{\textup{true}}\xspace}
```
will do exactly the same.
On the other hand, `\text` works both in math mode and in text mode. In text mode it will produce an `\mbox` which is probably what you want ("true" can't be hyphenated, bu... |
25,443 | This seems like a simple thing to do, but for some reason no one's been able to give me a clear answer at all. If I'm working with one stereo full mix track and one vocal track, how can I get the full mix to duck down when the voice over comes in? I haven't got any external hardware to work with -- just the base ProToo... | 2010/12/16 | [
"https://sound.stackexchange.com/questions/25443",
"https://sound.stackexchange.com",
"https://sound.stackexchange.com/users/-1/"
] | Set up a compressor on the stereo track (PT's own will do). Send the vocal track through a bus(mono) into the sidechain input of the compressor. Make sure to activate the sidechain, it's the knob with the key on it in the Sidechain section of the plugin.
Experiment with the knobs in order to get it to sound smooth.
... | * Create an empty project
* Import or create an audio track you want to duck (mono) (track A)
* Create an Aux track and assign its input to bus1 (track B)
* In track A send 0 dB to bus1 = track B
* Put Track B in mute (it only need for the compressor to "key")
* Create another Aux track and assign its input to bus2 (Tr... |
8,614,862 | Is it possible to select an element that is focused, like a:focus or input:focus, but on the other element, such as div, li, span or else?
If it's not possible, how can it be substituted with a tag?
I am trying to modify height of a li element when it's focused, tried with a, but the height won't change.
---
Reques... | 2011/12/23 | [
"https://Stackoverflow.com/questions/8614862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1113225/"
] | That's simple: just add a `tabindex` attribute to the elements which normally don't receive focus. | You can't focus list items. Not even using a script. I've tried doing `$("li:first").focus()` but it doesn't do anything. CSS doesn't get set as if it was focussed. This simply means that you either can't focus list items or that `:focus` pseudo classes don't work on list items.
Put anchors inside list items
---------... |
25,324,151 | Here's what brought this question up:
```
with open(path + "/OneChance1.mid") as f:
for line in f.readline():
print(line)
```
Here I am simply trying to read a midi file to scour its contents. I then receive this error message: `UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 153: c... | 2014/08/15 | [
"https://Stackoverflow.com/questions/25324151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2820306/"
] | MIDI files are **binary content**. By opening the file as a text file however, Python applies the default system encoding in trying to decode the text as Unicode.
Open the file in *binary mode* instead:
```
with open(midifile, 'rb') as mfile:
leader = mfile.read(4)
if leader != b'MThd':
raise ValueErr... | It's a binary file, it's not text using a text encoding like you seem to expect.
To open a file in binary mode in Python, pass a string containing `"b"` as the second argument to [`open()`](https://docs.python.org/2/library/functions.html#open).
[This page](http://www.sonicspot.com/guide/midifiles.html) contains a de... |
30,660,972 | serious problem here, I have an array like this:
```
[[0,50],[0,68],[1,26],[2,9],[2,32]]
```
The form I need is to split this array into two separated arrays like this:
```
array1 = [[0,50][1,0][2,9]]
array2 = [[0,68][1,26][2,32]]
```
Yeah you are right guys, I need that to build flot chart.
If anybody intereste... | 2015/06/05 | [
"https://Stackoverflow.com/questions/30660972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4842562/"
] | I created jsfiddle for you. Please tell, is it what you need?
<http://jsfiddle.net/1vdryy3L/1/>
```
// first, we'll get all possible keys ('key' is e.g. "-JpgJnANTpQFprRieImv")
var keys = [];
for (var i in data) {
for (var j in data[i]) {
if (keys.indexOf(j) == -1) {
keys.push(j);
} ... | Something like this should work provided that you are using jQuery. If you are not simply replace the jquery statements with standard js ones. (I have prepared a jsfiddle: [jsfiddle](http://jsfiddle.net/xcjrb5mz/1):
```
var first = []
var second = [];
var my_data = {
"1433203200000" : {
"-JpgJnANTpQFprRieImv" : ... |
37,696,505 | I am quite new to MATLAB matrix calculation and don't know how to improve the performance when I have many for-loops. I have tried to figure it out by looking through similar questions, but I still feel puzzled.
Here is my code:
```
pred = zeros(n_test,1) % vector saving all prediction results
for d = 1:n_test % n_... | 2016/06/08 | [
"https://Stackoverflow.com/questions/37696505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4129364/"
] | Performing broadcasted operations in parts using [`bsxfun`](http://www.mathworks.com/help/matlab/ref/bsxfun.html) and the efficient [`matrix-multiplication`](https://stackoverflow.com/questions/6058139/why-is-matlab-so-fast-in-matrix-multiplication), here's a fully vectorized approach -
```
p1 = bsxfun(@times,Pzu(:,us... | How about you write the associated matrix operations for this problem. Then you compute the probability of each location by using matrix operations directly not element wise operations. Matlab is much faster to use matrix operations as they use your CPU's vector instructions.
Relevant to your use case, bsxfun and pote... |
51,459,957 | ```
package main
import (
"fmt"
)
func printArray(x [3]int) {
fmt.Printf("%d", x[1]);
// cannot convert "%d" (type untyped string) to type int
// invalid operation: "%d" + v (mismatched types string and int)
// for _, v := range x {
// fmt.Printf("%d" + v);
// }
}
func main() {
a := ... | 2018/07/21 | [
"https://Stackoverflow.com/questions/51459957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9273148/"
] | I see your error now. You are trying to concatenate or add the string and the int, instead of passing the two arguments to the function.
```
for _, v := range x {
fmt.Printf("%d" + v); // The error is in this line
}
```
It should be:
```
func printArray(x [3]int) {
for _, v := range x {
fmt.Printf("%d... | My Answer is not particularly related to this Question, But I had similar error and the way I solved is updating here, may be some future users may found helpful!
**Got the same error for below Code: Here `itemID` is `int`**
```
strSQL := "SELECT item_desc,item_sel_price FROM item_master WHERE item_id=" + itemID)
`... |
27,377,306 | How can i create a menu effect like below,

Currently my application menu looks like this,

**HTML:**
```
<nav id="nav">
<ul id="navigation">
<li><a href="#" class="firs... | 2014/12/09 | [
"https://Stackoverflow.com/questions/27377306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1749403/"
] | A pseudo-element 'triangle' made using the border technique on the first `li` of any submenu would seem to be the answer.
```css
* {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
a {
color:white;
text-decoration: none;... | I don't know your entire code, but, it's something like this:
```
ul#navigation:before {
bottom: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(136, 183, 213, 0);
border-bottom-color: #c... |
4,993,035 | I have the following snippet for distinguishing between clicks and doubleclicks:
```
observeSingleAndDoubleClick: function (element, singleClickHandler, doubleClickHandler, timeout) {
var clicks;
$(element).observe('click', function (event) {
++clicks;
if (clicks === 1) {
var timeou... | 2011/02/14 | [
"https://Stackoverflow.com/questions/4993035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/468102/"
] | Don't only observe the click event but also the doubleclick event.
```
$(element).observe('click',singleClickHandler);
$(element).observe('dblclick',doubleClickHandler);
```
Here is a changed version after all the discussion:
```
var clicks;
observeSingleAndDoubleClick: function (element, singleClickHandler, d... | There's a `dblclick` event id on Prototype. Why don't you use it?
```
observeSingleAndDoubleClick: function (element, singleClickHandler, doubleClickHandler) {
$(element).observe('click', function (event) {
singleClickHandler.call(this, event);
}
$(element).observe('dblclick', function (event) {
double... |
4,993,035 | I have the following snippet for distinguishing between clicks and doubleclicks:
```
observeSingleAndDoubleClick: function (element, singleClickHandler, doubleClickHandler, timeout) {
var clicks;
$(element).observe('click', function (event) {
++clicks;
if (clicks === 1) {
var timeou... | 2011/02/14 | [
"https://Stackoverflow.com/questions/4993035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/468102/"
] | I know the OpenLayers project foes something similar. Look at line 210 in this file: [OpenLayers.Handler.Click sourcecode](http://trac.osgeo.org/openlayers/browser/trunk/openlayers/lib/OpenLayers/Handler/Click.js "See the sourcecode for OpenLayers.Handler.Click").
I don't know how to use this with the Prototype framew... | There's a `dblclick` event id on Prototype. Why don't you use it?
```
observeSingleAndDoubleClick: function (element, singleClickHandler, doubleClickHandler) {
$(element).observe('click', function (event) {
singleClickHandler.call(this, event);
}
$(element).observe('dblclick', function (event) {
double... |
41,412,360 | I am writing a code for Facebook where it takes the URL, ID, Password from a properties file but upon logging in I am hinted with a "Facebook wants to show notifications - Allow - Block" How do I make it so after login it (A.) Presses ESP or ALT+F4 and closes the popup or (B.) Finds the notification and closes it itsel... | 2016/12/31 | [
"https://Stackoverflow.com/questions/41412360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7327177/"
] | After further research I found my answer. It is a chrome notification so here is the required step to solve my problem.
```
ChromeOptions ops = new ChromeOptions();
ops.addArguments("--disable-notifications");
System.setProperty("webdriver.chrome.driver", "./lib/chromedriver");
driver ... | **Please Follow below steps :**
**Step 1:**
//Create a instance of ChromeOptions class
```
ChromeOptions options = new ChromeOptions();
```
**Step 2:**
//Add chrome switch to disable notification - "**--disable-notifications**"
```
options.addArguments("--disable-notifications");
```
**Step 3:**
//Set path... |
587,332 | Why is the `*` raised in the first example, unlike the second one?
```
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$ \operatorname{\text{$*$}hello} $
vs.
$ *\operatorname{hello} $
\end{document}
```
[](https://i.stack.imgur.com... | 2021/03/14 | [
"https://tex.stackexchange.com/questions/587332",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/19809/"
] | It's by design of `\operatorname`. In the documentation of `amsopn` we read:
>
> In operator names, it is sometimes desired to have text-mode
> punctuation characters such as \*-/:’. Because the body of an operator
> name is set in math mode, these few punctuation characters will not
> come out right (wrong symbol/an... | Since you say you are trying to work around the way `\operatorname` handles punctuation, you might have an XY problem. Defining a new command that typesets with the same font and spacing, but does not do that, might work for you:
```
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand\varopname[1]{... |
587,332 | Why is the `*` raised in the first example, unlike the second one?
```
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$ \operatorname{\text{$*$}hello} $
vs.
$ *\operatorname{hello} $
\end{document}
```
[](https://i.stack.imgur.com... | 2021/03/14 | [
"https://tex.stackexchange.com/questions/587332",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/19809/"
] | It's by design of `\operatorname`. In the documentation of `amsopn` we read:
>
> In operator names, it is sometimes desired to have text-mode
> punctuation characters such as \*-/:’. Because the body of an operator
> name is set in math mode, these few punctuation characters will not
> come out right (wrong symbol/an... | The operations for `\operatorname` and `\DeclareMathOperator` do `\newmcodes@`, which is defined as
```
% amsopn.sty, line 30:
\gdef\newmcodes@{\mathcode`\'39\mathcode`\*42\mathcode`\."613A%
\ifnum\mathcode`\-=45 \else
\mathchardef\std@minus\mathcode`\-\relax
\fi
\mathcode`\-45\mathcode`\/47\mathcode`\:"603A... |
587,332 | Why is the `*` raised in the first example, unlike the second one?
```
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$ \operatorname{\text{$*$}hello} $
vs.
$ *\operatorname{hello} $
\end{document}
```
[](https://i.stack.imgur.com... | 2021/03/14 | [
"https://tex.stackexchange.com/questions/587332",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/19809/"
] | The operations for `\operatorname` and `\DeclareMathOperator` do `\newmcodes@`, which is defined as
```
% amsopn.sty, line 30:
\gdef\newmcodes@{\mathcode`\'39\mathcode`\*42\mathcode`\."613A%
\ifnum\mathcode`\-=45 \else
\mathchardef\std@minus\mathcode`\-\relax
\fi
\mathcode`\-45\mathcode`\/47\mathcode`\:"603A... | Since you say you are trying to work around the way `\operatorname` handles punctuation, you might have an XY problem. Defining a new command that typesets with the same font and spacing, but does not do that, might work for you:
```
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand\varopname[1]{... |
14,727,627 | I have 2 project in my solution, a `web-service` project and a `win-forms` project. I want to cast returning data of web-service to win-forms data. I have class **Terminal** defined in both projects. In the win app I have written this cast:
```
static public implicit operator List<Terminal>(EService.Terminal[] svcTer... | 2013/02/06 | [
"https://Stackoverflow.com/questions/14727627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1471381/"
] | You can do:
```
eService.CheckTerminal(guid, ref cityName, ref portName).Select(x => (Terminal) x);
``` | MSDN says
>
> Either the type of the argument to be converted, or the type of the result of the conversion, but not both, must be the containing type.
>
>
>
So, for his to work you need to move your conversion operator declaration into the class you are converting to (or from), i.e. `List<Terminal>` or `EService.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.