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.


        <!(CDATA( A ))>
        <!(CDATA( B ))>
        <!(CDATA( C ))>
        <!(CDATA( ))>
        <!(CDATA( ))>
    <published>2020-03-04 20:05:47</published>


<xsl:stylesheet version="1.0"

<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 name="name">
                <xsl:value-of select="code"/>
            <xsl:element name="price">
                <xsl:value-of select="price"/>
            <xsl:element name="qty">
                <xsl:value-of select="stockamount"/>
            <xsl:element name="color">
                <xsl:value-of select="color"/>
            <xsl:element name="description">
                <xsl:value-of select="description"/>
            <xsl:element name="fabric">
                <xsl:value-of select="fabric"/>
            <xsl:element name="categories">
                <xsl:value-of select="normalize-space(concat(catalog,'/',category,'/',subcategory))"/>


<?xml version="1.0" encoding="utf-8"?>
<categories>Women / Clothes / Dresses</categories>


<?xml version="1.0" encoding="utf-8"?>
size as configurable_variations etc...


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.

    <li>*Further* indent</li>
      <li>Even **further **indent. With a (link)(</li>

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)(

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.

domain driven design – Primitive obsession, value objects, Commands, Events and where to convert

I tried to combine two rules.

  1. Don’t fall to primitive obsession (e.g. EMailAddress should be a value object in domain objects and not a string).
  2. Don’t use value objects in commands and events.

If commands and events should not contain value objects (for obvious and often discussed reason) they contain something as ” EMailAddress” as string.
In the aggregate it should be handled as an EMailAddress value object with it’s own constraints and checking.

So far, so good.

But where does the conversion happen?
Do we call a “void DoIt(string eMailAddress)” method on the aggregate root and one of its first actions is to convert the string into an EMail value object?
Or does the CommandHandler do the conversion and the aggregate root method looks like “void DoIt(EMailAddress eMailAddress)”?
Solution 2. seems more elegant, because it holds the aggregate root free of primitives and conversions.
But what about the events and even more interesting raising the event?

Example AggregateRoot Method with solution 2:

    public void ChangeEMailAddress(EMailAddress eMailAddress )
         //Do some interesting stuff without changing state 
        ApplyChange(new  EMailAddressChanged(???));

The ??? is the problem. If the event should not contain value objects the EMailAdress value object must be converted back into a string. Is a (second) constructor of the event (that takes the value object) allowed to do it, to keep the aggregate free of the conversion?

And what about the handling of the event in the aggregate root? In Simple CQRS Style it would be like this:

    private void Apply(EMailAddressChanged e)
        this.eMailAddress = new EMailAddress(e.eMailAddress);

So the conversion is again in the aggregate. We could also use EventHandlers here that do the conversion and then the method will look like:

    private void  EMailAddressChanged(EMailAddress eMailAddress)
        this.eMailAddress =  eMailAddress ;

(Yes I know thats simple CRUD stuff that maybe should not done the whole CQRS/ES way at all, assume that some logic is involved)

But there is one drawback here. In either solution, the conversion could fail. But an event should never fail. If I change the validation in the constructor of EMailAddress it is possible (if I use event sourcing) that older events can no longer be processed. So should I have 2 constructors/static create methods on my value objects? One with and one without validation?


  1. Where do you do the conversion from primitive to value object and back in the 3 cases Handling of the Command, Raising of the Event, Handling of the event?
  2. How do you deal with value objects in event sourcing to ensure its constructor validation do not fail for older events?

I found Where to convert primitive types in meaningful types in Clean Architecture / Onion Architecture and it’s partly related, but does not answer my question.

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?

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

Java: way to convert a 256-bit private key to WIF?

You should convert hex representation of bytes to byte array (not String to byte array). Then make hash. Then convert the byte array back to hex representation of bytes in String.

The whole solution will look like:


class HashExample {
    public static void main(String() args) throws NoSuchAlgorithmException {
        String string = "0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D";
        string = "80" + string;
        byte() data = hexStringToByteArray(string);
        byte() digest = MessageDigest.getInstance("SHA-256").digest(hexStringToByteArray(string));
        String result = bytesToHex(digest);
        //prints: 8147786c4d15106333bf278d71dadaf1079ef2d2440a4dde37d747ded5403592

    public static byte() hexStringToByteArray(String s) {
        int len = s.length();
        byte() data = new byte(len / 2);
        for (int i = 0; i < len; i += 2) {
            data(i / 2) = (byte) ((Character.digit(s.charAt(i), 16) << 4)
                    + Character.digit(s.charAt(i+1), 16));
        return data;

    private static String bytesToHex(byte() bytes) {
        StringBuffer result = new StringBuffer();
        for (byte b : bytes) result.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
        return result.toString();

Of course this is just example. In production code I recommend to use one of the available libraries which can perform this task.

2013 – Convert a column from text to choice(checkbox)

I need to upload (edit: currently trying via import spreadsheet) a table from excel where one of the columns needs to be a multiple choice selection field.

By adding a “;” separator into the excel column and then uploading it SP then converting the text column to a checkbox choice column SP seems to automatically know which values are the selected ones.

The only problem is that this does not work for filtering. When I click on the column to filter by and select a value the list will return 0 items.

Going into quick edit mode and opening the choices for that column on that item will then update the list so that when I filter by one of the selected values that item will appear.

I am looking for a quicker way of updating the columns so that I do not need to touch each row individually.

column data example:







php – How to convert custom html page into dynamic wordpress page

I am working on WordPress site. I have a custom HTML page which I already configured HTML page with my WordPress theme and I want to make its content dynamic, so that WP admin can change the content of the page. Below is the HTML page:

enter image description here

I want to allow admin to change the banner, the images, rules of the game and referral policy. How can I achieve this? I Don’t have much experience in WordPress but I do have knowledge of PHP. Any help would be highly appreciable.

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?

macintosh – 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!