text:
Q: Passing multiple headers in .ajax request for CORS domain doesn't work I have a function for CORS domain issue, I am trying to adding headers object and it doesn't seem to work. It showing that I am sending headers when I ajax_call_config but when I see network, request headers I only see this
Provisional headers are shown
Referer: http://127.0.0.1:8000/qa/ftest/
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
var make_external_request = function(obj, url, complete_callback_fn,
 post_load_callback, other_config){
     var response = ""
     var ajax_call_config = {
         url: url,
         xhr: function () {
         var xhr = jQuery.ajaxSettings.xhr();
          var setRequestHeader = xhr.setRequestHeader;
          xhr.setRequestHeader = function (name, value) {
          // Ignore the X-Requested-With header
           if (name == 'X-Requested-With') return;
                setRequestHeader.call(this, name, value);
             }
             return xhr;
         },
         xhrFields: {
              withCredentials: false
         },
         headers:{
             'az':'ss'
         },
         success: function (data) {
             response = data;
         },
         complete: function () {
             complete_callback_fn(obj, response, post_load_callback)

         },
         error:function(jqXHR, textStatus, errorThrown ) {
             console.log("printing error", jqXHR, textStatus, errorThrown )
         }
     };
     $.extend(true, ajax_call_config, other_config);

 $.ajax(ajax_call_config);
      }

Please help how to fix this?


text:
Q: Vb.net wild cards in registry path I want to read a registry value which resides in:
HKEY_LOCAL_MACHINE\SOFTWARE\MyProgram\PROG7.0.0\Info

The value name is "Information" but the key "PROG7.0.0" may have a variable name like "PROG7.2.111", changing the path to:
HKEY_LOCAL_MACHINE\SOFTWARE\MyProgram\PROG7.2.111\Info

The variable name will always be of the form "PROG7.xx.xxx", where x is an integer. Also, there will always be exactly one subkey of such name in HKEY_LOCAL_MACHINE\SOFTWARE\MyProgram
I know i can use Regestry.GetValue method for reading a registry value but in my case the path is a variable - how can i go about it?
Thanks a lot!

A: How to iterate all keys at a specific registry path
using System;

using Microsoft.Win32;

namespace RegistryLister {
    public static class Program {
        static void Main(string[] args) {
            //var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\MyProgram\");
            var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\");
            if (key != null)
                foreach (var keyName in key.GetSubKeyNames()) {
                    //if (keyName.StartsWith("PROG7"))
                    if (keyName.StartsWith("Mic"))
                        Console.WriteLine(keyName);
                }
            Console.ReadKey();

            /* Outputs:
             *
             * Microsoft
             * Microsoft Corporation
             *
             */
        }
    }
}

Read more about RegistryKey

redpajama_set_name: RedPajamaStackExchange


text:
Q: If function has two array parameters how to return the second one function isVow(a) {
  console.log(a);
}

isVow([1232, 1, 342], [3, 2, 4]);

// console output [1232, 1, 342]

How can I display [3, 2, 4]to the console?

A: You need 2nd parameter b
function isVow(a,b) {
  console.log(b);
}

isVow([1232, 1, 342], [3, 2, 4]);

Edit
You can try this with 1 parameter:
function isVow(a) {
  console.log(a[1]);
}

isVow([[1232, 1, 342], [3, 2, 4]]);

A: You need to add to function second param b
function func(a,b){
console.log(a,b);
}

isVow([1232, 1, 342], [3, 2,4]);

A: You can do something like this:
function func(){
    if(arguments.length > 1) {
        console.log(arguments[1]);
    }
}

Read more about arguments object

A: You need to use function's arguments like below
function isVow() {
  console.log('arguments[0]' , arguments[0]);
  console.log('arguments[1]' , arguments[1]);
}

isVow([1232, 1, 342], [3, 2, 4]);

You get output like this
arguments[0] [1232, 1, 342]
arguments[1] [3, 2, 4]

cheers....


text:
Q: Backpropagation neuron networks Hi I playing with neural nets right now. I made kind of reimplementation of this tutorial:
http://www.ai-junkie.com/ann/evolved/nnt5.html, but with fishes and food and also different programing language. But the point is same.

I have bunch of fishes (20) and bunch of foos (40).
Each fish has brain(neural network (I will use ANN since now)). At the moment neural network don't use backprop and is trained by genetic alghoritm. It works fine. I want to implement learning by using backpropagation and than compare this two approaches. Problem is only with backpropagation alghoritm. I read some articles about it but i kind of didn't get the point how it actually could be used on this example. I probably just don't understand it enought.
I'll explain the problem:
Now i have neural network with 4 inputs. LookAt vector lookAt(x,y), vector to closest food  closestFood(x,y) => the values of this vectors are inputs to the ANN. Output of the nn is speed of left an right flipper of the fish => ANN has 2 outputs leftFliperSpeed, rightFlipperSpeed.
So to sum up. I have ann like this:
inputs: 4 (lookAt.X,lookAt.Y, closestFood.X,closestFood.Y)
layers: 3 (input, output, and one hidden with 6 neurons)
outputs: 2 (leftFlipperSpeed, rightFlipperSpeed)

I use it like this:
1. By genetic alghoritm I get the first population of fishes (read I will get the weights for inputs of ANN).
2. Run for some number of iterations the simulation and let the fishes eat the fishes find and eat the food. I fish found the food, her fitness function is increased and food is repositioned somewhere else. I have constant number of fishes and food all the time.
3. After for example 2000 iterations I run again the genetic alghoritm and get from actual population new population - fishes with higher fitness has higher chance to survive or be dad or mom of new fishes. I get new weights for the Neural newtork. And continue from point 2.

The learning process is easy and clear here. And its learning without supervisor.
Now the backpropagation. From articles I read the backpropagation is supervised learning. The problem is with training set. With genetics alghs i didn't need it here yes.
What could I do to implement backpropagation.  Any tips how could I get the the new weights from it and how to replace the supervisor? I think backpropagation can't be done without supervisor. It can be somehow used the data which I get from learning by genetic alghoritm but its will be dependent on number of inputs, size of pool with food where will be fishes, etc.

A: Backpropagation is just a method of computing gradients, nothing else. It is not really the supervised learning technique, it is only about being able to efficiently compute gradients of some prefefined loss function (which often, in examples online will be supervised loss).
For the problem described the most reasonable technique is actually reinforcement learning. There, you will be able to backprop through your networks, and learn feeding policies in a well structured manner (as opposed to genetic algorithm which will fail with any more complex problem). You might want to take a look at objects like Deep Q-learning (which efficiently is just a simple RL technique where your policy is controled by a neural net, and this is exactly what you try to achieve - you have a neural net based policy, which chooses actions; although in your case it is a continuous output space thus you might need to discretize it for this particular use case).


text:
Q: Odoo access table inside model using xml-rpc I am working on an xml-rpc service that needs to read data from a table, res_groups_users_rel. But the service is not able to fetch data from that table. I tried the same service on res_groups table and it is working fine. Is there a way to access res_groups_users_rel table from an xml-rpc service?
Here is the xml-rpc service:
Object r2[] = new Object[7];
r2[0] = db;
r2[1] = (Integer) uId;
r2[2] = password;
r2[3] = "res.groups.users.rel";
r2[4] = "read";
r2[5] = moduleId;
Object[] params6 = { "uid", "gid"};
r2[6] = params6;

Object rules = xmlRpcClient.execute("execute", r2);

Note: I also found that res_groups table has a model named res.groups which is used by xml-rpc services. But res_groups_users_rel  table has no model.

A: I don't know if it can help.
I was also trying to access the "res.groups.users.rel" table to get the groups the user was in.
I finally found that the model "res_users" contain a field named "groups_id"
Php code using Ripcord :
$gids = $ripcord->execute_kw($this->db, $this->user, $this->pwd,
        'res.users', 'read',
        array($id),
        array('fields'=>array('groups_id')));

$gids['groups_id'] gives you and array of the groups ID for the specified user id
You can find the others availables models in the OpenErp web interface -> Settings tab -> in the menu Technical -> Database Structure -> Models
Hope it helps

A: You could access res.groups, that model have a field called "users" (it is an array  that represents the ids of the users that belong to that group).
Iterate that array and you will know the groups an specific user belong


text:
Q: Play Store - Error about distrubuted selected countries I'm trying to publish a closed test on Play Console, however, I get this error "Unknown validation VALIDATE_APP_MESSAGE_ILLEGAL_TO_DISTRIBUTE_IN_SELECTED_COUNTRIES". Even if I select one country, I get the same error.

A: This looks like a bug.
The error message should normally tell you that you are not allowed to publish in this country based on your content rating.


text:
Q: "no schema has been selected to create in" even after opening up postgres permissions diesel migration list
Failed with: no schema has been selected to create in

This is the error I'm trying to solve. I recently made some changes to roles and permissions in Postgres, and now my diesel migrations won't run.
cat .env

The result shows that indexer1 is the pg user.
But I've looked at https://dba.stackexchange.com/a/106067/18098 and https://stackoverflow.com/questions/41207259/no-schema-has-been-selected-to-create-in-error and even opened up the permissions as much as I know how (temporarily sacrificing security).
postgres=# show search_path ;
   search_path
-----------------
 "$user", public
(1 row)
 \dn+ public
                          List of schemas
  Name  |  Owner   |  Access privileges   |      Description
--------+----------+----------------------+------------------------
 public | postgres | postgres=UC/postgres+| standard public schema
        |          | indexer1=UC/postgres+|
        |          | =UC/postgres         |
(1 row)

 \du
                                        List of roles
     Role name      |                         Attributes                         | Member of
--------------------+------------------------------------------------------------+------------
 editor             | Cannot login                                               | {}
 indexer1           | Create DB                                                  | {}
 postgres           | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 readonly           | Cannot login                                               | {}

(I've omitted some additional roles that I think are irrelevant.)
UPDATE
I temporarily ran:
ALTER USER indexer1 WITH SUPERUSER;
\du

and now diesel migration list works.
But my question remains because this indexer1 user didn't need to be a superuser before.
What else should I check and adjust?
RESPONSE to first comment
What does the following result tell us?
\connect mainnet_node;
You are now connected to database "mainnet_node" as user "postgres".
mainnet_node=# show search_path ;
 search_path
-------------
 public
(1 row)
mainnet_node=# \dn+ public
                          List of schemas
  Name  |  Owner   |  Access privileges   |      Description
--------+----------+----------------------+------------------------
 public | postgres | postgres=UC/postgres+| standard public schema
        |          | editor=UC/postgres  +|
        |          | readonly=U/postgres  |
(1 row)

mainnet_node=# grant usage on schema public to indexer1;
GRANT
mainnet_node=# grant create on schema public to indexer1;
GRANT
mainnet_node=# \dn+ public
                          List of schemas
  Name  |  Owner   |  Access privileges   |      Description
--------+----------+----------------------+------------------------
 public | postgres | postgres=UC/postgres+| standard public schema
        |          | editor=UC/postgres  +|
        |          | readonly=U/postgres +|
        |          | indexer1=UC/postgres |
(1 row)

If I remove superuser from indexer1 now, will I probably be "back to normal"?


text:
Q: Does Peeta care about his family or not? In the film of Catching Fire at about 2:00:45 when Peeta explains to Katniss why she has to be the one to survive, he says:

If you die and I live, I'd have nothing. Nobody else that I care about.

However, earlier in the film at about 0:21:33 when yelling at Katniss for not telling him about the situation with President Snow, Peeta says:

Well, I have family too. Okay? People that I need to protect.

Sure sounds like he cares about them.
How are we to reconcile Peeta's apparently conflicting statements about his family?
In the parallel passages in the book, the contradiction is perhaps less pronounced.
In Chapter Five Peeta more explicitly says that he cares about his family:

"It's exactly like that!" he yells at me. "I have people I care about, too, Katniss! Family
and friends back in District Twelve who will be just as dead as yours if we don't pull this
thing off. So, after all we went through in the arena, don't I even rate the truth from you?"

But in Chapter Twenty-Four he doesn't quite say that he doesn't care about them. What he says is:

"Because I don't want you forgetting how different our circumstances are. If you die, and I
live, there's no life for me at all back in District Twelve. You're my whole life," he says. "I
would never be happy again." I start to object but he puts a finger to my lips. "It's different
for you. I'm not saying it wouldn't be hard. But there are other people who'd make your life
worth living."

This could be understood as even though he cares about his family, Katniss is so important to him that his life would be not worth living without her.

A: "Nobody else that I care about"... romantically.
When viewed through this lens, it makes more sense. Yes, they both have families that they don't want to see killed and care about. However, only Katniss has another romantic love — the "other people who'd make [her] life worth living" — Gale.
You may say that of course the plural "people" here must refer to "[Her] family. [Her] mother. [Her] sister". To that I say that "But Peeta's intension is clear. That Gale really is [her] family, or will be one day, if [she lives]. That [she'll] marry him."
Refer to the longer quote from Chapter 24.

A: In Chapter 24 (or that film clip) they're in the arena, with cameras on them.

The Capitol viewers will be glued to their sets so they don't miss one wretched word.
Chapter 24, Catching Fire

In Chapter 5, Haymitch has taken them to a room where they can't be overheard, and Peeta's just found out that their actions are at risk of causing uprisings and three people have been killed because of what they've just done. He's worried that his gift to Rue and Thresh's families will lead to their deaths. He's telling Katniss that he doesn't want his family and friends (or anybody else) to die because of their actions.
That isn't something he can talk about in the arena.
He can love his family enough to want to protect them (Chapter 5) whilst still thinking his life would be nothing without Katniss (Chapter 24).

A: Peeta does care that his family is safe, but he doesn't think they need him alive, and doesn't care to stay alive without Katniss.
Peeta does care to protect his family from harm - he doesn't want the Capitol to hurt them because of his actions. He wanted to know what the Capitol expects of him so he could act in a way that wouldn't cause anyone else to die.

"I know you had to choose one of us. And I'd have wanted it to be her. But this is something different. People are dead out there. More will follow unless we're very good. We all know I'm better than Katniss in front of the cameras. No one needs to coach me on what to say. But I have to know what I'm walking into," says Peeta." - Catching Fire (Chapter 5)

However, Peeta does not believe that his family need him alive, so while he cares about them, he does not see it as necessary to keep himself alive for them.

"No one really needs me," he says, and there's no self-pity in his voice. It's true his family doesn't need him. They will mourn him, as will a handful of friends. But they will get on. Even Haymitch, with the help of a lot of white liquor, will get on." - Catching Fire (Chapter 24)

Additionally, he is so smitten with Katniss that he does not consider that there could be anything else worth living for if she was dead. Haymitch even chose  Katniss over Peeta in the first Hunger Games because he knew Peeta would be protecting her over himself.

"But remember, until they changed the rules, I could only hope to get one of you out of there alive," he says. "I thought since he was determined to protect you, well, between the three of us, we might be able to bring you home." - Catching Fire (Chapter 5)

So while he may care about his family, Peeta is very willing to die in order to save Katniss, and since he does not see this as having a sufficiently negative effect on his family, he does not consider them an obstacle to this.

A: In my opinion he does care about his family on a basic level (because they are his family). But he cares about Katniss more than anything in the world. What he means is that Katniss is his everything but in situations where his family would/could be in danger, he cares.
On the other hand, Katniss has people she cares about so so much. She cares about her family more than Peeta does with his and on top of that, Katniss cares about Gale very much too. She can sacrifice everything she has for them. And Peeta would sacrifice everything for Katniss.


text:
Q: Azure AD B2C Direct to Identity Provider from Email At the company I work for, we have our own Active Directory setup. We also have a number of external partners who each have their own Active Directory setups. We are trying to use Azure AD B2C to create a single location to sign on. Adding multiple identity providers is easy, but buttons show up for each provider and due to privacy concerns we can not allow our partners to know who else we partner with. We wish to ask for an email, and direct the user to the correct identity provider based on the domain of the email.
I know there are ways to do this, however all of the ones I have found so far are extremely convoluted. The requirements for this feel like they would be very common in many businesses, so the concept that the easiest ways to implement this require approximately a hundred steps doesn't seem right.
I'm aware of Home Realm Discovery, but like above all examples I see of it require immensely complex setups (custom policies with claims providers calling an azure function to query from a database to return the idP), we already have to setup the Identity Providers is there really no simple way to say "emails from parter1.com use this provider, emails from partner2.com use this one"? If not, could someone explain the lease complex way of achieving this?

A: See this sample which collects email and does the HRD based on domain name.
https://github.com/azure-ad-b2c/samples/tree/master/policies/home-realm-discovery-modern
You must use custom policy if you collect email in the B2C page.
If you collect email in the app, then you could use a User Flow with a domain_hint param. You don't need to do any xml work, just pass a domain_hint parameter equal to the idp name in the portal.
https://learn.microsoft.com/en-us/azure/active-directory-b2c/direct-signin#redirect-sign-in-to-a-social-provider


text:
Q: Setting a custom zoom level in google maps I am using google maps api and would liken to get a zoom half way between two settings.  Is this possible and how would I go about it?
Thanks

A: Although Mapview workd internally with continuous zoom level variation (you can see it because in zoom animations, getProjection() is aligned with intermediate zoom levels), the API only makes available for selection integer zoom levels.
Regards.


text:
Q: Output of Reduce processed by ToRules - how to preserve sublist structure? I have some output from reduce as follows:

solutions =

{(m1 == -4 && m2 == 3 && m3 == 5 && m4 == -3) || (m1 == -4 &&
    m2 == 5 && m3 == 5 && m4 == -4) || (m1 == 0 && m2 == 1 &&
    m3 == -3 && m4 == 4), (m1 == -3 && m2 == 5 && m3 == 3 &&
    m4 == -4) || (m1 == 1 && m2 == 0 && m3 == -5 &&
    m4 == 3) || (m1 == 1 && m2 == 1 && m3 == -5 &&
    m4 == 4), (m1 == -5 && m2 == 3 && m3 == 1 &&
    m4 == 0) || (m1 == -5 && m2 == 4 && m3 == 1 &&
    m4 == 1) || (m1 == 3 && m2 == -4 && m3 == -3 &&
    m4 == 5), (m1 == -3 && m2 == 4 && m3 == 0 &&
    m4 == 1) || (m1 == 5 && m2 == -4 && m3 == -4 &&
    m4 == 5) || (m1 == 5 && m2 == -3 && m3 == -4 &&
    m4 == 3), (m1 == -1 && m2 == -1 && m3 == -4 &&
    m4 == 5) || (m1 == -1 && m2 == 0 && m3 == -4 &&
    m4 == 3) || (m1 == 3 && m2 == -5 && m3 == 0 &&
    m4 == 1), (m1 == 0 && m2 == -1 && m3 == -3 &&
    m4 == 5) || (m1 == 4 && m2 == -5 && m3 == 1 &&
    m4 == 1) || (m1 == 4 && m2 == -3 && m3 == 1 &&
    m4 == 0), (m1 == -5 && m2 == 4 && m3 == 4 &&
    m4 == -5) || (m1 == -5 && m2 == 5 && m3 == 4 &&
    m4 == -1) || (m1 == -1 && m2 == 0 && m3 == -4 &&
    m4 == 3), (m1 == -5 && m2 == 3 && m3 == 4 &&
    m4 == -3) || (m1 == -1 && m2 == -1 && m3 == -4 &&
    m4 == 5) || (m1 == -1 && m2 == 4 && m3 == -4 &&
    m4 == 1), (m1 == -4 && m2 == 1 && m3 == -1 &&
    m4 == 4) || (m1 == -4 && m2 == 5 && m3 == -1 &&
    m4 == -1) || (m1 == 4 && m2 == -3 && m3 == -5 &&
    m4 == 3), (m1 == -4 && m2 == 3 && m3 == -1 &&
    m4 == 0) || (m1 == 4 && m2 == -5 && m3 == -5 &&
    m4 == 4) || (m1 == 4 && m2 == -1 && m3 == -5 &&
    m4 == 5), (m1 == 1 && m2 == -4 && m3 == -5 &&
    m4 == 5) || (m1 == 1 && m2 == 1 && m3 == -5 &&
    m4 == 4) || (m1 == 5 && m2 == -3 && m3 == -1 &&
    m4 == 0), (m1 == 1 && m2 == 0 && m3 == -5 &&
    m4 == 3) || (m1 == 5 && m2 == -5 && m3 == -1 &&
    m4 == 4) || (m1 == 5 && m2 == -4 && m3 == -1 &&
    m4 == -1), (m1 == -5 && m2 == 5 && m3 == 4 &&
    m4 == -1) || (m1 == -1 && m2 == 4 && m3 == -4 &&
    m4 == 1) || (m1 == 3 && m2 == -3 && m3 == 0 &&
    m4 == 3) || (m1 == 3 && m2 == 0 && m3 == 0 &&
    m4 == -3), (m1 == -4 && m2 == 1 && m3 == -1 &&
    m4 == 4) || (m1 == 0 && m2 == -3 && m3 == 3 &&
    m4 == 0) || (m1 == 0 && m2 == 3 && m3 == 3 &&
    m4 == -3) || (m1 == 4 && m2 == -1 && m3 == -5 &&
    m4 == 5), (m1 == -3 && m2 == 0 && m3 == 3 &&
    m4 == -3) || (m1 == -3 && m2 == 3 && m3 == 3 &&
    m4 == 0) || (m1 == 1 && m2 == -4 && m3 == -5 &&
    m4 == 5) || (m1 == 5 && m2 == -5 && m3 == -1 && m4 == 4)}

Then I use Map on TotalRules giving

solutionsrules = Map[ToRules, solutions]

{{m1 -> -4, m2 -> 3, m3 -> 5, m4 -> -3}, {m1 -> -4, m2 -> 5, m3 -> 5,
  m4 -> -4}, {m1 -> 0, m2 -> 1, m3 -> -3, m4 -> 4}, {m1 -> -3,
  m2 -> 5, m3 -> 3, m4 -> -4}, {m1 -> 1, m2 -> 0, m3 -> -5,
  m4 -> 3}, {m1 -> 1, m2 -> 1, m3 -> -5, m4 -> 4}, {m1 -> -5, m2 -> 3,
   m3 -> 1, m4 -> 0}, {m1 -> -5, m2 -> 4, m3 -> 1, m4 -> 1}, {m1 -> 3,
   m2 -> -4, m3 -> -3, m4 -> 5}, {m1 -> -3, m2 -> 4, m3 -> 0,
  m4 -> 1}, {m1 -> 5, m2 -> -4, m3 -> -4, m4 -> 5}, {m1 -> 5,
  m2 -> -3, m3 -> -4, m4 -> 3}, {m1 -> -1, m2 -> -1, m3 -> -4,
  m4 -> 5}, {m1 -> -1, m2 -> 0, m3 -> -4, m4 -> 3}, {m1 -> 3,
  m2 -> -5, m3 -> 0, m4 -> 1}, {m1 -> 0, m2 -> -1, m3 -> -3,
  m4 -> 5}, {m1 -> 4, m2 -> -5, m3 -> 1, m4 -> 1}, {m1 -> 4, m2 -> -3,
   m3 -> 1, m4 -> 0}, {m1 -> -5, m2 -> 4, m3 -> 4,
  m4 -> -5}, {m1 -> -5, m2 -> 5, m3 -> 4, m4 -> -1}, {m1 -> -1,
  m2 -> 0, m3 -> -4, m4 -> 3}, {m1 -> -5, m2 -> 3, m3 -> 4,
  m4 -> -3}, {m1 -> -1, m2 -> -1, m3 -> -4, m4 -> 5}, {m1 -> -1,
  m2 -> 4, m3 -> -4, m4 -> 1}, {m1 -> -4, m2 -> 1, m3 -> -1,
  m4 -> 4}, {m1 -> -4, m2 -> 5, m3 -> -1, m4 -> -1}, {m1 -> 4,
  m2 -> -3, m3 -> -5, m4 -> 3}, {m1 -> -4, m2 -> 3, m3 -> -1,
  m4 -> 0}, {m1 -> 4, m2 -> -5, m3 -> -5, m4 -> 4}, {m1 -> 4,
  m2 -> -1, m3 -> -5, m4 -> 5}, {m1 -> 1, m2 -> -4, m3 -> -5,
  m4 -> 5}, {m1 -> 1, m2 -> 1, m3 -> -5, m4 -> 4}, {m1 -> 5, m2 -> -3,
   m3 -> -1, m4 -> 0}, {m1 -> 1, m2 -> 0, m3 -> -5,
  m4 -> 3}, {m1 -> 5, m2 -> -5, m3 -> -1, m4 -> 4}, {m1 -> 5,
  m2 -> -4, m3 -> -1, m4 -> -1}, {m1 -> -5, m2 -> 5, m3 -> 4,
  m4 -> -1}, {m1 -> -1, m2 -> 4, m3 -> -4, m4 -> 1}, {m1 -> 3,
  m2 -> -3, m3 -> 0, m4 -> 3}, {m1 -> 3, m2 -> 0, m3 -> 0,
  m4 -> -3}, {m1 -> -4, m2 -> 1, m3 -> -1, m4 -> 4}, {m1 -> 0,
  m2 -> -3, m3 -> 3, m4 -> 0}, {m1 -> 0, m2 -> 3, m3 -> 3,
  m4 -> -3}, {m1 -> 4, m2 -> -1, m3 -> -5, m4 -> 5}, {m1 -> -3,
  m2 -> 0, m3 -> 3, m4 -> -3}, {m1 -> -3, m2 -> 3, m3 -> 3,
  m4 -> 0}, {m1 -> 1, m2 -> -4, m3 -> -5, m4 -> 5}, {m1 -> 5,
  m2 -> -5, m3 -> -1, m4 -> 4}}

But my output here does not preserve the initial structure in the sense that I want the three initial conditional lists to become three elements of a first sublist and so on - the last three sublists would consist of four elements each.
I hope I am explaining that clearly. I just can't seem to get what I want from Map.

A: solutionsrules = Map[List @* ToRules, expr]

Alternatively, you can use
solutionsrules2 = solutions /. {And | Or -> List, Equal -> Rule};

solutionsrules2 == solutionsrules

True


text:
Q: Rails Mongoid search parents elements that have at least one child I have a rails 4 app and I have 2 objects: stores and books (referenced 1:n relation).
A store has many books, each book belongs to one store. Some stores don't have any books.
How can I make a query to find the 3 latest store that has at least 1 book - and the 3 latest stores that have no books ?
@stores = Store.order_by(:created_at => 'desc').limit(4).uniq
@books = Book.order_by(:created_at => 'desc').limit(4).uniq

This work but I don't know how to do a where(book.exists?) for store, or for the @books to make sure each book belongs to a unique store.

A: Basic CRUD operations in MongoDB operate on a single collection,
"join" capability is not yet implemented that would allow them to operate across two collections.
Once you understand this, you can easily construct two operations that will do what you want.
The following is the most obvious given the schema hints that you supplied.
To do anything more, you probably want to consider schema changes like embedding.
By definition, your supplied schema only allows a book to belong to one (unique by definition) store.
You can see this from the inspection of the books, that there is a single value store_id for each book.
Hope that this helps your understanding.
app/models/store.rb
class Store
  include Mongoid::Document
  include Mongoid::Timestamps
  field :name, type: String

  has_many :books
end

app/models/book.rb
class Book
  include Mongoid::Document
  include Mongoid::Timestamps
  field :title, type: String

  belongs_to :store
end

test/unit/store_test.rb
require 'test_helper'
require 'pp'
class StoreTest < ActiveSupport::TestCase
  def setup
    Mongoid.default_session.drop
  end
  test '0. mongoid version' do
    puts "\nMongoid::VERSION:#{Mongoid::VERSION}\nMoped::VERSION:#{Moped::VERSION}"
  end
  test 'store query has book, does not have book' do
    [
        ["Amazon.com", ["Outlander", "Taking It All"]],
        ["Barnes & Noble", ["Big Little Lies"]],
        ["Goodreads", []],
        ["Greenlight Bookstore", []],
        ["Powell's Books", ["Gone Girl", "Dark Skye"]],
        ["Strand Books", []]
    ].each do |store, books|
     store = Store.create(name: store)
     books.each do |title|
       store.books << Book.create(title: title)
     end
     sleep 1
    end
    assert_equal(6, Store.count)
    assert_equal(5, Book.count)
    puts
    store_ids_with_books = Book.distinct(:store_id)
    latest_stores_with_a_book = Store.in(_id: store_ids_with_books).order_by(:created_at => 'desc').limit(3).to_a
    puts "three latest stores with a book:"
    pp latest_stores_with_a_book
    latest_stores_without_a_book = Store.nin(_id: store_ids_with_books).order_by(:created_at => 'desc').limit(3).to_a
    puts "three latest stores without a book:"
    pp latest_stores_without_a_book
    puts "books:"
    pp Book.all.to_a
  end
end

rake test
Run options:

# Running tests:

[1/2] StoreTest#test_0._mongoid_version
Mongoid::VERSION:3.1.6
Moped::VERSION:1.5.2
[2/2] StoreTest#test_store_query_has_book,_does_not_have_book
three latest stores with a book:
[#<Store _id: 53f257287f11ba75e5000008, created_at: 2014-08-18 19:42:32 UTC, updated_at: 2014-08-18 19:42:32 UTC, name: "Powell's Books">,
 #<Store _id: 53f257257f11ba75e5000004, created_at: 2014-08-18 19:42:29 UTC, updated_at: 2014-08-18 19:42:29 UTC, name: "Barnes & Noble">,
 #<Store _id: 53f257247f11ba75e5000001, created_at: 2014-08-18 19:42:27 UTC, updated_at: 2014-08-18 19:42:27 UTC, name: "Amazon.com">]
three latest stores without a book:
[#<Store _id: 53f257297f11ba75e500000b, created_at: 2014-08-18 19:42:33 UTC, updated_at: 2014-08-18 19:42:33 UTC, name: "Strand Books">,
 #<Store _id: 53f257277f11ba75e5000007, created_at: 2014-08-18 19:42:31 UTC, updated_at: 2014-08-18 19:42:31 UTC, name: "Greenlight Bookstore">,
 #<Store _id: 53f257267f11ba75e5000006, created_at: 2014-08-18 19:42:30 UTC, updated_at: 2014-08-18 19:42:30 UTC, name: "Goodreads">]
books:
[#<Book _id: 53f257247f11ba75e5000002, created_at: 2014-08-18 19:42:28 UTC, updated_at: 2014-08-18 19:42:28 UTC, title: "Outlander", store_id: "53f257247f11ba75e5000001">,
 #<Book _id: 53f257247f11ba75e5000003, created_at: 2014-08-18 19:42:28 UTC, updated_at: 2014-08-18 19:42:28 UTC, title: "Taking It All", store_id: "53f257247f11ba75e5000001">,
 #<Book _id: 53f257257f11ba75e5000005, created_at: 2014-08-18 19:42:29 UTC, updated_at: 2014-08-18 19:42:29 UTC, title: "Big Little Lies", store_id: "53f257257f11ba75e5000004">,
 #<Book _id: 53f257287f11ba75e5000009, created_at: 2014-08-18 19:42:32 UTC, updated_at: 2014-08-18 19:42:32 UTC, title: "Gone Girl", store_id: "53f257287f11ba75e5000008">,
 #<Book _id: 53f257287f11ba75e500000a, created_at: 2014-08-18 19:42:32 UTC, updated_at: 2014-08-18 19:42:32 UTC, title: "Dark Skye", store_id: "53f257287f11ba75e5000008">]
Finished tests in 6.193234s, 0.3229 tests/s, 0.3229 assertions/s.
2 tests, 2 assertions, 0 failures, 0 errors, 0 skips


text:
Q: Horizontal legend React-vis I have a problem with horizontal legend in React-vis. I used this props orientation="horizontal", but nothing...
<DiscreteColorLegend width={2000} orientation="horizontal" items={json.items.map((item) => item.name)} colors={json.items.map((item) => item.color)} />

A: I just worked through this issue myself. In my case, the stylesheet wasn't being properly referenced. I did try to import it at the top of my js file like so:
import '../../../../node_modules/react-vis/dist/style.css';

But, I later found that the styles only actually worked once I copied my style.css file from /node_modules/react-vis/dist into app/assets/stylesheets, where my application.css file has a require_tree statement that includes the style sheet in question.
This is a bit of a bootleg workaround, as importing the stylesheet from its home in /node_modules/react-vis/dist is probably best practice, but it worked for me.


text:
Q: Best way to use voters/permissions on Symfony messenger async message handler? I am developing an application that have a Symfony Messenger component installed to handle async messages. The handler of message need to check some permissions for some particulars users, like if one determinate user should receive an email with information if have edition permissions for example.
To achieve that we use Symfony voters, but when we haven't any user logged into the system like in console commands and async messages is very annoying. What is the best solution to that? That are my main ideas:

*

*Force a "login" with the security context for message

*

*Pro: One way to check permissions without additional services. Voter is the service.

*Cons: When I have a collection of users check I should do "security context login" action multiple times. I think that is hard.

*Design a domain service to handle that.

*

*Pros: Solves the problem without force a login

*Cons: Duplicate code or differents ways to do the same things depending on the context (request, console command or async queue)

*A service that should be called by voter and domain service

*

*Cons: I think that add complexity to more simple issue

What is the best way? Any ideas outside of the previous three points?
Thank you so much

A: I would probably prefer to check user's permissions before dispatching a message, but let's think how we can approach if it's not a suitable case.
In order to check user permissions, you need to authenticate a user. But in case you're consuming a message asynchronously or executing a console command it's not straightforward, as you don't have an actual user. However, you can pass user id with your message or to a console command.
Let me share my idea of a simple solution for Symfony Messenger. In the Symfony Messenger, there is a concept of Stamps, which allows you to add metadata to your message. In our case it would be useful to pass a user id with a message, so we can authenticate a user within the message handling process.
Let's create a custom stamp to hold a user id. It's a simple PHP class, so no need to register it as a service.
<?php

namespace App\Messenger\Stamp;

use Symfony\Component\Messenger\Stamp\StampInterface;

class AuthenticationStamp implements StampInterface
{
    private $userId;

    public function __construct(string $userId)
    {
        $this->userId = $userId;
    }

    public function getUserId(): string
    {
        return $this->userId;
    }
}

Now we can add the stamp to a message.
$message = new SampleMessage($payload);
$this->messageBus->dispatch(
    (new Envelope($message))
        ->with(new AuthenticationStamp($userId))
);

We need to receive and handle the stamp in order to authenticate a user. Symfony Messenger has a concept of Middlewares, so let's create one to handle stamp when we receive a message by a worker. It would check if the message contains the AuthenticationStamp and authenticate a user if the user is not authenticated at the moment.
<?php

namespace App\Messenger\Middleware;

use App\Messenger\Stamp\AuthenticationStamp;
use App\Repository\UserRepositoryInterface;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Middleware\MiddlewareInterface;
use Symfony\Component\Messenger\Middleware\StackInterface;
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;

class AuthenticationMiddleware implements MiddlewareInterface
{
    private $tokenStorage;
    private $userRepository;

    public function __construct(TokenStorageInterface $tokenStorage, UserRepositoryInterface $userRepository)
    {
        $this->tokenStorage = $tokenStorage;
        $this->userRepository = $userRepository;
    }

    public function handle(Envelope $envelope, StackInterface $stack): Envelope
    {
        /** @var AuthenticationStamp|null $authenticationStamp */
        if ($authenticationStamp = $envelope->last(AuthenticationStamp::class)) {
            $userId = $authenticationStamp->getUserId();

            $token = $this->tokenStorage->getToken();
            if (null === $token || $token instanceof AnonymousToken) {
                $user = $this->userRepository->find($userId);
                if ($user) {
                    $this->tokenStorage->setToken(new UsernamePasswordToken(
                        $user,
                        null,
                        'provider',
                        $user->getRoles())
                    );
                }
            }
        }

        return $stack->next()->handle($envelope, $stack);
    }
}

Let's register it as a service (or autowire) and include into the messenger configuration definition.
framework:
  messenger:
    buses:
      messenger.bus.default:
        middleware:
          - 'App\Messenger\Middleware\AuthenticationMiddleware'

That's pretty much it. Now you should be able to use your regular way to check user's permissions, for example, voters.
As for console command, I would go for an authentication service, which would authenticate a user if the user id is passed to a command.


text:
Q: Better practice to throw custom PHP errors using procedural way I know this question may be asked previously but I want to show my code and I would like to know that whether am doing a simple thing or complicating the code? Moreover answers say use try and catch but am going with procedural method so I would like to know that am I going right?
What I do it, for example a contact form
<?php
if(isset($_POST['contact'])) {
    $throw_error = array();

    //First Block Is Validation
    if($_POST['first_name'] == '' || $_POST['last_name'] == '') {
        $throw_error['field_blank'] = 'Fields Cannot Be Blank';
    } elseif(strlen($_POST['first_name']) < 3) {
         $throw_error['char_len'] = 'First Name Cannot Be Less Than 3 Characters';
    }

    //Second Block Is Process If No Errors Are Found
    if(empty($throw_error)) {
        $first_name = $_POST['first_name'];
       //Don't worry about the sanitizing part, am doing it
       //Process the form ahead and then redirect using header()
       }
    } elseif(!empty($throw_error)) { //Third Block To Throw Error If Any Errors Found
        if(isset($throw_error['field_blank'])) {
            echo  $throw_error['field_blank'];
        } elseif(isset($throw_error['char_len'])) {
            echo  $throw_error['char_len'];
        }
    }
?>

<form>
   <input type="text" name="first_name" />
   <input type="text" name="last_name" />
   <input type="submit" value="Submit" name="contact" />
</form>

A: A try/catch you be great here. It eliminates all necessary for a throw_error array, as well as cuts down dramatically on the code.
try{
    $first_name = '';
    if(isset($_POST['contact'])) {
        if($_POST['first_name'] == '' || $_POST['last_name'] == '') {
            throw new Exception('Fields Cannot Be Blank');
        } elseif(strlen($_POST['first_name']) < 3) {
             throw new Exception('First Name Cannot Be Less Than 3 Characters');
        }
        $first_name = $_POST['first_name'];
    }
}catch(Exception $e){
    echo $e->getMessage();
}

If you were looking to pass an array to this catch statement, the easist way that I have found, is to serialize the array, then unserialize once complete. This will allow you to print all errors at once:
try{
    $first_name = '';
    if(isset($_POST['contact'])) {
        if($_POST['first_name'] == '' || $_POST['last_name'] == '') {
            $throw_error[] = 'Fields Cannot Be Blank';
        }
        if(strlen($_POST['first_name']) < 3) {
             $throw_error[] = 'First Name Cannot Be Less Than 3 Characters';
        }
        if(isset($throw_error)){
            throw new Exception(serialize($throw_error));
        }
        $first_name = $_POST['first_name'];
    }
}catch(Exception $e){
    $errors = unserialize($e->getMessage());
    foreach($errors as $error){
        echo $error.'
';
    }
}

A: I would also recommend using Try/Catch. You can still use it in procedural blocks.
If you are dead set against it, this code looks like it will do what you want it to do, but it's over-engineered. Since the user can either have a field_blank or char_len error, you only need a single string error variable.
$error = NULL;
if($_POST['first_name'] == '' || $_POST['last_name'] == '') {
    $error = 'Fields Cannot Be Blank';
} elseif(strlen($_POST['first_name']) < 3) {
     $error = 'First Name Cannot Be Less Than 3 Characters';
}

...
if(!empty($error)) {
   echo $error;
}

If you need to catch and display multiple non-exclusive errors, you can use the array you cited in your sample code and just iterate over the values rather than making a giant if/elseif block.
} elseif(!empty($throw_error)) { //Third Block To Throw Error If Any Errors Found
    foreach($throw_error as $key => $message) {
        echo $message.'
';
    }
}


text:
Q: Ubuntu One and mounted drives I'm trying to get my music onto Ubuntu One so I can keep it synced, but I'm having a problem.
My music is on my NAS (running on a Linux Server), it's mounted in my home directory.
I can set the directory as synchronised, however none of the files get synced.  If I move them into a standard folder on the system they do sync though.
Is this a problem with Ubuntu One or is it a limitation?

A: This is a limitation. Currently, we don't support syncing from folders outside your home directory.
The main reason is that Ubuntu One does synchronization. If you synced a removable device, and then uplugged it, it would see all the files disappear, and also remove all its contents from the website and all your other devices.


text:
Q: Within an interface specified by a core component, should it request IReadOnlyCollection or IEnumerable? In thinking about the principle of "be conservative in what you send and liberal in what you accept", I generally try to make my methods receive IEnumerable parameters, but emit a IReadOnlyCollection (except where deferred execution is truly valuable, then I do emit an IEnumerable).
However, I just realized that when specifying methods in an interface, this may be reversed. Is that true?
Should my interface specifications be telling any implementers "I'll give you an IReadOnlyCollection, but you can just give me any old IEnumerable back"? (Again, if deferred execution makes sense, I would provide an IEnumerable as a parameter type instead.) This makes those methods the reverse, accepting a narrow/conservative set but emitting a broad/liberal one. However, this seems right to me because with the dependency inversion, in reality the input arguments when the method is called are really the output arguments of the core system (specifying the interface).
I'm just wondering if my thinking is right on this or not. It seems that making the implementer side as easy as possible is really where the benefit is.
I'm realizing that part of the issue comes from my concern about not requiring implementers to think deeply about whether deferred execution makes sense or not. Knowing when an enumerable will be enumerated can be very important in a system, and with the separation of concerns that an interface can help bring to code, I wouldn't want to be so liberal in what the interface method outputs (which is ultimately an input to the core system) that improperly-deferred IEnumerables get thrown around...
This is not about speed. Not sure why this was raised, but please do not even think for a second about performance implications here. That is not the question.

A: I have similar concerns as you. Technically, you can't guarantee anything about IEnumerable other than that you can enumerate over it once. That may be a benefit--for instance, reading out of a buffered stream. Because the framework didn't support anything less specific than ICollection, I think this became the default for developers who didn't want to expose the ability to add elements to the enumeration. With the advent of .NET 4.5, we finally got the interface that express more properly what's being returned.
Returning IEnumerable for a List isn't wrong, but I do think that returning IReadOnlyCollection is a better choice when you can anticipate the data will be iterated over multiple times. ReSharper, for instance, will warn about multiple iterations over IEnumerable. As a library developer, I think that's more valid than a developer worrying about whether an implementation is deferred or not.


text:
Q: Attachment Data Type in Access? I've read that the attachment data type in MS Access should only be used if the database will be use within SharePoint.
Could someone recommend an alternative to this data type? I'm developing a database for users to submit entries and they would like the option to attach notes/pictures with some of the entries.

A: Generally, I find that storing a path to the file you want to attach is the best option, if it is viable.
If they are images, the image control now has a ControlSource property, so you can bind it to a field in the table that contains the path.


text:
Q: cannot scroll iframe content on Firefox I am using a modal window on my page, which actually has a frameset page called within an iframe. The code to dynamically append the modal window is like;
$("#TB_window").append(" ");

The generated HTML looks like;

Now while on IE, I can scroll through the main page as well as the inner frames, on Firefox, I cannot scroll completely through the main frameset page..
Also to summarize this issue and this is something which should help identify where the problem lies;
If I hide the Windows Taskbar so that more vertical space is available for Firefox window, I can see the complete frameset page ...So something like viewport or based on display height. Reverse is also true i.e. if I drag the taskbar up, so that less space is available for FF, it only shows that much content and I cannot scroll the rest..
Please help me. Thank you.

A: Add this
$("body").css("overflow", "auto");
$("html").css("overflow", "auto");

to top of tb_show function in thickbox.js uncompressed here is exapmple
This is How it's look
function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link

    try {
        if (typeof document.body.style.maxHeight

change it to this
function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link
    $("body").css("overflow", "auto");
    $("html").css("overflow", "auto");
    try {
        if (typeof document.body.style.maxHeight

And leave the rest in peace if not work post it to jsfiddle let me see it


text:
Q: How to add Class attribute into Custom Html Helper in MVC? I want to add Class into my Custom Html Helper. I am creating a Html Helper for Image.
I got confused how to add class into custom html helper.
Any suggestion is highly appreciated.
I want helper method for this scenario.

Code
 public static IHtmlString Image(this HtmlHelper helper, string src, string alt,string height, string width)
        {
            TagBuilder tb = new TagBuilder("img");
            tb.Attributes.Add("src", VirtualPathUtility.ToAbsolute(src));
            tb.Attributes.Add("alt", alt);
            tb.Attributes.Add("height", height);
            tb.Attributes.Add("width", width);

            return new MvcHtmlString(tb.ToString(TagRenderMode.SelfClosing));
        }

A:     public static IHtmlString Image(this HtmlHelper helper, string src, string alt, string height, string width, params string[] allClasses)
    {
        TagBuilder tb = new TagBuilder("img");
        tb.Attributes.Add("src", VirtualPathUtility.ToAbsolute(src));
        tb.Attributes.Add("alt", alt);
        if (!string.IsNullOrEmpty(height) || !string.IsNullOrEmpty(width))
        {
            StringBuilder value = new StringBuilder();

            if (!string.IsNullOrEmpty(height))
                value.AppendFormat("height:{0};", height);

            if (!string.IsNullOrEmpty(width))
                value.AppendFormat("width:{0};", width);

            tb.Attributes.Add("style", value.ToString());
        }
        if (allClasses?.Any() ?? false)
            tb.Attributes.Add("class", string.Join(" ", allClasses));

        return new MvcHtmlString(tb.ToString(TagRenderMode.SelfClosing));
    }

Something like that?

A: You have this code:

which works. Now you want to create an html helper so you created this:
public static IHtmlString Image(this HtmlHelper helper, string src, string alt, string height, string width)
{
    TagBuilder tb = new TagBuilder("img");
    tb.Attributes.Add("src", VirtualPathUtility.ToAbsolute(src));
    tb.Attributes.Add("alt", alt);
    tb.Attributes.Add("height", height);
    tb.Attributes.Add("width", width);

    return new MvcHtmlString(tb.ToString(TagRenderMode.SelfClosing));
}

but this helper will not produce the exact same html as the one above. It will treat each height and width as separate attributes and render this:

Correct Way
Whenever you create HTML helpers, see how the MVC Framework has done it because they invest a lot of time and money into making it and thus your code will be more inline with the pattern they use and it will also be more reusable.
It is not a good idea to include any of the properties that are in style attribute in your HTML or HTML helper (which just renders HTML eventually). A better approach is to keep the separations of structure and style separate: Separation of Concerns. Here is how to do so the MVC Framework way:
public static IHtmlString Image(this HtmlHelper helper, object htmlAttributes)
{
    TagBuilder tb = new TagBuilder("img");
    RouteValueDictionary htmlAttrs = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);
    foreach (var thisAttribute in htmlAttrs)
    {
        tb.Attributes.Add(thisAttribute.Key, thisAttribute.Value.ToString());
    }

    return new MvcHtmlString(tb.ToString(TagRenderMode.SelfClosing));
}

Usage
@Html.Image(new { Src = VirtualPathUtility.ToAbsolute("your path"), Alt = "alt", @Class = "my-stackoverflow-image" })

Notice how we are not passing style to the helper, that is what you want. You want your HTML to be style free and keep that in CSS file. Finally add your style to the a css file (MVC creates Site.css so you can just use that) like this:
.my-stackoverflow-image {
    height: 20px;
    width: 30px;
}

This is great because if you want to change your style, you do not need to recompile and in some cases when you work in a team, the front end designer (CSS expert) can add all sort of fancy CSS to it. All you need is to tell the front end designer that the image uses my-stackoverflow-image class.


text:
Q: ESLint couldn't find the config "prettier/@typescript-eslint" after relocating .eslintrc to parent I have a folder structure like
parentFolder > componentA
             > componentB
             > componentC

Each component has a package.json which defines a yarn lint command (eslint "myFilter" --no-error-on-unmatched-pattern). And each component has its own .eslintrc and .prettierrc
When I am in a componentA/B/C folder and run yarn lint, it is working as expected.
Since all of the .eslintrc are the same in each component folder, I moved the file under parentFolder and delete the copies in the component folders. When I call yarn lint, it used the .eslintrc in the parentFolder, but, I am getting an error.

Oops! Something went wrong! :(
ESLint: 6.8.0.
ESLint couldn't find the config "prettier/@typescript-eslint" to
extend from. Please check that the name of the config is correct.

I moved the .prettierrc to the parent folder, but, it couldn't find it. What should I do? Thank you
Update: I noticed if I add the prettier on the package.json in the parent folder and run the yarn install, it works. But, I don't know if this is the proper way to do it.

A: prettier/@typescript-eslint has been removed in eslint-config-prettier v8.0.0. Just remove it from your ESLint config file. The only entry in extends that is needed now for Prettier and ESLint to not conflict is "prettier" (make sure it's the last one in extends).

A: prettier/@typescript-eslint was removed in eslint-config-prettier v8.0.0
see https://github.com/prettier/eslint-config-prettier/issues/173
From v8, there is simpler configuration. Unfortunately there are still many How-Tos on the Internet that mention old config files that are all gone now.

A: I got the same error when I updated to eslint-config-prettier 8.0.0, I fixed it by changing .eslintrc.js to:
    "plugins": ['@typescript-eslint'],
    "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]

Make sure your package.json includes:
 @typescript-eslint/eslint-plugin
 @typescript-eslint/parser

You can of course include other plugins and other extends, you can find all the optons: https://www.npmjs.com/package/@typescript-eslint/eslint-plugin

A: just  to in  the  package .josn  add  this  package
as  dev
 "@typescript-eslint/eslint-plugin": "^4.30.0",
    "@typescript-eslint/parser": "^4.30.0",
   "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-prettier": "^4.0.0",

in eslint.js look  to  this  file add to try  to  cheack  if  it is the  same
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
    'plugin:react/recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:react-hooks/recommended',
    'plugin:prettier/recommended',
    'eslint:recommended'

],
"plugins": ['@typescript-eslint'],

parserOptions: {
    ecmaVersion: 2020,
    sourceType: 'module',
    ecmaFeatures: {
        jsx: true,
    },
},
rules: {
    'react/react-in-jsx-scope': 'off',

},
settings: {
    react: {
        version: 'detect',
    },
},

};


text:
Q: Connection attempt failed because party did not respond error in ASP.Net anyone  know how to fix it? Whenever I run my service it never responds, I know it isn't the service as I have one similar running in a different aspx file running. I've looked into it and it's something to do with the web.config file but I don't know where. I was given a small web config file however when you put it in the place it says it doesn't like one specific line of coding in it.
This is the error I am getting:

Server Error in '/webroot' Application.
  A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 195.195.43.253:880
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 195.195.43.253:880
Source Error:
  Line 29:         Response.Write(sortcode & " " & accountnumber & " " & selectcase)
  Line 30:
  Line 31:         screen.Text = balance.CheckBalance(accountnumber)
  Line 32:     End Sub
  Line 33:
Source File: H:\webroot\menu.aspx    Line: 31
Stack Trace:
[SocketException (0x274c): A connection attempt failed because the connected party did >not properly respond after a period of time, or established connection failed because >connected host has failed to respond 195.195.43.253:880]
    System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress >socketAddress) +239
    System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +35
    System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, >Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult >asyncResult, Int32 timeout, Exception& exception) +224
[WebException: Unable to connect to the remote server]
    System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) +1872945
    System.Net.HttpWebRequest.GetRequestStream() +13
    System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, >Object[] parameters) +103
    test.HSBC.CheckBalance(Int64 accountnumber) +72
    ASP.menu_aspx.checkbalance(Object sender, EventArgs e) in H:\webroot\menu.aspx:31
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
  System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(St>ring eventArgument) +10
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String >eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean >includeStagesAfterAsyncPoint) +1565
Version Information: Microsoft .NET Framework Version:2.0.50727.5448; ASP.NET >Version:2.0.50727.5420

This is the asmx file:
    <%@ Page Language="vb" Debug="true" %>
<%@ Import Namespace = "HSBC" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <title>Welcome to HSBC</title>

     <form id="form1" runat="server" method="post">
    <asp:Panel ID="Panel3" runat="server" style="top: 15px; left: 10px; position: absolute; height: 225px; width: 200px">
    </asp:Panel>

           <asp:Panel ID="Panel2" runat="server" Height="490px" Width="1024px" style="top: 17px; left: 10px; position: absolute">

                        <%-- Onclick is to put the numbers into the textbox --%>
                        <asp:button ID="btn1" runat="server" Text="1" width= "334px" height= "118px" style="top: 249px; left: 15px; position: absolute"  />
                        <asp:button ID="btn2" runat="server" Text="2" width= "334px" height= "118px" style="top: 249px; left: 355px; position: absolute" />
                        <asp:button ID="btn3" runat="server" Text="3" height= "118px" style="top: 249px; left: 694px; position: absolute; width: 328px;"   />
                        <asp:button ID="btn4" runat="server" Text="4" width= "334px" height= "118px" style="top: 372px; left: 15px; position: absolute; right: 1021px;" />
                        <asp:button ID="btn5" runat="server" Text="5" width= "334px" height= "118px" style="top: 372px; left: 355px; position: absolute" />
                        <asp:Button ID="btn6" runat="server" Text="6" height="118px" style="top: 372px; left: 695px; position: absolute; width: 327px;" />
                        <asp:button ID="btn7" runat="server" Text="7" width= "334px" height= "118px" style="top: 495px; left: 15px; position: absolute" />
                        <asp:button ID="btn8" runat="server" Text="8" width= "334px" height= "118px" style="top: 495px; left: 356px; position: absolute"  />
                        <asp:Button ID="btn9" runat="server" Text="9" height="118px" style="top: 495px; left: 694px; position: absolute; width: 329px;" />
                        <asp:button ID="btn0" runat="server" Text="0" width= "334px" height= "118px" style="top: 618px; left: 356px; position: absolute" />

                            <%-- Points to Visa Web Service to use their services --%>
                            <asp:button ID="submit" runat="server" Text="Enter" height= "118px" style="top: 618px; left: 695px; position: absolute; width: 327px;" />

                            <%-- Clears the text box --%>
                            <asp:Button ID="cancel" runat="server" Text="Cancel/Clear" height="118px" style="top: 618px; left: 15px; position: absolute"  width="334px" />

                        <asp:Panel ID="Panel4" runat="server" style="top: 1px; left: 827px; position: absolute; height: 221px; width: 196px">
                            <asp:Button ID="Button7" runat="server"
                                style="width: 195px; height: 46px; top: 1px; left: -210px; position: absolute"
                                Text="Check Balance" onclick="checkbalance" />
                            <asp:Button ID="Button8" runat="server"
                                style="width: 195px; height: 46px; top: 61px; left: -200px; position: absolute"
                                Text="Withdraw Cash" onclick="withdraw" />

                        </asp:Panel>

                        <asp:Label ID="lblBalance" runat="server"></asp:Label>
                        <asp:TextBox ID="screen" runat="server"

                            style="width: 383px; height: 214px; top: 8px; left: 221px; position: absolute"></asp:TextBox>
             </asp:Panel>
          <asp:Label ID="testbank" runat="server"></asp:Label>

                            <asp:Label ID="testsort" runat="server"></asp:Label>

                            <asp:Label ID="testselectc" runat="server"></asp:Label>

                            </form>

The error tells me it's on the actual call part screen.Text = balance.Withdraw(accountnumber, amount). I know it is working as I've commented it out had it writing what is in the variables to the screen.
This is what is in the asmx file
  <%@ WebService Language="vb" Class="HSBC" %>
Imports System
Imports System.Web.Services
Imports System.Xml.Serialization
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Services.Protocols

'Imports everything that is needed ready to use within the web services

<WebService(Namespace:="http://heweb.grimsby.ac.uk/s0082708/")> Public Class HSBC

    'Public to allow access

    Inherits System.Web.Services.WebService

    Public AuthSoapHd As New AuthenticationHeader

    'Inherits the imports to use in the web service

    Public Auth As New AuthenticationHeader

    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    '                                                   Unsecure Balance Call
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    <WebMethod()> Public Function CheckBalance(ByVal accountnumber As Long) As String
        Return CheckBal(accountnumber)
    End Function

    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    '                                                   Check Balance Call - Secure (SOAP HEADER AUTH)
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    '<WebMethod(), SoapHeader("Auth")> Public Function AuthCheckBalance(ByVal accountnumber As Long) As String
    '   If (Auth.username = "HSBC" And Auth.password = "HSBC") Then
    '      Return CheckBal(accountnumber)
    ' Else
    '    Throw New Exception("Did not manage to login")
    ' End If

    'End Function

    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    '                                   Check Balance function
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    'Creates a service web method

    Private Function CheckBal(ByVal accountnumber As Long) As String

        Dim account As String = CType(Session.Item("sessionaccount"), String)

        'Database drivers, connections and commands
        Dim BalanceDr As OleDbDataReader
        Dim BalanceConn As OleDbConnection
        Dim BalanceCmd As OleDbCommand

        'Database connection string
        Dim Connx As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../database/HSBC.mdb") & ";"

        'SQL

        Dim SQL As String = "SELECT Transaction_Amount FROM Transaction WHERE Account_Number = " & _
        account

        Dim bal As String

        'Open the connection to the database
        BalanceConn = New OleDbConnection(Connx)
        BalanceCmd = New OleDbCommand(SQL, BalanceConn)
        BalanceConn.Open()

        'Create a DataReader that will return information.
        BalanceDr = _
        BalanceCmd.ExecuteReader(CommandBehavior.CloseConnection)

        If BalanceDr.Read() Then
            'A row was returned
            bal = BalanceDr(0)
        Else
            'A row was not returned
            bal = "No Name Found"
        End If

        BalanceDr.Close()
        Return bal
    End Function
End Class

And this is the web config file:
 <?xml version="1.0"?>
<configuration>
    <configSections>
        <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

                <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

                </sectionGroup>
            </sectionGroup>
        </sectionGroup>
    </configSections>
    <appSettings>
        Web references sit here
    </appSettings>
    <connectionStrings/>
    <system.web>

        <compilation debug="false">
            <assemblies>
                <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            </assemblies>
        </compilation>

        <authentication mode="Windows"/>

        <pages>
            <controls>
                <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            </controls>
        </pages>
        <httpHandlers>
            <remove verb="*" path="*.asmx"/>
            <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
        </httpHandlers>
        <httpModules>
            <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        </httpModules>
    </system.web>
    <system.codedom>
        <compilers>
            <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
                <providerOption name="CompilerVersion" value="v3.5"/>
                <providerOption name="WarnAsError" value="false"/>
            </compiler>
            <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
                <providerOption name="CompilerVersion" value="v3.5"/>
                <providerOption name="OptionInfer" value="true"/>
                <providerOption name="WarnAsError" value="false"/>
            </compiler>
        </compilers>
    </system.codedom>

    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <modules>
            <remove name="ScriptModule"/>
            <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        </modules>
        <handlers>
            <remove name="WebServiceHandlerFactory-Integrated"/>
            <remove name="ScriptHandlerFactory"/>
            <remove name="ScriptHandlerFactoryAppServices"/>
            <remove name="ScriptResource"/>
            <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        </handlers>
    </system.webServer>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
                <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
                <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

Does anyone have any ideas what is causing it to fail connection?

A: It was redirecting wrong in the web config.
http://www.example.com:808/example
Deleted the 808 in the address like all the others without the 808 and it seems to be working fine as it complained about the virtual directly, it was running from usb stick, so it seems to be working now. So if anyone else has this problem check the web ref part of your web.config as it could be that.


text:
Q: How to inject service in DTO class? (NestJS) How to inject service in DTO class?
I have DTO and Service
dto
@Injectable()
export class DTO {
  constructor(private readonly testService: TestService) {}

  @Validate(IsValidAddress)
  address: string;

  @Expose()
  get realAddress() {
    return this.testService.isValidAddress(this.address);
  }
}

and dto used in addressController
@Controller('address')
export class AddressController {
  constructor(private readonly addressService: AddressService) {}

  @Get('balance')
  getBalance(@Param() params: DTO) {
    console.log(params.realAddress);
    return this.addressService.getBalance({ ...params });
  }
}

this throw error that testService undefined..
How can i use that service in dto class?


text:
Q: Открыть файл с помощю другой
У меня есть файл base.db
Когда я открывал его показывалось предложение: открыть с помощю другого приложения
Я открыл его с помощю sqlite studio
Теперь я не знаю как сделать по прежднему...

A: Я так понял, вы хотите, чтобы файл открывался по умолчанию с помощью той программы, с помощью которой он открывался по умолчанию раньше.
Вот как можно решить вашу проблему:

*

*Нужно щёлкнуть правой клавишей мыши по файлу, выбрать <открыть c помощью<выбрать программу.

*Поставьте галочку в пункте "Использовать выбранную программу для всех файлов такого типа".

*Выберите программу, с помощью которой вы хотите открывать этот тип файлов в будущем.

Вот скриншоты:


text:
Q: Draw the graph polar coordinates Draw the graph $r=3\cos a$  and  write me how do you this?
Show me polar coordinates system $a=360°$.

A: $$r=3\cos\alpha\\x=r\cos\alpha\\y=r\sin\alpha$$
From here $$y=3\sin\alpha\cos\alpha=\frac 32\sin(2\alpha)\\x=3\cos^2\alpha=\frac 32\cos(2\alpha)-\frac 32$$
Moving the last term in $x$ to the left hand side, squaring the two equations, and summing them, you get $$\left(x-\frac 32\right)^2+y^2=\left(\frac32\right)^2$$
This is the equation of a circle with radius $1.5$ and center at $(1.5,0)$


text:
Q: How to change the field name by using existing header row name of the table; Google BigQuery platform enter image description heremy dataset are from google drive in csv format, already uploaded into BigQuery. (sandbox version)
and I found out that the existing header row are not detected automatically. also the table have null row as gap/space and table information note. the existing header row is still in the table but have misplaced at different row automatically.
then preview mode shows that they are using string_field_0, string_field_1, string_field_2, ... as field names.
my goal is how can I change the field name by using the existing header row of the table?
I have tried upload with tick / untick auto-detect box function during the uploading process. the result does not help.

A: yeahh, I already found out the way how to ensure the existing column header detected and being there as field name.
acknowledge that this situation is table have null row before the header row. so we need to know at what row the header row is located.
the solution is during upload process, the last one before hit button create. go to advanced option and enter number of row where the header row is located.
then tadaa, the header row is used as field name.


text:
Q: How to insert single quotes in double quotes in VB .NET I'm trying to insert single Quotation marks inside a double quotation marks...
Beginning Quotation mark like this """ ..... and ending Quotation mark like this """ ...
My code:
objWriter.WriteLine("
" + """ + "" + BP1.Text + "" + """ + " ― " + "" + BPGB1.Text + "" + "
")

A: 1st:
The characters that you mentioned are not a single quote, are a double quote.

*

*Left Double Quotation Mark

*Right Double Quotation Mark
2nd:
In Vb.Net, unlike C#, string concatenations are made with the & operator, avoid using the + operator, it will give you unexpected results in some scenarios.

The Visual Studio's code editor automaticaly replaces the characters that you've mentioned with a common double quote, however, knowing the Unicode references you can get the specific characters at execution time then concat them as normally or using the String.Format() method in this way:
Dim lQuotes As Char = Convert.ToChar(&H201C) ' "
Dim rQuotes As Char = Convert.ToChar(&H201D) ' "

Dim str As String = String.Format("{0}Hello World{1}", lQuotes, rQuotes)

Console.WriteLine(str) ' "Hello World"

UPDATE
An example with the string that you've provided:
Dim lQuotes As Char = Convert.ToChar(&H201C) ' "
Dim rQuotes As Char = Convert.ToChar(&H201D) ' "

Dim str As String =
    String.Format("
{0}{2}{1} ― {3}
",
                  lQuotes, rQuotes, BP1.Text, BPGB1.Text)

objWriter.WriteLine(str)

A: It seems you used the wrong character for single quotation:
objWriter.WriteLine("
" + "'" + "" + BP1.Text + "" + "'" + " ― " + "" + BPGB1.Text + "" + "
")

A: not sure if this works or not:
objWriter.WriteLine("
" & """" & "" + BP1.Text + "" + """" + " ― " + "" + BPGB1.Text + "" + "
")

or maybe even this
objWriter.WriteLine("
" & """" & "" + BP1.Text + "" + """" + " ― " + "" + BPGB1.Text + "" + "
")

A: You will have to change the &"""" with chr(24)
so you would have something like this objWriter.WriteLine("
*" & chr(34 ) & chr(34) & "" + BP1.Text + ". . . . .


text:
Q: SQL Server on Linux "Verify that the certificate file(s) are of a supported format." I'm running SQL Server on Linux (CentOS 8)
Microsoft SQL Server 2017 (RTM-CU19) (KB4535007) - 14.0.3281.6 (X64)
I'm trying to setup TLS certificates for incoming connections and followed these commands
/opt/mssql/bin/mssql-conf set network.tlscert (path to pem file)
/opt/mssql/bin/mssql-conf set network.tlskey (path to key file)
/opt/mssql/bin/mssql-conf set network.tlsprotocols 1.2
/opt/mssql/bin/mssql-conf set network.forceencryption 1

However when the server starts, it crashes after a few seconds with the following error:
2022-07-13 15:37:28.85 spid19s     Error: 49941, Severity: 16, State: 1.
2022-07-13 15:37:28.85 spid19s     Unable to load one or more of the user-specified certificate file(s). Verify that the certificate file(s) are of a supported format.
2022-07-13 15:37:28.89 spid19s     Error: 49939, Severity: 16, State: 1.
2022-07-13 15:37:28.89 spid19s     Unable to initialize user-specified certificate configuration. The server is being shut down. Verify that the certificate is correctly configured. Error[30]. State[51].

The certificates themselves where created using openssl. I have a self-signed CA that I used to sign all my certificates. These have worked without issue in other applications (e.g NGINX / Tomcat)
I've verified the certificate subject and SAN entries are all accurate.
The error is very ambiguous. I'm not sure what is meant by "supported format" and there is nothing on Microsofts sites to suggest what this is. They themselves give examples using PEM format certificates.


text:
Q: No audio output on Ubuntu 21.10, Dell Latitude 14 1404 Rugged Audio on Windows works perfectly, no issues. No option in BIOS to disable.
Speakers are not muted in GUI or in Alsamixer, though Alsamixer pulls up HDA Intel HDMI first, but when switching to HDA Intel PCH nothing changes.
I have installed, updated, uninstalled, disabled and enabled PulseAudio
Output of lspci -v | grep -A7 -i "audio":
00:03.0 Audio device: Intel Corporation Haswell-ULT HD Audio Controller (rev 0b)
    Subsystem: Dell Haswell-ULT HD Audio Controller
    Flags: bus master, fast devsel, latency 0, IRQ 53
    Memory at f7c34000 (64-bit, non-prefetchable) [size=16K]
    Capabilities: <access denied>
    Kernel driver in use: snd_hda_intel
    Kernel modules: snd_hda_intel

00:14.0 USB controller: Intel Corporation 8 Series USB xHCI HC (rev 04) (prog-if 30 [XHCI])
--
00:1b.0 Audio device: Intel Corporation 8 Series HD Audio Controller (rev 04)
    Subsystem: Dell 8 Series HD Audio Controller
    Flags: bus master, fast devsel, latency 0, IRQ 52
    Memory at f7c30000 (64-bit, non-prefetchable) [size=16K]
    Capabilities: <access denied>
    Kernel driver in use: snd_hda_intel
    Kernel modules: snd_hda_intel

00:1c.0 PCI bridge: Intel Corporation 8 Series PCI Express Root Port 1 (rev e4) (prog-if 00 [Normal decode])

Any ideas? I think I've read every forum post related to this computer and audio in general, and still hit a wall.

A: not sure if it will help a Latitude but add this parameter to the kernel  command line:
snd_intel_dspcfg.dsp_driver=3

I had to do this on a Dell Venue Pro 11 and the sound worked perfectly.
It is for kernels after 5.10 as a change was made to the drivers.
Source: https://fedoraproject.org/wiki/Changes/SofDefaultForIntelLpe


text: Q: Tool to Monitor Performance of H2 Database I wonder if there is any tool to monitor the performance of H2 database, such as IO, CPU usage. Live performance with graphs such as Oracle's Enterprise Manager. If not, is there at least anything like a diagnostic tool to give suggestions of missing indexes, etc?


text:
Q: Show postgis geometry transform point? I want to show my table with its id and its geom point.
I just can show geometry
"010300000001000000040000009EDBE50D6862404000000000A06E5E407CCF473E0D9B3B4000000000002E5D407C535EB51A3A3C4000000000D02E60409EDBE50D6862404000000000A06E5E40"
I want it show as I execute sql
SELECT ST_AsText(geom) from gtest where polyname='ttttttt';
result, e.g.
"POLYGON((32.7688004848817 121.728515625,27.6056708264655 116.71875,28.2269700389183 129.462890625,32.7688004848817 121.728515625))"
this is my jsp code
<%@ page language="java" contentType="text/html;charset=utf-8" import="java.io.*" import="java.util.*" import="java.sql.*"%>
<%
    Class.forName("org.postgresql.Driver").newInstance();
    String url="jdbc:postgresql://localhost/template_postgis_20";
    String user="postgres";
    String password="123456";
    Connection con=DriverManager.getConnection(url,user,password);
    Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
    String sql="select * from gtest";
    ResultSet rs=stmt.executeQuery(sql);
    while(rs.next()){
%>
    <%=rs.getString("polyname")%>,
    <%=rs.getString("geom")%>,//I want it transform to SQL:SELECT ST_AsText(geom) from gtest
<%
    }
rs.last();
rs.close();
stmt.close();
con.close();
%>

My postgresql sql:
CREATE TABLE gtest
(
  polyname character varying(20) NOT NULL,
  geom geometry(Polygon),
  CONSTRAINT gtest_pkey PRIMARY KEY (polyname)
)


text:
Q: Run SQL Unit Test in TFS Build Pipeline I have a SQL Unit test project (.sqlproj) as part of my solution. What do I do to run my tests in my build pipeline? If a test fails I would like the build to break?
Visual Studio Test Assemblies is for C# Unit Tests and not SQL


text:
Q: Vanishing zeroes in matrix powers For a matrix $M\in\mathbb{R}^{n\times n}_{\geq 0}$ with nonnegative entries, we define $m$ as the smallest positive integer such that all the entries of $M^m$ are strictly positive (if there is one).
What is, as a function of $n$, the maximum possible (finite) value of $m$ over all possible choices of $M$?
My attempt: By taking the matrix $M(i,i+1)=M(1,1)=M(1,n)=1$ else $M(i,j)=0$ I got $m=6,12,18$ for $n=4,7,10$. So it seems that $m=2n-2$?
I added the "probability" tag because Markov chain convergence was the motivation.

A: This is a combination of the answer Gerry Myerson gave on MSE, the paper linked there, and the comments here.
The largest possible minimum $m$ is $(n-1)^2+1 = n^2-2n+2$. This was proved by Wielandt, although this proof was not published. He claimed the result in H. Wielandt, "Unzerlegbare, nicht negative Matrizen," Math. Z., 52, 642–648 (1950). There is an essentially unique matrix showing that this is sharp, although there are many examples built from similar ideas showing that the minimum $m$ is $\Omega(n^2)$.
$$\begin{pmatrix}0 & 0  & \cdots & 0 & 1 \newline 1 & 0 & \cdots & 0 & 0 \newline \epsilon & 1 & \cdots & 0  & 0 \newline  \vdots & \vdots & \ddots & \vdots \newline 0 & 0 & \cdots & 1 & 0 \end{pmatrix}$$
Except for the $\epsilon$, this is a circulant matrix.
For example, let $n=8$, and set $\epsilon=1$. Here is the $40$th power:
$$\begin{pmatrix}1 & 0 & 0 & 1 & 5 & 10 & 10 & 5 \newline 5 & 1 & 0 & 0 & 1 & 5 & 10& 10 \newline 15 & 5 & 1 & 0 & 1 & 6 & 15 & 20 \newline 20 & 10 & 5 & 1 & 0 & 1 & 6 & 15 \newline 15 & 10 & 10 & 5 & 1 & 0 & 1 & 6\newline 6& 5& 10 & 10 & 5 & 1 & 0 & 1 \newline 1 & 1 & 5 & 10 & 10 & 5 & 1 & 0 \newline 0 & 0 & 1 & 5 & 10 & 10 & 5 & 1  \end{pmatrix}$$
Here is some Mathematica code you can use to animate the powers of the matrix.
wmat[n_] := Table[If[Mod[i - j, n] == 1 || (i == 2 && j == 0), 1, 0], {i, 0, n - 1}, {j, 0, n - 1}]
ListAnimate[Table[TableForm[MatrixPower[wmat[8], i]], {i, 1, 50}]]

A: There is an example in the book "Essentials of Stochastic processes" of Durrett, which shows that, in general, $m$ need not be equal to $2n-2$ (it is Example 4.5 of the chapter devoted to Markov chains, Durrett calls this example "Mathematician's nightmare"). The state space of the chain is $\{0,1,\ldots,14\}$, from $0$ it jumps to $5,9,14$ with equal probabilities, from other states $x>0$ it always jumps to $x-1$. It is then claimed that $m$ is at least $30$ for this chain (I didn't do the calculations myself, though).


text:
Q: Cannot use HTMLUnit Webdriver from Python I'm trying to use the HTMLUnit WebDriver from Python with the following code:
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.remote.webdriver import WebDriver

if __name__ == '__main__':
    webdriver = WebDriver('http://127.0.0.1:4444/wd/hub', DesiredCapabilities.HTMLUNIT)
    webdriver.get('http://www.google.com')

... and get the following error:
Traceback (most recent call last):
  File "bcc_mon_webdriver.py", line 8, in <module>
    webdriver = WebDriver('http://127.0.0.1:4444/wd/hub', DesiredCapabilities.HTMLUNIT)
  File "c:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 63, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "c:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 105, in start_session
    'desiredCapabilities': desired_capabilities,
  File "c:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 156, in execute
    self.error_handler.check_response(response)
  File "c:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 147, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: u'Error forwarding the new session cannot find : {platform=ANY, browserName=htmlunit, version=}' ; Stacktrace: Method process threw an error in RequestHandler.java

I use selenium-server-standalone-2.25.0.jar with the Python selenium module also in version 2.25.  The Selenium server is running on localhost and it works fine with e.g. DesiredCapabilities.FIREFOX.
Do I have to install htmlunit manually? The selenium websites says that the standalone-jar contains all dependencies.

A: The problem is you don't have a node that matches the {platform=ANY, browserName=htmlunit, version=} pattern. To fix it you need to start a selenium node with those browser settings, like this:
java -jar selenium-server-standalone-2.25.0.jar -role node -hub http://localhost:4444/grid/register -browser browserName=htmlunit

On the Selenium wiki ( http://code.google.com/p/selenium/wiki/Grid2 ) it says:

"By default, this starts 11 browsers : 5 Firefox, 5 Chrome, 1 Internet
  Explorer."

So to be able to use different browsers - like htmlunit - you'll have to start nodes with -browser parameter, check desired_capabilities.py file (located in your selenium egg under selenium/webdriver/common/) for a reference of which parameters are required for each browser.


text:
Q: Typescript: Why is the result of the "typeof" operator correctly compared with literals and incorrectly with constants? Typescript: Why is the result of the "typeof" operator correctly compared with literals and incorrectly with constants?
function foo(param: string) { }

const s = 'string';

function test(param: string | number) {
    if (typeof (param) == 'string') foo(param);  // ok
    if (typeof (param) == s) foo(param);         // error
}

Error message: "Argument of type 'string | number' is not assignable to parameter of type 'string'. Type 'number' is not assignable to type 'string'."

A: TypeScript has special treatment for the use of typeof with the values "string", "number", "boolean", and "symbol", but only if they are literals.
The TypeScript spec says this about these type guards:

A type guard of the form typeof x === s, where s is a string literal with the value 'string', 'number', or 'boolean',
  when true, narrows the type of x to the given primitive type provided it is a subtype of the type of x, or, if the type of x is a union type, removes from the type of x all constituent types that aren't subtypes of the given primitive type, or
  when false, removes the primitive type from the type of x.

As shown here, the right-side of the equals can take on one of three (actually four, including 'symbol') values in order to use typeof as a type guard. Anything else (e.g. s) and it doesn't work.
Side note: there's no need to use parentheses around param in typeof (param).


text:
Q: Create a TFS alert rule that triggers when a field is changed from a non-blank value? Is it possible to create a TFS alert for when a field is changed in a work item only when it's a non-blank value? Basically, I'd like the negation of 'When changes from ""'
Something like this:

A: Sorry it's not able to achieve this through built-in Alert filters. Since we do not have a symbol which stands for  a non-blank value
If there are not so many specified values for that Filed, you could add multiple alert filters and with or which may do the trick, kind like below:
And Design Target Changes from Value1

  or Design Target Changes from Value2

     or Design Target Changes from Value3
                .....

Otherwise, you may do this through a server side event handler to achieve this.

*

*Intercept the Work Item changed event

*Check if the change was a
change in state

*If it is, then email the address listed in the
Requester field.

There are couple of old projects on codeplex which should get you up and running but you'll need to update for newly TFS version (and test with any updates you apply later)
Email alerts for TFS
TFS Work Item Watcher


text:
Q: вывод в консоли на русском конфликт пробую вывести в VC++ 2017 в консоль русские буквы. Setlocale и chcp не помогли, помогло только
    _setmode(_fileno(stdout), _O_U16TEXT);
wcout << L"Сколько автомобилей поместить в каталог?";
Но теперь когда пытаюсь вывести string оно кидает какой-то exception после вывода "Вот ваша коллекция: ". В чём проблема? Вот код:
#include <iostream>
#include <string>
#include <io.h>
#include <fcntl.h>
int main(void)
{
    using namespace std;
    _setmode(_fileno(stdout), _O_U16TEXT);
    struct car {
        string name;
        int year;
    };
    int qnt;
    wcout << L"Сколько автомобилей поместить в каталог?";
    cin >> qnt;
    car *cars = new car[qnt];
    for (int i = 0; i < qnt; i++)
    {
        wcout << L"Автомобиль #" << i + 1 << endl;
        cin.get();
        wcout << L"Введите производителя:";
        getline(cin, cars[i].name);
        wcout << L"Укажите год выпуска:";
        cin >> cars[i].year;
    }
    wcout << L"Вот ваша коллекция: " << endl;
    for (int i = 0; i < qnt; i++) {
        cout << cars[i].name << " ";
        cout << cars[i].year;
    }
    system("pause");
    return 0;
}

A: Объявите `
wstring name

Для хранения unicode обычный не годится. И во время ввода также
getline(wcin, cars[i].name);

Вместо _setmode(_fileno(stdout), _O_U16TEXT);
 wcout.imbue(locale("rus_rus.866"));
    wcin.imbue(locale("rus_rus.866"));


text:
Q: Power MOSFET thermal calculations For this BSC0902NSI Infineon MOSFET from page 3, I am trying to determine the size of heatsink required, temperature and heat dissipated. I have the following

*

*Pd: 0.2 W

*Ta: 35 °C

*Theeta_jc: 20 °C/W - The datasheet has two jc, top and bottom. I chose the top since that is where I would placing the heatsink, because the bottom will have a copper pour of 6 x 6 cm.

Is Tsa and Tj calculated as

*

*Tsa: 35 + (20 x 0.2) = 39 °C

*Tj:  35 + 39 + 0.2 =  74 °C


text:
Q: How to handle assets in a Sylius theme? I'm new to Sylius and I have many issues handling shop customization. My current issue is adding assets (images, css...) to my custom theme. I've tried every way but I can't figure it out. My questions are:

*

*Where are you supposed to put them exactly?

*How do you get them to the public folder? I tried the assets:install and sylius:theme:assets:install commands, but since I don't know where to put the files in the first place it didn't really help.

*How do you reference them in your templates? I can't find where the asset() function points to.

Context

*

*I'm using the most recent versions of Sylius Standard (1.7.0), Windows 10 Pro and Firefox

*The theme works, I can select it in the channel settings and I can overwrite the templates and the translations no problem in my themes/SomethingTheme/SyliusShopBundle folder

I've seen similar issues on Stack Overflow but they don't seem relevant to this version of Sylius.

A: I've placed the public folder of my assets inside the SyliusShopBundle of the theme. These files are copied to the public folder after the command
sylius:theme:assets:install

is executed.
Here is a image to my folder structure
Here a implementation inside the theme


text:
Q: How to get button color back to normal after a simulated click In my Android app I simulate a button click with the following code :
  void clickButton(final Button b, int delay)
  {

    final Handler handler = new Handler();
    handler.postDelayed(new Runnable()
    {
      public void run()
      {
        final Drawable drawable = b.getBackground();
        b.performClick();
        b.getBackground().setColorFilter(b.getContext().getResources().getColor(R.color.colorAccent), PorterDuff.Mode.MULTIPLY);
//        b.setBackgroundColor(Color.rgb(88, 166, 198));
        b.setPressed(true);
        b.invalidate();
        // delay completion till animation completes
        b.postDelayed(new Runnable() {  //delay button
          public void run() {
            b.setPressed(false);
            b.invalidate();
            b.setBackground(drawable);
            //any other associated action
          }
        }, 800);  // .8secs delay time
      }
    }, delay);
  }

But the color of the button will stay green after a click, how to get it back to the color before the click, after a .5 sec delay?

A: b.setBackgroundColor(ContextCompat.getColor(b.getContext(), R.color.colorAccent));
b.postDelayed(new Runnable() {
    public void run() {
        b.setBackgroundColor(ContextCompat.getColor(b.getContext(), R.color.initialColor));
    }
}, 800);


text:
Q: A few questions about Kolmogorov complexity and falsification. I tied asking this question a different way over at the philospohy stackexchange, but I think I want to ask it in a more formal way.
If I understand Solomonoff induction correctly, given two hypotheses which have been able to accurately predict a data set, the hypothesis with the lower Kolmogorov complexity is the one which is more likely to produce a correct prediction for the next data point.
Would it be reasonable to say that a hypothesis with a higher Kolmogorov complexity is more easily falsified? It seems that the answer is yes, since it has a lower probability of correctly predicting the next data point in the sequence.
Also, can something be said about relative complexity when one program generates more than just the data set in question? For instance,
A: y = 2x
B: y ∝ x
for say {(1, 2)}. The reason I am asking is because I am curious about cases when one hypothesis implies the other. A implies B and it seems like B is less "complex" than A. But this measure of complexity may be incompatible with the concepts in Solomonoff induction.
Suggested edits are welcome. Thank you.


text:
Q: jquery ui tabs add tab strange behaviour i m adding new jquery ui tabs to a tab
the sample page(click on Create a new Tab)
the code
  $('#tabs-2').tabs(
 {
load: function(e, ui)
{
    $('.show_comment').die('click');
    if ($('#tabs-2').tabs('option','selected') == 0)
    {
           $('.new_text').click(function(){
              $("#tabs-2").tabs("add", 'ushout.jsp' , 'album_name' );
              return false;
           });

            return false;
        });
    }
}
 ,
selected: 1,
fx:{height: 'toggle', duration: 'fast'},
 spinner: 'Loading...' ,
collapsible: true
});

but on selecting the tab(album_name) first time no page is displayed...
but on selecting the tab second time the page is displayed
please help
thanks

A: adding tabs will have this behaviour with any effects on the tabs
the line
fx:{height: 'toggle', duration: 'fast'}

is causing the problem
use with no effects
$('#tabs-2').tabs(
{
load: function(e, ui)
{
$('.show_comment').die('click');
if ($('#tabs-2').tabs('option','selected') == 0)
{
       $('.new_text').click(function(){
          $("#tabs-2").tabs("add", 'ushout.jsp' , 'album_name' );
          return false;
       });

        return false;
    });
  }
}
,
selected: 1,
/* fx:{height: 'toggle', duration: 'fast'}, */
spinner: 'Loading...' ,
collapsible: true
});

thanks


text:
Q: SQL Query Restricting to 1 return per condition contained within IN clause Running MYSQL 5.5 and trying to essentially return only 1 record from each of the conditions in my IN clause.  I can't use the DISTINCT because there should be multiple distinct records that are attached to each code (namely cost will be different) from the IN clause.  Below is a dummy query of what I was trying to do, but doesn't work in 5.5 because of the ROW_NUMBER() function.
'1b' may have multiple records with differing cost values.  title should always be the same across every record with the same codes value.
Any thoughts?
SELECT codes, name_place, title, cost
FROM (
    SELECT *, ROW_NUMBER() OVER(PARTITION BY codes) rn
    FROM MyDB.MyTable
    )
WHERE codes IN ('1b', '1c', '1d', '1e')
AND rn = 1;


text:
Q: using two functions in same class The startFunction has a task to call the doFunction for 3 seconds, and then to stop. Unfortunatly that doesn't work without any compiler error. Just blank output. Probably some easy mistake, but i'm a beginner and can't find the solution since few hours. I've cut the code to make it more clear, but can paste if necessary.
    package  {
        //all imports

        public class MemoryPuzzles extends MovieClip{
            //all variables

            public function MemoryPuzzles():void {//first function

 //function memory puzzles
                }//first function end end

    public function startFunction():void//beginning of second function in the single class
    {
                    trace("start function works");

    startTime = getTimer();
    if( (getTimer() - startTime)<3000 ){
    addEventListener(Event.ENTER_FRAME, doFunction);
    } else {
    removeEventListener(Event.ENTER_FRAME, doFunction);
    }

    function doFunction(e:Event):void
    {
        trace("do function works");
    }//end of dofunction
    }//end of startfunction
    }//class end
}//import end

Thanks

A: refer a following code. i tested.
package
{
    import flash.display.MovieClip;
    import flash.utils.getTimer;

        public class MemoryPuzzles extends MovieClip
        {

            public function MemoryPuzzles():void
            {
                startFunction();
            }

            public function startFunction():void
            {
                trace("start function works");

                var startTime = getTimer();
                addEventListener(Event.ENTER_FRAME, doFunction);
                function doFunction(e:Event):void
                {
                    trace("time: " + (int)(getTimer()-startTime));
                    if((int)(getTimer()-startTime)>=3000)
                    {
                        removeEventListener(Event.ENTER_FRAME, doFunction);
                        trace("ended");
                    }
                }
            }
       }
}