design decision – already existed bad design [on hold]

If there is an already existed project but with bad design and there is no time for refactoring and code enhancement for the already existed code. So for example in a layered architecture rest web service , the service layer classes are interacting with each other directly without interface (coupled) So is it a good decision to put an interface for my new service added unlike the rest ?

TWRP: vendor partition is not existed

I try to flash LineageOS on a OnePlus 5 (cheeseburger). I installed TWRP 3.3.0-0 from here. I repeatedly wiped the partitions.

What I cannot manage is to adb sideload LineageOS 16.0. I get this message:

Starting ADB sideload feature... Installing zip file '/sideload/package.zip' Error: Vendor partition doesn't exist! Updater process ended with ERROR: 7 

I have read here that I should install the latest stock ROM (from here), but that results in almost the same error message:

Starting ADB sideload feature... Installing zip file '/sideload/package.zip' vendor partition is not existed, exit ota!! Updater process ended with ERROR: 7 

How can I create/populate/fix that vendor partition?

How to Replace Words with Hypertext Link But Ignore Previously Existed Links?

Auto-linking for “selected words” in the_content I am currently using the following code:

function wp_affiliate_links($  text){     $  replace = array(  '/ example /' => ' <a rel="nofollow" href="http:example.com">example</a> ', '/ Google /' => ' <a rel="nofollow" href="http:Google.com">Google</a> ',     );         }     $  text = preg_replace( array_keys($  replace), $  replace, $  text, 1 );     return $  text;     } add_filter('the_content', 'wp_affiliate_links');  

But the problem is that – it also try to replace the word that’s already hyperlinked and spoils the whole code. If word “example” or Google are linked or comes into a previously linked phrase then it replace (and mess) inside the <a hreaf=""> tag too.

I want to to ignore few tags like <a>, <h1>, <button> etc. I’ve tried a lot but no luck.

nginx redirect non existed sub-domain to named subdomains issue

Let’s say I have the following domains:

example.com in cloudflare

with these subdomains:

test1.example.com test2.example.com … test10.example.com

test1.example.com is accessable with https or http and test2 to test10 are working well with http. I installed letsencrypt wildcard ssl on test1.example.com with this command

sudo certbot --server https://acme-v02.api.letsencrypt.org/directory --manual --preferred-challenges dns  --installer nginx -d nexlabs.better.hr 

Here is the issue come. Before I installed letsencrypt, when user go non-existance domains like gggg.example.com and hhhh.example.com, they get served by the standard nginx index.html. After I installed letsencrypt when someone enter domain like gggg.example.com , it automatically redirect to test1.example.com. I don’t want to happen like this . and here is my nginx conf file for this

upstream test1_api {     server < some_ip >:8523; } upstream test1_dashboard {  server < some_ip >:3523; } server {     listen       443 ssl;     server_name  test1.example.com;     access_log  /var/log/nginx/log/test1/access.log;     error_log  /var/log/nginx/log/test1/error.log;     index  index.html index.htm;      ssl on;     ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;  managed by Certbot     ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;  managed by Certbot     include /etc/letsencrypt/options-ssl-nginx.conf;  managed by Certbot     ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;  managed by Certbot     location / {      proxy_pass  http://test1_dashboard;      proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;      proxy_redirect off;      proxy_buffering off;      proxy_set_header        Host            $  host;      proxy_set_header        X-Real-IP       $  remote_addr;      proxy_set_header        X-Forwarded-For $  proxy_add_x_forwarded_for;    }      location /api/ {      proxy_pass  http://test1_api/;      proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;      proxy_redirect off;      proxy_buffering off;      proxy_set_header        Host            $  host;      proxy_set_header        X-Real-IP       $  remote_addr;      proxy_set_header        X-Forwarded-For $  proxy_add_x_forwarded_for;    }  } server {      listen       80;     server_name  test1.better.hr;     access_log  /var/log/nginx/log/test1/access.log;     error_log  /var/log/nginx/log/test1/error.log;     index  index.html index.htm;      location / {      proxy_pass  http://test1_dashboard;      proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;      proxy_redirect off;      proxy_buffering off;      proxy_set_header        Host            $  host;      proxy_set_header        X-Real-IP       $  remote_addr;      proxy_set_header        X-Forwarded-For $  proxy_add_x_forwarded_for;    }      location /api/ {      proxy_pass  http://test1_api/;      proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;      proxy_redirect off;      proxy_buffering off;      proxy_set_header        Host            $  host;      proxy_set_header        X-Real-IP       $  remote_addr;      proxy_set_header        X-Forwarded-For $  proxy_add_x_forwarded_for;    } } 

Please help me to find out the issue .

How to write content into a file without bothering whether the file existed or not

If am using C++14 and I want to write some contents into a file. The simple objective is to create a file and write the content into it. And, do this irrespective of whether this file existed or not existed.

The logic is pretty simple and here it is.

Code:

const std::string some_file_path = "/some/file"; std::ifstream some_file_if(some_file_path); std::ofstream some_file_of(some_file_path.c_str());  // If some_file already existed, will this override all the contents and replace it with new contents? some_file_of << some_file_path;  if (some_file_if.good()) {     std::cout << "The file is created and it now exists" << std::endl; } 

The logic works ok.

Question/review:
All I want to confirm is that, on the line of code where I do some_file << some_file_path, will it override all the contents of some_file if it already existed? If it does, then this is how I want it to be.

I just wanted to know if there are better ways of writing the code I have above without falling into the trap logic of checking if the file existed do this and if did not do that!

Other than that, Please let me know if there are opinions on how to do this in a better way if there are any..