How to eliminate a variable from coupled ODEs?

I found this question with an answer: How to eliminate variables in ODE?

With[{f = Function[t, {x'[t] + x[t]/10 + y[t], x[t] - y'[t] + z[t], x[t] + 3 y[t] - z'[t]}]},  With[{ndiff = Function[{exp, t}, Array[D[exp, {t, #}] &, Length[f[t]] + 1, 0]]}, Eliminate[Join @@  ndiff[f[t], t] == 0, Complement[ndiff[f[t], t] // Variables, ndiff[x[t], t]]]]] 

I want to know why is this Array[D[exp, {t, #}] &, Length[f[t]] + 1, 0] created? If I change the Length of the array the solution returns ‘True’.

How can we eliminate passwords given the problems with biometric authentication?

I’ve read articles suggesting that passwords will eventually go the way of the dinosaur only to be replaced by biometrics, PINs, and other methods of authentication. This piece claims that Microsoft, Google, and Apple are decreasing password dependency because passwords are expensive (to change) and present a high security risk. On the other hand, Dr. Mike Pound at Computerphile claims that we will always need passwords (I think this is the correct video).

But as this wonderful Security StackExchange thread notes, biometrics are not perfect. Granted, the criticisms are roughly six years old, but still stand. Moreover, and perhaps I have a fundamental misunderstanding of how biometric data is stored, but what if this information is breached? Changing a password may be tedious and expensive, but at least it can be changed. I’m uncertain how biometric authentication address this problem–as I cannot change my face, iris, fingerprint, and etc.–or if it needs to address this problem at all.

Are those who argue that we can eliminate passwords prematurely popping champagne bottles or are their projections correct?

Do best practices eliminate the need for a CSRF token when writing an API server?

I realize that OWASP recommends CSRF tokens but I rarely see them used with public standalone HTTP APIs. This would seem to indicate that they’re not always necessary.

To make this a little more concrete, I would envision the following scenario:

  • The API server serves a limited number of frontends with an explicit CORS whitelist.

  • HTTP method semantics are followed religiously (no writes in GET).

  • All routes require authentication.

  • All POST routes require a request body[1].

  • All routes that take a request body require a JSON content-type header.

  • Cookies are httpOnly but not sameSite.

Based on my understanding of SOP setting a JSON content-type header on requests should trigger a preflight request which would fail for untrusted origins. If all POST routes require a JSON content-type header, that should then mean they’ll always fail the preflight, leaving only GET requests.

So this would not mitigate CSRF attacks against GET routes but as these can’t be used for exfiltration (as SOP prevents the response from being read) and the GET routes should not cause any data modification, guarding these requests with CSRF tokens would not appear to make a practical difference.

Given how viciously some people defend CSRF tokens, I can’t shake the feeling I’m overlooking an obvious problem here. I realize redundant protections may be valuable in their own right, but what I’m trying to understand is whether in the scenario described the CSRF token would really be redundant or not.


[1]: I realise this might be a practical limitation of this approach as in some real-world APIs there are legitimate POST routes that don’t take a request body or there may be routes that need to take a content-type like form-data that won’t trigger a preflight.

Circular dependency – is there a good design to eliminate

I was writing some code and came across a scenario that I was thinking about doing a circular dependent class, which I have not done before. I then looked circular dependencies up and whether they are impermissible, and found that it is achievable but not desirable. But I have some dilemma regarding how to implement it without circular dependencies so I thought I should see if there are other suggestions available.

Imagine that you are building an index for a number of files, and those files have a number of attributes, including an attribute that records what files the particular file references.

Attempting to set up some classes mimicking such structure, I have written a number of classes.

  1. subClassA includes defining attributes of a file, let’s call this attribute set A

  2. subClassB includes classification attributes of a file, let’s call this attribute set B

  3. fileObject is an object representing a file, and has one subClassA object and one subClassB object.

  4. fileSet is an object representing a particular set of files, and is essentially a collection of fileObjects

As I was creating subClassB, I realized that the information related to reference files within subClassB is really just fileSet with limited subClassA information. Is it wise then to simply circular reference within subClassB a fileSet object? Or if that is a terrible idea, how should one go about storing the information? Technically, we can create another collection class object under fileObjectthat will store a bunch of subClassA objects, but I don’t really favor that as I would need to duplicate certain functions of fileSet within that new class definition (for example, functions that checks those object, combines those objects, and etc). But if I do it where I have two separate collections with one hosting subClassA attributes and subClassB attributes (like, skipping fileObject altogether, and directly record subClassA and subClassB into a fileSet object), it seems that I am introducing more complexities as I now need to find a way to link these subClassA and subClassB attributes together from a pooled up mess.

With the given scenario, should I just go with circular dependency? Or is there a better way to do it altogether?

Site Performance – Leverage browser caching & Eliminate render-blocking resources

How do i fix these to get a high score on PageSpeed?

  • amazon pay is from built-in magento 2 payment methods.

    Leverage browser caching for the following cacheable resources:  https://coin.amazonpay.com/cs/uedata (expiration not specified) https://coin.amazonpay.com/rb/checkStatus (expiration not specified) https://v1.addthisedge.com/live/boost/ra-xxxxxxxxxx/_ate.track.config_resp 

    (55 seconds) https://chimpstatic.com/mcjs-connected/js/users/xxxx/xxxxxx.js (1 minute 24 seconds) https://www.google.com/recaptcha/api.js?onload=recaptchaOnload&render=explicit (5 minutes) https://hello.zonos.com/api/country?siteKey=xxxxxxx (10 minutes) https://hello.zonos.com/api/translation?c=CA&siteKey=xxxx (10 minutes) https://static-na.payments-amazon.com/OffAmazonPayments/us/js/Widgets.js?nomin (20 minutes) https://static-na.payments-amazon.com/v2/login.js (20 minutes) https://www.google-analytics.com/analytics.js (2 hours)

Eliminate render-blocking resources

Eliminate render-blocking resources 0.88 s Resources are blocking the first paint of your page. Consider delivering critical JS/CSS inline and deferring all non-critical JS/styles. Learn more. URL Size Potential Savings …mage/calendar.min.css(www.mystore.com) 2 KB 70 ms …css/styles-m.min.css(www.mystore.com) 67 KB 470 ms …css/blog-m.min.css(www.mystore.com) 2 KB 150 ms …css/blog-custom.min.css(www.mystore.com) 1 KB 150 ms …css/styles-l.min.css(www.mystore.com) 11 KB 230 ms …requirejs/require.min.js(www.mystore.com) 8 KB 190 ms …en_US/requirejs-min-resolver.min.js(www.mystore.com) 1 KB 70 ms …requirejs/mixins.min.js(www.mystore.com) 2 KB 70 ms …en_US/requirejs-config.min.js(www.mystore.com) 4 KB 70 ms …f/cfg.css(www.mystore.com) 6 KB 110 ms /css?family=Bitter|Open+Sans:300,400,600,700(fonts.googleapis.com) 1 KB 230 ms …mailchimp/slim.css(www.mystore.com) 1 KB 70 ms 

Can I find such an encoding scheme so that I can eliminate certain rows of a vector?

Given a secret binary vector B=$ \left( {\begin{array}{*{20}{c}} {{b_0}}\ {{b_1}}\ \vdots \ {{b_{n-1}}} \end{array}} \right)$ , and a public uniformly random matrix $ A = \left( {\begin{array}{*{20}{c}} {{a_{00}}}&{{a_{01}}}& \cdots &{{a_{0,n-1}}}\ \vdots & \vdots & \ddots & \vdots \ {{a_{r-1,0}}}&{{a_{r-1,1}}}& \cdots &{{a_{r-1, n-1}}} \end{array}} \right)$ in $ (\mathbb{Z}_q)^{r \times n}$ , where $ q$ is a prime of size independent of $ n$ or $ r$ . Here $ n=r\log(r)$ .

I am trying to find an encoding scheme so that I can homomorphically eliminate some elements in the secret vector B given the encoding of $ A \cdot$ B i.e., turn them into zero. It doesn’t matter that the rest non-zero elements are no longer 1, as long as I know what the respective final values will be.

I have come up with the following encoding scheme: suppose $ q=11$ , a unknown matrix B=$ \left( {\begin{array}{*{20}{c}} {{1}}\ {{1}}\ {0} \ {{1}} \end{array}} \right)$ , I use two indexes to represent the non-zero positions. In other words, B1=$ \left( {\begin{array}{*{20}{c}} {{2}}\ {{4}}\ {0} \ {{8}} \end{array}} \right)$ and B2=$ \left( {\begin{array}{*{20}{c}} {{3}}\ {{5}}\ {0} \ {{9}} \end{array}} \right)$ . So the idea is that 1 in the $ i$ position will be represented as two shares: $ 2i+2$ and $ 2i+3$ Then two split vectors $ A\cdot$ B1 and $ A\cdot$ B2 will be the encoding of $ A\cdot$ B. Suppose I wish to eliminate the $ 0$ -th position of B given $ A\cdot$ B1 and $ A\cdot$ B2, I will perform the following operations to update the two split vectors: $ 5*2^{-1}*A\cdot$ B1+$ 6*3^{-1}*A\cdot$ B2 and $ 4*2^{-1}*A\cdot$ B1+$ 7*3^{-1}*A\cdot$ B2. However, the approach only goes so far, it does not work if I try to eliminate the next position, say $ 1$ -th since no matter what linear combination I choose to generate the split vectors I will turn the whole vector into 0. One can see here the expansion rate of the encoding scheme is constant since there are only two split vetors.

If one is allowed to choose any non-zero element from $ \mathbb{Z}_q$ to represent 1 in B, does there exist an encoding scheme of constant expansion rate so that I can homomorphically eliminate any desired positions in B only given the encoding of $ A\cdot$ B without any additional knowledge of B other than what the encoding scheme reveals?

Refactoring a LINQ lambda expression to eliminate duplicate object creation code

the following code fetches data from a MySql database to generate a simple report on accrued work time on projects.

I’ve been away from Entity Framework for a while and looking at this code you can see that the creation of ListProject is basically repeated 3 times.

Is there any way to refactor this so I can reuse the duplicate parts?

I’ve thought about a factory method, but that won’t work because it can’t be translated to SQL by the expression interpreter.

    var project = entities.Tickets         .Where(p => p.ID == id)         .Select(p => new ListProject         {             Id = p.ID,             Name = p.ueberschrift,             AssignedEmployee = new ListEmployee             {                 Id = p.AssignedEmployee.ID,                 Name = p.AssignedEmployee.name             },             WorkUnits = p.WorkUnits                 .Select(wu => new ListProjectWorkUnit                 {                     Duration = wu.dauer,                     PauseDuration = wu.pauseDauer,                     Employee = new ListEmployee                     {                         Id = wu.AssignedEmployee.ID,                         Name = wu.AssignedEmployee.name                     }                 })                 .ToList()             })             .Single(); 
    project.Tickets = entities.Tickets         .Where(p => p.vonProjekt == id)         .Where(p => p.phaseID == 0)         .OrderBy(p => p.ueberschrift)         .Select(p => new ListProject         {             Id = p.ID,             Name = p.ueberschrift,             AssignedEmployee = new ListEmployee             {                 Id = p.AssignedEmployee.ID,                 Name = p.AssignedEmployee.name             },             WorkUnits = p.WorkUnits                 .Select(wu => new ListProjectWorkUnit                 {                     Duration = wu.dauer,                     PauseDuration = wu.pauseDauer,                     Employee = new ListEmployee                     {                         Id = wu.AssignedEmployee.ID,                         Name = wu.AssignedEmployee.name                     }                 })                 .ToList()             })             .Single(); 
    project.Phases = entities.projekt_phase         .Where(p => p.projektID == id)         .OrderBy(p => p.rang)         .Select(p => new ListProjectPhase         {             Id = p.ID,             Name = p.name,             Tickets = p.Tickets                 .OrderBy(t => t.ueberschrift)                 .Select(t => new ListProject                 {                     Name = t.ueberschrift,                     Id = t.ID,                     AssignedEmployee = new ListEmployee                     {                         Id = t.AssignedEmployee.ID,                         Name = t.AssignedEmployee.name                     },                     WorkUnits = t.WorkUnits                         .Select(wu => new ListProjectWorkUnit                         {                             Duration = wu.dauer,                             PauseDuration = wu.pauseDauer,                             Employee = new ListEmployee                             {                                 Id = wu.AssignedEmployee.ID,                                 Name = wu.AssignedEmployee.name                             }                         })                         .ToList()                 })                 .ToList()         })         .ToList();