magento2 – Convert XML via XSLT

I want to convert & compatible the below XML file structure with Magento 2 via XSLT,
I start handling it but cannot complete it.

product.xml

<products>
<product>
    <id>234234</id>
    <code>TEST</code>
    <price>16</price>
    <stockamount>2983</stockamount>
    <catalog>
        <!(CDATA( A ))>
    </catalog>
    <category>
        <!(CDATA( B ))>
    </category>
    <subcategory>
        <!(CDATA( C ))>
    </subcategory>
    <color>Black</color>
    <description>
        <!(CDATA( ))>
    </description>
    <fabric>
        <!(CDATA( ))>
    </fabric>
    <published>2020-03-04 20:05:47</published>
    <sizes>
        <size>
            <name>55</name>
            <amount>997</amount>
        </size>
        <size>
            <name>50</name>
            <amount>993</amount>
        </size>
        <size>
            <name>48</name>
            <amount>993</amount>
        </size>
    </sizes>
    <images>
        <image>http://example.com/1.jpg</image>
        <image>http://example.com/2.jpg</image>
        <image>http://example.com/3.jpg</image>
        <image>http://example.com/4.jpg</image>
    </images>
</product>

XSLT:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" encoding="utf-8" indent="no"/>
<xsl:strip-space elements="description fabric catalog category subcategory" />

<xsl:template match="products">
    <xsl:element name="product">
        <xsl:for-each select="product">
            <xsl:element name="sku">
                <xsl:value-of select="id"/>
            </xsl:element>
            <xsl:element name="name">
                <xsl:value-of select="code"/>
            </xsl:element>
            <xsl:element name="price">
                <xsl:value-of select="price"/>
            </xsl:element>
            <xsl:element name="qty">
                <xsl:value-of select="stockamount"/>
            </xsl:element>
            <xsl:element name="color">
                <xsl:value-of select="color"/>
            </xsl:element>
            <xsl:element name="description">
                <xsl:value-of select="description"/>
            </xsl:element>
            <xsl:element name="fabric">
                <xsl:value-of select="fabric"/>
            </xsl:element>
            <xsl:element name="categories">
                <xsl:value-of select="normalize-space(concat(catalog,"https://magento.stackexchange.com/",category,"https://magento.stackexchange.com/",subcategory))"/>
            </xsl:element>
        </xsl:for-each>
    </xsl:element>
</xsl:template>
</xsl:stylesheet>

CurrentXMLResult:

<?xml version="1.0" encoding="utf-8"?>
<product>
<sku>234234</sku>
<name>TEST</name>
<price>16</price>
<qty>2983</qty>
<color>Black</color>
<description></description>
<fabric></fabric>
<categories>Women / Clothes / Dresses</categories>
</product>

ExpectedXMLResult:

<?xml version="1.0" encoding="utf-8"?>
<product>
<sku>132320</sku>
<name>BBT102103-B2</name>
<price>16</price>
<qty>2983</qty>
<color>Black</color>
<description></description>
<fabric></fabric>
**<categories>Women/Clothes/Dresses</categories>**
<base_image>http://example.com/1.jpg</base_image>
<small_image>http://example.com/2.jpg</small_image>
<thumbnail_image>http://example.com/3.jpg</thumbnail_image>
<additional_image>http://example.com/4.jpg</additional_image>
size as configurable_variations etc...
</product>

Thanks.

text – Convert bulleted and numbered list HTML code to Markdown in AppleScript?

I have this text to manipulate in AppleScript (e.g. the text of a variable):

Example note exported from Apple.

<ul>
  <li>Indent</li>
  <ul>
    <li>*Further* indent</li>
    <ul>
      <li>Even **further **indent. With a (link)(https://duck.com).</li>
    </ul>
  </ul>
</ul>

End note.

I’m converting it all to Markdown from HTML. I need to clean up this remaining bit of HTML which is the bullet list, so that the result is:

Example note exported from Apple.

- Indent
    - *Further* indent
        - Even **further **indent. With a (link)(https://duck.com).

End note.

It has to be able to cater to nested indenting with some rich text inside the items such as this example. I prefer Markdown output to use hyphens and either a tab or two spaces for the indenting.

It also has to be containable inside the applescript – no external .py files etc, and to not require homebrew or a third party tool to be installed.

shaders – How to convert from frag position to UV coordinates when my viewport doesn’t cover the screen?

So, I’m implementing SSAO as part of my rendering pipeline using OpenGL/GLSL. It works pretty well when I have a camera that takes up the entire screen. However, when my camera is smaller than the full screen size, the SSAO texture doesn’t get sampled correctly. Here is the relevant GLSL shader code:

// Convert from clip-space
vec2 fragCoords = (fragPos.xy/ fragPos.w); // fragPos is MVP * worldPosition
vec2 screenCoords = fragCoords * 0.5 + 0.5; // Convert from (-1, 1) to (0, 1) to sample UV coordinates

// Sample texture
float ssaoFactor = texture2D(ssaoTexture, screenCoords).r;

I know that there is some funkiness going on with the viewport, but the fixes that I’ve tried haven’t worked. My first thought was to scale fragCoords by normalized size of my viewport (e.g. vec2(0.5, 0.5) for a viewport with half of the width and height of the screen), but that just produced a very strange result. Any thoughts?

python – Convert custom image dataset to tf.data format

I am following the TF Image Segmentation and wanted to convert my Custom dataset in the same format. There are 4 folders 2 image folder for Train and Validation and 2 label images folder(indexed png) for train and validation.

I’m trying to convert this custom data into a tf.data format so that it will be easier to follow the tutorial

My Code:

path_to_train_images = input_img_paths(:10)
buffer_size = 400
train_dataset = tf.data.Dataset.list_files(path_to_train_images)
train_dataset = train_dataset.shuffle(buffer_size)
train_dataset = train_dataset.map(
    load_image_train, num_parallel_calls=tf.data.experimental.AUTOTUNE)
train_dataset = train_dataset.batch(batch_size)

test_dataset = tf.data.Dataset.list_files(path_to_test_images)
test_dataset = test_dataset.map(
  load_image_test, num_parallel_calls=AUTOTUNE)
test_dataset = test_dataset.batch(batch_size)

load image:

@tf.function
def load_image_train(datapoint):
  input_image = tf.image.resize(datapoint('image'), (128, 128))
  input_mask = tf.image.resize(datapoint('segmentation_mask'), (128, 128))

  if tf.random.uniform(()) > 0.5:
    input_image = tf.image.flip_left_right(input_image)
    input_mask = tf.image.flip_left_right(input_mask)

  input_image, input_mask = normalize(input_image, input_mask)

  return input_image, input_mask

I am not sure how can I get datapoint(‘segmentation_mask’) in the load_image_train() function because
tf.data.Dataset.list_files() takes only one argument i.e. path of a folder at a time.

8 – Imagemagick error convert delegate failed `’cwebp’

i’m following this guide

I’ve installed Imagemagick, run

composer require drupal/imagemagick
drush en -y imagemagick

and all next steps.

After add convert to WEBP to specific image style, receive this error:

ImageMagick error 1: convert: delegate failed `'cwebp' -quiet -q %Q '%i' -o '%o'' @ error/delegate.c/InvokeDelegate/1919. [command: /Applications/MAMP/bin/apache2/bin/convert '/Applications/MAMP/htdocs/mysite/sites/default/files/2020-10/image.png' -resize 406x376! -crop 336x376+35+0! -quality 70 WEBP:'/Applications/MAMP/htdocs/mysite/sites/default/files/styles/image_336x376/public/2020-10/image.png.webp']

But if run this command in my Terminal:

/Applications/MAMP/bin/apache2/bin/convert '/Applications/MAMP/htdocs/mysite/sites/default/files/2020-10/image.png' -resize 406x376! -crop 336x376+35+0! -quality 70 WEBP:'/Applications/MAMP/htdocs/mysite/sites/default/files/styles/image_336x376/public/2020-10/image.png.webp'

convert correctly

My OS is Macos Catalina 10.15.7, i’ve installed yet webp with homebrew

google cloud functions – Typescript convert File to Uint8ClampedArray

Is there a way to convert a File to an Uint8ClampedArray in Typescript?

Or is there maybe a way to convert the File to an Image? That way I could access the ImageData which is of type Uint8ClampedArray.

Also, side question: How can you get a File from the File path?

Thanks!

Unity3D: Convert all game objects to same size irrespective of it’s scale

Suppose I have a reference GameObject, Cube, with scale (1,1,1). There is another GameObject with scale (1,1,1), but the size is 3 times bigger than the Cube. How do I dynamically change the scale of the Game objects to fit the size of the Cube?

krita – Convert multi-layer Paint.NET (pdn) files to Krit (kra)

I am moving to a Mac from Windows and thus moving away from Paint.NET.

I have several multi-layer Paint.NET (.pdn) files that I would like to continue using. How can I move these easily to Krita?

I know I could save each layer as a separate image and create a new Krita project and add each layer one by one. I would prefer a single multi-layer export and import or something simple like that.

I have one solution that I have discovered that I will post as an answer, but welcome any better answers!

In Google Docs, can I highlight a few words or a dozen words and convert it to a table?

For example, if I listed some items in Google Docs:

Cherry Blossom
Mushroom
Pine cone, Acorn
Maple leaf
Snowflake

and now I want to highlight them and convert them to a table with 5 rows with each row having each line above, is it possible? Or do I have to create a new table, and cut-and-paste the 5 lines, or use highlight and drag and drop? So if there are 20 lines, it has to be repeated 20 times?

Convert to list with React

I have the following code:

const appendRowsToFile = async () => {
let cA = customerArticle;
let cL = listSelectCustumer;

let articles = cA.filter(a => a.price && a.price > 0)

/*console.log(cA, cL, articles)
setListSelectNewTable(())*/

if (articles) {
  let row = cL.map(c => {
    return (articles.map(a => {
      return { ...a, ...c }
    }))
  })
  
  console.log(row)
  articles = row
  console.log(articles)
  var tabla = ()
  tabla.forEach(l => { 
    
    tabla.push(l) })
    console.log(tabla)
  setListSelectNewTable(tabla)
}

}

What I want is to pass cA and cL to setListSelectNewTable to show it in a table, but when I do it it only saves the information of "row" of cA and not of cL

Any solution?