[Solved] How to rem...
 
Notifications
Clear all

[Solved] How to remove duplicate attributes from HTML tag and leave last only

0 Posts
1 Users
0 Likes
5 Views
0
Topic starter
Andreas Hunter Asks: How to remove duplicate attributes from HTML tag and leave last only
I have like this html code in my project:

Code:
<p class="text-red" class="text-green">hello <span class="text-red" class="text-green">world</span></p>

How I can remove from span tag duplicate attribute class with class name text-red?

Valid result:

Code:
<p class="text-green">hello <span class="text-green">world</span></p>

It's possible without using any parser except regex?


enter image description here

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

Unreplied Posts

[Solved] How to include python script inside a bash script

Amal P Ramesh Asks: How to include python script inside a bash script
I need to include below python script inside a bash script.

If the bash script end success, I need to execute the below script:

Code:
#!/usr/bin/python    
from smtplib import SMTP
import datetime
debuglevel = 0

smtp = SMTP()
smtp.set_debuglevel(debuglevel)
smtp.connect('192.168.75.1', 25)
smtp.login('my_mail', 'mail_passwd')

from_addr = "My Name <my_mail@192.168.75.1>"
to_addr = "<my_mail@192.168.75.1"
subj = "Process completed"
date = datetime.datetime.now().strftime( "%d/%m/%Y %H:%M" )
#print (date)
message_text = "Hai..nnThe process completed."

msg = "From: %snTo: %snSubject: %snDate: %snn%s" % ( from_addr, to_addr, subj, date, message_text )

smtp.sendmail(from_addr, to_addr, msg)
smtp.quit()

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.
 
 
 

[Solved] How do I configure grub to boot another linux distribution off an lvm partition?

Cestarian Asks: How do I configure grub to boot another linux distribution off an lvm partition?
(I no longer have this setup so I cannot test new answers, sorry. I had to switch computers and am now only using arch; I am leaving the question as it is though since I’d love to know a solution if it occurs again, grub has been very hostile towards me these past few months) I have fedora 23 as my main OS with custom partitioning (all physical partitions) /boot/efi=/dev/sda1 root=/dev/sda3. Then on /dev/Sda2 I just set up an LVM physical partition, and created an LVM group (arch) and volume (root) and then I installed Arch Linux (without bootloader) on /dev/arch/root

I have /dev/sda (GPT), /dev/sdb (GPT) then grub also seems to detect a hd2 and gives errors about being unable to load it (I assume this is the LVM physical partition) anyhow, I use os-prober and grub2-mkconfig to detect my arch installation, which it successfully does (and does so two times, I get two menu entries for it); but when I try to boot it I get the following errors:

Code:
error: failure reading sector 0x0fc from 'hd2'.
error: failure reading sector 0x0e0 from 'hd2'.
error: failure reading sector 0x0 from 'hd2'.
error: can't find command 'linux'.
error: can't find command 'initrd'.

I only get the sector reading errors on the first boot attempt (for the record, fsck reports the drive to be clean) any retries only give me the can’t find command errors. This is the grub.conf menuentry:

Code:
### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Arch (on /dev/mapper/arch-Root)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-38305dfb-279b-4490-948b-480b81fef81f' {
    insmod part_gpt
    insmod lvm
    insmod ext2
    set root='lvmid/6ZmQFy-ijXr-mYra-3Gp9-l0dh-J4Wi-GSHXhd/WGN2VN-t34t-rYWi-kvje-2BfF-WoD4-4NinnP'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint='lvmid/6ZmQFy-ijXr-mYra-3Gp9-l0dh-J4Wi-GSHXhd/WGN2VN-t34t-rYWi-kvje-2BfF-WoD4-4NinnP'  38305dfb-279b-4490-948b-480b81fef81f
    else
      search --no-floppy --fs-uuid --set=root 38305dfb-279b-4490-948b-480b81fef81f
    fi
    linux /boot/vmlinuz-linux root=UUID=38305dfb-279b-4490-948b-480b81fef81f rw quiet
    initrd /boot/initramfs-linux.img
}

Anyone got any ideas how to fix this? Any solution that will allow me to boot into arch (besides reinstalling the bootloader from arch instead of fedora) will be fine; I don’t mind getting my hands dirty editing the grub.cfg file by hand.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] CentOS: Install git with yum says glibc requires glibc-common older than installed

Neil Asks: CentOS: Install git with yum says glibc requires glibc-common older than installed
I’m using CentOS 6 from Docker, and when I install git, I get this dependency error:

Code:
Error: Package: glibc-2.12-1.166.el6_7.7.i686 (updates)
           Requires: glibc-common = 2.12-1.166.el6_7.7
           Installed: glibc-common-2.12-1.192.el6.x86_64 (@CR/6.7)
               glibc-common = 2.12-1.192.el6
           Available: glibc-common-2.12-1.166.el6.x86_64 (base)
               glibc-common = 2.12-1.166.el6
           Available: glibc-common-2.12-1.166.el6_7.1.x86_64 (updates)
               glibc-common = 2.12-1.166.el6_7.1
           Available: glibc-common-2.12-1.166.el6_7.3.x86_64 (updates)
               glibc-common = 2.12-1.166.el6_7.3
           Available: glibc-common-2.12-1.166.el6_7.7.x86_64 (updates)
               glibc-common = 2.12-1.166.el6_7.7

You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

Service 'docker-project' failed to build: The command '/bin/sh -c yum install -y 
    java-1.8.0-openjdk-devel.x86_64 
    unzip 
    git 
    && yum clean all' returned a non-zero code: 1

This was working a few days ago without any changes. What happened to the CentOS repository?

For reference, here is my Dockerfile:

Code:
FROM centos:6
RUN yum install -y 
        java-1.8.0-openjdk-devel.x86_64 
        unzip 
        git 
    && yum clean all

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] How can I fix a “conflicting requests” kernel module error when running dnf update on Fedora 32?

Mister October Asks: How can I fix a “conflicting requests” kernel module error when running dnf update on Fedora 32?
Background: I’m running Fedora 32 on a Thinkpad. Current kernel version is as follows:

Linux 5.8.4-200.fc32.x86_64 x86_64

Problem: It was working as expected for several months, but now when I run dnf update the following error is given:

Code:
Error: 
 Problem 1: package kernel-modules-extra-5.7.15-200.fc32.x86_64 requires kernel-uname-r = 5.7.15-200.fc32.x86_64, but none of the providers can be installed
  - conflicting requests
 Problem 2: package kernel-5.7.15-200.fc32.x86_64 requires kernel-core-uname-r = 5.7.15-200.fc32.x86_64, but none of the providers can be installed
  - conflicting requests

Current situation / what I’ve tried: My (current, likely incorrect) understanding is that this older kernel package is being specified by some other package, and can’t be installed because it’s older and does not appear in the default repos.

I can get non-kernel packages to update by running dnf --excludepkgs=kernel* , but I’d like to 1) understand, and 2) fix this error so that I can get kernel updates normally.

I have researched the error somewhat (see links below), but none of the similar conflict errors match my situation very closely, and I’m reluctant to remove or disable the denoted module(s) without understanding what that might do.

All guidance much appreciated!

Links I’ve investigate to date:

(How to fix “Problem: conflicting requests…” on dnf install on Centos?)

(“package X requires Y, but none of the providers can be installed”)

(Askbot.fedoraproject.org archives are going away)

(yum update returns kernel error) NOTE: this one looks similar, but the config file fix suggested here is not applicable to my configuration

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Ubuntu vs CentOS Imagemagick output differences

Kalvin Klien Asks: Ubuntu vs CentOS Imagemagick output differences
I’m having an issue with ImageMagick on different machines.

The command I’m running: identify -verbose *.jpg 2>&1 | grep “Corrupt”

Here I’m trying to identify images in a folder that are corrupt:


partially uploaded image - corrupt

On CentOS machine I’m getting the correct output for this image:

Code:
identify: Corrupt JPEG data: premature end of data segment `sdfsd.jpg' @ warning/jpeg.c/JPEGWarningHandler/390.

But, on Ubuntu Machine I’m not getting Corrupt line at all.

ImageMagick Version on CentOS:

Code:
Version: ImageMagick 6.9.10-68 Q16 x86_64 2021-02-24 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP(3.1)
Delegates (built-in): bzlib cairo fontconfig freetype gslib jng jp2 jpeg lcms ltdl lzma openexr pangocairo png ps rsvg tiff wmf x xml zlib

ImageMagick Version on Ubuntu

Code:
Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff webp wmf x xml zlib

What gives? Why is the output different? Why is there no “corrupt” output?

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Update an deeply nested array of objects based on an object : Javascript

li97 Asks: Update an deeply nested array of objects based on an object : Javascript
I am having an deeply nested array of objects with certain properties, and given an object as input, it should update that object along with its children recursively. The format it has is as follows,

Code:
const arr = [
  {
    name: "parent",
    children: [
      {
        name: "child1",
        children: [
          {
            name: "granchild1",
            children: [],
            class: "level-2 leaf",
            config: {
              name: "granchild1",
              value1: false,
              value2: false
            }
          }
        ],
        class: "level-1 leaf",
        config: {
          name: "child1",
          value1: false,
          value2: false
        }
      },
      {
        name: "child2",
        children: [],
        class: "level-1 leaf",
        config: {
          name: "child2",
          value1: false,
          value2: false
        }
      }
    ],
    class: "level-0 group",
    config: {
      name: "parent",
      value1: false,
      value2: false
    }
  }
];

The given input object will look like

Code:
const obj = {
  name: "parent",
  value1: true,
  value2: true
};

Given this input, the object with matching name should update it’s and children’s value1 and value2 with the obj's values

Output should look like

Code:
const result = [
  {
    name: "parent",
    children: [
      {
        name: "child1",
        children: [
          {
            name: "granchild1",
            children: [],
            class: "level-2 leaf",
            config: {
              name: "granchild1",
              value1: true,
              value2: true
            }
          }
        ],
        class: "level-1 leaf",
        config: {
          name: "child1",
          value1: true,
          value2: true
        }
      },
      {
        name: "child2",
        children: [],
        class: "level-1 leaf",
        config: {
          name: "child2",
          value1: true,
          value2: true
        }
      }
    ],
    class: "level-0 group",
    config: {
      name: "parent",
      value1: true,
      value2: true
    }
  }
];

Code that I tried. How do I achieve the same output

Code:
const res = arr.map((item) => {
  let foundItem = arr.find((item) => item.name === obj.name);
  return {
    ...foundItem,
    children: {
      value1: obj.value1,
      value2: obj.value2
    }
  };
});

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] How C++ alias works?

alexHX12 Asks: How C++ alias works?
How does alias internally work in C++?
Does it allocate its own memory like pointers?
Otherwise how does the compiler treat it?
Is it like C++ Macro preprocessor computing?

Code:
int x=5;
int &y=x; //Assembly of this???

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Using xml2 to add child node with an attribute

Dubukay Asks: Using xml2 to add child node with an attribute
I’m using R’s xml2 package to edit an XML document. I’d like to add a node with a specific XML attribute, but I don’t seem to understand the syntax of add_child_node.

Adding a node works great:

Code:
library(xml2)
my_xml <- read_xml("<fruits><apple/><banana/></fruits>")
xml_add_child(.x = my_xml, .value = "coconut")
my_xml

# {xml_document}
# <fruits>
# [1] <apple/>
# [2] <banana/>
# [3] <coconut/>

and according my understanding of the documentation, I should be able to add an attribute to the node by using the ellipsis argument to provide a named vector of text:

Code:
my_xml <- read_xml("<fruits><apple/><banana/></fruits>")
xml_add_child(.x = my_xml, .value = "coconut", c(id="new"))
my_xml

# {xml_document}
# <fruits>
# [1] <apple/>
# [2] <banana/>
# [3] <coconut>new</coconut>

However, this appears to simply insert the text into the node, as it does when the text is unnamed. The attribute doesn’t show up at all.

What I’d like to get is this:

Code:
# {xml_document}
# <fruits>
# [1] <apple/>
# [2] <banana/>
# [3] <coconut id="new"/>

Any thoughts? I’m aware that I can set attributes manually after the fact using xml_attr<- but my use case doesn’t support that method very well.

Snapshot of the documentation for anyone who doesn’t want to pull it up:
Documentation from ?xml2::add_child_node

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Convert PDF to HTML with PHP

Ítalo Torres Lima Asks: Convert PDF to HTML with PHP
Hey guys some days ago i did a conversor with pdf.js that converts PDF to HTML with JavaScript, and now i need to do the same with PHP. Someone know how some lib that can helps me or somethig like that?

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Clean up white space in middle of text

Brando Asks: Clean up white space in middle of text
I’ve read quite a few different posts related to cleaning up text at the end, and a few that talk about cleaning in the middle, but none seem to work for me. Here’s what I’m trying to do:

I’ve got an alert on a home page that will display an alert message. From there I’ll capture the message and pass it into a separate value ( the separate value isn’t important though).

Code:
<div class="globalAlert-text col-md-12 col-xs-12">
    <div class="alert-left" style="width: 100%;">
        <span class="alert-left-body">
          <strong>My App Update : </strong>
          <span class="alert-desc">
            If you’re unable to access the mobile app, please visit the Apple App Store (for iOS) or Google Play (for Android) and update the app on your mobile device.

          </span>
          <span class="notification-desc  " style="display: inline;">
            If you’re unable to access the mobile app, please visit the Apple App Store (for iOS) or Google Play (for Android) and update the app on your mobile device.

          </span>
         </span>
     </div>
     <div class="cta-link">
                                         </div>
</div>

From there I’m trying to use jQuery to capture the alert message using one of the following:

Code:
jQuery('.globalAlert-text').text().trim(str.replace(/[tn]+/g,' '))
jQuery('.globalAlert-text').text().trim(str.split(/s/).join(' '))

Both return the following:

‘My App Update : nttttt nttttttIf you’re unable to access the mobile app, please visit the Apple App Store (for iOS) or Google Play (for Android) and update the app on your mobile device.nnttttt nttttt nttttttIf you’re unable to access the mobile app, please visit the Apple App Store (for iOS) or Google Play (for Android) and update the app on your mobile device.’

I’ve been racking my brain on this and can’t seem to figure out a good way to clean this up. Is there something I’m missing here?

Thanks for the help!!

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

Share: