priority – Prioritised outgoing emails using Exim

Our outgoing email queue uses Exim (on Centos) and is used both for sending bulk batches of email to clients and sending authentication keys, eg as part of the forgotten password routine. On some occasions there are already many bulk emails queued in the outgoing queue when someone requests a forgotten password authorisation link. This email is queued with all the other emails and processed in the order received so it can sometimes be many minutes before it is sent, preventing them from completing their login.

Is there a way to add emails from the password reset process to the start of the queue so that they are processed immediately?

heaps – Java Implementation of PriorityQueue supporting priority updates

I’ve coded up an implementation of MinPriorityQueue in java using a hashMap to store the indices of the elements in my heap. I require such an implementation for Prim’s and Dijkstra’s algorithm, while this implementation works for most test cases upto 200 nodes, I’m getting incorrect outputs for many larger test cases. I’ve spent 2 days now trying to debug my implementation and I still have no idea why it fails.

I understand that debugging this for anyone else will also be a time consuming task.
Therefore can someone please share such an implementation in java or c++ using Hashmap (java preferably).
Because at this point it seems only looking at a correct implementation could help me fix my code.

Also, I’m under the impression that such an implementation using hashmap is common. If I’m wrong in my assumption, please tell me what is the most common implementation of a PriorityQueue for problems such as Dijkstra’s or Prim’s

Here is my implementation, in case something very obvious is missing and someone with more expertise can point out the mistake that would be most appreciated.

import java.util.HashMap;
import java.util.NoSuchElementException;

public class Heap<Key extends Comparable<Key>> {
    private Key() heap;
    private int maxN, n;
    private HashMap<Key, Integer> map;
    @SuppressWarnings("unchecked")
    public Heap(int maxN) {
        if(maxN < 0 ) throw new IllegalArgumentException();
        this.maxN = maxN;
        n = 0;
        heap = (Key()) new Comparable(maxN);
        map = new HashMap<>(maxN);
    }

    boolean isEmpty() {
        return n == 0;
    }

    boolean insert(Key e) {
        if(n +1 > maxN) throw new IllegalArgumentException("maximum capacity reached " + maxN);
        heap(n) = e;
        map.put(e,n);
        int i = n++;
        while ( (i+1)/2 - 1 >= 0){
            if ( e.compareTo(heap((i+1)/2 - 1)) < 0 ) {
                swap(i, (i+1)/2 - 1);
                i = (i+1)/2 - 1;
            }
            else 
                break;
        }
        return true;
    }

    Key extractMin() {
        if(n == 0) throw new NoSuchElementException("Priority queue underflow ");
        Key min = heap(0);
        swap(0, n-1);
        map.remove(min);
        n--;
        int j = 0, s;
        while(j <= (n/2)-1){
            if(j == (n/2)-1 && n == (j+1)*2 )
                s = (j+1)*2 - 1;
            else 
                s = heap((j+1)*2 - 1).compareTo(heap((j+1)*2)) < 0 ? (j+1)*2 - 1 : (j+1)*2; 
            if(heap(j).compareTo(heap(s)) > 0 ){
                swap(j, s);
                j = s;
            }
            else break;
        }
        return min;
    }

    Key delete(Key e){
        if(!map.containsKey(e)) throw new NoSuchElementException(e+"does not exist ");
        int j = map.get(e), s;
        Key del = e;
        swap(j, n-1);
        map.remove(e);
        n--;
        while( j <= n/2 - 1){
            if(j == (n/2)-1 && n == (j+1)*2)
                s = (j+1)*2 - 1;
            else
                s = heap((j+1)*2 - 1).compareTo(heap((j+1)*2)) < 0 ? (j+1)*2 - 1 : (j+1)*2; 
            if(heap(j).compareTo(heap(s)) > 0 ){
                swap(j, s);
                j = s;
            }
            else break;
        }
        return del;
    }

    boolean decreasePriority(Key e){
        if(n == 0)
            return insert(e);
        if(map.containsKey(e))
            delete(e);
        return insert(e);
    }

    private void swap(int i, int j) {
        Key t = heap(i);
        heap(i) = heap(j);
        heap(j) = t;
        map.replace(heap(i), i);
        map.replace(heap(j), j);
    }

    @Override
    public String toString() {
        String res = "(";
        int i;
        for (i = 0; i < n-1; i++){
            res += heap(i) + ", ";
        }
        res += heap(i)+")";
        return res;
    }
}

Diagrams – Implementation of the debugging priority queue to support priority update

Please let me know if you need additional information, but please help me here.

For an efficient implementation of algorithms like Dijkstra and Prim, we need a priority queue that supports operation with reduced priority. I came up with the following code (heap-based priority queue) that uses a hash map to store the index of each entry in the priority queue.

import java.util.HashMap;
import java.util.NoSuchElementException;

public class Heap> {
    private Key() heap;
    private int maxN, n;
    private HashMap map;
    @SuppressWarnings("unchecked")
    public Heap(int maxN) {
        if(maxN < 0 ) throw new IllegalArgumentException();
        this.maxN = maxN;
        n = 0;
        heap = (Key()) new Comparable(maxN);
        map = new HashMap<>();
    }

    boolean isEmpty() {
        return n == 0;
    }

    boolean insert(Key e) {
        if(n +1 > maxN) throw new IllegalArgumentException("maximum capacity reached " + maxN);
        heap(n) = e;
        map.put(e,n);
        int i = n;
        while ( (i+1)/2 - 1 >= 0){
            if ( e.compareTo(heap((i+1)/2 - 1)) < 0 ) {
                swap(i, (i+1)/2 - 1);
                i = (i+1)/2 - 1;
            }
            else 
                break;
        }
        n++;
        return true;
    }

    Key extractMin() {
        if(n == 0) throw new NoSuchElementException("Priority queue underflow ");
        Key min = heap(0);
        swap(0, n-1);
        map.remove(min);
        n--;
        int j = 0, s;
        while(j <= n/2 - 1){
            if(j == n/2 -1 && n == (j+1)*2 )
                s = (j+1)*2 - 1;
            else 
                s = heap((j+1)*2 - 1).compareTo(heap((j+1)*2)) < 0 ? (j+1)*2 - 1 : (j+1)*2; 
            if(heap(j).compareTo(heap(s)) > 0 ){
                swap(j, s);
                j = s;
            }
            else break;
        }
        return min;
    }

    Key delete(Key e){
        if(!map.containsKey(e)) throw new NoSuchElementException(e+"does not exist ");
        int j = map.get(e), s;
        Key del = heap(j);
        swap(j, n-1);
        map.remove(e);
        n--;
        while( j <= n/2 - 1){
            if(j == n/2 -1 && n == (j+1)*2)
                s = (j+1)*2 - 1;
            else
                s = heap((j+1)*2 - 1).compareTo(heap((j+1)*2)) < 0 ? (j+1)*2 - 1 : (j+1)*2; 
            if(heap(j).compareTo(heap(s)) > 0 ){
                swap(j, s);
                j = s;
            }
            else break;
        }
        return del;
    }

    boolean decreasePriority(Key e){
        if(n == 0)
            return insert(e);
        if(map.containsKey(e))
            delete(e);
        return insert(e);
    }

    private void swap(int i, int j) {
        Key t = heap(i);
        heap(i) = heap(j);
        heap(j) = t;
        map.replace(heap(i), i);
        map.replace(heap(j), j);
    }

    @Override
    public String toString() {
        String res = "(";
        int i;
        for (i = 0; i < n-1; i++)
            res += heap(i) + ", ";
        res += heap(i)+")";
        return res;
    }
}

For the problem I'm working on, the program is supposed to output the total weight of the minimum spanning tree found using the prim algorithm. The input diagram is a 500-node diagram, and the answer received through this implementation is incorrect.
I'm sure the problem is with the heap and not with my implementation of the prim algorithm because using the built-in priority queue in Java gives the correct answer.
Here is my program that runs the prims algorithm.

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Edge{
    Key v;
    int w;
    public Edge(Key v, int w){
        this.v = v; this.w = w;
    }
    @Override
    public String toString(){
        return "("+v+","+w+")";
    }
}

class vertex implements Comparable{
    int position, dis;
    public vertex(int position){
        this.position = position;
        dis = Integer.MAX_VALUE;
    }
    @Override
    public int compareTo(vertex v) {
        if(dis > v.dis)
            return 1;
        if(dis < v.dis)
            return -1;
        return 0;
    }
    @Override
    public String toString(){
        return Integer.toString(position+1);
    }
}
public class Prims {
    public static void main(String() args) throws FileNotFoundException {
        Scanner in = new Scanner(new FileReader("prims.txt"));
        int n = in.nextInt(), m = in.nextInt();
        List>> graph = new ArrayList>>();
        List nodes = new ArrayList();
        for(int i = 0; i());
            nodes.add(new vertex(i));
        }
        while(m-- > 0){
            int u = in.nextInt()-1, v = in.nextInt()-1, w = in.nextInt();
            graph.get(u).add(new Edge(nodes.get(v), w));
            graph.get(v).add(new Edge(nodes.get(u), w));
        }
        in.close();
        long st = System.currentTimeMillis();
        System.out.println(prims(graph,nodes));
        long end = System.currentTimeMillis();
        System.out.println("Runtime = "+(end-st)+"ms");
    }
    static int prims(List>> graph, List nodes){
        int n = graph.size(), weight = 0;
        boolean() inSpanTree = new boolean(n);
        Heap pq = new Heap<>(n);
        inSpanTree(0) = true;
        for(Edge e : graph.get(0)){
            e.v.dis = e.w;
            pq.insert(e.v);
        }
        while(!pq.isEmpty()){
            vertex u = pq.extractMin();
            inSpanTree(u.position) = true;
            weight += u.dis;
            for(Edge e : graph.get(u.position)){
                if(!inSpanTree(e.v.position)){
                    if(e.v.dis > e.w){
                        e.v.dis = e.w;
                        pq.decreasePriority(nodes.get(e.v.position));
                    }
                }
            }
        }
        return weight;
    }
}

When I use the built-in priority queue for the same implementation, I get the correct output(-3612829)

static int prims(List>> graph, List nodes){
        int n = graph.size(), weight = 0;
        boolean() inSpanTree = new boolean(n);
        PriorityQueue pq = new PriorityQueue<>();
        inSpanTree(0) = true;
        for(Edge e : graph.get(0)){
            e.v.dis = e.w;
            pq.add(e.v);
        }
        System.out.println(pq);
        while(!pq.isEmpty()){
            vertex u = pq.poll();
            if(u.position == 307)
                System.out.println(pq);
            inSpanTree(u.position) = true;
            weight += u.dis;
            for(Edge e : graph.get(u.position)){
                if(!inSpanTree(e.v.position)){
                    if(e.v.dis > e.w){
                        e.v.dis = e.w;
                        pq.remove(nodes.get(e.v.position));
                        pq.add(nodes.get(e.v.position));
                    }
                }
            }
        }
        return weight;
    }

My heap implementation works for almost all test cases, even up to 300 nodes. I don't understand how to debug and find out where the problem is.
Here is the link to input problems:

https://d3c33hcgiwev3.cloudfront.net/_d4f3531eac1d289525141e95a2fea52f_edges.txt?Expires=1589673600&Signature=WSP-z481nsQgNDfN6zo0XNWy9nNTLAIty2k4HNhoQgW3pAsY0vUVaMdjg3g-UnKz9tKajuYcgGpYO3cw9H7N24tqescamo0q0n3Rykfb6BSkcI~DiKuiGpeA4gb630CU4gLAS8tDoaFRCjKNiyXAbXqHLeWhmGAmOrAnYl2rAMU_&Key-Pair-Id=APKAJLTNE6QMUY6HBC5A

Can someone please help me debug my heap implementation? I've been busy for a long time now.
Thanks in advance.

boot – change UEFI display priority

I have a PowerSpec G419 desktop and have just added another monitor. I turned my old monitor aside and placed it on an adjacent desk. The old monitor is (still) connected via Mini DisplayPort. The new monitor does not have display port connections, but only HDMI. Things usually work fine in Windows (10) because I can specify which display is primary. I set display # 2, the new monitor, as my primary display and put the other display as my secondary display in portrait mode.

My problem is with the boot. The home screen and UEFI setup screen are only shown on monitor # 1 and are on the side. There is a prompt that says "Press Tab to switch screens" that I tried, but it just changes and moves the text but still appears sideways and on the same monitor. I can't find any settings in this system's setup to change the primary display. Am I there?

I see two strange behaviors in Windows and I'm not sure if they are relevant. I mention them here if it helps to understand the cause of the problem (but would also be interested in fixing it):

  1. When I select multiple images as the desktop background, it initially works great when the first selected image is displayed on my primary desktop on monitor 2 and the second image on my secondary desktop on monitor 1. But after a while, the images change (or the background from a desktop is replicated on both monitors. I can't remember exactly what I saw, but I saw it several times).

  2. When I lock the screen or play a full-screen game like The Witcher 2 and then switch back to my desktop, all windows that were on my secondary desktop on monitor 1 are moved to my primary desktop on monitor 2. I can't seem to do anything to keep the windows on my secondary desktop.

Aperture priority on Nikon DF doesn't work with pre-AI lenses?

I just bought a 55 / 3.5 pre-AI.

To use aperture priority mode, I did the following:

  1. Raise the coupling lever on the meter
  2. Data on non-CPU lenses:
    Focal length: 55
    maximum appearance: F / 3.5
    Light meter coupling: non-AI

As I change the aperture, the display stays at F / 10. No wonder my photos are underexposed.
However, with other AI / AIS lenses, the camera correctly recognizes the lens hood. And of course the aperture priority works flawlessly.

Is there something wrong with my 55 / 3.5 pre-AI?

Apperture priority at Nikon DF doesn't work with pre-AI lenses?

I just bought a 55 / 3.5 pre-AI.

To use Apperture priority mode, I did the following:

  1. Raise the coupling lever on the meter
  2. Data on non-CPU lenses:
    Focal length: 55
    maximum appearance: F3.5
    Light meter couping: non-AI

As I change the appearance, the display freezes at F10. No wonder my photos are underexposed.
With other AI / AIS lenses, the camera recognizes the lens correctly. And of course the Apperture priority works perfectly.

Is there something wrong with my 55 / 3.5 pre-AI?

Categories – How to give pages priority over product categories

Great community, very useful!

I have a problem that I cannot solve. I found a few articles online but not really the solution. Problem: I have duplicated Slug & URLs for product categories with pages.

Example:
– Product category: URL http://example.com/product-category/sub-productcategory/
– Page: URL http://example.com/product-category/sub-productcategory/
Normal behavior with the same URL is that you see the product category and not the page. I want to display the page (and not the product category) to our users if there is a page with the same name as the product category.

Why? For SEO and user experience, we provide custom pages of important product categories with more content.

I use WordPress (CMS), Woocommerce (SHOP), Yoast (SEO), Premmelence (Premmerce Permalink Manager: remove category in URL), Elementor (Page Builder).

I found code from other online posts

/**
 * Override query for pages that match a category slug.
 * 
 * @param   WP  $wp
 */ 
function wpse_177014_category_to_page ( $wp ) {
    if ( ! empty( $wp->query_vars('category_name') ) && get_page_by_path( $slug = $wp->query_vars('category_name') ) ) {
        if ( ! empty( $wp->query_vars('paged') ) )
            $page = $wp->query_vars('paged');
        else
            $page = '';

        $wp->matched_query = "pagename=$slug&page=$page";
        $wp->query_vars    = array(
            'pagename' => $slug,
            'page'     => $page,    
        );      
    }
}

add_action( 'parse_request', 'wpse_177014_category_to_page' );

I have & # 39; category_name & # 39; by & # 39; product_cat & # 39; replaced. But it doesn't work. Maybe someone can help me do this job?

What were high priority transactions in Bitcoin Core v0.9?

I came across these Bitcoin Core 0.9 release notes and saw this quote under "Transaction Fees". Does this distinction between high priority transactions and the highest fee transactions still exist? What exactly were high priority transactions?

Note that forwarding a transaction over the network is NOT a guarantee
that the transaction is accepted by a miner; By default, miners fill up
their blocks with 50 kilobyte high priority transactions and then with
700 kilobytes of transactions with the highest fee per kilobyte.

Give priority to Siri MBP when iPhone and iPad are nearby

Your Apple devices actually negotiate between them to decide which device is closest to the speaker, and there's no way to control which device takes priority.

As you suggest, your iOS devices do not respond to "Hey Siri" when you turn them over. This is the only control you have over the situation. The Mac has similar controls when the lid is closed. If you have switched off Bluetooth on one of the devices, they are not part of the negotiations because they communicate with each other via Bluetooth.

For more information, see this Apple support document:
https://support.apple.com/en-us/HT208472