installing – How do I avoid overwriting the .htaccess file when I use the Compose command?

On my new Drupal 9 website, I customized the .htaccess file and the robots.txt file

I don’t want its files to be overwritten when updating with Composer.

I added the lines below in my composer.json file but the .htassess file is overwritten every time. What’s wrong with my code ? Thank you

"extra": {
    "drupal-scaffold": {
        "locations": {
            "web-root": "./"
        },
        "file-mapping": {
            "[web-root]/.htaccess": false,
            "[web-root]/robots.txt": false
        }
    },
...

linux – On Ubuntu 20.04, DHCP keeps overwriting static address assigned via Network Manager

I have properly configured the interface with this yaml file:

network:
  renderer: networkd
  ethernets:
    ens33:
      addresses: (192.168.174.131/24)
      gateway4: 192.168.174.2
      nameservers:
        addresses: (8.8.8.8, 8.8.4.4)
      routes:
        - to: 192.168.174.0
          via: 192.168.173.131
    lo:
      addresses: (127.0.0.1/24,0.0.0.0/24)

and the route table shows the access to the VMNAT8 address (which is 192.168.174.20):

my_env) ubuntu@ubuntu2010:/etc/netplan$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         _gateway        0.0.0.0         UG    0      0        0 ens33
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.174.0   0.0.0.0         255.255.255.0   U     0      0        0 ens33

The problem is after a period of time, an ipv6 address is assigned to ens33, as if the dhclient ran and ignored the static configuration.

The question is how to prevent this from happening? I have not found a solution suggested on the various sites which describe related issues.

Am I over-writing unsafe data with this strcpy_s?

const myName = "BlueBug";
char* name = new char(strlen(string) + 1); //allocate spaces
strcpy_s(newLine, strlen(string)+1,  string); //Tada! perfect
//Hey but what if... I do this?

const myNewName = "SuchAVeryLongNameIHave";
strcpy_s(name, strlen(myNewName ) + 1, myNewName ); 
// 

I am copying my new name to, starting from the location in which….

my previous name has started, but my previous name is a lot shorter than myNewName

Shouldn’t i be yelled at because my previous name was BlueBug,

so I only allocated 8 character lengths… but I am now writing 10+ characters without allocating space

How to avoid overwriting a value in Unity (C#)

I’m working on a Tower Defence style game, and wondering how best to handle the “resources” part. I have multiple enemies on screen at a time, and when an enemy dies, it updates a resource that allows the player to build more towers

var tower = Instantiate(buildables(0), center, Quaternion.identity);
var controller = tower.GetComponent<TowerController>();
controller.OnKilledEnemy += (sender, args) =>
{
    int.TryParse(goldAmount.text.Replace(",", ""), out var curr);
    curr += args.gold;
    goldAmount.text = $"{curr:n0}";
};

But if 2 enemies die in the same frame, wouldn’t the value there miss an update?

What ways are there in Unity/C# to mitigate this problem?

Does overwriting a file consumes extra space?

I have 1gb available space in my HDD which is composed of mainly movies and I want to overwrite files with same names and file size. The file that I want to replace is a 2gb movie and I want to replace it with the exact same file but with subtitles because I copy the movie from my HDD to my desktop and put subtitles on it and now I want to replace the movie with no subtitle with it. So my question is does overwriting a file consumes extra space?

magento2.3.4 – M2 – Custom theme custom Font overwriting by bootstrap fonts

I have laca adobe font,

and my _typography.less

& when (@media-common = true) {
    .lib-font-face(
    @family-name: @font-family__base,
    @font-path: '@{baseDir}fonts/Laca-Regular',
    @font-weight: 400,
    @font-style: normal,
    @font-display: swap
    );
    }
    @font-family__base: 'laca, sans-serif';

if i inspect bootstrap font applied,

enter image description here

How to solve this issuemagento2.3.?

magento2 – Overwriting block is not used in 2.4.1

I’m simply trying to overwrite the following method with a preference, but I can’t get it work after over 3 hours of trying and scratching my head at the sheer amount of effort required to do such a simple thing. I’ve read about a dozen posts and articles on how to do this, but none of the suggested solutions work.

Method to overwrite MagentoCatalogBlockProductListProduct::_getProductCollection to add additional filtering on the product collection displayed on catalogsearch/result/?q=xyz.

Module is correctly set up and shows to be enabled through CLI.

Vendor/Module/etc/di.xml (tried etc/frontend/di.xml also):

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="MagentoCatalogBlockProductListProduct" type="VendorModuleBlockProductListProduct" />
</config>

Testing the overwrite with the ObjectManager yields my class:

<?php
require_once 'app/bootstrap.php';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
$sample = $bootstrap->getObjectManager()->create('MagentoCatalogBlockProductListProduct');
var_dump(get_class($sample)); 
// Prints VendorModuleBlockProductListProduct

I have the module block at Vendor/Module/Block/Product/ListProduct.php, but it does not get used.
I have also tried adding my own layout update at Vendor/Module/view/frontend/layout/catalog_category_view.xml in an attempt to try filtering our some results on the template level, but it does not use my template.

<?xml version="1.0"?>
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
    <referenceBlock name="category.products.list">
        <action method="setTemplate">
            <argument name="template" xsi:type="string">Vendor_Module::product-list.phtml</argument>
        </action>
    </referenceBlock>
</layout>

I have tried the any combinations of the following each time file changes are made:

  • All cache turned off
  • cache:clean/flush
  • setup:di:compile
  • rm -rf generated
  • print-die methods and xdebug breakpoints on my files

I have noticed:

  • Manually using ObjectManager yields my class.
  • My module is turned on (module:status)
  • di.xml and catalog_category_view.xml are indeed read. Having invalid XML breaks the page.
  • Xdebug will not stop at my files, but stops on the core Magento_Catalog files.

Any idea what’s going on?

python – Multiple if-statements with overwriting lists

I currently have the following piece of code in place that attempts to find matches within a list, based on a priority system:

possible_combinations = ("ABC", "AB", "A", "D")


if len(possible_combinations) >= 1:
    chosen_combination = (comb for comb in possible_combinations if ("A" in comb) and ("C" in comb))
    if (len(chosen_combination) == 0):
        chosen_combination = (comb for comb in possible_combinations if ("A" in comb))
        if (len(chosen_combination) == 0):
            chosen_combination = (comb for comb in possible_combinations if ("C" in comb))
            if (len(chosen_combination) == 0):
                raise ValueError(f"No match found.")
                
print(chosen_combination)

('ABC')

Is there any way I could refactor this code to get rid of these if-statements, and thereby make my code look nicer?

Ansible: Append string to a list in inventory without overwriting the original content

I have a ansible inventory which is structured like this:

(organization:children)
debian
ubuntu    

(ubuntu:children)
application1
apllication2

(debian:children)
application3
apllication4

(application1)
server1

(application2)
server2

(application3)
server3

(application4)
server4
server5

Now i want to specify a list on organization level var1 = string1, string2 and add more strings to this depending on the group:

var1 should have the content of "(organization.var1) + string3 + string4" for all debian servers and "(organization.var1) + string5" for all ubuntu ones.

My previous workaround is to specify role_X system_X and os_X variables on each group level and add their content to one variable which contains all values together, which can then be used in a task.

backup – How can I rsync multiple subfolders without overwriting content for folders with the same name?

I’m having troubles with the following problem. I want to save one subfolder with a common name of many subfolders. For example, use the following commands to prepare the scenario:

cd /tmp/
mkdir deleteme/
cd deleteme/
mkdir -p folder1/backups
mkdir -p folder2/backups
mkdir destination
touch folder1/backups/file1
touch folder1/dont_copy_this
touch folder2/backups/file2
touch folder2/dont_copy_this
touch folder2/backups/file1
# Make some file the same name
echo "1" > folder1/backups/file1
echo "2" > folder2/backups/file1

Now we have something as follows using tree:

.
├── destination
├── folder1
│   ├── backups
│   │   └── file1
│   └── dont_copy_this
└── folder2
    ├── backups
    │   ├── file1
    │   └── file2
    └── dont_copy_this

I want to have only store the root path if this folder and the destination folder. And then copy from source to destination with one command having at the end something like this. I want to use rsync because there are huge files which I don’t want to copy again unless there is something missing.

destination/
├── folder1
│   └── backups
│       └── file1
└── folder2
    └── backups
        ├── file1
        └── file2

My intial guess was having something like the following:

source=folder*/backups/
destination=destination/

and used in rsync:

rsync -rAvz --progress folder*/backups/ destination/

But this won’t create the top folder of backups and the file1 will be overwritten.

Is there something I can do without the need of having more than 2 parameters so that I can still use this for other folder structures?