text:
Q: How to stop fish shell from underlining path? The fish shell will underline a path given as an argument to a command such as ls.  Is there a way to change that behavior since I find it very ugly?
For example:

A: fish underlining valid path by defaul:
$ set | grep fish_color_valid_path
fish_color_valid_path --underline

You only need to reset it:
$ set fish_color_valid_path
$ ls /etc/fstab


text:
Q: Error when updating state with useState + TypeScript There is a state initialized with an array of objects:
interface Product {
  id: number;
  status: boolean;
  color: string;
  price: number;
}

const productList: Product[] = [
  {
    id: 1,
    status: true,
    color: 'yellow',
    price: 275
  },
  {
    id: 2,
    status: true,
    color: 'blue',
    price: 325
  }
];

const [products, setProducts] = useState<Product[]>(productList);

Only those products are displayed for which the property status == true.
I'm trying to delete a product, so I calculate the new state using the previous state:
const productsRender = products.map((product: Product): false | JSX.Element => {
  return(product.status &&
    <ProductWrapper>
      <Product key={product.id}>
        <Remove
          type='button'
          onClick={(): void =>
            //TypeScript error TS2345
            setProducts(prevProducts => [...prevProducts, product.status = false])
          }
        />
        <Color>color: {product.color}</Color>
        <Price>${product.price}</Price>
      </Product>
    </ProductWrapper>
  );
});

But I am getting an error:
Argument of type '(prevProducts: Product[]) => (boolean | Product)[]' is not assignable to parameter of type 'SetStateAction<Product[]>'.
  Type '(prevProducts: Product[]) => (boolean | Product)[]' is not assignable to type '(prevState: Product[]) => Product[]'.
    Type '(boolean | Product)[]' is not assignable to type 'Product[]'.
      Type 'boolean | Product' is not assignable to type 'Product'.
        Type 'boolean' is not assignable to type 'Product'.

I have tried not passing the function in setProducts:
setProducts([...products, product.status = false])

But I get TypeScript error TS2322:
Type 'boolean | Product' is not assignable to type 'Product'.
  Type 'boolean' is not assignable to type 'Product'.

It's not clear to me how to properly update the state.
I would be grateful for help.

A: When using ...products, you're referring to the previous products in the array and you're trying to append a product.status = false to the array, which is not a Product.
If you want to update the last value of the products array, you can do this.
const productsRender = products.map((product: Product): false | JSX.Element => {
   return(product.status &&
     <ProductWrapper>
       <Product key={product.id}>
         <Remove
           type='button'
           onClick={(): void => {
             let new_products = [...products];
             let atIndex = products.indexOf(product);
             new_products[atIndex].status = false;
             setProducts(new_products);

             // This might work - haven't tested
             //let atIndex = products.indexOf(product);
             //products[atIndex].status = false;
             //setProducts(products);
           }}
         />
         <Color>color: {product.color}</Color>
         <Price>${product.price}</Price>
       </Product>
     </ProductWrapper>
   );
});

There might be another way (much prettier).

redpajama_set_name: RedPajamaStackExchange


text:
Q: Mixed Models in SPSS and interpretation of Random Effects I am trying to run a mixed model using SPSS. The example I am using is taken from the book "Linear Mixed Models, a practical guide using statistical software" of West, Welch and Galecki.
The example I am using is the rat pup example, in which the dependent variable is birth weight of rat pups. The independent variables are sex, treatment that the mother got (control, low dose, high dose), the litter size, and the interaction between the sex and the treatment. The litter is a random effect, since there is correlation between pups born to the same mother.
My model in mathematical terms is:
$weight=\beta _{0}+\beta _{1}Treat1+\beta _{2}Treat2+\beta _{3}Sex1+\beta _{4}LitterSize+\beta _{5}Sex1\times Treat1+\beta _{6}Sex1\times Treat2+u+\varepsilon $
where $u:N(0,\sigma _{litter}^{2})$ and $\varepsilon : N(0,\sigma ^{2})$
I attach the main output and have two questions.

*

*How do I make interpretation of the random effect ? I got two numbers there: 0.0965 and 0.0328. I understand that 0.0328 is probably the estimate of the square root of $\sigma _{litter}^{2}$, but what does the second number tells me ? Which part of the model equation does it estimate ?

*In the book, after running this model, they tried another model in which $\sigma _{\varepsilon }^{2}$ is different for each level of treatment. They wrote that this can be done using R and SAS only and version 13 of SPSS doesn't support it. I am using version 25. Does anyone knows if it can be done now, and how ?
Thank you.

A: The research question is:

I want to check the relation of the fixed effects to the dependent variable, taking into account the fact that the design is clustered.

This is answered by the fixed effects estimates.

How do I make interpretation of the random effect

Generally there is no requirement to interpret the random effects - you are controlling for clustering / repeated measures by fitting random intercepts for litter. That said, there is obviously nothing wrong with understanding what the output means. 0.0965 is the estimate for the variance of the random intercept for litter (I am not familiar with SPSS, so it's possible this is the standard deviation, not the variance, so please check with the documentation). 0.0328 is the standard error of this estimate (which can be used, given some assumotions/caveats) to test the significance of the estimate (ie whether it is truly greater than zero). Assuming that they are variances, not standard deviations, then you can compute the intra-class correlation coefficient (ICC) as 0.096517 / (0.096517 + 0.163488) and this is a measure of the dependence (correlation) within the clusters, because observations within one cluster are more similar to (corrrelated with) other observations within the same cluster, compared to other clusters. If the estimates are standard deviations, then you will need to square them before making the calculation for the ICC.
Regarding the 2nd question, this is a software specific question, and is off-topic here. Do they show the R syntax for such a model ?


text:
Q: Custom URL routes I'm a newbie in Wordpress, so excuse me if I ask a noob question.
I want to redirect some of the URLs to a specific page (single-deal.php). Now, these set of URLs (regex provided for these URLS) does not exist on my server. So, currently my WP returns 404 error. However, I still want to load single-deal.php and let it decide.
My single-deal.php fires a GET request to an API, and my processing will follow thereafter.
For eg:- If I have an url (for eg) /properties/1/  and it's permalink is not available in my WP settings, I want it load single-deal.php page, and let my API decide the further processing.
Here's what I've tried reading on multiple other questions:-
add_action( 'init', 'wpse26388_rewrites_init' );
function wpse26388_rewrites_init(){
    add_rewrite_rule(
        'properties/([0-9]+)/?$',
        'single-deal.php?pagename=single-deal&property_id=$matches[1]',
        'top' );
}

add_filter( 'query_vars', 'wpse26388_query_vars' );
function wpse26388_query_vars( $query_vars ){
    $query_vars[] = 'property_id';
    return $query_vars;
}

A: All internal rewrite rules must point to index.php. This isn't a theme file, it's the main bootstrap file in the root of your WordPress install. So, your rule should look like:
add_action( 'init', 'wpse26388_rewrites_init' );
function wpse26388_rewrites_init(){
    add_rewrite_rule(
        'properties/([0-9]+)/?$',
        'index.php?pagename=single-deal&property_id=$matches[1]',
        'top'
    );
}

You can then assign the deal.php template to your single-deal page in the admin interface, or you can use the page_template filter if you want to apply conditional template loading, like for example only if your property_id query var is set.


text:
Q: How to suppress table in `aggr` function of `Vim` I am doing some descriptive analysis, and all what I want is the graphic from VIM::aggr. However, when I set sortVars = T or sortCombs = T, the plot command also shows a table:
ds <- structure(list(RC_1 = c(4, 5, 5, 7, 7, 6, 5, 5, 5, 5, 7, 5, 7,
7, 6, 5, 5, 5, 6, 5), RC_2 = c(NA, 7, 7, 6, 5, 3, 5, 5, 5, 3,
5, 6, 7, 6, 5, 4, 5, 5, 7, 5), RC_3 = c(7, 4, 4, 7, 5, 6, 7,
5, 5, 4, 5, 5, 7, 4, 5, 4, 5, 5, 6, 6), RC_4 = c(7, 7, 5, 7,
6, 5, 6, 5, 5, 5, 6, 5, 7, 7, 6, 5, 5, 5, 6, 6)), row.names = c(NA,
-20L), class = c("tbl_df", "tbl", "data.frame"))
mice_plot <- aggr(ds, plot = F)
plot(mice_plot,
     col = c('navyblue','yellow'),
          ylab = c("Proporção de Dados Faltantes","Padrão de dados Faltantes"),
     numbers = T,
     sortVars = T,
     sortCombs = T,
     gap = 2)

Output in Rmarkdown:

How can I omit the below table? (via R code or RMarkdown).

A: One option is to capture the output and direct to a temporary file
capture.output(plot(mice_plot,
     col = c('navyblue','yellow'),
           ylab = c("Proporção de Dados Faltantes","Padrão de dados Faltantes"),
      numbers = T,
      sortVars = T,
      sortCombs = T,
      gap = 2), file = tempfile())

-checking in markdown
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r first}
suppressMessages(library(VIM))
ds <- structure(list(RC_1 = c(4, 5, 5, 7, 7, 6, 5, 5, 5, 5, 7, 5, 7,
7, 6, 5, 5, 5, 6, 5), RC_2 = c(NA, 7, 7, 6, 5, 3, 5, 5, 5, 3,
5, 6, 7, 6, 5, 4, 5, 5, 7, 5), RC_3 = c(7, 4, 4, 7, 5, 6, 7,
5, 5, 4, 5, 5, 7, 4, 5, 4, 5, 5, 6, 6), RC_4 = c(7, 7, 5, 7,
6, 5, 6, 5, 5, 5, 6, 5, 7, 7, 6, 5, 5, 5, 6, 6)), row.names = c(NA, -20L), class = c("tbl_df", "tbl", "data.frame"))
mice_plot <- aggr(ds, plot = F)

```

```{r second, echo=FALSE}
capture.output(plot(mice_plot,
     col = c('navyblue','yellow'),
          ylab = c("Proporção de Dados Faltantes","Padrão de dados Faltantes"),
     numbers = T,
     sortVars = T,
     sortCombs = T,
     gap = 2), file = tempfile())
```

-output

The output is from the plot.aggr cat prints
getAnywhere('plot.aggr')
...
...
 if (sortVars) {
        if (!imputed)
            cat("\n Variables sorted by number of missings: \n")
        else if (!miss_imp)
            cat("\n Variables sorted by number of imputed missings: \n")
        else cat("\n Variables sorted by number of missings or imputed missings: \n")
        tmp <- data.frame(Variable = cn, Count = miss)
        print(tmp, row.names = FALSE)
    }
    invisible()
}


text:
Q: Python signal.signal is it preventing propagation? So I have this code (partially taken from python docs):
import signal

def handler(signum, frame):
    print 'Signal handler called with signal', signum

s = signal.signal(signal.SIGINT, handler)

some_fancy_code() # this code is using subprocess.Popen() to call another script

singal.signal(signal.SIGINT, s)

What I found right now is that if I do Ctrl+C in my program, it correctly enters that handler and prints. Now, what I thought is that after receiving Ctrl+C my handler will suppress default handler so for example my subprocess.Popen will not get the KeyboardInterrupt signal. But this is not the case.
But when we replace 'handler' with 'signal.SIG_IGN', this propagation never happens. Modified snippet:
import signal

s = signal.signal(signal.SIGINT, signal.SIG_IGN)

some_fancy_code() # this code is using subprocess.Popen() to call another script

singal.signal(signal.SIGINT, s)

Is this because SIG_IGN is some kind of 'magic' signal written in language itself? Or maybe there is a way to make similar suppression in my own handler?
After reading a bit of question on stack overflow I am bit confused. If someone could make clear for me why such difference in behaviour.

A: This is the specified POSIX behaviour of signals:
   A child created via fork(2) inherits a copy of its parent's signal dis‐
   positions.  During an execve(2), the dispositions  of  handled  signals
   are  reset to the default; the dispositions of ignored signals are left
   unchanged.

When you execute (fork/execve) your another script in the first case, the SIGINT handler is reset to the default handler in the another script (default behaviour is to terminate the process) - of course, the another script could install its own handler and change this behaviour.
However, in the second case, you've configured SIGINT to be ignored. This behaviour will be propagated to the another script, as indicated in the definition above. Again, the another script could change this behaviour by installing its own handler.
So this has nothing to do with Python directly. It is the expected behaviour of the underlying operating system's POSIX signal handling implementation.
PS. If you're wondering what fork() and execve() are, fork() creates a copy of the running process (a child) and execve() replaces the current process with another. This is the underlying mechanism used by subprocess.Popen() to run the 'another script': first make a copy of the current process and then replace it with the target process.


text:
Q: Laravel integrity constraint violation when saving many to many relationship When storing a new user and then syncing some many to many relationships I get an integrity constraint error as the ID of the newly created user seems to not be passed to the sync() method. Here is my store controller method:
$user = new User;
$user->name = Input::get('name');
$user->username = Input::get('username');
$user->email = Input::get('email');
$user->password = Input::get('password');
$user->save();

// See if roles are passed, if not assign the default role of "view_site"
$roles = Input::has('roles') ? Input::get('roles') : [3];
$user->roles()->sync($roles);

As you can see I call save() before trying to sync the related data so it should have an ID. Here is the error:

Integrity constraint violation: 1048 Column 'user_id' cannot be null
  (SQL: insert into users_roles (role_id, user_id) values (3, ))

If I run the sync method on an already existent user (User::find($id)->roles()->sync([1,2,3])) it works fine.
For reference, the relationships:
// User.php
public function roles()
{
    return $this->belongsToMany('Role', 'users_roles');
}
// Role.php
public function users()
{
    return $this->belongsToMany('User', 'users_roles');
}

Edit:
Query log prior to the sync(). Looks like the save() is not writing to the database...
Array
(
    [0] => Array
        (
            [query] => select * from `users` where `id` = ? limit 1
            [bindings] => Array
                (
                    [0] => 1
                )

            [time] => 0.63
        )

    [1] => Array
        (
            [query] => select `roles`.*, `users_roles`.`user_id` as `pivot_user_id`, `users_roles`.`role_id` as `pivot_role_id` from `roles` inner join `users_roles` on `roles`.`id` = `users_roles`.`role_id` where `users_roles`.`user_id` = ?
            [bindings] => Array
                (
                    [0] => 1
                )

            [time] => 0.58
        )

    [2] => Array
        (
            [query] => select count(*) as aggregate from `users` where `email` = ? or `username` = ?
            [bindings] => Array
                (
                    [0] => test@example.com
                    [1] => example
                )

            [time] => 0.48
        )

)

A: Since you are using confide, the validation is based on Ardent.
In your store method, add if statement
if($user->save());
    $roles = Input::has('roles') ? Input::get('roles') : [3];
    $user->roles()->sync($roles);
}else{
    return Redirect::back()->withErrors($user->errors());
}

If you don't need to check validation , you may use
$user->forceSave();


text:
Q: Internet Explorer 8 - JS Charts Company policy restricts to IE8, but jscharts does not appear to work in IE8, is there any way to fix this?

A: Alternate method for your jscharts webpage is to configure it to use Chrome Frame plugin for IE8.
<meta http-equiv="X-UA-Compatible" content="chrome=1">

This will allow your IE8 to run close to Google Chrome's browser, less IE8 limitations like CSS3.
However as Ahmad Alfy mentions in comments, it's suppose to work in IE8.


text:
Q: 'At the weekend' or 'At weekends' for regular occurence Which sentence is correct?

I go running at the weekend.
  I go running at weekends.

A: In American English you would say:

I go running on weekends.
Weekends I go running.

if you wanted to say that it is your practice to run every weekend; or

I am going running this weekend.

if you wanted to say that you have plans for this upcoming weekend.


text:
Q: I would like to add condition to change Image in this script or create new I want to change image by use val["id"] to define the condition:
if (val["id"] > 10) {
    //show the first image
} else if (val["id"] > 20) {
    //show the second image
} else {
    //show the third image
};

I don't understand some syntax of ajax can you help me to done with above condition
function getDataFromDb() {
    $.ajax({
            url: "getData.php",
            type: "POST",

        })
        .success(function(result) {
            var obj = jQuery.parseJSON(result);
            if (obj != '') {
                //$("#myTable tbody tr:not(:first-child)").remove();
                $("#myBody").empty();
                $.each(obj, function(key, val) {
                    var tr = "
";
                    tr = tr + "" + val["id"] + "	";
                    tr = tr + "" + val["first_name"] + "	";
                    tr = tr + "" + val["last_name"] + "	";
                    tr = tr + "" + val["age"] + "	";
                    tr = tr + "" + val["hometown"] + "	";
                    tr = tr + "" + val["job"] + "	";
                    tr = tr + "
";
                    $('#myTable > tbody:last').append(tr);
                });
            }

        });

}

setInterval(getDataFromDb, 100); // 1000 = 1 second

A: May be this can help.
function getDataFromDb() {
$.ajax({
        url: "getData.php",
        type: "POST",

    })
    .success(function(result) {
        var obj = jQuery.parseJSON(result);
        if (obj != '') {
            //$("#myTable tbody tr:not(:first-child)").remove();
            $("#myBody").empty();
            $.each(obj, function(key, val) {
                var tr = "
";
                tr = tr + "" + val["id"] + "	";
                tr = tr + "" + val["first_name"] + "	";
                tr = tr + "" + val["last_name"] + "	";
                tr = tr + "" + val["age"] + "	";
                tr = tr + "" + val["hometown"] + "	";
                tr = tr + "" + val["job"] + "	";
                tr = tr + "" + "" + "	";
                tr = tr + "
";
                $('#myTable > tbody:last').append(tr);
            });
        }

    });

}
function GetImage(id){
  if (val["id"] < 10) {
    return "images/img01.jpg"; // edit this to which works for you
   } else if (val["id"] < 20) {
    return "images/img02.jpg"
   } else {
    return "images/img03.jpg"
  };
}

setInterval(getDataFromDb, 100); // 1000 = 1 second

The function assumes that if the Id is less than 10 then show first if its less than 20 show second else 3rd. Your initial logic would show the first image if the id was 10+ that is to inifnity...

A: index.php
<!DOCTYPE html>

<title>TEST REAL TIME UPDATE</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<meta charset=utf-8 />

TEST AJAX CHANGE PICTURE

ID

First_Name

Last_Name

Age

Hometown

Job

getData.php
<?php
    $objConnect = mysql_connect("localhost","root","") or die(mysql_error());
    $objDB = mysql_select_db("ajax_demo");
    $strSQL = "SELECT * FROM my_db WHERE 1 ORDER BY id DESC limit 1 ";
    $objQuery = mysql_query($strSQL) or die (mysql_error());
    $intNumField = mysql_num_fields($objQuery);
    $resultArray = array();
    while($obResult = mysql_fetch_array($objQuery))
    {
        $arrCol = array();
        for($i=0;$i<$intNumField;$i++)
        {
            $arrCol[mysql_field_name($objQuery,$i)] = $obResult[$i];
        }
        array_push($resultArray,$arrCol);
    }

    mysql_close($objConnect);

    echo json_encode($resultArray);
?>


text:
Q: Firestore: How can I force data synchronization when coming back online I am building a flutter app with cloud firestore and I am using the offline capabilities.
When coming back online after I made changes offline, it seems like the changes take quite some time to synchronise (sometime up to a minute).
Is there any ways to force the synchronisation manually so that I can could trigger it myself when listening for the device to get back online?
Thanks a lot for your help!

A: The native SDKs for iOS, Android, and Web have API calls that allow you to explicitly manage connection state. While those are not explicitly made for your use-case, it'd be worth a try to see if disabling/re-enabling the network in short succession makes a difference.
Unfortunately those methods are currently not wrapped in the Firestore class of the FlutterFire library.
There is an open issue in the Github repo to track demand and progress on it. I just gave it an upvote.


text:
Q: Wicket - Create Request Manually I use Hibernate in wicket and i create a Hibernate Session at the beginning of each request. now i want to create a TimerTask and work with database but there is no open session in this thread and if I open session manually, it doesn't work because my entities work with the session that give form RequestCycle.get(). so is there any way to manually create a request and finalize it?
I try this
    final MockWebRequest request = new MockWebRequest(null);
    final NullResponse response = NullResponse.getInstance();
    RequestCycle rc = Application.get().createRequestCycle(request, response);
    //do jobs
    rc.detach()

but at line 3 it said that There is no application attached to current thread.


text:
Q: Even? function in Scheme (Dr. Racket) I'm trying to write a program in Scheme to compute the result of the power function using the fast power algorithm/recursion. The algorithm should be correct, but somewhere my syntax is off. The program compiles, but when I input a base and exp to test, Dr. Racket freezes up and runs out of memory. Having a difficult time locating online examples for how the (even?) function should appear in scheme code. I think this might be throwing my syntax off. New to scheme so any help would be much appreciated.
(define (powFun base exp)
    (if ( = exp 0)                       //base case
     1
       (even? exp                        //if exp is even
          (*
            (powFun base ( / exp 2))
            (powFun base ( / exp 2))
          )

       (*
          (powFun base (- exp 1) )      // else if exp is odd
           base
       )
     )
  )

)

A: You seem to be using even? as if it was some kind of macro that behaves like if. But even? is a regular function that takes one argument, so you should have written (even? exp) and not (even? exp evaluate-if-even evaluate-if-not-even). That means the return value of even? needs its own if expression:
(if base-case
   1
   (if (even? exp)
       evaluate-if-even
       evaluate-if-not-even))

...which means you should be using cond instead.
Or, you could define a macro that works the way you thought even? worked. Let's call it if-even:
(define-syntax if-even
    (syntax-rules ()
       ((_ n evaluate-if-even evaluate-if-not-even)
        (if (even? n) evaluate-if-even evaluate-if-not-even))))

Then replace even? in your original program with if-even. Correcting your use of even? and then switching to cond instead of if  is the better option, though.

A: even? is not similar to if - you use it to test whether one number is even.
It does not have "branches":
> (even? 2)
#t
> (even? 2 "even" "odd")
. . ..\..\Program Files (x86)\Racket\share\pkgs\drracket\drracket\private\rep.rkt:1088:24: even?: arity mismatch;
 the expected number of arguments does not match the given number
  expected: 1
  given: 3
  arguments...:
   2
   "even"
   "odd"

You can use it as a test in a conditional:
> (if (even? 2) "even" "odd")
"even"

If you want to test several conditions, it's convenient to use cond instead of if:
> (define x 3)
> (cond ((= x 1) "one")
         ((even? x) "even")
         (else "odd"))
"odd"

But that's not the reason for DrRacket "freezing".
The reason for that is that the division is not an integer division but actually produces an exact fractional result:
> (/ 1 2)
1/2
> (/ (/ 1 2) 2)
1/4
> (/ (/ (/ 1 2) 2) 2)
1/8

so you will never reach the terminating case.
You should use the quotient procedure:
> (quotient 3 2)
1
> (quotient 2 2)
1
> (quotient 1 2)
0

Making use of the sqr procedure and changing your brackets from "C style" to "Scheme style", it might look like this:
(define (powFun base exp)
    (if (= exp 0)
        1
       (if (even? exp)
           (sqr (powFun base (quotient exp 2)))
           (* (powFun base (- exp 1)) base))))

Or
(define (powFun base exp)
    (cond ((= exp 0) 1)
          ((even? exp) (sqr (powFun base (quotient exp 2))))
          (else (* (powFun base (- exp 1)) base))))

> (powFun 2 3)
8
> (powFun 2 0)
1
> (powFun 2 300)
2037035976334486086268445688409378161051468393665936250636140449354381299763336706183397376

Side note: the interaction window is extremely useful for testing small parts of code when you're looking for a problem.

A: if can only take max 2 clauses, then and else without keyword. In this situation, you can either use nested if or cond. Following is an example of cond:
(cond ((= expr 0) 1)
      ((even? exp) #| do even ... |#)
      (else #| do odd |#))


text:
Q: libpython2.7.so.1.0()(64bit) not found by yum So I'm trying to install Azure on CentOS with yum: link.
But it keeps telling me it needs libpython2.7.so.1.0:
[root@minnow02 Desktop]# yum install azure-cli
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirror.sfo12.us.leaseweb.net
 * extras: mirror.sfo12.us.leaseweb.net
 * updates: mirror.sfo12.us.leaseweb.net
Resolving Dependencies
--> Running transaction check
---> Package azure-cli.x86_64 0:2.0.28-1.el7 will be installed
--> Processing Dependency: libpython2.7.so.1.0()(64bit) for package: azure-cli-2.0.28-1.el7.x86_64
--> Finished Dependency Resolution
Error: Package: azure-cli-2.0.28-1.el7.x86_64 (azure-cli)
           Requires: libpython2.7.so.1.0()(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

But I have python 2.7:

[root@minnow02 Desktop]# python -V

 Python 2.7.5

[root@minnow02 Desktop]# find / -iname "pyth.so*"

/usr/lib/libpython2.7.so.1.0
/usr/lib/libpython2.7.so
/usr/lib/libpython2.7.so.1.0()(64bit)
/usr/local/python2.7/lib/libpython2.7.so.1.0
/usr/local/python2.7/lib/libpython2.7.so
/usr/local/python2.7/lib/libpython2.7.so.1.0()(64bit)

What's going on?

A: I have test it with Centos 6.8 and Centos 7.4, can't reproduce your error.
Please use this command to install Azure CLI:
# 1. Install a package with repository for your system:
# On CentOS, install package centos-release-scl available in CentOS repository:
$ sudo yum install centos-release-scl

# 2. Install the collection:
$ sudo yum install python27

# 3. Start using software collections:
$ scl enable python27 bash

# 4. Import the Microsoft repository key.
$ sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

# 5. Create local azure-cli repository information.
$ sudo sh -c 'echo -e "[azure-cli]\nname=Azure CLI\nbaseurl=https://packages.microsoft.com/yumrepos/azure-cli\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/azure-cli.repo'

# 6. Install with the yum install command.
$ sudo yum install azure-cli

Please try it.


text:
Q: URL adding www when loading site, and not https:// I am unable to get my WordPress website to initially load without www and with https:// instead of http://.
I set the WordPress permalinks to "Post name", so the url looks like "https://example.com/sample-post". I also changed the "WordPress Address (URL)" and "Site Address (URL)" to "https://example.com".
I added this to the wp-config.php:
define( 'FORCE_SSL_ADMIN', true );

Nothing works.
One thing I did that sort of worked was adding this to .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

And it will initially load my website as www.example.com, then 3 seconds later change it to https://example.com. This seems like a weird hack.
What am I missing? How do I have my website initially load normally with https://

A: Add this to your .htaccess file
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]


text:
Q: In my Singly linked List implementation why is it even though I allocated memory for the node to be freed, the pointer to the Node isn't NULL? Using the delete_SLL function I want to delete the head of this singly linked list(head = 4). Although I get the correct output, the var struct Node* "temp" holding the value of the head isn't NULL. What is it about the variable "temp" that the free function not like? Is the node temp not Malloc-ed when setting it equal to the list head?
Source:Deleting a Node
Code:
#include <stdio.h>
#include <stdlib.h>
struct Node{
  int item;
  struct Node* next;
};

struct List{
  struct Node* head;
  struct Node* tail;
};

int SLL_empty(struct List* lst){
  return lst->head == NULL ;
}

//newLst work
struct List newLst(){
  struct List  lst;
  lst.head = NULL;
  lst.tail = NULL;
  return lst;
}

//Inserts a node to the front of the list[WORKS]
void insert_SLL(struct List* lst, int x){
  struct Node* nde = (struct Node*)malloc(sizeof(struct Node));
  nde->next = lst->head;
  nde->item = x;
  if (SLL_empty(lst))
    lst->tail=nde;
  lst->head = nde;
}

//Deletes a given Node
void delete_SLL(struct List* lst, int x){
  struct Node* temp =  (struct Node*)malloc(sizeof(struct Node));;
  temp = lst->head;
  struct Node* prev = NULL;`enter code here`

  //If the head has the key
  if (temp != NULL && temp->item == x){
    lst->head = temp->next;
    temp->next = NULL;
    free(temp);
  }

  // stops once the key is found
  while(temp != NULL && temp->item != x){
    prev = temp;
    temp= temp->next;
  }

  //If not in list
  if (temp == NULL) return;

  //If middle
  if (temp != NULL && temp->item == x){
    prev->next = temp->next;
    temp->next = NULL;
  }

  //if at the end
  if (temp != NULL && temp->item == lst->tail->item){
    lst->tail= prev;
    prev->next = NULL;
  }
  free(temp);
}

int SLL_pop(struct List *list){
 struct Node* nde = list->head;
 int item = nde->item;
  list->head = nde->next;
  free(nde);
  if (SLL_empty(list))
    list->tail = NULL;
  return item;
}

int main(int argc, const char * argv[]) {
  int i;
  struct List list = newLst();
  for (i = 0; i < 5; ++i)
   insert_SLL(&list, i);
//  printf("The length of the linkedLst is: %d\n",SLL_length(&list));

  delete_SLL(&list, 4);
  while ( list.head != NULL )
    printf("Node: %d\n", SLL_pop(&list));

  return 0;
}

A: The main purpose of free() is to ask the OS take the allocated memory back to the system. You might not be able to "see" that but if you try to access any element at the "temp" afterward, you should get an error.

While the "temp" in the program is only a variable. C doesn't require to, and can't change the given pointer to NULL due to pass-by-value sense. It's the programmer's work to remember that this pointer is no longer valid.
Or you can set it to NULL manually each time you free a pointer.


text:
Q: Error finding msaccess driver on windows parallel on a mac I'm using pyodbc to acces a MSaccess database using python 2.7. I'm running windows 7 on parallels v10 on osx10.9. I'm using the following code to test it:
DBfile = 'c:\\dir\\testdb.db'
conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ='+DBfile)

and it cannot seem to locate the MSAccess driver, resulting in the following error:
> Traceback (most recent call last):   File "C:/Projects/DBtest.py",
> line 6, in <module>
>     conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ='+DBfile) Error: ('HY024', "[HY024] [Microsoft][ODBC
> Microsoft Access Driver] '(unknown)' is not a valid path.  Make sure
> that the path name is spelled correctly and that you are connected to
> the server on which the file resides. (-1023) (SQLDriverConnect);
> [01000] [Microsoft][ODBC Microsoft Access Driver]General Warning
> Unable to open registry key 'Temporary (volatile) Jet DSN for process
>  0x590 Thread 0xa50 DBC 0x2c9389c Jet'. (1); [01000] [Microsoft][ODBC
> Microsoft Access Driver]General Warning Unable to open registry key
> 'Temporary (volatile) Jet DSN for process 0x590 Thread 0xa50 DBC
> 0x2c9389c Jet'. (1); [HY024] [Microsoft][ODBC Microsoft Access Driver]
> '(unknown)' is not a valid path.  Make sure that the path name is
> spelled correctly and that you are connected to the server on which
> the file resides. (-1023)")

I can't see anything else on SO that covers this issue but I'm new to ODBC and fairly new to SO so apologies if I've overlooked anything. Does anyone have any ideas?
Cheers


text:
Q: Help simplifying a product I have this "product of products":
$$\prod_{k=1}^{x}\prod_{i=1}^{k}(x-f(i))$$
Is there any way to simplify it respect to $x$?
Thank you!

A: The factor $x-f(i)$ appears once for every $k\geq i$, so it equals
$$(x-f(1))^{x}(x-f(2))^{x-1}\cdots(x-f(x-1))^2\cdot(x-f(x))^1.$$
There is no way to simplify it further if $f$ is unknown. One could expand it and find explicit formulas for all terms, but that won't give a simpler expression. Compare with $a^3+3a^2b+3ab^2+b^3$ vs. $(a+b)^3$.


text:
Q: How did std::allocators allow to support near/far pointers? Several sources ([1],[2]) mention that the purpose of std::allocator was to allow for different pointer types (near/far/huge) on 16 bit platforms and parts of this original design still remain in the standard.
My questions are:

*

*How specifically did allocators work with different pointer types those days? For example, if near pointer is meaningless without a value in DS register, how could near pointer allocator be useful?

*Was there something in allocator requirements which was removed from standard, totally breaking support for segmented memory? If not, are the same facilities still used on modern 16 bit platforms, shall one exist which has a c++ compiler?
[1] https://www.youtube.com/watch?v=LIb3L4vKZ7U
[2] Josuttis, The C++ Standard Library: A Tutorial and Reference


text:
Q: Find matching records based on dynamic columns I have a list of pets:

And I need to find a correct owner for each of the pet from Owner table

In order to correctly match each pet to an owner I need to use a special matching table that looks like this:

So, for pet with PetID=2 I need to find an owner that has a matched based on three fields:
    Pet.Zip = Owner.Zip
    and Pet.OwnerName = Owner.Name
    and Pet.Document = Owner.Document

In our example, it will work like this:
 select top 1 OwnerID from owners
         where Zip = 23456
         and Name = 'Alex'
         and Document = 'a.csv'

if OwnerID is not found I then need to match based on 2 fields (Not using field with the highest priority)
In our example:
 select top 1 OwnerID from owners where
             Name = 'Alex'
             and Document = 'a.csv'

Since no record is found I we then need to match on less fields. In our example:
select top 1 OwnerID from owners where Document = 'a.csv'

Now, we found an owner with OwnerID = 6.
Now we need to update pet with ownerID = 6 and then we can process next pet.
The only way that I can do this right now involves a loop or a cursor + dynamic SQL.
Is it possible to achieve this without loops+dynamic sql? Maybe STUFF + Pivot somehow?
sql fiddle: http://sqlfiddle.com/#!18/10982/1/0
Sample data:
create table  temp_builder
(
    PetID int not null,
    Field varchar(30) not null,
    MatchTo varchar(30) not null,
    Priority int not null
)

insert into temp_builder values
(1,'Address', 'Addr',4),
(1,'Zip', 'Zip', 3),
(1,'Country', 'Country', 2),
(1,'OwnerName', 'Name',1),
(2,'Zip', 'Zip',3),
(2,'OwnerName','Name', 2),
(2,'Document', 'Document', 1),
(3,'Country', 'Country', 1)

create table temp_pets
(
    PetID int null,
    Address varchar(100) null,
    Zip int null,
    Country varchar(100) null,
    Document varchar(100) null,
    OwnerName varchar(100) null,
    OwnerID int null,
    Field1 bit null,
    Field2 bit null
)

insert into temp_pets values
(1, '123 5th st', 12345, 'US', 'test.csv', 'John', NULL, NULL, NULL),
(2, '234 6th st', 23456, 'US', 'a.csv', 'Alex', NULL, NULL, NULL),
(3, '345 7th st', 34567, 'US', 'b.csv', 'Mike', NULL, NULL, NULL)

create table temp_owners
(
    OwnerID int null,
    Addr varchar(100) null,
    Zip int null,
    Country varchar(100) null,
    Document varchar(100) null,
    Name varchar(100) null,
    OtherField bit null,
    OtherField2 bit null,
)

insert into temp_owners values
(1, '456 8th st',  45678, 'US', 'c.csv', 'Mike',  NULL, NULL),
(2, '678 9th st',  45678, 'US', 'b.csv', 'John',  NULL, NULL),
(3, '890 10th st', 45678, 'US', 'b.csv', 'Alex',  NULL, NULL),
(4, '901 11th st', 23456, 'US', 'b.csv', 'Alex',  NULL, NULL),
(5, '234 5th st',  12345, 'US', 'b.csv', 'John',  NULL, NULL),
(6, '123 5th st',  45678, 'US', 'a.csv', 'John',  NULL, NULL)

Edit: I'm overwhelmed by a number of great suggestions and responses. I've tested them and many worked well for me. Unfortunately, I can only award bounty to one solution.

A: The use of cursor, loops and dynamic SQL can be avoided by treating the fields used for comparison as an entry in a bit set for each pet. A bit set (FieldSetRank column) is calculated for each priority based on a bit entry (FieldRank rank column).
The Pets and Owner tables has to be unpivoted so that the fields and their associated values can be compared. Each of the fields and value that has been matched is assigned to a corresponding FieldRank. A new bit set is then calculated based on the matched values (MatchSetRank). Only records where the matched sets (MatchSetRank) are equal to the desired sets (FieldSetRank) are returned.
The query performs one final ranking to return records with the highest MatchSetRank (records that matched on the highest number of columns while maintaining priority criteria.
The following T-SQL demonstrates the concept.
;WITH CTE_Builder
 AS
 (
     SELECT  [PetID]
            ,[Field]
            ,[Priority]
            ,[MatchTo]
            ,POWER(2, [Priority] - 1) AS [FieldRank] -- Define the field ranking as bit set numbered item.
            ,SUM(POWER(2, [Priority] - 1)) OVER (PARTITION BY [PetID] ORDER BY [Priority] ROWS UNBOUNDED PRECEDING) FieldSetRank -- Sum all the bit set IDs to define what constitutes a completed field set ordered by priority.
     FROM   temp_builder
 ),
CTE_PetsUnpivoted
AS
(   -- Unpivot pets table and assign Field Rank and Field Set Rank.
    SELECT   [PetsUnPivot].[PetID]
            ,[PetsUnPivot].[Field]
            ,[Builder].[MatchTo]
            ,[PetsUnPivot].[FieldValue]
            ,[Builder].[Priority]
            ,[Builder].[FieldRank]
            ,[Builder].[FieldSetRank]

    FROM
       (
            SELECT [PetID], [Address], CAST([Zip] AS VARCHAR(100)) AS [Zip], [Country], [Document], [OwnerName]
            FROM temp_pets
        ) [Pets]
    UNPIVOT
       (FieldValue FOR Field IN
          ([Address], [Zip], [Country], [Document], [OwnerName])
    ) AS [PetsUnPivot]
    INNER JOIN [CTE_Builder] [Builder] ON [PetsUnPivot].PetID = [Builder].PetID AND [PetsUnPivot].Field = [Builder].Field
),
CTE_Owners
AS
(
    -- Unpivot Owners table and join with unpivoted Pets table on field name and field value.
    -- Next assign Pets field rank then calculated the field set rank (MatchSetRank) based on actual matches made.
    SELECT   [OwnersUnPivot].[OwnerID]
            ,[Pets].[PetID]
            ,[OwnersUnPivot].[Field]
            ,[Pets].Field AS [PetField]
            ,[Pets].FieldValue as PetFieldValue
            ,[OwnersUnPivot].[FieldValue]
            ,[Pets].[Priority]
            ,[Pets].[FieldRank]
            ,[Pets].[FieldSetRank]
            ,SUM([FieldRank]) OVER (PARTITION BY [Pets].[PetID], [OwnersUnPivot].[OwnerID] ORDER BY [Pets].[Priority] ROWS UNBOUNDED PRECEDING) MatchSetRank
    FROM
       (
            SELECT [OwnerID], [Addr], CAST([Zip] AS VARCHAR(100)) AS [Zip], [Country], [Document], [Name]
            FROM temp_owners
        ) [Owners]
    UNPIVOT
       (FieldValue FOR Field IN
          ([Addr], [Zip], [Country], [Document], [Name])
    ) AS [OwnersUnPivot]
    INNER JOIN [CTE_PetsUnpivoted] [Pets] ON [OwnersUnPivot].[Field] = [Pets].[MatchTo] AND [OwnersUnPivot].[FieldValue] = [Pets].[FieldValue]
),
CTE_FinalRanking
AS
(
    SELECT   [PetID]
            ,[OwnerID]
            -- -- Calculate final rank, if multiple matches have the same rank then multiple rows will be returned per pet.
            -- Change the "RANK()" function to "ROW_NUMBER()" to only return on result per pet.
            ,RANK() OVER (PARTITION BY [PetID] ORDER BY [MatchSetRank] DESC) AS [FinalRank]
    FROM    CTE_Owners
    WHERE   [FieldSetRank] = [MatchSetRank] -- Only return records where the field sets calculated based on
                                            -- actual matches is equal to desired field set ranks. This will
                                            -- eliminate matches where the number of fields that meets the
                                            -- criteria is the same but does not meet priority requirements.
)
SELECT   [PetID]
        ,[OwnerID]
FROM    CTE_FinalRanking
WHERE   [FinalRank] = 1

A: It's quite big task to accomplish... Here's how I have done it:
First, you need add a table, which will hold semi-where clauses, i.e. conditions ready-to-use based on temp_builder table. Also, since you have 5 columns, I assumed there can be at most 5 conditions. Here's creation of the table:
CREATE TABLE [dbo].[temp_builder_with_where](
    [petid] [int] NULL,
    [priority1] [bit] NULL,
    [priority2] [bit] NULL,
    [priority3] [bit] NULL,
    [priority4] [bit] NULL,
    [priority5] [bit] NULL,
    [whereClause] [varchar](200) NULL
)
--it's good to create index, for better performance
create clustered index idx on [temp_builder_with_where]([petid])

insert into temp_builder_with_where
select petid,[priority1],[priority2],[priority3],[priority4],[priority5],
         '[pets].' + CAST(field as varchar(100)) + ' = [owners].' + CAST(matchto as varchar(100)) [whereClause]
from (
select petid, field, matchto, [priority],
        1 Priority1,
        case when [priority] > 1 then 1 else 0 end Priority2,
        case when [priority] > 2 then 1 else 0 end Priority3,
        case when [priority] > 3 then 1 else 0 end Priority4,
        case when [priority] > 4 then 1 else 0 end Priority5
from temp_builder) [builder]

Now we are going to loop through that table. You told that this table contains 8000 rows, so I have chosen other way: dynamic query will now insert results only for one petid at once.
In order to do that we need table to store our results:
CREATE TABLE [dbo].[TableWithNewId](
    [petid] [int] NULL,
    [ownerid] [int] NULL,
    [priority] [int] NULL
)

Now dynamic SQL is used for insert statements:
declare @query varchar(1000) = ''
declare @i int, @max int
set @i = 1
select @max = MAX(petid) from temp_builder_with_where

while @i <= @max
begin

    set @query = ''

    select @query = @query + whereClause1 + whereClause2 + whereClause3 + whereClause4 + whereClause5 + ' union all ' from (
    select 'insert into [MY_DATABASE].dbo.TableWithNewId  select ' + CAST(petid as varchar(3)) + ' [petid], [owners].ownerid, 1 [priority] from temp_pets [pets], temp_owners [owners] where (' + [where_petid] + [where1] + ')' [whereClause1],
           case when [where2] is null then '' else ' union all select ' + CAST(petid as varchar(3)) + ' [petid], [owners].ownerid, 2 [priority] from temp_pets [pets], temp_owners [owners] where (' + [where_petid] + [where2] + ')' end [whereClause2],
           case when [where3] is null then '' else ' union all select ' + CAST(petid as varchar(3)) + ' [petid], [owners].ownerid, 3 [priority] from temp_pets [pets], temp_owners [owners] where (' + [where_petid] + [where3] + ')' end [whereClause3],
           case when [where4] is null then '' else ' union all select ' + CAST(petid as varchar(3)) + ' [petid], [owners].ownerid, 4 [priority] from temp_pets [pets], temp_owners [owners] where (' + [where_petid] + [where4] + ')' end [whereClause4],
           case when [where5] is null then '' else ' union all select ' + CAST(petid as varchar(3)) + ' [petid], [owners].ownerid, 5 [priority] from temp_pets [pets], temp_owners [owners] where (' + [where_petid] + [where5] + ')' end [whereClause5]
    from (
            select petid, 'petid = ' + CAST(petid as nvarchar(3)) [where_petid],
               (select ' and ' + whereClause from temp_builder_with_where where petid = t.petid and priority1 = 1 for xml path(''),type).value('(.)[1]', 'varchar(500)') [where1],
               (select ' and ' + whereClause from temp_builder_with_where where petid = t.petid and priority2 = 1 for xml path(''),type).value('(.)[1]', 'varchar(500)') [where2],
               (select ' and ' + whereClause from temp_builder_with_where where petid = t.petid and priority3 = 1 for xml path(''),type).value('(.)[1]', 'varchar(500)') [where3],
               (select ' and ' + whereClause from temp_builder_with_where where petid = t.petid and priority4 = 1 for xml path(''),type).value('(.)[1]', 'varchar(500)') [where4],
               (select ' and ' + whereClause from temp_builder_with_where where petid = t.petid and priority5 = 1 for xml path(''),type).value('(.)[1]', 'varchar(500)') [where5]
       from temp_builder_with_where [t]
       where petid = @i
        group by petid
    ) a
    ) a
    --remove last union all
    set @query = left(@query, len(@query) - 10)
    exec (@query)

    set @i = @i + 1

end

Keep in mind that you must to replace [MY_DATABASE] in above code with your database name
.
From your example data, this will be the result of query select * from TableWithNewId:
PetId|OwnerId|Priority
1    |6      |4
2    |4      |2
2    |4      |3
3    |1      |1
3    |2      |1
3    |3      |1
3    |4      |1
3    |5      |1
3    |6      |1

Based on that result, you can now assign OwnerId to PetId based on lowest priority (well, you didn't say how to handle situation where there's found more than one OwnerId for the same priority).

A: I will say right away to save your time:

*

*My solution uses dynamic SQL. Michał Turczyn correctly noted that you can't avoid it while names of compared column are stored in the DB.

*My solution uses loops. And I strongly believe that you will not solve this problem with the pure SQL query which will work fast enough on the data size you declared (tables have > 1M records). The logic you described implies iterations by its nature - from bigger set of matching fields to the lower set. SQL as a query language was not designed to cover such tricky scenarios. You could try to solve your problem with pure SQL query, but even if you manage to build such query, it will be very tricky, complex and unclear. I'm not a fan of such solutions. That's why I have not even dig into this direction.

*On the other hand my solution does not require creation of temporary tables which is an advantage.

Given this, my approach is fair straightforward:

*

*There is an outer loop that iterates from the biggest set of matchers (all matching fields) to the smallest set of matchers (one field). On the first iteration, when we don't know yet how many matchers are stored in the database for the pet, we read and use them all. On the next iterations, we decrease number of used matchers by 1 (removing the one with highest priority).

*The inner loop iterates over current set of matchers and builds the WHERE clause that compares fields between Pets and Owners table.

*Current query is executed and if some owner matches given criteria, we break from the outer loop.
Here is the code that implements this logic:
DECLARE @PetId INT = 2;

DECLARE @MatchersLimit INT;
DECLARE @OwnerID INT;

WHILE (@MatchersLimit IS NULL OR @MatchersLimit > 0) AND @OwnerID IS NULL
BEGIN

    DECLARE @CurrMatchFilter VARCHAR(max) = ''
    DECLARE @Field VARCHAR(30)
    DECLARE @MatchTo VARCHAR(30)
    DECLARE @CurrMatchersNumber INT = 0;

    DECLARE @GetMatchers CURSOR;
    IF @MatchersLimit IS NULL
        SET @GetMatchers = CURSOR FOR SELECT Field, MatchTo FROM temp_builder WHERE PetID = @PetId ORDER BY Priority ASC;
    ELSE
        SET @GetMatchers = CURSOR FOR SELECT TOP (@MatchersLimit) Field, MatchTo FROM temp_builder WHERE PetID = @PetId ORDER BY Priority ASC;

    OPEN @GetMatchers;
    FETCH NEXT FROM @GetMatchers INTO @Field, @MatchTo;
    WHILE @@FETCH_STATUS = 0
    BEGIN
        IF @CurrMatchFilter <> '' SET @CurrMatchFilter = @CurrMatchFilter + ' AND ';
        SET @CurrMatchFilter = @CurrMatchFilter + ('temp_pets.' + @Field + ' = ' + 'temp_owners.' + @MatchTo);
        FETCH NEXT FROM @GetMatchers INTO @field, @matchTo;
        SET @CurrMatchersNumber = @CurrMatchersNumber + 1;
    END
    CLOSE @GetMatchers;
    DEALLOCATE @GetMatchers;

    IF @CurrMatchersNumber = 0 BREAK;

    DECLARE @CurrQuery nvarchar(max) = N'SELECT @id = temp_owners.OwnerID FROM temp_owners INNER JOIN temp_pets ON (' + CAST(@CurrMatchFilter AS NVARCHAR(MAX)) + N') WHERE temp_pets.PetID = ' + CAST(@PetId AS NVARCHAR(MAX));
    EXECUTE sp_executesql @CurrQuery, N'@id int OUTPUT', @id=@OwnerID OUTPUT;

    IF @MatchersLimit IS NULL
        SET @MatchersLimit = @CurrMatchersNumber - 1;
    ELSE
        SET @MatchersLimit = @MatchersLimit - 1;

END

SELECT @OwnerID AS OwnerID, @MatchersLimit + 1 AS Matched;

Performance considerations
There are basically 2 queries that are executed in this approach:

*

*SELECT Field, MatchTo FROM temp_builder WHERE PetID = @PetId;
You should add an index on PetID field in temp_builder table and this query will be executed very fast.

*SELECT @id = temp_owners.OwnerID FROM temp_owners INNER JOIN temp_pets ON (temp_pets.Document = temp_owners.Document AND temp_pets.OwnerName = temp_owners.Name AND temp_pets.Zip = temp_owners.Zip AND ...) WHERE temp_pets.PetID = @PetId;
This query looks scary because it joins two big tables - temp_owners and temp_pets. However temp_pets table is filtered by PetID column that should result in just one record. So if you have an index on temp_pets.PetID column (and you should as this column seems like a primary key), the query will result into scan of temp_owners table. Such scan will not take the ages even for table with over 1M rows. If the query is still too slow, you could consider adding indexes for columns of temp_owners table that are used in the matchers (Addr, Zip, etc.). Adding indexes has downsides, like bigger database and slower insert/update operations. So before adding the indexes on temp_owners columns, check the query speed on table without indexes.

A: I'm not sure if I've got the end result correctly or not, But I suggest using a couple of common table expressions to generate a batch of update statements using dynamic SQL (I'm afraid it can't be done without dynamic SQL), and then execute them using Exec(sql).
The benefit of this approach is that it involves no loops or cursors.
Every update statement I generate is using an inner join between the pets and the owners tables, updating the pets table's owner id with the owners table owner id, using the mappings from the builder table as the basis to the on clause.
The first cte is responsible of generating the on clause from the builder table, and the second one is responsible to generate the update statements.
Finally, I'm selecting all the SQL statements from the second CTE into a single nvarchar(max) variable and execute it.
The way I've tackled the priority issue is to generate a single update statement for each group of priorities, starting with including all priorities, and excluding values from the next SQL statement, highest priority gets excluded first, until I'm left with an on clause mapping only a single set of columns.
So, the first thing is to declare a variable to hold the generated update statements:
DECLARE @Sql nvarchar(max) = ''

Now, the first CTE is using cross apply with stuff and for xml to generate the on clause for each pair of petId and Priority:
;WITH OnClauseCTE AS
(
SELECT DISTINCT PetId, Priority, OnClause
FROM temp_builder t0
CROSS APPLY
(
    SELECT STUFF (
    (
        SELECT ' AND p.'+ Field +' = o.'+ MatchTo
        FROM temp_builder t1
        WHERE PetID = t0.PetId
        AND Priority <= t0.Priority
        FOR XML PATH('')
    )
    , 1, 5, '') As OnClause
) onClauseGenerator
)

The second CTE generates a single UPDATE statement for every petId and Priority combination:
, UpdateStatementCTE AS
(
    SELECT  PetId,
            Priority,
            'UPDATE p
            SET OwnerID = o.OwnerID
            FROM temp_pets p
            INNER JOIN temp_owners o ON ' + OnClause + '
            WHERE p.PetId = '+ CAST(PetId as varchar(10)) +'
            AND p.OwnerID IS NULL; -- THIS IS CRITICAL!
            ' AS SQL
    FROM OnClauseCTE
)

And Finally, Generating a single batch of update statements from the UpdateStatementCTE:
SELECT @Sql = @Sql + SQL
FROM UpdateStatementCTE
ORDER BY PetId, Priority DESC -- ORDER BY Priority is CRITICAL!

The order by PetId is strictly to help the readability, when you print out the content of @Sql. However, the Priority DESC part of the order by clause is critical, since we want to execute the highest priority first and the lowest priority last.
Now, @Sql contains this (shortened):
UPDATE p
SET OwnerID = o.OwnerID
FROM temp_pets p
INNER JOIN temp_owners o ON p.Address = o.Addr AND p.Zip = o.Zip AND p.Country = o.Country AND p.OwnerName = o.Name
WHERE p.PetId = 1
AND p.OwnerID IS NULL;

...

UPDATE p
SET OwnerID = o.OwnerID
FROM temp_pets p
INNER JOIN temp_owners o ON p.OwnerName = o.Name
WHERE p.PetId = 1
AND p.OwnerID IS NULL;

...

UPDATE p
SET OwnerID = o.OwnerID
FROM temp_pets p
INNER JOIN temp_owners o ON p.OwnerName = o.Name AND p.Document = o.Document
WHERE p.PetId = 2
AND p.OwnerID IS NULL;

...

UPDATE p
SET OwnerID = o.OwnerID
FROM temp_pets p
INNER JOIN temp_owners o ON p.Country = o.Country
WHERE p.PetId = 3
AND p.OwnerID IS NULL;

As you can see, every update statement is represented in the builder table, and will only change the Owner Id if the previous update statement haven't already, because of the AND p.OwnerID IS NULL part of the where clause.
After running the batch of update statements, your temp_pets table looks like this:
PetID   Address         Zip     Country     Document    OwnerName   OwnerID     Field1  Field2
1       123 5th st      12345   US          test.csv    John        5           NULL    NULL
2       234 6th st      23456   US          a.csv       Alex        6           NULL    NULL
3       345 7th st      34567   US          b.csv       Mike        1           NULL    NUL

You can see a live demo on rextester.
However, please note that the less conditions you have the more records might return back from the join, making the update more likely to be inaccurate.
For instance, For PetId 3 I've got OwnerId 1 since the only thing I've had to match the records was the Country column, meaning it could actually be every OwnerId in this sample data, since everyone have the same value US in the Country column.
Under the following rules, there is not much I can do about that.

A: This is possible to do without dynamic sql or loops. The key point is that the
columns used to match the pets and owners are static. Only the priorities are dynamic. However, the performance depends largely on your data. You'll have to test that yourself and consider what you think is the best approach.
The solution below basically finds all owners that match any given pet. The owners are then filtered to only include the owners that match priority 1, or 1 & 2, or 1 & 2 & 3, etc. Finally the "best" of the matching owners is found, and the pet table is updated with this value.
I've added some explanatory comments to the query, but please feel free to ask if anything is unclear.
-- We start off by converting the priority values into int values that are suitable to add up to a bit array
-- I'll save those in a #Temp table to cut that piece of logic out of the final query
IF EXISTS(SELECT 1 FROM #TempBuilder)
BEGIN
    DROP TABLE #TempBuilder
END
SELECT
    PetID, Field, MatchTo,
    CASE [Priority]
    WHEN 1 THEN 16 -- Priority one goes on the 16-bit (10000)
    WHEN 2 THEN 8 -- Priority two goes on the 8-bit (01000)
    WHEN 3 THEN 4 -- Priority three goes on the 4-bit (00100)
    WHEN 4 THEN 2 -- Priority four goes on the 2-bit (00010)
    WHEN 5 THEN 1 END AS [Priority] -- Priority five goes on the 1-bit (00001)
INTO #TempBuilder
FROM dbo.temp_builder;

-- Then we pivot the match priorities to be able to join them on our pets
WITH PivotedMatchPriorities AS (
    SELECT
        PetId,
        [Address], [Zip], [Country], [OwnerName], [Document]
    FROM (SELECT PetId, Field, [Priority] FROM #TempBuilder) tb
        PIVOT
        (
            SUM([Priority])
            FOR [Field] IN ([Address], [Zip], [Country], [OwnerName], [Document])
        )
        AS PivotedMatchPriorities
),
-- Next we get (for each pet) all owners with ANY matching value
-- We want to filter the matching owners to find these that match priorities 1 (priority sum 10000, i.e. 16),
    --- or match priorities 1 & 2 (priority sum 11000, i.e. 24)
    --- or match priorities 1 & 2 & 3 (priority sum 11100, i.e. 28)
    --- etc.
MatchingOwners AS (
    SELECT o.*,
        p.PetID,
        pmp.[Address] AS AddressPrio,
        pmp.Country AS CountryPrio,
        pmp.Zip AS ZipPrio,
        pmp.OwnerName AS OwnerPrio,
        pmp.Document AS DocumentPrio,
        CASE WHEN o.Addr = p.[Address] THEN ISNULL(pmp.[Address],0) ELSE 0 END
        + CASE WHEN o.Zip = p.Zip THEN ISNULL(pmp.Zip,0) ELSE 0 END
        + CASE WHEN o.Country = p.Country THEN ISNULL(pmp.Country,0) ELSE 0 END
        + CASE WHEN o.Document = p.Document THEN ISNULL(pmp.[Document],0) ELSE 0 END
        + CASE WHEN o.[Name] = p.OwnerName THEN ISNULL(pmp.OwnerName,0) ELSE 0 END AS MatchValue -- Calculate a match value for each matching owner
    FROM dbo.temp_pets p
        INNER JOIN dbo.temp_owners o
            ON p.[Address] = o.Addr
            OR p.Country = o.Country
            OR p.Document = o.Document
            OR p.OwnerName = o.[Name]
            OR p.Zip = o.Zip
        INNER JOIN PivotedMatchPriorities pmp ON pmp.PetId = p.PetId
),
-- Now we can get all owners that match the pet, along with a match value for each owner.
-- We want to rank the matching owners for each pet to allow selecting the best ranked owner
-- Note: In the demo data there are multiple owners that match petId 3 equally well. We'll pick a random one in such cases.
RankedValidMatches AS (
    SELECT
        PetID,
        OwnerID,
        MatchValue,
        ROW_NUMBER() OVER (PARTITION BY PetID ORDER BY MatchValue DESC) AS OwnerRank
    FROM MatchingOwners
    WHERE MatchValue IN (16, 24, 28, 30, 31)
)
-- Finally we can get the best valid match per pet
--SELECT * FROM RankedValidMatches WHERE OwnerRank = 1
-- Or we can update our pet table to reflect our results
UPDATE dbo.temp_pets
SET OwnerID = rvm.OwnerID
FROM dbo.temp_pets tp
    INNER JOIN RankedValidMatches rvm ON rvm.PetID = tp.PetID AND rvm.OwnerRank = 1

A: The following approach is based on the fact that the number of different combinations to select and order the columns to match on, is limited and likely to be far less than the number of records.
With 5 columns, the total number of combinations is 325, but since it is unlikely that every possible combination is being used, the actual number will probably be less than 100.
Compared to the number of records (OP mentioned >1M), it pays off to try and combine pets that share the same combination of columns.
Characteristics of the SQL script below:

*

*No dynamic SQL.

*Loops, but no cursors; the number of iterations is limited and does not grow proportionally with the number of records.

*Creates two (indexed) helper tables. (Please feel free to make them temporary tables or table variables.) This greatly speeds up the matching process (INNER JOIN), but it does bring some overhead in having to populate the tables.

*Only straightforward SQL constructs (no pivots, no stuffed FOR XML, not even CTEs).

*Relies only on indexes on key columns (PetID, OwnerID), the Priority column, and the columns in the helper tables. Does not need indexes on address, zip, country, document, name.

At first sight the query seems like total overkill (47 SQL statements executed on the small amount of sample data proposed by OP), but for bigger tables the advantage should become apparent. Worst case time complexity should be O(n log n), which is a lot better than many an alternative.
But of course it still needs to prove itself in practice; I haven't tested it yet with large data sets.
Fiddle: http://sqlfiddle.com/#!18/53320/1
-- Adding indexes to OP's tables to optimize the queries that follow.
CREATE INDEX IX_PetID ON temp_builder (PetID)
CREATE INDEX IX_Priority ON temp_builder (Priority)
CREATE INDEX IX_PetID ON temp_pets (PetID)
CREATE INDEX IX_OwnerID ON temp_owners (OwnerID)

-- Helper table for pets. Each column has its own index.
CREATE TABLE PetKey (
    PetID int NOT NULL PRIMARY KEY CLUSTERED,
    KeyNames varchar(200) NOT NULL INDEX IX_KeyNames NONCLUSTERED,
    KeyValues varchar(900) NOT NULL INDEX IX_KeyValues NONCLUSTERED
)

-- Helper table for owners. Each column has its own index.
CREATE TABLE OwnerKey (
    OwnerID int NOT NULL PRIMARY KEY CLUSTERED,
    KeyValues varchar(900) NULL INDEX IX_KeyValues NONCLUSTERED
)

-- For every pet, create a record in table PetKey.
-- (Unless the pet already belongs to someone.)
INSERT INTO PetKey (PetID, KeyNames, KeyValues)
SELECT PetID, '', ''
FROM temp_pets
WHERE OwnerID IS NULL

-- For every owner, create a record in table OwnerKey.
INSERT INTO OwnerKey (OwnerID, KeyValues)
SELECT OwnerID, ''
FROM temp_owners

-- Populate columns KeyNames and KeyValues in table PetKey.
-- Lowest priority (i.e. highest number in column Priority) comes first.
-- We use CHAR(1) as a separator character; anything will do as long as it does not occur in any column values.
-- Example: when a pet has address as prio 1, zip as prio 2, then:
--    KeyNames = 'Zip' + CHAR(1) + 'Address' + CHAR(1)
--    KeyValues = '12345' + CHAR(1) + 'John' + CHAR(1)
-- NULL is replaced by CHAR(2); can be any value as long as it does not match any owner's value.
DECLARE @priority int = 1
WHILE EXISTS (SELECT * FROM temp_builder WHERE Priority = @priority)
BEGIN
    UPDATE pk
    SET KeyNames = b.Field + CHAR(1) + KeyNames,
        KeyValues = ISNULL(CASE b.Field
                               WHEN 'Address' THEN p.Address
                               WHEN 'Zip' THEN CAST(p.Zip AS varchar)
                               WHEN 'Country' THEN p.Country
                               WHEN 'Document' THEN p.Document
                               WHEN 'OwnerName' THEN p.OwnerName
                           END, CHAR(2)) +
                    CHAR(1) + KeyValues
    FROM PetKey pk
    INNER JOIN temp_pets p ON p.PetID = pk.PetID
    INNER JOIN temp_builder b ON b.PetID = pk.PetID
    WHERE b.Priority = @priority

    SET @priority = @priority + 1
END

-- Loop through all distinct key combinations.
DECLARE @maxKeyNames varchar(200), @namesToAdd varchar(200), @index int
SELECT @maxKeyNames = MAX(KeyNames) FROM PetKey
WHILE @maxKeyNames <> '' BEGIN
    -- Populate column KeyValues in table OwnerKey.
    -- The order of the values is determined by the column names listed in @maxKeyNames.
    UPDATE OwnerKey
    SET KeyValues = ''

    SET @namesToAdd = @maxKeyNames
    WHILE @namesToAdd <> '' BEGIN
        SET @index = CHARINDEX(CHAR(1), @namesToAdd)

        UPDATE ok
        SET KeyValues = KeyValues +
                        CASE LEFT(@namesToAdd, @index - 1)
                            WHEN 'Address' THEN o.Addr
                            WHEN 'Zip' THEN CAST(o.Zip AS varchar)
                            WHEN 'Country' THEN o.Country
                            WHEN 'Document' THEN o.Document
                            WHEN 'OwnerName' THEN o.Name
                        END +
                        CHAR(1)
        FROM OwnerKey ok
        INNER JOIN temp_owners o ON o.OwnerID = ok.OwnerID

        SET @namesToAdd = SUBSTRING(@namesToAdd, @index + 1, 200)
    END

    -- Match pets with owners, based on their KeyValues.
    UPDATE p
    SET OwnerID = (SELECT TOP 1 ok.OwnerID FROM OwnerKey ok WHERE ok.KeyValues = pk.KeyValues)
    FROM temp_pets p
    INNER JOIN PetKey pk ON pk.PetID = p.PetID
    WHERE pk.KeyNames = @maxKeyNames

    -- Pets that were successfully matched are removed from PetKey.
    DELETE FROM pk
    FROM PetKey pk
    INNER JOIN temp_pets p ON p.PetID = pk.PetID
    WHERE p.OwnerID IS NOT NULL

    -- For pets with no match, strip off the first (lowest priority) name and value.
    SET @namesToAdd = SUBSTRING(@maxKeyNames, CHARINDEX(CHAR(1), @maxKeyNames) + 1, 200)

    UPDATE pk
    SET KeyNames = @namesToAdd,
        KeyValues = SUBSTRING(KeyValues, CHARINDEX(CHAR(1), KeyValues) + 1, 900)
    FROM PetKey pk
    INNER JOIN temp_pets p ON p.PetID = pk.PetID
    WHERE pk.KeyNames = @maxKeyNames

    -- Next key combination.
    SELECT @maxKeyNames = MAX(KeyNames) FROM PetKey
END

A: I have written another version using UNPIVOT, but ranking rows and filtering them in a simpler way
;with
-- r: rules table
r as (select * from temp_builder),
-- o0: owners table with all fields unpivotable (varchar)
o0 as (SELECT [OwnerID], [Addr], CAST([Zip] AS VARCHAR(100)) AS [Zip], [Country], [Document], [Name] FROM temp_owners ),
-- o: owners table unpivoted
o as (
    SELECT * FROM o0
    UNPIVOT (FieldValue FOR Field IN ([Addr], [Zip], [Country], [Document], [Name])) AS p
),
-- p0: pets table with all fields unpivotable (varchar)
p0 as (SELECT [PetID], [Address], CAST([Zip] AS VARCHAR(100)) AS [Zip], [Country], [Document], [OwnerName] FROM temp_pets),
-- p: petstable unpivoted
p as (
    SELECT * FROM p0
    UNPIVOT (FieldValue FOR Field IN ([Address], [Zip], [Country], [Document], [OwnerName])) AS p
),
-- t: join up all data and keep only matching priority
d as (
    select petid, ownerid, priority
    from (
        select r.*, o.ownerid, ROW_NUMBER() over (partition by r.petid, o.ownerid order by r.petid, o.ownerid, priority) calc_priority
        from r
        join p on (r.field = p.field) and (p.petid = r.petid)
        join o on (r.matchto = o.field) and (p.fieldvalue=o.fieldvalue)
    ) x
    where calc_priority=priority
),
-- g: group by the matching rows to know the best priority reached for each pet
g as (
    select petid, max(priority) max_priority
    from d
    group by petid
)
-- output only the rows with best priority
select d.*
from d
join g on d.petid = g.petid and d.priority = g.max_priority
order by petid, ownerid, priority

This version is not more performant than @EdmondQuinton one, (I voted for him), mine is 5% slower but i think it is more simple to understand and maintain for non pro users.

A: I would take a slightly different approach, rather than store the columns to match, you could store the query to be executed:
create table builder
(
    PetID int not null,
    Query varchar(max)
)

INSERT INTO builder
VALUES (1, 'SELECT TOP 1 *
FROM pets
INNER JOIN Owners
    ON Owners.Name = pets.OwnerName
WHERE petId = 1
ORDER BY
    CASE WHEN Owners.Country = pets.Country THEN 0 ELSE 1 END,
    CASE WHEN Owners.Zip = pets.Zip THEN 0 ELSE 1 END,
    CASE WHEN Owners.Addr = pets.Address THEN 0 ELSE 1 END'),
(2, 'SELECT TOP 1 *
FROM pets
INNER JOIN Owners
    ON Owners.Name = pets.OwnerName
WHERE petId = 2
ORDER BY
    CASE WHEN Owners.Document = pets.Document THEN 0 ELSE 1 END,
    CASE WHEN Owners.Name = pets.OwnerName THEN 0 ELSE 1 END,
    CASE WHEN Owners.Zip = pets.Zip THEN 0 ELSE 1 END'),
(3, 'SELECT TOP 1 *
FROM pets
INNER JOIN Owners
    ON Owners.Name = pets.OwnerName
WHERE petId = 3
ORDER BY
    CASE WHEN Owners.Country = pets.Country THEN 0 ELSE 1 END
')

create table pets
(
    PetID int null,
    Address varchar(100) null,
    Zip int null,
    Country varchar(100) null,
    Document varchar(100) null,
    OwnerName varchar(100) null,
    OwnerID int null,
    Field1 bit null,
    Field2 bit null
)

insert into pets values
(1, '123 5th st', 12345, 'US', 'test.csv', 'John', NULL, NULL, NULL),
(2, '234 6th st', 23456, 'US', 'a.csv', 'Alex', NULL, NULL, NULL),
(3, '345 7th st', 34567, 'US', 'b.csv', 'Mike', NULL, NULL, NULL)

create table owners
(
    OwnerID int null,
    Addr varchar(100) null,
    Zip int null,
    Country varchar(100) null,
    Document varchar(100) null,
    Name varchar(100) null,
    OtherField bit null,
    OtherField2 bit null,
)

insert into owners values
(1, '456 8th st',  45678, 'US', 'c.csv', 'Mike',  NULL, NULL),
(2, '678 9th st',  45678, 'US', 'b.csv', 'John',  NULL, NULL),
(3, '890 10th st', 45678, 'US', 'b.csv', 'Alex',  NULL, NULL),
(4, '901 11th st', 23456, 'US', 'b.csv', 'Alex',  NULL, NULL),
(5, '234 5th st',  12345, 'US', 'b.csv', 'John',  NULL, NULL),
(6, '123 5th st',  45678, 'US', 'a.csv', 'John',  NULL, NULL)

Now to find the matching owner for a particular pet you just find the query out of the table and execute it:
DECLARE @query varchar(max)
SELECT TOP 1 @query = query
FROM builder
WHERE petId =1

EXEC (@query)

A: This is an answer that strictly solves your problem considering this

*

*Following the rules you proposed no loops, no cursors, no dynamic sql

*And also considering strictly your problem so this is not a general solution it is very specific for your problem and the columns you have
TestData
declare @Pets table
(
    PetID int null,
    Address varchar(100) null,
    Zip int null,
    Country varchar(100) null,
    Document varchar(100) null,
    OwnerName varchar(100) null,
    OwnerID int null,
    Field1 bit null,
    Field2 bit null
)

insert into @Pets values
(1, '123 5th st', 12345, 'US', 'test.csv', 'John', NULL, NULL, NULL),
(2, '234 6th st', 23456, 'US', 'a.csv', 'Alex', NULL, NULL, NULL),
(3, '345 7th st', 34567, 'US', 'b.csv', 'Mike', NULL, NULL, NULL)

declare @owners table
(
    OwnerID int null,
    Addr varchar(100) null,
    Zip int null,
    Country varchar(100) null,
    Document varchar(100) null,
    Name varchar(100) null,
    OtherField bit null,
    OtherField2 bit null
)

insert into @owners values
(1, '456 8th st',  45678, 'US', 'c.csv', 'Mike',  NULL, NULL),
(2, '678 9th st',  45678, 'US', 'b.csv', 'John',  NULL, NULL),
(3, '890 10th st', 45678, 'US', 'b.csv', 'Alex',  NULL, NULL),
(4, '901 11th st', 23456, 'US', 'b.csv', 'Alex',  NULL, NULL),
(5, '234 5th st',  12345, 'US', 'b.csv', 'John',  NULL, NULL),
(6, '123 5th st',  45678, 'US', 'a.csv', 'John',  NULL, NULL)

declare @builder table
(
    PetID int not null,
    Field varchar(30) not null,
    MatchTo varchar(30) not null,
    Priority int not null
)

insert into @builder values
(1,'Address', 'Addr',4),
(1,'Zip', 'Zip', 3),
(1,'Country', 'Country', 2),
(1,'OwnerName', 'Name',1),
(2,'Zip', 'Zip',3),
(2,'OwnerName','Name', 2),
(2,'Document', 'Document', 1),
(3,'Country', 'Country', 1)

Code that solves the problem
select distinct p.PetID, min(o.OwnerID) as ownerID from @pets p
inner join @builder b on p.PetID = b.PetID
inner join @owners o on
(
   (case when b.Field = 'Address' and b.Priority = 1 then p.Address else '0' end) = (case when b.MatchTo = 'Addr' and b.Priority = 1 then o.Addr else '-1' end)
or (case when b.Field = 'Zip' and b.Priority = 1 then p.Zip else '0' end) = (case when b.MatchTo = 'Zip' and b.Priority = 1 then o.Zip else '-1' end)
or (case when b.Field = 'Country' and b.Priority = 1 then p.Country else '0' end) = (case when b.MatchTo = 'Country' and b.Priority = 1 then o.Country else '-1' end)
or (case when b.Field = 'OwnerName' and b.Priority = 1 then p.OwnerName else '0' end) = (case when b.MatchTo = 'Name' and b.Priority = 1 then o.Name else '-1' end)
or (case when b.Field = 'Document' and b.Priority = 1 then p.Document else '0' end) = (case when b.MatchTo = 'Document' and b.Priority = 1 then o.Document else '-1' end)
)
AND
(
   (case when b.Field = 'Address' and b.Priority = 2 then p.Address else '0' end) = (case when b.MatchTo = 'Addr' and b.Priority = 2 then o.Addr else '-1' end)
or (case when b.Field = 'Zip' and b.Priority = 2 then p.Zip else '0' end) = (case when b.MatchTo = 'Zip' and b.Priority = 2 then o.Zip else '-1' end)
or (case when b.Field = 'Country' and b.Priority = 2 then p.Country else '0' end) = (case when b.MatchTo = 'Country' and b.Priority = 2 then o.Country else '-1' end)
or (case when b.Field = 'OwnerName' and b.Priority = 2 then p.OwnerName else '0' end) = (case when b.MatchTo = 'Name' and b.Priority = 2 then o.Name else '-1' end)
or (case when b.Field = 'Document' and b.Priority = 2 then p.Document else '0' end) = (case when b.MatchTo = 'Document' and b.Priority = 2 then o.Document else '-1' end)
)
AND
(
   (case when b.Field = 'Address' and b.Priority = 3 then p.Address else '0' end) = (case when b.MatchTo = 'Addr' and b.Priority = 3 then o.Addr else '-1' end)
or (case when b.Field = 'Zip' and b.Priority = 3 then p.Zip else '0' end) = (case when b.MatchTo = 'Zip' and b.Priority = 3 then o.Zip else '-1' end)
or (case when b.Field = 'Country' and b.Priority = 3 then p.Country else '0' end) = (case when b.MatchTo = 'Country' and b.Priority = 3 then o.Country else '-1' end)
or (case when b.Field = 'OwnerName' and b.Priority = 3 then p.OwnerName else '0' end) = (case when b.MatchTo = 'Name' and b.Priority = 3 then o.Name else '-1' end)
or (case when b.Field = 'Document' and b.Priority = 3 then p.Document else '0' end) = (case when b.MatchTo = 'Document' and b.Priority = 3 then o.Document else '-1' end)
)
AND
(
   (case when b.Field = 'Address' and b.Priority = 4 then p.Address else '0' end) = (case when b.MatchTo = 'Addr' and b.Priority = 4 then o.Addr else '-1' end)
or (case when b.Field = 'Zip' and b.Priority = 4 then p.Zip else '0' end) = (case when b.MatchTo = 'Zip' and b.Priority = 4 then o.Zip else '-1' end)
or (case when b.Field = 'Country' and b.Priority = 4 then p.Country else '0' end) = (case when b.MatchTo = 'Country' and b.Priority = 4 then o.Country else '-1' end)
or (case when b.Field = 'OwnerName' and b.Priority = 4 then p.OwnerName else '0' end) = (case when b.MatchTo = 'Name' and b.Priority = 4 then o.Name else '-1' end)
or (case when b.Field = 'Document' and b.Priority = 4 then p.Document else '0' end) = (case when b.MatchTo = 'Document' and b.Priority = 4 then o.Document else '-1' end)
)
AND
(
   (case when b.Field = 'Address' and b.Priority = 5 then p.Address else '0' end) = (case when b.MatchTo = 'Addr' and b.Priority = 5 then o.Addr else '-1' end)
or (case when b.Field = 'Zip' and b.Priority = 5 then p.Zip else '0' end) = (case when b.MatchTo = 'Zip' and b.Priority = 5 then o.Zip else '-1' end)
or (case when b.Field = 'Country' and b.Priority = 5 then p.Country else '0' end) = (case when b.MatchTo = 'Country' and b.Priority = 5 then o.Country else '-1' end)
or (case when b.Field = 'OwnerName' and b.Priority = 5 then p.OwnerName else '0' end) = (case when b.MatchTo = 'Name' and b.Priority = 5 then o.Name else '-1' end)
or (case when b.Field = 'Document' and b.Priority = 5 then p.Document else '0' end) = (case when b.MatchTo = 'Document' and b.Priority = 5 then o.Document else '-1' end)
)
group by p.PetID

union
--------------------------

select distinct p.PetID, min(o.OwnerID) as ownerID from @pets p
inner join @builder b on p.PetID = b.PetID
inner join @owners o on
(
   (case when b.Field = 'Address' and b.Priority = 1 then p.Address else '0' end) = (case when b.MatchTo = 'Addr' and b.Priority = 1 then o.Addr else '-1' end)
or (case when b.Field = 'Zip' and b.Priority = 1 then p.Zip else '0' end) = (case when b.MatchTo = 'Zip' and b.Priority = 1 then o.Zip else '-1' end)
or (case when b.Field = 'Country' and b.Priority = 1 then p.Country else '0' end) = (case when b.MatchTo = 'Country' and b.Priority = 1 then o.Country else '-1' end)
or (case when b.Field = 'OwnerName' and b.Priority = 1 then p.OwnerName else '0' end) = (case when b.MatchTo = 'Name' and b.Priority = 1 then o.Name else '-1' end)
or (case when b.Field = 'Document' and b.Priority = 1 then p.Document else '0' end) = (case when b.MatchTo = 'Document' and b.Priority = 1 then o.Document else '-1' end)
)
AND
(
   (case when b.Field = 'Address' and b.Priority = 2 then p.Address else '0' end) = (case when b.MatchTo = 'Addr' and b.Priority = 2 then o.Addr else '-1' end)
or (case when b.Field = 'Zip' and b.Priority = 2 then p.Zip else '0' end) = (case when b.MatchTo = 'Zip' and b.Priority = 2 then o.Zip else '-1' end)
or (case when b.Field = 'Country' and b.Priority = 2 then p.Country else '0' end) = (case when b.MatchTo = 'Country' and b.Priority = 2 then o.Country else '-1' end)
or (case when b.Field = 'OwnerName' and b.Priority = 2 then p.OwnerName else '0' end) = (case when b.MatchTo = 'Name' and b.Priority = 2 then o.Name else '-1' end)
or (case when b.Field = 'Document' and b.Priority = 2 then p.Document else '0' end) = (case when b.MatchTo = 'Document' and b.Priority = 2 then o.Document else '-1' end)
)
AND
(
   (case when b.Field = 'Address' and b.Priority = 3 then p.Address else '0' end) = (case when b.MatchTo = 'Addr' and b.Priority = 3 then o.Addr else '-1' end)
or (case when b.Field = 'Zip' and b.Priority = 3 then p.Zip else '0' end) = (case when b.MatchTo = 'Zip' and b.Priority = 3 then o.Zip else '-1' end)
or (case when b.Field = 'Country' and b.Priority = 3 then p.Country else '0' end) = (case when b.MatchTo = 'Country' and b.Priority = 3 then o.Country else '-1' end)
or (case when b.Field = 'OwnerName' and b.Priority = 3 then p.OwnerName else '0' end) = (case when b.MatchTo = 'Name' and b.Priority = 3 then o.Name else '-1' end)
or (case when b.Field = 'Document' and b.Priority = 3 then p.Document else '0' end) = (case when b.MatchTo = 'Document' and b.Priority = 3 then o.Document else '-1' end)
)
AND
(
   (case when b.Field = 'Address' and b.Priority = 4 then p.Address else '0' end) = (case when b.MatchTo = 'Addr' and b.Priority = 4 then o.Addr else '-1' end)
or (case when b.Field = 'Zip' and b.Priority = 4 then p.Zip else '0' end) = (case when b.MatchTo = 'Zip' and b.Priority = 4 then o.Zip else '-1' end)
or (case when b.Field = 'Country' and b.Priority = 4 then p.Country else '0' end) = (case when b.MatchTo = 'Country' and b.Priority = 4 then o.Country else '-1' end)
or (case when b.Field = 'OwnerName' and b.Priority = 4 then p.OwnerName else '0' end) = (case when b.MatchTo = 'Name' and b.Priority = 4 then o.Name else '-1' end)
or (case when b.Field = 'Document' and b.Priority = 4 then p.Document else '0' end) = (case when b.MatchTo = 'Document' and b.Priority = 4 then o.Document else '-1' end)
)
group by p.PetID

union
--------------------------

select distinct p.PetID, min(o.OwnerID) as ownerID from @pets p
inner join @builder b on p.PetID = b.PetID
inner join @owners o on
(
   (case when b.Field = 'Address' and b.Priority = 1 then p.Address else '0' end) = (case when b.MatchTo = 'Addr' and b.Priority = 1 then o.Addr else '-1' end)
or (case when b.Field = 'Zip' and b.Priority = 1 then p.Zip else '0' end) = (case when b.MatchTo = 'Zip' and b.Priority = 1 then o.Zip else '-1' end)
or (case when b.Field = 'Country' and b.Priority = 1 then p.Country else '0' end) = (case when b.MatchTo = 'Country' and b.Priority = 1 then o.Country else '-1' end)
or (case when b.Field = 'OwnerName' and b.Priority = 1 then p.OwnerName else '0' end) = (case when b.MatchTo = 'Name' and b.Priority = 1 then o.Name else '-1' end)
or (case when b.Field = 'Document' and b.Priority = 1 then p.Document else '0' end) = (case when b.MatchTo = 'Document' and b.Priority = 1 then o.Document else '-1' end)
)
AND
(
   (case when b.Field = 'Address' and b.Priority = 2 then p.Address else '0' end) = (case when b.MatchTo = 'Addr' and b.Priority = 2 then o.Addr else '-1' end)
or (case when b.Field = 'Zip' and b.Priority = 2 then p.Zip else '0' end) = (case when b.MatchTo = 'Zip' and b.Priority = 2 then o.Zip else '-1' end)
or (case when b.Field = 'Country' and b.Priority = 2 then p.Country else '0' end) = (case when b.MatchTo = 'Country' and b.Priority = 2 then o.Country else '-1' end)
or (case when b.Field = 'OwnerName' and b.Priority = 2 then p.OwnerName else '0' end) = (case when b.MatchTo = 'Name' and b.Priority = 2 then o.Name else '-1' end)
or (case when b.Field = 'Document' and b.Priority = 2 then p.Document else '0' end) = (case when b.MatchTo = 'Document' and b.Priority = 2 then o.Document else '-1' end)
)
AND
(
   (case when b.Field = 'Address' and b.Priority = 3 then p.Address else '0' end) = (case when b.MatchTo = 'Addr' and b.Priority = 3 then o.Addr else '-1' end)
or (case when b.Field = 'Zip' and b.Priority = 3 then p.Zip else '0' end) = (case when b.MatchTo = 'Zip' and b.Priority = 3 then o.Zip else '-1' end)
or (case when b.Field = 'Country' and b.Priority = 3 then p.Country else '0' end) = (case when b.MatchTo = 'Country' and b.Priority = 3 then o.Country else '-1' end)
or (case when b.Field = 'OwnerName' and b.Priority = 3 then p.OwnerName else '0' end) = (case when b.MatchTo = 'Name' and b.Priority = 3 then o.Name else '-1' end)
or (case when b.Field = 'Document' and b.Priority = 3 then p.Document else '0' end) = (case when b.MatchTo = 'Document' and b.Priority = 3 then o.Document else '-1' end)
)
group by p.PetID

union
------------------------

select distinct p.PetID, min(o.OwnerID) as ownerID from @pets p
inner join @builder b on p.PetID = b.PetID
inner join @owners o on
(
   (case when b.Field = 'Address' and b.Priority = 1 then p.Address else '0' end) = (case when b.MatchTo = 'Addr' and b.Priority = 1 then o.Addr else '-1' end)
or (case when b.Field = 'Zip' and b.Priority = 1 then p.Zip else '0' end) = (case when b.MatchTo = 'Zip' and b.Priority = 1 then o.Zip else '-1' end)
or (case when b.Field = 'Country' and b.Priority = 1 then p.Country else '0' end) = (case when b.MatchTo = 'Country' and b.Priority = 1 then o.Country else '-1' end)
or (case when b.Field = 'OwnerName' and b.Priority = 1 then p.OwnerName else '0' end) = (case when b.MatchTo = 'Name' and b.Priority = 1 then o.Name else '-1' end)
or (case when b.Field = 'Document' and b.Priority = 1 then p.Document else '0' end) = (case when b.MatchTo = 'Document' and b.Priority = 1 then o.Document else '-1' end)
)
AND
(
   (case when b.Field = 'Address' and b.Priority = 2 then p.Address else '0' end) = (case when b.MatchTo = 'Addr' and b.Priority = 2 then o.Addr else '-1' end)
or (case when b.Field = 'Zip' and b.Priority = 2 then p.Zip else '0' end) = (case when b.MatchTo = 'Zip' and b.Priority = 2 then o.Zip else '-1' end)
or (case when b.Field = 'Country' and b.Priority = 2 then p.Country else '0' end) = (case when b.MatchTo = 'Country' and b.Priority = 2 then o.Country else '-1' end)
or (case when b.Field = 'OwnerName' and b.Priority = 2 then p.OwnerName else '0' end) = (case when b.MatchTo = 'Name' and b.Priority = 2 then o.Name else '-1' end)
or (case when b.Field = 'Document' and b.Priority = 2 then p.Document else '0' end) = (case when b.MatchTo = 'Document' and b.Priority = 2 then o.Document else '-1' end)
)
group by p.PetID

union
------------------------

select distinct p.PetID, min(o.OwnerID) as ownerID from @pets p
inner join @builder b on p.PetID = b.PetID
inner join @owners o on
(
   (case when b.Field = 'Address' and b.Priority = 1 then p.Address else '0' end) = (case when b.MatchTo = 'Addr' and b.Priority = 1 then o.Addr else '-1' end)
or (case when b.Field = 'Zip' and b.Priority = 1 then p.Zip else '0' end) = (case when b.MatchTo = 'Zip' and b.Priority = 1 then o.Zip else '-1' end)
or (case when b.Field = 'Country' and b.Priority = 1 then p.Country else '0' end) = (case when b.MatchTo = 'Country' and b.Priority = 1 then o.Country else '-1' end)
or (case when b.Field = 'OwnerName' and b.Priority = 1 then p.OwnerName else '0' end) = (case when b.MatchTo = 'Name' and b.Priority = 1 then o.Name else '-1' end)
or (case when b.Field = 'Document' and b.Priority = 1 then p.Document else '0' end) = (case when b.MatchTo = 'Document' and b.Priority = 1 then o.Document else '-1' end)
)
group by p.PetID

Result
PetID   OwnerID
1       2
2       6
3       1

A: If you are looking for a simple solution without union, loop or a cursor or dynamic SQL below query works fine.
SQL Fiddle : http://sqlfiddle.com/#!18/10982/41
select PetID ,COALESCE(
 (select  top 1 OwnerID from temp_owners
     where Zip = pets.Zip
     and Name = pets.OwnerName
     and Document = pets.Document) ,
     (select top 1 OwnerID from temp_owners where
         Name = pets.OwnerName
         and Document = pets.Document)  ,
         (select top 1 OwnerID from temp_owners where
          Document = pets.Document)  ) OwnerId
       from
temp_pets pets

Result:
PetID   OwnerId
1       (null)
2       6
3       2


text:
Q: SSSD - start LDAP-search with logging-in user Situation today: we've got a functional sssd-config on multiple Ubuntu-clients. This config contains authenticating against a LDAP-server. The SASL-Mech is as "gssapi" specified and uses a krb5-keytab-file. Bombastic feauture: the specified user of the keytab-file expires every 90 days. Not that bad, but replacing the keytab-file on the clients will take a long time and additional is more risky.
Situation tomorrow will be: if possible we'd like to use the credentials used to log in, because the LDAP isn't anonymous-readable and every domain user will have read access. Actually, I don't have an idea to put the active login-credentials to sssd to check authentication against LDAP. Any assistance would be appreciated!
Before asking to not expire this user: we're in some complex network, which is not administrated by ourself and we're only allowed to use those users.

A: You can use ldap_default_bind_dn together with ldap_default_authtok_type=password and then put the login credentials into ldap_default_authtok.


text:
Q: "Deep in the forest a call was sounding", existential construction?
"Deep in the forest a call was sounding, and as often as he heard this call, mysteriously thrilling and luring, he felt compelled to turn his back upon the fire and the beaten earth around it, and to plunge into the forest, and on and on, he knew not where or why; nor did he wonder where or why, the call sounding imperiously, deep in the forest."
  ― Jack London, The Call of the Wild.

Deep, adverb(?) I may not get what it may modify? Do you discern Deep in the forest like a prepositional phrase, or maybe mostly in the forest? From there, may this seem a complete sentence? A call (noun phrase[?]) subject, was copular verb, sounding (does this get utilized like a noun here?), object? I guess this may seem like an existential construction *A call was sounding.?

A: Deep in the forest, high in the sky, off in the distance, out on the highway, down in a cavern...
Deep, high, far, out, down  -- nowadays I believe these words may be considered adpositions or prepositions. Their function is to indicate remoteness. Back in the past, they might have been called adverbs or adverbial particles.
P.S. ... a call was sounding:  a "call" is the cry of an animal; "was sounding" = was making the sound that it makes (for example, a siren was sounding, off in the distance; a moose's call was sounding deep in the woods)

A:
A call was sounding.

This is not an existential construction.   There is no dummy subject.   We can consider this clause to consist of an ordinary subject (a call) and an ordinary intransitive verb (was sounding).   The verb employs the active voice, past tense, continuous aspect and indicative mode.
At a glance, it might seem oddly redundant:  a noise was making noise.   However, a call isn't simply a noise.   It might not be (and, in this context, is not) a literal noise at all.   A call is a request for a response; it requires an answer.   A request for his presence was making itself known.
It is a complete independent clause, and it could stand on its own as a sentence.

A call was sounding in the forest.

The prepositional phrase "in the forest" modifies the verb "was sounding".

A call was sounding deep in the forest.

As I parse this, the word "deep" modifies the phrase "in the forest".   I consider this example of "deep" to be an adverb.
Others might label "deep" differently, as an intransitive preposition or a particle.   Another possible parsing is that "in the forest" modifies "deep".
In either case, the phrase "deep in the forest" is grammatically coherent.   I'll let others argue about which word is the head of the phrase or how its dependency structure should be understood.   One way or another, the entire phrase "deep in the forest" functions as an adverbial prepositional phrase.   As a unit, it modifies the verb "was sounding", just as the simpler "in the forest" does in my earlier example.

Deep in the forest a call was sounding.

Here, the adverbial prepositional phrase is placed at the beginning of the clause.   That changes the rhythm of the clause and gives more emphasis to the leading word "deep", but it doesn't change the grammatical structure.
This entire independent clause is, in the original text, just one part of a long, convoluted compound-complex sentence.   It could have been a sentence on its own, but in the original text it is not on its own and it is only one part of a sentence.


text:
Q: How to make less empty space between Basemap subplots when using plt.subplot2grid() I have 5 maps I am trying to plot in one figure. I would like them to be laid out like
1 2 3
 4 5

To do this, I tried to follow the answer given here:
Position 5 subplots in Matplotlib
This gives me the correct layout, but there is a ton of empty space left between the subplots.
#S,W,N,E Bounds
lonMin = 119
lonMax = 124
latMin = 12
latMax = 19

m = Basemap(llcrnrlon=lonMin,llcrnrlat=latMin,urcrnrlon=lonMax,urcrnrlat=latMax, projection = 'cea', resolution = 'i')

fig = plt.figure()
axes = [plt.subplot2grid(shape=(2,6), loc=(0,0), colspan=2),
        plt.subplot2grid((2,6), (0,2), colspan=2),
        plt.subplot2grid((2,6), (0,4), colspan=2),
        plt.subplot2grid((2,6), (1,1), colspan=2),
        plt.subplot2grid((2,6), (1,3), colspan=2)]
for i in range(5):
    m.ax = axes[i]
    m.drawcoastlines()
fig.suptitle('Title', fontsize = 20, fontweight = 'bold')

How can I reduce the spacing between the subplots?
EDIT:
The problem appears to somehow be tied to putting Basemaps in the plot. If I comment out the m.drawcoastlines() call, the axes look like this, which is fine:

A: First of all you may try to call plt.tight_layout() to  adjust spacing between subplots to minimize the overlaps.
Another way is to use subplots_adjust to set all spaces manually like
fig.subplots_adjust(hspace=.1) # height spaces
fig.subplots_adjust(wspace=.1) # width spaces

These functions affect all subplots. If you need more control use GridSpec.


text:
Q: Why change net.inet.tcp.tcbhashsize in FreeBSD? In virtually every FreeBSD network tuning document I can find:
# /boot/loader.conf
net.inet.tcp.tcbhashsize=4096

This is usually paired with some unhelpful statement like "TCP control-block hash table tuning" or "Set this to a reasonable value." man 4 tcp isn't much help either:

tcbhashsize         Size of the TCP control-block hash table (read-only).
                    This may be tuned using the kernel option TCBHASHSIZE
                    or by setting net.inet.tcp.tcbhashsize in the
                    loader(8).

The only document I can find that touches on this mysterious thing is the Protocol Control Block Lookup subsection beneath Transport Layer in Optimizing the FreeBSD IP and TCP Stack, but its description is more about potential bottlenecks in using it. It seems tied to matching new TCP segments to their listening sockets, but I'm not sure how.
What exactly is the TCP Control Block used for? Why would you want to set its hash size to 4096 or any other particular number?

A: It's more like computer science question. Especially if you want to dig into hash tables and big-O notations.
The answer is:
If you are handling many TCP sessions on sever you really want to look up connection's tcp parameters in O(1) time instead of O(n). FreeBSD uses chaining to resolve hash table collisions. So if there is lots of connection there will be lots of collisions and so instead of O(1) hash table lookup you'll need to do an linear chain lookup with O(n) complexity.
Parameter you mentioned - tcbhashsize is basically number of buckets in hash table.
On our servers it's set to pretty high values like 16384 and even higher. With that setting we are handling about 60,000 connections per server.
Each entry in hash table by itself currently on x86_64 uses 252 bytes (tcp_inpcb) + 688 bytes(tcpcb) of kernel memory for each entry (kmem size is 512G in amd64 since 7.2+ IIRC). It can be viewed via vmstat -z.
About structure of TCP Control block you can read FreeBSD sources: tcp_var.h or read TCP/IP Illustrated, Volume 2: The Implementation By Gary R. Wright, W. Richard Stevens


text:
Q: integrating presto with airflow I will like to integrate Airflow with presto. on the bash shell the commmand - */opt/presto/bin/presto --server 10.0.0.15:8190 --catalog hive --schema cvm_db --execute "select * from cvm_db.cvm_weekly_rech limit 10"* works fine but in python airflow scripts , it throws and error- invalid sythax and highlights the command.
Please what is the best way to do this.
Below is the airflow script.
            import airflow
            from airflow.models import DAG
            from airflow.operators.bash_operator import BashOperator
            from airflow.operators.dummy_operator import DummyOperator
            from datetime import datetime, timedelta, date
            default_args = {
              'owner': 'daasuser',
              'depends_on_past': False,
              'start_date': airflow.utils.dates.days_ago(0),
              'email': ['a.olabamidele@ligadata.com'],
              'email_on_failure': True,
              #'email_on_retry': True,
              'retries': 5,
              'retry_delay': timedelta(minutes = 10),
              #'queue': 'bash_queue',
              #'pool': 'backfill',
              #'priority_weight': 10,
              #'end_date': datetime(2016, 1, 1),
              #'wait_for_downstream': False,
              #'dag': dag,
              #'sla': timedelta(hours = 2),
              #'execution_timeout': timedelta(seconds = 300),
              #'on_failure_callback': some_function,
              #'on_success_callback': some_other_function,
              #'on_retry_callback': another_function,
            }
            dag = DAG(
                'cvm_weekly_datamart',
                default_args=default_args,
                description='To insert records into cvm datamart weekly',
                schedule_interval='0 5 * * 0')
            #date1='/opt/presto/bin/presto --server 10.0.0.15:8190 --catalog hive --schema cvm_db --execute "select * from cvm_db.cvm_weekly_rech limit 10"
            t1 = BashOperator(
                task_id='print_date',
                bash_command=/opt/presto/bin/presto --server 54.242.0.153:8180 --catalog hive --schema cvm_db --execute "select * from cvm_db.cvm_weekly_rech limit 10",
                dag=dag)
            print1='echo "Completed"'
            t2 = BashOperator(
                task_id='print',
                bash_command=print1,
                #retries=1,
                dag=dag)
            t1>>t2

A: The command should be:
bash_command='/opt/presto/bin/presto --server 54.242.0.153:8180 --catalog hive --schema cvm_db --execute "select * from cvm_db.cvm_weekly_rech limit 10"'

The command should be a string.


text:
Q: VPN breaks connectivity between 2 NICs on 3 NIC machine My current working setup is as follows:
Linux machine with 2 NICs (eth0 and wlan0) sitting behind a wireless router. Let's call this machine PC1.

*

*connected to eth0 on PC1 is PC2 (Windows).

*wireless router is 192.168.0.1 and wlan0 is 192.168.0.xxx.

*eth0 is 10.42.0.1 and PC2 is at 10.42.0.xxx.
I have successfully used this setup to establish an OpenVPN connection (by right-clicking on a config file) from PC2 to an external server. That is, the connection goes through eth0 to the wireless router. Starting VPN creates on PC2 a virtual network adapter at 10.7.112.xxx with a gateway at 10.7.112.1.
So far, so good.
Problems started after I added eth1 to PC1. Its IP address is 192.168.1.1. Connected to it is PC3 at 192.168.1.xxx.
What kind of problems?
I can access PC2 from PC3 and the other way around unless I establish a VPN connection from PC2. After I do, PC2 and PC3 cannot see each other anymore unless I disconnect VPN, getting rid of the 10.7.112.xxx virtual adapter. Then, connectivity restores immediately.
I made sure, there's no active firewall rules.
The subnet masks on all of the above are 255.255.255.0. Does that matter?
What do I have to change to make the 3-NIC setup work as well as the 2-NIC one? Please do not suggest changing the layout - I need to understand what exactly is wrong with the current routing.
Thank you!