Range Query Question: Index Compression and Updates

Given an array of up to 200000 elements, my task is to process up to 200000 queries, which either ask me to update a single value within the array or ask me to find the number of elements that lie in a given range.

My current idea is to first use index compression on the given array, then keep another array that contains the number of occurrences of each number. Then, processing and updating queries could be done using a sum segment tree.

However, I ran into a problem while trying to implement this approach. I realized that updating a single array value could force me to shift the compressed array.

For example, given an array [1, 5, 3, 3, 2], I would define a compression function C such that

C[1] = 0; C[2] = 1; C[3] = 2; C[5] = 3; 

Then, the occurrence array would be [1, 1, 2, 1], and processing sum queries would be efficient. However, if I were instructed to update a value, say, change the third element to 4, then that throws everything out of balance. The compression function would have to change to

C[1] = 0; C[2] = 1; C[3] = 2; C[4] = 3; C[5] = 4; 

which would force me to reconstruct my occurrence array, resulting in O(N) update time.

Since N can be up to 200000, my approach will not work efficiently enough to solve the problem, although I think I have the right idea with index compression. Can somebody please point me in the right direction?

Show subcategories broken when WP/WC updates

I’ve been given to mantain a site who wasn’t updated for a while: it had WP 4.9.15 and WooCommerce 2.6.14

Now I’ve made a site test where i’ve updated all these things and now i have WP 5.4.2 and WC 4.3.1

One thing that is broken and i’m not able to figure why is the page showing the products by category: they have a 3 level category tree. It worked this way: if the category asked was a leaf, the page showed the product list. If it wasn’t a leaf, it showed all the subcategories.

The template page doing this is archive-product.php which has this simple loop to show everything:

            <h1 class="page-title"><?php woocommerce_page_title(); ?></h1>              <?php if ( have_posts() ) : ?>                  <?php                     /**                      * woocommerce_before_shop_loop hook                      *                      * @hooked woocommerce_result_count - 20                      * @hooked woocommerce_catalog_ordering - 30                      */                     do_action( 'woocommerce_before_shop_loop' );                 ?>                  <?php woocommerce_product_loop_start(); ?>                      <?php woocommerce_product_subcategories(); ?>                      <?php while ( have_posts() ) : the_post(); ?>                          <?php wc_get_template_part( 'content', 'product' ); ?>                      <?php endwhile; // end of the loop. ?>                  <?php woocommerce_product_loop_end(); ?>                  <?php                     /**                      * woocommerce_after_shop_loop hook                      *                      * @hooked woocommerce_pagination - 10                      */                     do_action( 'woocommerce_after_shop_loop' );                 ?>              <?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?>                  <?php wc_get_template( 'loop/no-products-found.php' ); ?>              <?php endif; ?> 

Now this page works only if the category requested is a leaf thus it has to display a list of products. If the category requested is not a leaf, no subcategory is shown and the page is blank with only the category name (page_title) showing. So it means that the query is somewhat did good, but why no category is shown? Thank you if you can help me solving this trouble

Create a Postgresql trigger that updates column with PK of other table

Hello and thanks for taking the time in advance to look at my question. This is my first try at using triggers and functions in PostgreSQL (using DBeaver) and I appreciate your feedback.

I’d like to update a column (village_id) every time a new row is entered or updated with the primary key value of a different table (which is not connected as a foreign key directly). See below for an outline of my tables and trigger + function.

Unfortunately, after using the code below I received an error each time I was entering a new row with information. I used an UPDATE statement, but I also considered using an insert into statement, but wasn’t sure what is more preferable. Thank you in advance.

CREATE TABLE register_table (   register_id integer CONSTRAINT register_id_pk PRIMARY KEY,   village_id integer NOT NULL );  CREATE TABLE er_table (   er_id integer CONSTRAINT er_id_pk PRIMARY KEY,   register_id integer NOT NULL,   village_id integer NOT NULL );  CREATE OR REPLACE FUNCTION update_village_id_column() RETURNS trigger AS $  BODY$   BEGIN    UPDATE schema_example.er_table   SET    village_id = register_table.village_id   FROM   schema_example.register_table   WHERE  (schema_example.register_id = new.register_id);    RETURN new;   END; $  BODY$   LANGUAGE plpgsql VOLATILE COST 100;  CREATE TRIGGER update_village_id AFTER INSERT OR UPDATE ON schema_example.er_table FOR EACH ROW EXECUTE PROCEDURE update_village_id_column(); 

Storing private keys for updates to remote device

I’m reading up on how to perform signed updates for remote hardware devices. I need to check if the new software has been generated by a "trusted" source, ie me.

Based on my understanding of asymmetric cryptography I understand that I can embed a public key on all my devices and then any new software that needs to be updated on the device, needs to have a signed hash in a header that I could check against. I’m all onboard until this part, and it sounds great for secure updates, but I’m wondering how one would securely store the private key. Say I built 1M units. All have the public key programmed on them. If my private key is lost for whatever reason, I lose the ability to update any of these devices. It sounds like the jugular vein. Should I accept storing private keys very safely as a cost of doing business, or is there a better way to handle this case?

Installing only security updates is a mistake?

On my Debian, I only do security updates:

deb http://security.debian.org/debian-security/ buster/updates main

deb-src http://security.debian.org/debian-security/ buster/updates main

For example, Debian recently migrated from 10.3 to 10.4, but I still use version 10.3 and automatically install available security updates.

Is that enough for security?

Coronavirus, you and hosting company important updates for hosting customers 2020.

Corona-virus, you and hosting company important updates for hosting customers 2020.

Corona-virus created problems in almost all countries and maybe you are facing the same also. Please take care and stay safe. If your are hosting customer please support hosting industry if anything urgent or important then contact provider because most of the employees working from home and few facing health issues. So it is time to help each other. If any hosting provider was not able to provide you support then maybe they are facing big problems so please trust them and don’t cancel your services.

If any customer looking for a web hosting plan for any startup idea in this situation and we provide free of cost hosting and support. Also logo designing. We are ready to help you and make your business successful.
Many thanks for your valuable time.

Below are Free Hosting for a lifetime, host without cost details:

FREE Startup-$0 /Lifetime

>> Single Domain Hosting
>> 200MB Web Space
>> 200MB Bandwidth
>> 2 Email Accounts
>> 2 Sub Domains
>> FREE Auto SSL
>> DDOS Protection
>> 99.99% uptime
>> Softacolous Supported
>> Tier 1 Technical Support

Order Now >> https://hostpoco.com/free-hosting.php

Thank you.

About Microsoft delivering Windows 10 updates [closed]

I’m really curious to know the answers to these questions. I Hope you can help me out.

1- For how long will the Surface Go receive software updates(feature & security) ?

2- Is there a difference between: • the software updates(feature & security) delivered to Microsoft’s own hardware(Surface lineup devices) and • the software updates(feature & security) delivered to computers from other manufacturers(like LG, for example…) ???

3- Does Microsoft’s own hardware gets supported with software updates(feature & security) for a longer period of time than computers from other manufacturers?

Thank you.