magento2 – Set all categories to use Config Settings for ‘Default Product Listing Sort By’ option via SQL

I want to set all of my Magento 2 categories to ‘Use Config Settings’ for the ‘Default Product Listing Sort By’ within the Category Display Settings.

I don’t want to do this manually as there are thousands of them.

What SQL command do I need to run to achieve this?

Distribution Sort – Number of split elements

What affects the number of split elements in Distribution Sort?
What would be the ideal value of count in relation to the number of D disks? (In an external memory model)

display most active user sort by comment count

i’m using "WP_User_Query" to displaying the most active user orderby = "post_count" in front and It works fine,

now i want to display the most active user based on comment count in front

i will be appreciate it if anyone could help me on this.

applescript – Script sort MP4 (and other) videos by orientation to portrait and landscape folders >>> IMPOSSIBLE?

I’ve been wrestling with a 14TB+ video library for the last months trying to dedupe and sort all of it into production ready folder structure.

For the life of me I have not been able to find (spent 3 solid days with no sleep) a script that will sort a folder of video files, using their dimensions, into Portrait and Landscape folders.

The closest I’ve found is this –

#!/bin/bash
shopt -s nullglob

for f in *.{mp4,MP4,mov,MOV,m4v,M4V}
    do 
        height=`mdls -raw -name  kMDItemPixelHeight "$f"`
        width=`mdls -raw -name  kMDItemPixelWidth "$f"`
        mkdir -p "${height}x${width}"
        mv "$f" "${height}x${width}"/
        
        printf "File: $fn"     
        printf "> Dimensions: $height x $width nn"
    done

printf "All done! n"

Which gets me closer by sorting them into folders based on dimensions, but it’s not what I’m trying to achieve.

Alternatively I found this script for images using Imagemagick, (which I installed via Homebrew) it does read the files, though it moves them ALL into the portraits directory. I’m assuming the variables may be different to extract height and width from a video file?

#/bin/zsh
mkdir -p portraits
mkdir -p landscapes
for f in ./*.mp4
do
  r=$(identify -format '%(fx:(h/w))' "$f")
  if (( r < 1.0 )) 
  then
      echo "Portrait detected."
  mv "$f" ./portraits/
  elif  (( r > 1.0 ))
  then
  echo "Landscape detected."
      mv "$f" ./landscapes/
  fi
done

If ANYONE OUT THERE can help me with this, it’s worth a PayPal to me. I know it’s quick work for the right mind.

The same, if someone has another solution using folder actions or automator or ANYTHING else. I’m running Mac OS with terminal.

Much appreciated!

jason@speedheathens.com

postgresql – Sort varchar by its numeric fields

I’m sure this has been asked before, but since the question can be formulated in many different ways it’s difficult to find the proper answer.

I have an orders table with a varchar field for the order number, which is formatted with 4-digits year, a dash (-), and a progressive numeric value. For example it may contain the following values:

SELECT number FROM orders ORDER BY number LIMIT 10;

  number  
----------
 1999-13
 2019-11
 2020-1
 2020-10
 2020-100
 2020-12
 2020-2
 2020-21
 2020-3
 2021-1

I need to sort that field by year and then by the progressive number, with this expected result:

  number  
----------
 1999-13
 2019-11
 2020-1
 2020-2
 2020-3
 2020-10
 2020-12
 2020-21
 2020-100
 2021-1

My questions are:

  1. Which is the simplest way to achieve this with an ORDER subclause?
  2. How to add an efficient index using this custom sort without having to modify the table?

If different best answers are possible for different DBMS/versions, let’s assume PostgreSQL 12.

performance – How do I optimize the bubble sort in Assembly8086?

I tried to implement bubble sort in Assembly 8086.

datasg      SEGMENT BYTE 'data'
array       DB 1, 3, 2, 5, 4
n           DW 5
datasg      ENDS
stacksg     SEGMENT BYTE STACK 'stack'
            DW 12 DUP(?)
stacksg     ENDS
codesg      SEGMENT PARA 'code'
            ASSUME CS:codesg, DS:datasg, SS:stacksg
MAIN        PROC FAR

; Pushing the previous data segment to keep it secure.
            PUSH DS
            XOR AX, AX
            PUSH AX
            MOV AX, datasg
            MOV DS, AX
;SI = i
            XOR SI, SI
            MOV CX, n
            DEC CX
out:        PUSH CX; Pushing CX to the stack before entering the second for loop
            XOR DI, DI
            MOV CX, n
            DEC CX
            SUB CX, SI
in:         MOV AH, array(DI)
            CMP AH, array(DI+1)
            JLE if_end
            XCHG AH, array(DI+1)
            MOV array(DI), AH
if_end:     INC DI
            LOOP in
            POP CX
            INC SI
            LOOP out
            XOR SI, SI
; Some garbage code to move array elements to AL register one by one to see them while debugging.
            MOV AL, array(SI)
            INC SI
            MOV AL, array(SI)
            INC SI
            MOV AL, array(SI)
            INC SI
            MOV AL, array(SI)
            INC SI
            MOV AL, array(SI)
            RETF
MAIN        ENDP
codesg      ENDS
            END MAIN

It seems to be working for the given example in the above code. I also tried it with different arrays and they all seem to work.
I just want to learn if there is a way to improve it? Improvements like changing JMP codes to decrease the size of code or using AX with XCHG because that is faster.

I also can’t comprehend the idea of pushing CX to stack for using nested-for loops. If you would give some suggestion about it I would be very happy.

how can sort my column

How can I add order?

add_filter('manage_articles_posts_columns', 
function ( $columns ) 
{
    if( is_array( $columns ) && ! isset( $columns('post_views') ) )
        $columns('post_views') = __( 'views' );     
     if(current_user_can('administrator'))
    return $columns;
},  );

add_action( 'manage_articles_posts_custom_column', 
function ( $column_name, $post_id ) 
{
    if ( $column_name == 'post_views') {
        $post_view_count = get_post_meta($post_id, 'views', true);
        $count = $post_view_count ? $post_view_count : 0;
        if(current_user_can('administrator'))
            echo $count;
    }
 
}, 10, 2);

covid 19 – Does Indonesia require some sort of mandatory quarantine in a facility upon arrival?

I have finally managed to get a visa to visit Indonesia, which has closed all borders except for citizens.
However, I can’t find concrete information on the quarantine part.

Does Indonesia require some sort of quarantine in a facility? I have read that somewhere a while ago now I can’t find it. I am ok with self-quarantine as I have a house there.

homework – Build using merge sort the ordered string of bytes that contain all characters from s1 and s2

Being given two alphabetical ordered strings of characters, s1 and s2, build using merge sort the ordered string of bytes that contain all characters from s1 and s2.

I have issues with adding the last element. I

bits 32

global start        

extern exit         
import exit msvcrt.dll
segment data use32 class=data
    ; ...
    s1 db 'acdefgwxyz' ; first string in alphabetical order
    len_s1 equ ($ - s1) ; length of first string
    s2 db 'bcdfhij' ; second string in alphabetical order
    len_s2 equ ($ - s2) ; length of second string
    rez times len_s1 + len_s2 db 0
    str_reminder dd 0

segment code use32 class=code
    start:
        cld ; set direction flag to 0 to go from left to right
        mov ESI, s1 ; s1 in source
        mov EDI, s2 ; s2 in destination
       
        mov ECX, len_s1 + len_s2 ; the max length (len_s1 + len_s2)
        mov EBX, 0 ; for s2, how many elements we went through
        mov EAX, 0 ; for s1, how many elements we went through
        mov EDX, 0 ; contorul pentru pozitia curenta din sirul rezultat
        
        repeta:
            cmpsb ; comparing the elements of the two strings
            
            jng smaller_s1 ; s1(pos) < s2(pos)
            jg larger_s1 ; s1(pos) > s2(pos)
            je equals; s1(pos) = s2(pos)
            
            smaller_s1:
                dec ESI ; decrementing ESI
                dec EDI ; decrementing EDI
                mov (str_reminder), EAX ; save the value of EAX
                lodsb ; put current value from esi in al
                mov (rez + EDX), AL ; put in result on position edx the value from al
                mov EAX, (str_reminder)
                inc EDX ; incrementing EDX
                inc EAX ; incrementing EAX
                cmp EAX, len_s1 ; if we are done with elements from s1
                jge sf_prg ; jump to sf_prog
                loop repeta ; repeating the loop
                jecxz sf_prg ; if ecx = 00000000, we jump to sf_prog
            
            larger_s1:
                dec EDI
                dec ESI
                mov (str_reminder), EAX
                mov AL, (EDI)
                mov (rez + EDX), AL
                mov EAX, (str_reminder)
                inc EDI
                inc EDX
                inc EBX
                cmp EBX, len_s2
                jge sf_prg
                loop repeta
                jecxz sf_prg
            
            equals:
                dec ESI
                mov (str_reminder), EAX
                lodsb
                mov (rez + EDX), AL
                mov EAX, (str_reminder)
                inc EDX
                inc EBX
                cmp EBX, len_s2
                jge sf_prg
                inc EAX
                cmp EAX, len_s1
                jge sf_prg
                loop repeta
                jecxz sf_prg
        sf_prg:
        
        cmp EAX, len_s1 ; comparing EAX with the length of s1, if EAX = len_s1 then we are done with the terms of s1 
        je ebx_bigger; if we have to add terms from s2
        jne ebx_smaller ; if EAX is not equal to len_s1 we are done with the terms of s2
        
        ebx_bigger: ; the remaining terms of s1
            mov ECX, len_s2
            sbb ECX, EBX
            repeat_:
                mov AL, (EDI)
                mov (rez + EDX), AL
                inc EDX
                inc EDI
            loop repeat_
            jmp end_prg
        
        ebx_smaller:
            mov ECX, len_s1
            sbb ECX, EAX
            repeat__:
                lodsb
                mov (rez + EDX), AL
                inc EDX
            loop repeat__
        
        
        end_prg:
        push    dword 0      
        call    (exit)      
```

wp query – WordPress | Sort posts based on the children of the custom taxonomy term

i have a cpt: pro

Custom taxonomy: servizi_pro

where pro they are the professionals

and servizi_pro are the services they can do to customers.

Example:

John Dean

servizi_pro
|
|_ Sito Web (Website)
   |
   |_1600$

Going to see what happens in the database of the wordpress tables, I find this situation.

posts.ID: 185

table: term_relationships

object_id  |  term_taxonomy_id

185             22
185             41

table: term_taxonomy

term_taxonomy_id    |    term_id        |    taxonomy        |     parent

      22                    22              servizi_pro              0
      41                    41              servizi_pro              22  

table terms:

term_id          |          name

22                          Sito Web
41                           1600

this is the structure inside my db for a professional, who has as services the creation of a website at a cost of 1600$

the structure shown above is only for a professional with ID 185, now making an example to 2 Professionals I report the same table including all the data

posts.ID: 185

posts.ID: 331

table: term_relationships

object_id  |  term_taxonomy_id

185             22
185             41
331             22
331             43

table: term_taxonomy

term_taxonomy_id    |    term_id        |    taxonomy        |     parent

      22                    22              servizi_pro              0
      41                    41              servizi_pro              22  
      43                    43              servizi_pro              22

table terms:

term_id          |          name

22                          Sito Web
41                           1600
43                           900

now that I have provided the data, I write the query I have in my code:

$qprice = $wpdb->get_results(
        $wpdb->prepare(" SELECT *
                         FROM {$wpdb->prefix}term_relationships 
                                             
                         LEFT JOIN {$wpdb->prefix}posts
                         ON {$wpdb->prefix}term_relationships.object_id = {$wpdb->prefix}posts.ID
                         
                         LEFT JOIN {$wpdb->prefix}term_taxonomy
                         ON {$wpdb->prefix}term_relationships.term_taxonomy_id = {$wpdb->prefix}term_taxonomy.term_id
                                             
                         LEFT JOIN {$wpdb->prefix}terms 
                         ON {$wpdb->prefix}term_relationships.term_taxonomy_id =  {$wpdb->prefix}terms.term_id 
                                             
                         WHERE {$wpdb->prefix}terms.name = '$art_p'
                         AND {$wpdb->prefix}posts.post_type = 'pro'
 
                         GROUP BY {$wpdb->prefix}posts.ID
                         ORDER BY  {$wpdb->prefix}terms.name DESC
                     
                     ")
    );

where $art_p is the service that the user requires in this case: Sito Web (Website).

how do i sort posts in ascending or descending order with respect to children then 1600 and 900.

Because the final case is it shows the prices of the professionals who are able to make the $ art_p service from the most expensive to the least expensive or vice versa by implementing the opposite.

But I can’t get the children sorted with my query