python – Standards for explaining a simple programming function

If I want from an associate to write a simple module (software function – python to say more clearly), and considering writing a SDD is overkill for this task, how would you explain it to him briefly?

  • The inputs of the function
  • The expected outputs
  • Expected error handling (raising specific errors when needed to)
  • Other limitations

Are there any standards for this; especially in pyhthon?

8 – Configure JS standards correctly in Drupal

How to configure the code editor correctly

First, this is not a problem, it is a question about the correct use of standards in an IDE integrated development environment.

I found myself trying to configure eslint for Drupal in PHPStorm, and it really is confusing.

ESLint Standards
For example, I have installed the node dependencies that comes in the web / core / package.json file

In PHPStorm in the Eslint settings I have configured,
web/core/node_modules/eslint, but with this module (eslint-config-drupal), I don’t know if to configure it with node_modules/eslint which is in the root where I installed eslint-config-drupal. The same goes for prettier.

When I check the Drupal Js code standards using for example the command:

$(web/core) ./node_modules/.bin/eslint --no-ignore "../modules/custom/my_module/js/file.js"

As you can see I had to pass the --no-ignore argument in order to see the style errors.

NPM scripts

The package.json that brings the drupal core has some interesting commands that I am interested in using, such as transpiling ES6 to ES5, what the core does is transpile a file called file.es6.js to file.js in it. same place that the file is located.

In the drupal documentation I see that the command can be used apparently like this:

$(web/core) npm run build:js -- --file ../modules/custom/my_module/js/file.es6.js

But when doing it, I notice that the babel plugins do not process them and only show the same file, I only add a generic header text.

I understand that these commands are for the Drupal core, and if I temporarily copy my file.es6.js file to a location within the core, node with babel transpiles it correctly.

The only way that I have managed to transpile it is to copy the package.json, the core JS scripts, and use it in the root of the project. What I don’t like is having everything duplicated.

I don’t know if there is a way to use the standards, scripts, etc. that come from the core in a transparent way.


post meta – Correct processing of `$_POST`, following WordPress Coding Standards

I’m building a project that according to the specifications need to follow the WordPress Coding Standards. I am using phpcs to scan my code.

If I try to pass $_POST-data into a function without sanitizing it, I will get an error.

What I do before my code:

  • Verify that this is actually a POST request by checking that $_POST is set.
  • Verify that we have a value by checking if $_POST('faq_highlighted') is set.
  • Verify the nonce field using wp_verify_nonce to make sure that the request is from a valid source.

The code

I noticed that depending on how i pass the posted value, the the error will behave differently, or disappear, even though there is no change to the functionality of the code.

Version 1

In this version, I check if $_POST('faq_highlighted') is set. If it is, I update_post_meta against the meta key faq_highlighted with the value of $_POST('faq_highlighted').

// Version 1.
if ( isset( $_POST('faq_highlighted') ) ) {
    update_post_meta( $post_id, 'faq_highlighted', $_POST('faq_highlighted') ); // Error on this line.

This rightfully gives me the following error on row 3:

$_POST data not unslashed before sanitization. Use wp_unslash() or similar.
Detected usage of a non-sanitized input variable: $_POST(‘faq_highlighted’)

Version 2

In this version, without any unslashing, escaping or sanitazion, I pass the value of $_POST('faq_highlighted') into a variable called $value_of_post_faq_highlighted. And I get the same error, but on that line.

This makes sense, as it’s the use of a $_POST variable that is not unslashed that is triggering the error.

// Version 2.
$value_of_post_faq_highlighted = $_POST('faq_highlighted'); // Error on this line.
if ( isset( $post_faq_highlighted ) ) {
    update_post_meta( $post_id, 'faq_highlighted', $post_faq_highlighted );
Version 3

This is where it gets strange. I’m now passing the whole $_POST into a variable called $value_of_post. There is still no unslashing, escaping or sanitazion, but phpcs does not give me any warnings.

// Version 3 - No error!
$value_of_post = $_POST;
if ( isset( $value_of_post('faq_highlighted') ) ) {
    update_post_meta( $post_id, 'faq_highlighted', $value_of_post('faq_highlighted') );
  • Aren’t all the above mentioned blocks of code doing the exact same thing?
  • They should all fail the test, but why does the last one pass?
  • What would be the correct way of doing this?

As Version 3 passes, while still not looking okay to me, I’m not sure that my suggestion below is right either.

Version 4 – My suggestion

This is what I have come to use. I first wp_unslash and then sanitize_text_field, and I get no errors, which makes sense, as this is the only version that resolves the two errors from the first version.

// Version 4.
if ( isset( $_POST('faq_highlighted') ) ) {
    update_post_meta( $post_id, 'faq_highlighted', sanitize_text_field( wp_unslash( $_POST('faq_highlighted') ) ) );

standards – What is the PKCS#7 detached signature format?

This website claims that (emphasis added):

In PKCS#7 SignedData, attached and detached formats are supported… In detached format, data that is signed is not embedded inside the SignedData package instead it is placed at some external location…

However, RFC2315 seems to define no such “detached” format.

  • SignedData comprises:
    • version = INTEGER 1
    • digestAlgorithms: SET OF DigestAlgorithmIdentifier
    • contentInfo, comprising:
      • contentType = data (OBJECT ID “1.2.840.113549.1.7.1”)
      • content: Data = the message that was signed
    • signerInfos: SET OF SignerInfo, each comprising:
      • version = INTEGER 1
      • issuerAndSerialNumber
      • digestAlgorithm: DigestAlgorithmIdentifier
      • encryptedDigest: EncryptedDigest = the low-level signature

Neither SignedData/contentInfo nor ContentInfo/content:data are OPTIONAL; and the former may only be one of the six defined types: data, signedData, envelopedData, signedAndEnvelopedData, digestedData, and encryptedData; I see no detachedData or any similar options. (Choosing digestedData does not resolve it, as ContentInfo/content:digestedData is also non-optional.)

What belongs in the contentInfo field of a detached SignedData object?

ISO/IEC 13818-3 – Does apple iTunes have documentation on standards for audio file’s uploaded for streaming and the iTunes store

Documentation related to the ISO/IEC 13818-3 standard. The standard for information technology, generic coding of moving pictures, and associated audio information systems.

I would like to know before coding and modifying audio files such as .mp4 files submitted to the iTunes store or other media type’s such as Podcasts, that it applies to Apple’s media standards.

  • Or is there a universal pre-processing stage Apple implements when such audio files are submitted to iTunes?

So far I have only found a utility set that allows conversion from .wav files to .mp4 by iTunes. Would be nice to know what these conditions these droplet files and scripts provide, specification-wise.

The Mastering Suite (Apple)

Most Helpful Way To Tell Someone The Quality Of Their Work Is Not Meeting The Give Standards

Discussion in ‘Self Improvement and Being Successful’ started by StyYLL, May 5, 2021 at 1:26 PM.

  1. StyYLL




    New Member

    Likes Received:

    I have a friend that wants to work with me and I want to work with them. But it takes almost as much time from me to help them do the jobs and double check the work as it would for me to do it by myself. I would also know the work was done 100% right… How do I tell them I want to keep working with them, but they need to practice more to be able to do the work? Is that reasonable to not pay them while they practice? I have paid them in the past to do this but they need more pratice.



    May 5, 2021 at 1:26 PM

Share This Page

coding standards – chdir() should show my custom message rather than warning

chdir() should show my custom message rather than a warning

Here is My code

if ( false ===  chdir('a') ){
    echo 'Path is Not Valid';


$a = chdir('a');
if ( false ===  $a ){
    echo 'Path is Not Valid';

Expected Output

Path is Not Valid

Actual Output

Path is Not ValidPHP Warning:  chdir(): No such file or directory (errno 2) in /home/cg/root/3745402/main.php on line 

authentication – While we put elaborate standards to authenticate users (eg via OAuth), why do APIs only need an API Key?

Today, OATH is the standard for Authenticating Users. It employs an elaborate setup to eliminate all vulnerabilities.

YET, when it comes to APIs, the standard is just have an API Key inserted in the HTTP Request Header. Voila, you’re in. This is even adopted by google.

Why is this so? These API endpoints are public!