kubuntu – Prevent programs (wine/steam) from disabling monitors

I use Kubuntu 18.04 on my Laptop with two monitors connected.

Some programs (Mostly Wine, Steam and Proton) sometimes disable both of my secondary monitors.
For instance, sometimes (not always, which is weird) when I launch Steam all of my monitors would flicker for a while (even the primary monitor) and the secondary monitors would stay black or just one of them stays dark.
This also happens when I launch games in steam (proton / wine) and also when I just type winecfg in my terminal.

How can I permanently prevent applications from turning off my screens?

Sometimes the monitors show up as “disabled” in system settings and sometimes they don’t show up at all and I have to pull the HDMI/DP cable and reconnect it.

postgresql – How to prevent implicit casting from bytea to text during the current connection in postgres?

for example if there are non-ASCII bytes it cannot work smoothly

Why would you think so? bytea is coerced to either hex (default) or escape format when assigned to a text column. Non-ASCII characters are encoded automatically. Should work “smoothly” at all times – except that you don’t want to allow it.

How do I make (implicit) casts from bytea to text throw an exception only within the current connection?

… I can add a preceding SQL statement before every statement, that’s no problem.

Solution with custom cast

Currently (all versions incl. Postgres 13) the cast from bytea to text has no explicit entry in the system catalog pg_cast. It is provided by basic input/output functions of the respective types. This behavior can be overruled with an explicit entry, created with CREATE CAST.

You need to be the owner of the involved types, so this basically means you have to be superuser install it.

Create this casting function once per database:

CREATE FUNCTION public.text(bytea, int, bool) 
  RETURNS text
  LANGUAGE plpgsql STABLE STRICT PARALLEL SAFE AS
$func$
BEGIN
   IF $3 THEN           -- true if the cast is an explicit cast, false otherwise.
     -- no infinite loop because we do the cast manually
     -- honors current setting for bytea_output, hence function not IMMUTABLE
      RETURN textin(byteaout($1));
   ELSE
      RAISE EXCEPTION 'Assignment cast from bytea to text forbidden by custom cast rules in this database!';
      RETURN textin(byteaout($1));  -- we should *never* get here!
   END IF;
END
$func$;

To allow creating / dropping the special cast to unprivileged roles, add wrapper functions. Do this as superuser (or as dedicated daemon role):

CREATE FUNCTION public.f_create_cast_bytea2text() 
  RETURNS void
  LANGUAGE sql SECURITY DEFINER AS
'CREATE CAST (bytea AS text) WITH FUNCTION public.text(bytea, int, bool) AS ASSIGNMENT;';

CREATE FUNCTION public.f_drop_cast_bytea2text() 
  RETURNS void
  LANGUAGE sql SECURITY DEFINER AS
'DROP CAST IF EXISTS (bytea AS text);';

Now you can do what you asked for:

BEGIN;
SELECT public.f_create_cast_bytea2text();  -- optionally activate your casting rule

INSERT INTO tbl(txt_col)
VALUES ('00'::bytea::text, 'local bytea_output: hex');    -- explicit cast still works!

INSERT INTO tbl(txt_col)
VALUES ('00'::bytea); -- but assignment cast forbidden! -> ERROR

SELECT public.f_drop_cast_bytea2text();  -- deactivate your casting rule
END;

db<>fiddle here — second half does not execute due to missing privileges.

Extended test case

Test table:

CREATE TABLE test(id int, txt_col text, note text);
INSERT INTO test(id, txt_col, note) VALUES
  (-1, 'foo', 'plain text input')
, ( 0, '00'::bytea, 'default bytea_output: ' || current_setting('bytea_output'));

No exception raised:

BEGIN;
SELECT public.f_create_cast_bytea2text();

SET LOCAL bytea_output = 'hex';
INSERT INTO test(id, txt_col, note)
VALUES (1, '00'::bytea::text, 'local bytea_output: hex');    -- explicit cast still works

SET LOCAL bytea_output = 'escape';
INSERT INTO test(id, txt_col, note)
VALUES (2, '00'::bytea::text, 'local bytea_output: escape'); -- explicit cast still works

SELECT public.f_drop_cast_bytea2text();
END;

Also no exception:

BEGIN;
SELECT public.f_drop_cast_bytea2text();

SELECT '00'::bytea || text 'foo'; -- implicit cast still works

SELECT public.f_drop_cast_bytea2text();
END;

Exception raised:

BEGIN;
SELECT public.f_create_cast_bytea2text();

INSERT INTO test(id, txt_col, note)
VALUES (3, '00'::bytea, 'must fail!'); -- assignment cast forbidden!

SELECT public.f_drop_cast_bytea2text();
END;

postgresql – How to prevent different connections treating bytea in same query differently?

I find that identical postgresql queries issued by two different clients are handled differently. Specifically, bytea values are inserted differently.

A query that demonstrated the behaviour is this:

INSERT INTO "TestTable" ("Input") VALUES (decode('74657374', 'hex'))

74657374 is hexadecimal for ‘test’. In one client, ‘test’ is inserted into the “Input” field, whether that field is text/varchar or bytea. That is the behaviour I desire. In another client, ‘x74657374’ is inserted into the “Input” field, whether it is text/varchar or bytea. This string is the postgresql literal representation of the bytea bytes of ASCII ‘test’. But the sql literal syntax itself is inserted. I do not desire this behaviour.

I use a single piece of hand-written SQL, the bytea value only occurs “within” the query (if column “Input” has type Text then none of literals nor the receiving column have bytea type), and it seems unlikely to me that either client is parsing then rebuilding the query. Therefore it seems that the difference must be happening on the server where the query is executed. That means there must be some connection specific configuration setting which is altering the server behaviour.

Can anyone please tell me what connection specific settings could be altering this behaviour?

I know the queries are really behaving differently and it is not a display issue etc., because I can see the rows in the same table having different values (‘test’ and ‘x74657374’). I have tried various alternative bytea handling methods, but they are all affected by this problem. For those who are interested, the “good” client is pgAdminIII and the “bad” client is Ruby PG gem. Though for the reason I gave above I believe there must be some built-in feature of postgresql supporting this behaviour.

magento2 – How do I prevent empty checkout fields from being validated on page load?

I am using Magento 2.3.5 and Amasty’s “One Step Checkout” module. Amazon Pay is also present.

When viewing the checkout page, it seems something is trying to validate the <input> fields even though the user hasn’t entered anything:

enter image description here

Is this something anyone has encountered before?

dnd 5e – Ways to prevent Counterspell from being cast?

You can counterspell a counterspell to prevent it from effecting the original spell. It can also be prevented by simply being out of range of counterspell (60ft or 120ft with a sorcerer’s distant spell).

You could also deny the enemy a reaction through multiple different effects such as Stun or slow.

All of your options seem pretty viable. If the person doesn’t see the spell, they can’t counterspell it.

My Bose QuietComfort 35 II headphones are connected to Windows 7 and an iPad: how can I prevent Windows 7 from muting the audio coming from the iPad?

My Bose QuietComfort 35 II headphones are connected to Windows 7 and some iPad (iPad Pro MM172LL/A): how can I prevent Windows 7 from muting the audio coming from the iPad? Even when no audio is played on Windows 7, I have to disconnect the Bose QuietComfort 35 II headphones from Windows 7 to be able to hear the iPad.

d

How to prevent sleep on Ubuntu 20.04 Live

I’m using a Ubuntu 20.04 Live USB to run some gparted and backup work across my drives, but it keeps going to sleep after a while, stopping the backup process.

The settings menu crashes when I try to open it so I can’t access the power settings to turn off sleep. How do I stop it from going to sleep?

Things i’ve tried:

didn’t work

8 – How can I prevent one template from displaying cached values?

I have a site with Drupal 8.9 and I created a TWIG file to display a counter on my home page.

I deactivated the cache of each block which is integrated in the templates :

enter image description here

My problem :

The counter never changes, to update it I have to do a drush cr

How to correct this problem ?

myfile.html.twig

{% set dangers = 0 %}
{% if drupal_view_result('boutique_page_liste_des_taches_aucun_produit', 'block_1', store_entity.id()) is empty %}
  {% set dangers = dangers + 1 %}
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_aucune_variation', 'block_1', store_entity.id()) is not empty %}
  {% set dangers = dangers + 1 %}
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_commande', 'block_1', store_entity.id()) is not empty %}
  {% set dangers = dangers + 1 %}
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_mode_de_livraison', 'block_1', store_entity.id()) is empty %}
  {% set dangers = dangers + 1 %}
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_passerelle_de_paiement', 'block_1', store_entity.id()) is empty %}
  {% set dangers = dangers + 1 %}
{% endif %}

Vous avez {{ dangers }} tâches importantes à traiter dans votre {{ store_entity.type.entity.label }} "{{ store_entity.name.value }}".
<a href="http://drupal.stackexchange.com/store/{{ store_entity.id }}/tasks" data-drupal-link-system-path="/store/{{ store_entity.id }}/tasks">Voir la liste</a>

Maybe I should add something to my .theme file.

To deactivate the cache of this template.

Or update this code with JS.