linux – LADSPA (custom) module on PulseAudio

I’m trying to make a LADSPA module which streams any audio currently playing to a FIFO pipe. The script works like a charm with ALSA (tried using the apply-plugin and aplay commands). Now, for a system-wide operation, I tried to add it to PulseAudio using the commands in this answer:

pacmd load-module module-ladspa-sink sink_name=alsa_output.pci-0000_00_1f.3.analog-stereo master=ladspa_out plugin=myamp label=amp_example control=2,,,,

(I checked: the sink_name is the name outputted by pactl list sinks short, the file is called myamp.so and the path to it is in the LADSPA_PATH variable)

However, when using pacmd list-modules, it isn’t there (there are no LADSPA related modules in the whole list).

The script itself is a very slightly modified version of this script: https://pastebin.com/unCnjYfD (the modifications include opening a FIFO pipe and writing to it, while removing the actual amplification).
The script uses the controls as follows (at least, I hope it will be used that way): first is skipped (artifact from the original script), then two input channels (left, right), then two output channels (left, right).

My ultimate goal is to have the module load on boot & just listen to all audio passing through the sound card. How is this achieved?

In case it helps:
System information:
OS: Manjaro (Kernel 5.10.2-2-MANJARO)
WM/DE: KDE Plasma 5.20.4
PulseAudio: 14.0
ALSA: k5.10.2-2-MANJARO (lib & utils: 1.2.4)

Thank you in advance for your help!

8 – Creating an API via module routing files that includes csrf verification headers

I am working on migrating a custom API from D7 to D8 and am doing so by using module routing. I have a routing.yml file that looks like so:

ytp_user.api.login:
  path: "/api/v1/user/login"
  defaults:
    _title: "User API Login"
    _controller: 'Drupalytp_userControllerUserAPIController::login'
  methods: [POST]
  requirements:
    _csrf_request_header_token: "TRUE"
ytp_user.api.get_current_user:
  path: "/api/v2/user/me"
  defaults:
    _title: "User API Get Current User"
    _controller: 'Drupalytp_userControllerUserAPIController::getCurrentUser'
  methods: [GET]
  requirements:
    _custom_access: 'Drupalytp_userControllerUserAPIController::authorize'

In the first route, I am trying to validate a csrf token provided in the headers, via the requirement _csrf_request_header_token: "TRUE", however, this does absolutely nothing. It doesn’t validate or even check that the header exists as the documentation suggests it should.

I’ve tried replacing this with _csrf_token: 'TRUE' which at least checks that the token exists in the query, but I can’t get a valid token!!! If I grab a token from /session/token and then pass it along in the query as ?token=<token-from-session/token> then I just get an error saying the CSRF token is invalid.

Am I missing another step or is the documentation just straight up incorrect? I have been searching for hours and everything suggests that what I have should work, so why is the CSRF token not being validated properly?

dungeons and dragons – Trying to find an early D&D module that had a drider lair

I played this module about 25 years back and don’t remember much of it, but it did have these features:

There was a ‘trap’ consisting of a long chain that descended into a pool leading to an underwater tunnel, and eventually dead-ended stapled to a blank rock face, drowning the character who thought they could use the chain to pull themselves to air on the far side.

There was an empty drider lair above the main corridor than you had to climb up into. It was dusty and empty except for one 50gp gem.

There was a very long, steep, narrow, winding corridor going down at some point.

It was likely a module for player levels 1-4, and may have been for beginning DMs as well.

Given the drider and the corridor going down, I thought perhaps it was Descent into the Depths of the Earth, but that’s for too high a character level.

Anyone remember this?

blocks – Panelizer content missing on module update

I’m in the process of migrating a client’s Drupal 8 installation to the preferred composer structure (outside of docroot), but having a single issue causing a full stop. They use Panelizer for most pages, and most layouts are Flexible (flexible_layout). The issue is that anything that uses the Flexible layout seems unable to see any blocks. Other layouts are fine. The Flexible layout itself seems intact, all rows/regions are where they should be and labeled properly, just missing the blocks. The blocks are still there, as reverting the change fixes the problem.

Current (working) setup.

  • Drupal 8.9.7
  • Panelizer 8.x-4.1
  • Panels 8.x-4.3
  • Ctools 8.x-3.0
  • Composer inside docroot, but not for modules, only core.

Steps I’ve tried:

  • Migrate composer to outside docroot, use composer for all modules,
    pinned at current versions.
  • Migrate composer as above, also update Drupal to 8.9.11 (before 12
    came out).
  • Migrate composer as above, let all modules update as needed, also update Drupal to 8.9.11 (before 12 came out).
  • Only update panelizer/panels/ctools. Tried going up one release each,
    and going fully current.

Every step always ends up with the empty Content page for a Flexible layout. Everything else all seems to work fine. Reverting any step gets it working fine again.
When the Content page is empty, the front end of the node is blank except for anything not part of the panelized page (header/footer/template renderings/etc).
I think this is specifically in panelizer, but can’t be sure. It also happens when just doing the composer migration and keeping the versions the same…

Question: Does anybody know what could cause the disappearing blocks?

I have no contact with the original developers, and am not very familiar with the inner workings of Drupal.

htaccess – Understanding mod_expires apache module

Working with htaccess is a new capitol for me. I have already read about mod_expires here https://httpd.apache.org/docs/current/mod/mod_expires.htm, but I’m stil confused.

I have the next code from stack overflow:

ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access plus 2 months"

My questions are:

  1. I suppose the line ExpiresByType image/jpg "access 1 year" tells the client (browser) to download the file and keep it for one year. And when the client accesses the same page from my website, the jpg image won’t be downloaded from my website. It will be read from his computer (where the browser saved first time). After one year, the browser automatically deletes the file and, once the client access my website, it will download again, for another year. If the client cleans his browser history after 2 months, then the browser will download it again even if a year hasn’t passed. Do I miss something ?

  2. What cache availability should I set for each file type ? It depends on the file ? What should I consider when set the expiration time ?

  3. What’s the difference between "access 1 year" and "access plus 1 year" ?

  4. Does ExpiresDefault rule works for php files too ? I mean, if I have a contact.php file with some content and I modify the content of contact.php, because of ExpiresDefault rule, the content won’t change to the user ?

  5. Do search engine spiders listen for this cache rules or they download the files each time they crawling my website ?

  6. Is it true that ExpiresDefault is for the files I don’t set using ExpiresByType ? If the answer is yes, what are the other types ? What types of files are included here ?

  7. Do I understand correct that Header set Cache-Control "max-age=290304000, public" is the maximum time allowed for a file to be cached ? If the answer is yes, then means that "access 999 years" will take no effect as long 290304000 is the limit. True or false ?

javascript – Cannot use import statement outside a module – Typescript e Babel

Eu tenho a seguinte configuração:

Package.json:

 "scripts": {
    "start": "node dist/server",
    "build": "babel src --extensions ".js,.ts" --out-dir dist --copy-files --no-copy-ignored",
    "dev:server": "ts-node-dev --inspect --transpile-only --ignore node_modules src/server.ts",
    "typeorm": "ts-node-dev ./node_modules/typeorm/cli.js"
  },

tsconfig.json:

{
  "compilerOptions": {
    "target": "es2017",
    "module": "commonjs",
    "allowJs": true,
    // "outDir": "./build",
    "rootDir": "./src",
    "removeComments": true,
    "noImplicitAny": false,
    "strictPropertyInitialization": false,
    "moduleResolution": "node",
    "typeRoots": (
      "./node_modules/@types",
      ".src/@types"
    ),
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "skipLibCheck": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "baseUrl": ".",
    "paths": {
      "@middlewares/*": (
        "./src/middlewares/*"
      ),
    }
  },
  "include": (
    "src/**/*"
  )
}

babel.config.js:

module.exports = {
  presets: (
    (
      '@babel/preset-env',
      {
        targets: {
          node: 'current'
        }
      }
    ),
    '@babel/preset-typescript'
  ),
  plugins: (
    ('module-resolver', {
      alias: {
        '@config': './src/config',
        '@database': './src/database',
        '@helpers': './src/helpers',
        '@middlewares': './src/middlewares',
        '@models': './src/models',
        '@routes': './src/routes',
        '@schemas': './src/schemas',
        '@services': './src/services',
      }
    }),
    'babel-plugin-transform-typescript-metadata',
    ("@babel/plugin-proposal-decorators", { "legacy": true }),
  ),
  ignore: ('**/*.spec.ts'),
}

Após gerar a build da minha API, é retornado o seguinte erro:

(node:21680) UnhandledPromiseRejectionWarning: C:UsersLucasDocumentsProjetosBetsbets - backendsrcmodelsBankroll.ts:2
import {
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:979:16)
    at Module._compile (internal/modules/cjs/loader.js:1027:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Function.PlatformTools.load (C:UsersLucasDocumentsProjetosBetsbets - backendnode_modulestypeormplatformPlatformTools.js:109:28)
    at C:UsersLucasDocumentsProjetosBetsbets - backendnode_modulestypeormutilDirectoryExportedClassesLoader.js:39:69
    at Array.map (<anonymous>)
    at Object.importClassesFromDirectories (C:UsersLucasDocumentsProjetosBetsbets - backendnode_modulestypeormutilDirectoryExportedClassesLoader.js:39:10)
    at ConnectionMetadataBuilder.buildEntityMetadatas (C:UsersLucasDocumentsProjetosBetsbets - backendnode_modulestypeormconnectionConnectionMetadataBuilder.js:50:97)
    at Connection.buildMetadatas (C:UsersLucasDocumentsProjetosBetsbets - backendnode_modulestypeormconnectionConnection.js:495:57)
    at Connection.<anonymous> (C:UsersLucasDocumentsProjetosBetsbets - backendnode_modulestypeormconnectionConnection.js:127:30)
    at step (C:UsersLucasDocumentsProjetosBetsbets - backendnode_modulestslibtslib.js:141:27)
    at Object.next (C:UsersLucasDocumentsProjetosBetsbets - backendnode_modulestslibtslib.js:122:57)

Eu não consegui entender o motivo do erro, uma vez que ele está tentando executar um arquivo ts após a transpilação pelo babel (com o babel tendo gerado todos os arquivos .js sem problema).

nodes – Access Paragraph fields programmatically in custom module

I have a Product content type with these fields; title, body, and one entity reference revisions(Paragraph: field_select_module).

I am creating a custom REST API(custom module) to export the fields in the JSON. I am able to print the title and body. Could someone help me to print the paragraph fields which have title and image(Media) and title and image will repeat 3 times. It should be inside this array ‘product_list’ => array(),

Here is my controller.

<?php

namespace Drupaldrupalup_json_apiController;

use DrupalCoreControllerControllerBase;
use DrupalnodeEntityNode;
use SymfonyComponentHttpFoundationJsonResponse;
use DrupalparagraphsEntityParagraph;

/**
 * Controller for export json.
 */
class JsonApiController extends ControllerBase {

  /**
   * {@inheritdoc}
   */
  public function data() {
    $json_array = array(
      'data' => array()
    );
    $nids = Drupal::entityQuery('node')->condition('type','product_main_categories')->execute();
    $nodes =  Node::loadMultiple($nids);

    foreach ($nodes as $node) {
      $json_array = array(
        'id' => $node->get('nid')->value,
        'title' =>  $node->get('title')->value,
        'content' => $node->get('body')->value,
        'product_list' => array(
            
        ),
      );
    }
    return new JsonResponse($json_array);
  }
}

forms – Adding a dependent field with the Business Rules module makes the loading time and queries increase abnormally

I have an entity form with a dependent field. The dependent field is created following this guide and using Business Rules module.

Everything works fine, but now the form takes an insane amount of time to load (7011.24 ms) and makes an insane amount of queries (4040).

These queries come from business_rules.process and many of them are repeated. For example, this one SELECT name, value FROM key_value_expire WHERE collection = :collection AND expire > :now is made 1287 times.

If I disable the Bussines Rules module or remove the dependent field, everything goes to normal, with ~120 queries and normal form loading time.

Is there something I am missing? If not, any alternatives to make a dependent field?

python 3.x – How to schedule a code to run everyday using sched module?

I want my code to run everyday at a specific time evryday, I would have used scheduler module but for some reason I am unable to import it. So I decided to use sched and time module, here is my code:

### this library lets us randomise numbers:
import random  
###this library lets us copy the message to clipboard automatically:
import pyperclip 
# ###this library schedules to run the code:
import sched
###this library gives us access to time:
import time


def ok(ele):
    """this function takes in a string and multiply it with a random number between 20 and 50, feel free to change the range"""       
    x=str(ele)*random.randint(20,50)
    return(x)

def send_message():
      message=f'g{ok("o")}d morn{ok("i")}n{ok("g")} br{ok("o")}'  ### this is a f string, with this format we can easily insert variables and functions within a string...very convinient
      pyperclip.copy(message)
      print(message)

installation – How to configure a pre-installed module in centos8?

I have a fresh centos8 machine which has the module chrony pre-installed. From the chrony documentation, it mentions a flag (--disable-sechash) that I can add to configure:

If development files for the Nettle, NSS, or libtomcrypt library are
available, chronyd will be built with support for other cryptographic
hash functions than MD5, which can be used for NTP authentication with
a symmetric key. If you don’t want to enable the support, specify the
–disable-sechash flag to configure.

I looked up the chrony source code and I found this description within the configure file:

`configure' configures this package to adapt to many kinds of systems.

Usage: ./configure (OPTION)...

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit

How do I run this configure? Do I have to navigate to a directory where chrony lives and run this file? How do I find that directory if so?