magento2 – Magento 2: How to cancel the same block method in two different modules?

I'm canceling a MagentoCatalogPricingRenderFinalPriceBox in my two different modules

Vendor Module1 etc di.xml



      

Vendor Module2 etc di.xml



      

Both blocks override the same method.
wrapResult($html).

It only shows the output of Module2, not the output of both modules at the same time. I have installed the conflict detector extension to see the conflict that shows something like this.

Screenshot

What I have tried so far

How to override the main class that is already overridden by another custom module in Magento 2

7 – How to mark a node and take the values ​​of a node in a block and set them in the fields of the marked node

I am creating a calendar view that shows the available sessions of a Teacher (role). Each session has a global flag called "Book Session". A student (role) may have several courses, but only one should be shown above this view and when the student marks / reserves a session, the student Username should be established in a reference field of that session and the Course name (or id?) must be set in the course reference field of that session.

How do I capture the data of that particular Course node and use the Rules to establish this data?

blockchain: What is the Python program that prints information about the current block?

To take the information from the bitcoin blockchain, you can use the Bitcoin core RPC Framework, to use it, you must have all the blockchain in your computer

  1. Bitcoin core download
  2. line up the bitcoin node
  3. Configure the rpc framework
  4. Use the API to take the information, I prefer to use this library with python, this is an example to use it

You can use this documentation to study API

also for an answer to the last comment, you can use the API to call the Mining commands, but it is difficult to understand your question "I can print information about the block that you are extracting now" because mining is a war for the node and each one the node can have different information

8 – How to block all users that do not contain a pattern?

I suggest using drush block

drush ublk $(drush sqlq 'SELECT GROUP_CONCAT(ufd.name) FROM users u join user__roles ur on  u.uid = ur.entity_id  join users_field_data ufd on ufd.uid = u.uid where ur.roles_target_id ="YOUR_ROLE_MACHINENAME" and ufd.name like "%PATTERN%"')

before that, make sure the query is correct and answer whatever you want

drush sqlq 'SELECT GROUP_CONCAT(ufd.name) FROM users u join user__roles ur on  u.uid = ur.entity_id  join users_field_data ufd on ufd.uid = u.uid where ur.roles_target_id ="YOUR_ROLE_MACHINENAME" and ufd.name like "%PATTERN%"

and finally, make sure they are locked by checking the "User Status" column of the result of the following command

drush uinf $(drush sqlq 'SELECT GROUP_CONCAT(ufd.name) FROM users u join user__roles ur on  u.uid = ur.entity_id  join users_field_data ufd on ufd.uid = u.uid where ur.roles_target_id ="YOUR_ROLE_MACHINENAME" and ufd.name like "%PATTERN%"')

P.S.:

  • YOUR_ROLE_MACHINENAME: change it with your desired role.
  • PATTERN: you can use the MySQL LIKE statement

Confirmations – Shortest and longest block interval time ever recorded in Bitcoin

(This data is current through block 535276).

based on block timestamps (which does not have to be precise), the longest difference between successive blocks is 463160 seconds (5 days, 8 hours, 39 minutes, 20 seconds) between blocks 0 and 1. The second longest is 90532 seconds (1 day 1 hour 8 minutes 52 seconds) between blocks 15323 and 15324.

For "shorter", since timestamps are not strictly applied and can be accidentally or intentionally falsified, it is possible that a block has a timestamp prior to its predecessor, up to 2 hours (7200 seconds), in which case the time difference is negative This has happened 13828 times. The most negative difference is −7125 seconds (1 hour 58 minutes 45 seconds) between blocks 156113 and 156114.

There have been 222 blocks with the same timestamp as its predecessor, giving a difference of 0.

The script I used to collect this data is at https://github.com/neldredge/bitcoin-blocks.

Real block intervals are difficult to know precisely, since we have no way of knowing with certainty the actual time at which each block was extracted. Some sites such as blockchain.info record the first time that their node received the block, but there is an unknown propagation delay between the moment a block is removed and the moment another node receives it (although for a well connected node it is probably don't be much more than 1 second). It is also possible to receive blocks out of service, so the difference in reception times could also be negative. In addition, such data is obviously not available for the first blocks before the existence of the site in question.

In principle, it might be possible to find the longest and shortest difference between reception times, but I don't know how to recover that data in bulk.

blockchain: how do people who use thin clients know the correct route of transactions they have sent without knowing the entire block?

How do A and B know Merkle's correct path without needing the entire block?

Many thin clients will synchronize with the longer chain of headers, under the assumption that other nodes in the network will verify the validity of the complete content of those blocks. (Consider: if each node were a thin client, miners could include invalid block transactions, and none of the thin clients would know!)

When requesting the intermediate states of the Merkle tree of a node that has the complete block, a thin client can verify that a transaction in which the user is interested is included in a block that is part of the longer chain, in a more Efficient way to validate the entire block itself (the warning is the assumption of validity mentioned above).

Do you need a centralized provider to process the blocks to calculate them? Is it possible to do it in a decentralized way?

This depends entirely on the implementation. Some light wallets can call back a certain server, operated by the wallet developers, for example. Other thin clients might try to extract this information from random nodes in the network. Some are even designed to connect to their own node.

Ultimately, the highest level of certainty will come from running a complete validation node yourself (that is, a complete node). As bitcoiners like to say: don't trust, verify.

services: if my application runs in the foreground or in the background, all other installed applications block the notification notification and do not interfere with Android Pie

I build the gameplay mode. If my application runs in the foreground or in the background, all other installed applications block the notification notification and there are no problems in Android Pie. So I have no idea. Use Service, Broadcast Receiver and NotificationListenerService.

Help me if you find the best solution.

services: block all other notification notifications if my application runs in the foreground in Android Studio

I build the gameplay mode. If my application runs in the foreground or in the background, all other installed applications block the notification notification and there are no problems in Android Pie. So I have no idea. Use Service, Broadcast Receiver and NotificationListenerService.

Help me if you find the best solution.

// ************************************************ ***

Public class BGService extends the Service {

public int counter = 0;
Sqlitehelper sqlitehelper;
CallReceiver callReceiver;
private ActivityManager mActivityManager;

public BGService(Context applicationContext) {
    super();

    Log.i("HERE", "here I am!");
}
public BGService(){

}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    super.onStartCommand(intent, flags, startId);
    startTimer();
    return START_STICKY;
}

@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onDestroy() {
    super.onDestroy();
    Log.i("EXIT", "ondestroy!");

    Intent broadcastIntent = new Intent(this, RestarterBroadcastReceiver.class);
    sendBroadcast(broadcastIntent);

    stoptimertask();
}

private Timer timer;
private TimerTask timerTask;
long oldTime = 0;

public void startTimer() {
    //set a new Timer
    timer = new Timer();
    //initialize the TimerTask's job
    initializeTimerTask();

    //schedule the timer, to wake up every 1 second
    timer.schedule(timerTask, 1000, 1000 * 15); //
}

/**
 * it sets the timer to print the counter every x seconds
 */
public void initializeTimerTask() {
    timerTask = new TimerTask() {
        public void run() {

            Log.i("in timer", "in timer ++++  " + (counter++));
            printForegroundTask();


        }
    };
}


private void printForegroundTask() {
    sqlitehelper = new Sqlitehelper(getApplicationContext());
    AppChecker appChecker = new AppChecker();
    String packageName = appChecker.getForegroundApp(getApplicationContext());

    if (packageName != null) {
        for (int i = 0; i < sqlitehelper.getAllQuestion_practice().size(); i++) {
            if (sqlitehelper.getAllQuestion_practice().get(i).getApplicationPackageName().equalsIgnoreCase(packageName)) {

                //***************current foreground app if save in db -close all notification-----
                if (sqlitehelper.getAllQuestion_practice().get(i).getNoti_block() == 1) {
                    //************notification off
                    NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

                    StatusBarNotification() barNotifications = new StatusBarNotification(0);
                    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
                        barNotifications = mNotificationManager.getActiveNotifications();
                    }
                    for(StatusBarNotification notification: barNotifications) {
                        if (notification.getId() != 11111) {
                            mNotificationManager.cancelAll();
                            Intent intent = new Intent(getApplicationContext(), NotificationListener.class);
                            startService(intent);
                        }
                    }


                } else {
                 //notification off
                    try {
                        NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                        if (mNotificationManager != null) {
                            mNotificationManager.cancel(11111);
                        }
                    } catch (Exception e) {

                    }
                }

            }

        }

    }

}



/**
 * not needed
 */
public void stoptimertask() {
    //stop the timer, if it's not already null
    if (timer != null) {
        timer.cancel();
        timer = null;

    }


}

@Nullable
@Override
public IBinder onBind(Intent intent) {
    return null;
}

}

// *********************************************
NotificationListener class.

@SuppressLint ("OverrideAbstract")

NotificationListener public class extends NotificationListenerService {
Context context;

@Override
public void onCreate() {
    super.onCreate();
    context = getApplicationContext();
}


@Override
public void onNotificationPosted(StatusBarNotification statusBarNotification) {
    if (statusBarNotification.getId() != 11111) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            cancelNotification(statusBarNotification.getKey());

            NotificationListener.this.cancelAllNotifications();

            boolean condition = true; // say your test is running
            if (condition)
                cancelAllNotifications(); //Cancel all the notifications . No Disturbance

        }


    }


}


@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
    Log.i("Msg", "Notification Removed");

    if (sbn.getId() != 11111) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            cancelNotification(sbn.getKey());
        }
    }
}

}

//****manifest–

  

    

    

    

    
        
            
        
    

How to override this file in magento2 Magento Bundle Block Catalog Product View Type Bundle Options.php

How to override this file in magento2 Magento Bundle Block Catalog Product View Type Bundle Option

8 – How to access the block ID in hook_block_view_alter ()?

How can I access the block ID in hook_block_view_alter ()?

function mysite_block_view_alter(array &$build, DrupalCoreBlockBlockPluginInterface $block) {

  if ('my-block-id' == $block->maybe_there_is_some_method_that_returns_the_id()) {
    // Do something.
  }
}

Is there any way to inspect the $ block variable? I am discovering that calling var_dump or kint inside hook_block_view_alter () has no effect.

Actually, I have not been able to confirm that the hook is triggered at all:

function mysite_block_view_alter(array &$build, DrupalCoreBlockBlockPluginInterface $block) {

  Drupal::logger('mei')->warning('did it fire at all');
}

The above does not generate any message in the registry.