views – Create a custom block programmatically in Drupal 8

I couldn't find a way to show view and restrict certain roles.

But I have managed to solve the problem in another way.

I created a script in Admin> Structure> Block> My_Block> Configure> PHP Visibility:

getAccount()->getRoles(TRUE);
$hide_from_roles = array('administrator', 'sefii', 'membership');
 if (count(array_intersect($heh, $hide_from_roles)) > 0) {
    $match = FALSE;
}
return $match;
?>

networks: can a MOFI4500 block domains on a schedule within a day?

I use a MOFI4500-4GXeLTE-V2 as the primary Internet in my home. It provides wired and WIFI connectivity and I'd like to block some attention-grabbing social media domains during the first half of my day, but allow them in the second half of the day.

I found an option on the MOFI menus to lock a domain directly, adding it to the Blacklist in the "Mofi Lock" section, but I don't see any sync option.

I tried iptables, but it seems this is the wrong approach to lock a domain. I see an application acl but that doesn't seem to be installed in the Mofi shell and I'm not sure if I could install it.

I'm sure I could easily do this on my desktop PC, but I have many devices and am not interested in a solution that involves managing them separately.

Performance – Estimating Block Bootstrap in Java – Part 2

The following is my attempt at parallelization (I learned about parallel computing last weekend, so I'm very new to it) and making the code more efficient in my previous question Block Bootstrap Estimation using Java. The text.txt text file can be found at https://drive.google.com/open?id=1vLBoNmFyh4alDZt1eoJpavuEwWlPZSKX (download the file directly if you want to try it out – there are some weird things you won't select) above even via Notepad notes). This is a small 10×10 data set with maxBlockSize = 10, but this needs to scale up to twenty 5000 x 3000 data sets with maxBlockSize = 3000, just to get an idea of ​​the scale.

import java.io.FileInputStream;
import java.lang.Math;
import java.util.Scanner;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.FileOutputStream;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.DoubleStream;

public class BlockBootstrapTestParallel {

    // Sum of a subarray, based on B(x, i, L) -- i is one-indexing
    public static double sum(double() x, int i, int L) {
        return IntStream.range(i, i + L)
                        .parallel()
                        .mapToDouble(idx -> x(idx - 1))
                        .sum();
    }

    // Mean of a subarray, based on B(x, i, L) -- i is one-indexing
    public static double mean(double() x, int i, int L) {
        return IntStream.range(i, i + L)
                        .parallel()
                        .mapToDouble(idx -> x(idx - 1))
                        .average()
                        .orElse(0);
    }

    // Compute MBB mean
    public static double mbbMu(double() x, int L) {     
        return IntStream.range(0, x.length - L + 1)
                        .parallel()
                        .mapToDouble(idx -> mean(x, idx + 1, L))
                        .average()
                        .orElse(0);
    }

    // Compute MBB variance
    public static double mbbVariance(double() x, int L, double alpha) {
        return IntStream.range(0, x.length - L + 1)
                        .parallel()
                        .mapToDouble(idx -> (Math.pow(L, alpha) * Math.pow(mean(x, idx + 1, L) - mbbMu(x, L), 2)))
                        .average()
                        .orElse(0);
    }

    // Compute NBB mean
    public static double nbbMu(double() x, int L) {
        return IntStream.range(0, x.length / L)
                        .parallel()
                        .mapToDouble(idx -> (mean(x, 1 + ((idx + 1) - 1) * L, L)))
                        .average()
                        .orElse(0);
    }

    // Compute NBB variance
    public static double nbbVariance(double() x, int L, double alpha) {

        double varSum = IntStream.range(0, x.length / L)
                                 .parallel()
                                 .mapToDouble(idx -> (Math.pow(mean(x, 1 + ((idx + 1) - 1) * L, L) - nbbMu(x, L), 2)))
                                 .average()
                                 .orElse(0);

        return Math.pow((double) L, alpha) * varSum;

    }

    // factorial implementation
    public static double factorial(int x) {
        double() fact = {1.0, 1.0, 2.0, 6.0, 24.0, 120.0, 720.0, 5040.0, 40320.0, 362880.0, 3628800.0};
        return fact(x);
    }

    // Hermite polynomial
    public static double H(double x, int p) {
        double out = 0;
        for (int i = 0; i < (p / 2) + 1; i++) {
            out += Math.pow(-1, i) * Math.pow(x, p - (2 * i)) / 
                ((factorial(i) * factorial(p - (2 * i))) * (1L << i));
        }
        out *= factorial(p);
        return out;
    }

    // Row means
    public static double() rowMeans(double()() x, int nrows, int ncols) {
        double() means = new double(nrows);
        for (int i = 0; i < nrows; i++) {
            means(i) = mean(x(i), 1, ncols);
        }
        return means;
    }

    public static void duration(long start, long end) {
        System.out.println("Total execution time: " + (((double)(end - start))/60000) + " minutes");
    }


    public static void main(String() argv) throws IOException {
        final long start = System.currentTimeMillis();
        FileInputStream fileIn = new FileInputStream("test.txt");
        FileOutputStream fileOutMBB = new FileOutputStream("MBB_test.txt");
        FileOutputStream fileOutNBB = new FileOutputStream("NBB_test.txt");
        FileOutputStream fileOutMean = new FileOutputStream("means_test.txt");

        Scanner scnr = new Scanner(fileIn);
        PrintWriter outFSMBB = new PrintWriter(fileOutMBB);
        PrintWriter outFSNBB = new PrintWriter(fileOutNBB);
        PrintWriter outFSmean = new PrintWriter(fileOutMean);

        // These variables are taken from the command line, but are inputted here for ease of use.
        int rows = 10;
        int cols = 10;
        int maxBlockSize = 10; // this could potentially be any value <= cols
        int p = 1;
        double alpha = 0.1;
        double()() timeSeries = new double(rows)(cols);

        // read in the file, and perform the H_p(x) transformation
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                timeSeries(i)(j) = H(scnr.nextDouble(), p);
            }
            scnr.next(); // skip null terminator
        }

        // row means
        double() sampleMeans = rowMeans(timeSeries, rows, cols);
        for (int i = 0; i < rows; i++) {
            outFSmean.print(sampleMeans(i) + " ");
        }
        outFSmean.println();
        outFSmean.close();

        new Thread(() -> {
            for (int j = 0; j < rows; j++) {
                for (int m = 0; m < maxBlockSize; m++) {
                    outFSMBB.print(mbbVariance(timeSeries(j), m + 1, alpha) + " ");
                }
            outFSMBB.println();
            }           
            outFSMBB.close();
        }).start();

        new Thread(() -> {
            for (int j = 0; j < rows; j++) {
                for (int m = 0; m < maxBlockSize; m++) {
                    outFSNBB.print(nbbVariance(timeSeries(j), m + 1, alpha) + " ");
                }
            outFSNBB.println();
            }           
            outFSNBB.close();
        }).start();
        duration(start, System.currentTimeMillis());
    }
}

If it's useful, I have 8 cores available with 64GB of RAM, as well as two GPUs that I have no idea how to use (Intel UHD Graphics 630, NVIDIA Quadro P620). I will see how to use them in the coming days if necessary.

8 – How to restrict access to see a block for a certain role?

The base of the visibility block in the role is a built-in function of Drupal 8.

to go admin/structure/block and click on your wish block configure button

enter the image description here

so in the Visibility section, there is Role you can define for what function your module shows or not.

enter the image description here

8 – Is a block rendering array built with EntityViewBuilderInterface :: view supposed to represent the entire block template or just the internal fields?

After rendering custom blocks in templates, I got this js error: Quick Edit failed to associate markup of rendered entity field. What I have done so far:

To repeatedly represent custom blocks in templates, I wrote this function in mytheme.theme :

function render_block_in_template($block_id) {
  // $block = Drupal::entityTypeManager()->getStorage('block_content')->load($block_id);
  $block = Drupalblock_contentEntityBlockContent::load($block_id);

  if(!empty($block)) {
    $block_content = Drupal::entityTypeManager()
      ->getViewBuilder('block_content')
      ->view($block);

    if($block_content) {
      // kint($block_content);
      return $block_content;
    }
  }
}

And called him mytheme_preprocess_node :

function mytheme_preprocess_node(&$variables) {
  $node = $variables('node');

  if($node->bundle() == 'some_bundle') {
    $variables('some_block') = render_block_in_template(12);
    $variables('some_other_block') = render_block_in_template(13);
    // ...
  }
}

Then I render the blocks in node--some-bundle.html.twig :

{{ some_block }}
{{ some_other_block }}

So far so good. But I got this js error from quickedit.js:

Error: Quick edit failed to associate rendered entity field marking
(with (data-quickedit-field-id="block_content/12/body/fr/full")) with
corresponding processed entity markup: parent DOM node not found
with (data-quickedit-entity-id="block_content/12"). This is typically
caused by the theme template for this type of entity forgetting
print the attributes.

What brought me to this problem: Custom Block Interrupt Design Builder Module: Quick Edit was unable to associate rendering entity field markup, but applying the patch didn't change anything, and further reading allows me to think that this is not exactly related.

If I {{ kint(some_block) }} In twig, the #attributes key with the expected values ​​is here:

enter the image description here

and this is the HTML output:

// FIELD CONTENT

Lastly, wrapping it manually with the following eliminates the error:

So it seems that the above part of the envelope The block template is not rendered, only the fields are and cause the error.

Is there really a mistake or am I doing things wrong?

content – Block URL in Bing that still appears in search results

I am trying to block a URL from appearing in search results. I am the webmaster of the site, and the content has been removed, I used the URL blocking link 2 days ago and it is still showing up. Last night I used the content removal tool and the status shows "completed" and once again the link still appears.

How do I get rid of them as soon as possible?

8 – Is a block processed from EntityViewBuilderInterface :: view supposed to represent a complete block template or just internal fields?

To repeatedly represent custom blocks in templates, I wrote this little function in mytheme.theme :

function render_block_in_template($block_id) {
  // Both work below
  // $block = Drupal::entityTypeManager()->getStorage('block_content')->load($block_id);
  $block = Drupalblock_contentEntityBlockContent::load($block_id);

  if(!empty($block)) {
    $block_content = Drupal::entityTypeManager()
      ->getViewBuilder('block_content')
      ->view($block);

    if($block_content) {
      // kint($block_content);
      return $block_content;
    }
  }
}

And called him mytheme_preprocess_node :

function mytheme_preprocess_node(&$variables) {
  $node = $variables('node');

  if($node->bundle() == 'some_bundle') {
    $variables('some_block') = render_block_in_template(12);
    $variables('some_other_block') = render_block_in_template(13);
    // ...
  }
}

Then I render the blocks in node--some-bundle.html.twig :

{{ some_block }}
{{ some_other_block }}

So far so good. But I got this js error from quickedit.js:

BUG: Quick Edit Failed to Associate Processed Entity Field Markup
(with (data-quickedit-field-id = "block_content / 12 / body / fr / full")) with
corresponding processed entity markup: parent DOM node not found
with (data-quickedit-entity-id = "block_content / 12"). This is typically
caused by the theme template for this type of entity forgetting
print the attributes.

What brought me to this problem: Custom Block Interrupt Design Builder Module: Quick Edit was unable to associate rendering entity field markup, but applying the patch didn't change anything, and further reading allows me to think that this is not exactly related.

If I {{ kint(some_block) }} In twig, the #attributes key with the expected values ​​is here:

enter the image description here

and this is the HTML output:

// FIELD CONTENT

Lastly, wrapping it manually with the following eliminates the error:

So it seems that that part of the block template container is not rendered, just the fields. Is that correct ? Is there really a mistake or am I doing things wrong?

magento2: unable to remove block from Magento 2 home page

I am working on the Magento 2 website that someone developed before me. The website has Ultimate Theme.
I am trying to remove a block with a slider at the top of the home page. In the Ultime guide, that block is referred to as a static "preface" block (found below the navigation bar and just above the page content). The actual block has the CSS class "slideshow-wrapper-additional", but on the admin page under Content -> Blocks there is no block with that name.

So should i remove it using admin panel or direct connection via ftp / ssh?

I have Magento 2.2.9 and Ultimate Theme 2.

applications: application to block other applications and system settings

I am looking for an application that

  • It blocks any other application you select (by blocking I mean avoiding changing any settings of those applications, or even opening them), including system settings (so that for example system time cannot be changed or other applications cannot can be changed) installed)
  • it is protected by PIN or password, where the PIN or password can be arbitrarily long.

Can you tell me if there is such an application? I have a non-rooted phone running Android 9.

topic: subtopic that adds prefix to all block machine names

On my site, I have created a subtopic of a subtopic using this as a guide to configure this https://www.drupal.org/docs/8/theming-drupal-8/creating-a-drupal -8-sub-theme -or-sub-theme-of-sub-theme and works with handover of all css / js / regions but for some reason it is renaming all blocks with the subtopic prefix.

So for example I have a block with a primary navigation machine name when I install / set the subtopic by default it will change this block to theme3_mainnavigation.

I have tried to delete the block and put it back with the same main navigation name, but I run into a problem where a message will appear saying that this machine name already exists.

Does anyone know how to fix this so that the subtopic uses the machine names of the existing names instead of creating a prefix?

Thanks for any help!