Postgresql: sort by value position in array column, then by secondary order

I’m not quite sure what the best way to phrase this is…

So in my DB there is pillars text array which is basically an enum where providers ordered what values meant the most to their business, from most important to providing that value for their clients, to least important.

I’m using PostGIS to query providers in a specific area, and want to return providers ordered first by the pillar that a client selected they were looking for, then by closest location.

so if the pillars all have values ['a', 'b', 'c', 'd'], in any order depending on what providers selected, and the client selected pillar c

the results of the query would preferably return any/all providers that have pillar c at array index 0 first, ordered by distance to geopoint, then by providers that have pillar c at array index 1 second ordered by distance to client geopoint, then idx 2, then idx 3

I’m really only looking for the top 3 results in all cases, and providers with pillar c at idx 1 would only be needed if there were less than 3 results for index 0

Is this possible to pull off in a single query? or should I just run it with a where clause and check the results length until I have 3 results?

The pillars column is indexed with a gin index btw

How do I find out whenever a value changes in a certain column?

Need help if anyone can offer!

I currently have my select statement returning the TOP 1000 * results from a table. They are CC numbers that are currently active. I’d like to see how I can go about writing a query that could show me what has CC numbers have changed.

If something has changed, it will send a report to the listed people. If nothing, then it does nothing. It only actions once something has happened. We have an inhouse system that will do the automated part… I just need a select statement that will return what has changed. If I can get some help on this, it would be amazing!

Thank you!

How to avoid overwriting a value in Unity (C#)

I’m working on a Tower Defence style game, and wondering how best to handle the "resources" part. I have multiple enemies on screen at a time, and when an enemy dies, it updates a resource that allows the player to build more towers

var tower = Instantiate(buildables[0], center, Quaternion.identity); var controller = tower.GetComponent<TowerController>(); controller.OnKilledEnemy += (sender, args) => {     int.TryParse(goldAmount.text.Replace(",", ""), out var curr);     curr +=;     goldAmount.text = $  "{curr:n0}"; }; 

But if 2 enemies die in the same frame, wouldn’t the value there miss an update?

What ways are there in Unity/C# to mitigate this problem?

How to get max value of filtered query post

I have a query post to filter my post in my CPT, filtered on front end by a form filter.

The problem is that with different filter, I have different max value.

For example I have the following custom field meta value:

  • filter #1 – Ford, Nissan, Toyota
  • filter #2 – Blue, Red, White
  • and on with other filter#3, #4 etc…

Choosing different filter (for example ‘Ford and Red’ vs ‘Nissan and White’), I may have different max value price of total cars in the same query post, that have the same characteristics.

How I can get the max value of current filter on query post, and use this value on each line of same query post to show the different price from the max?

Someone can help me? Thanks in advance

Does a ` with a non-matching media value download sync or async, render-blocking or non-render-blocking?

I’m looking for an authoritative reference with regard to whether <link rel="stylesheet"> with a non-matching media attribute value downloads synchronously or render-blocking or neither.

MDN helpfully draws attention to Scott Jehl’s experiments from several years ago:

A style sheet with a media query attached to its tag will still download even if the query returns false.


Additional Reference:

So far, so good.

But is that download-which-is-happening-anyway:

  • synchronous or asynchronous ?
  • render-blocking or non-render-blocking ?

I’m going to guess that it’s asynchronous, non-render-blocking and low priority.

But I’d really like to confirm this via an authoritative source – and I’ve been unable to find one.

Background to this question:

Now that Firefox (as of Jan 2021) supports <link rel="preload"> (see:, I’ve been running some experiments to see whether I am happiest with the behaviour of:

<link rel="preload" href="/my-non-critical-styles.css" as="style" onload="this.onload=null; this.rel='stylesheet';" /> 


<link rel="stylesheet" href="/my-non-critical-styles.css" media="print" onload="'all';"> 

I can see that they do behave differently – a speed/performance tool like GTMetrix shows very clearly that the rel="preload" approach prioritises loading the non-critical stylesheet over images, while the media="print" approach prioritises loading images over the non-critical stylesheet – but I also want to be certain that the two approaches are alike in all other respects.

Asymptotic value of an integral using Mathematica

When I plug the integral
$ $ n \int_0^1 t^{r-1}(2t-t^2)(2-2t) dt$ $ , I get the following : $ $ 2^{(-1 + 2 n) }nt^{(-1 + r) }(Beta[n, n] – 4 Beta[1/2, 1 + n, n])$ $ where $ Beta(x,a,b)=\int_0^x u^{a-1}(1-u)^{b-1} du$ is the incomplete beta integral.I want to know whether Mathematica can give me intermediate steps and,more importantly,how I can get the asyptotic limit of the value of the integral as n approches infinity.Lots of thanks for any help or hints in advance

I want to get the value of a select attribute in the checkout page, and then use it to show or not the delivery data

I want to get the value of a select attribute in the checkout page on WooCommerce, and then use it to show or not the delivery data.

I have tried everything but it still does not appear, the object of my products when I go through it comes out empty.

I have tried something similar to this to see what data I am getting but it comes out empty:

add_filter( 'woocommerce_cart_item_name', 'cart_variation_description', 20, 3); function cart_variation_description( $  name, $  cart_item, $  cart_item_key ) {     // Get the corresponding WC_Product     $  product_item = $  cart_item['data'];      if(!empty($  product_item) && $  product_item->is_type( 'variation' ) ) {         // WC 3+ compatibility         //$  descrition = $  product_item->get_description();         //$  descrition = $  product_item->get_attribute( 'pa_modo' );         $  descrition = $  product_item->get_post_meta( $  variation->ID, 'price_1_50', true );         $  result = __( 'Description: ', 'woocommerce' ) . $  descrition;         return $  name . '<br>' . $  result;     } else         return $  name; } 

Thanks a lot.

Solve an equation in mathematica without replacing the value of the parameter

Suppose I want to solve a simple equation in mathematica x-a=0.So I am writing the mathematica code for this as below:

Solve[x - a == 0, x] 

So the output will be as below:

{{x -> a}} 

Now suppose I have assigned a value for ‘a’ beforehand and then want to solve the same equation.So my code will look like below:

a = 1; Solve[x - a == 0, x] 

And the output in this case will be like below:

{{x -> 1}} 

Now if I want an output in this case as {{x -> a}},what modification should I do in my code ?

Note: Clear[a] will work,but I don’t want to remove permanently the assigned value to a

CPT email notification including only new value custom fields

I have a custom post type «teams» with a set of different custom fields (ACF). I’m not a big coder, but hope to get some guidance in how to create a function that sends an email including ACF every time one of the teams (CPT) is updated by a WP-user.

I’ve found plugins that accomplish this, but unfortunately I need a bit more complex solution. The problem is the email should ONLY include custom fields that actually has changed. So I need to loop through and check each custom field for any change, and then only include the fields that has a new value in the final email.

I guess I’m asking if this is a very difficult task, or could it be done in a rather simple way? All sources would be very appreciated!