<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hodunov</title>
    <description>The latest articles on DEV Community by Hodunov (@hodunov).</description>
    <link>https://dev.to/hodunov</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F666642%2F773fb8e0-3296-4fd3-802e-152fa1a5269d.jpeg</url>
      <title>DEV Community: Hodunov</title>
      <link>https://dev.to/hodunov</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hodunov"/>
    <language>en</language>
    <item>
      <title>Fixed: slow internet on WSL 2 on Ubuntu 22.04 LTS on Windows 11</title>
      <dc:creator>Hodunov</dc:creator>
      <pubDate>Sat, 30 Apr 2022 15:08:02 +0000</pubDate>
      <link>https://dev.to/hodunov/fixed-slow-internet-in-wsl-20-on-ubuntu-2204-lts-on-windows-11-313b</link>
      <guid>https://dev.to/hodunov/fixed-slow-internet-in-wsl-20-on-ubuntu-2204-lts-on-windows-11-313b</guid>
      <description>&lt;p&gt;When upgrading from Windows 10 to Windows 11, you can certainly run into a lot of problems. One of them is the really slow internet speed in Ubuntu 22.04 LTS in WSL 2.&lt;/p&gt;

&lt;p&gt;To solve this problem, you will need to follow a short instruction.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;TL;DL: if it seems easier and faster to you - reinstall the WSL feature.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A possible solution for Windows 10 is described in the instructions here - &lt;a href="https://townsyio.medium.com/wsl2-how-to-fix-download-speed-3edb0c348e29"&gt;https://townsyio.medium.com/wsl2-how-to-fix-download-speed-3edb0c348e29&lt;/a&gt; .&lt;br&gt;
The solution is to change the &lt;strong&gt;vEthernet adapter (WSL)&lt;/strong&gt; settings.&lt;br&gt;
But in my case, it was not on the list of available.&lt;br&gt;
The solution from &lt;a href="https://github.com/microsoft/WSL/issues/4901"&gt;the github issue&lt;/a&gt; helped me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Run &lt;strong&gt;PowerShell&lt;/strong&gt; as administrator and run the following command, it will disable &lt;strong&gt;vEthernet (WSL)&lt;/strong&gt;:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Disable-NetAdapterLso -Name "vEthernet (WSL)"&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; In the &lt;strong&gt;WSL&lt;/strong&gt; terminal, run the commands:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;sudo echo "[network]" &amp;gt; /etc/wsl.conf&lt;/code&gt;&lt;br&gt;
&lt;code&gt;sudo echo "generateResolvConf = false" &amp;gt;&amp;gt; /etc/wsl.conf&lt;/code&gt;&lt;br&gt;
&lt;code&gt;sudo rm /etc/resolv.conf&lt;/code&gt;&lt;br&gt;
&lt;code&gt;sudo echo "nameserver 8.8.8.8" &amp;gt; /etc/resolv.conf&lt;/code&gt;&lt;br&gt;
&lt;code&gt;sudo chattr +i /etc/resolv.conf&lt;/code&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; And then turn off WSL in the &lt;strong&gt;PowerShell&lt;/strong&gt; terminal: 
&lt;code&gt;wsl --shutdown&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>windows11</category>
      <category>win11</category>
      <category>wsl</category>
      <category>ubuntu</category>
    </item>
    <item>
      <title>Recursive XML parsing using ElementTree module in Python</title>
      <dc:creator>Hodunov</dc:creator>
      <pubDate>Tue, 13 Jul 2021 21:06:19 +0000</pubDate>
      <link>https://dev.to/hodunov/recursive-xml-parsing-using-elementtree-module-in-python-beb</link>
      <guid>https://dev.to/hodunov/recursive-xml-parsing-using-elementtree-module-in-python-beb</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8byvb39blrj4pvg8v4cb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8byvb39blrj4pvg8v4cb.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Working with files in python is not a difficult task.&lt;/p&gt;

&lt;p&gt;Suppose you have the task of converting an xml file coming to you into a python dictionary. And then do some manipulation with it at your discretion.&lt;/p&gt;

&lt;p&gt;How do you handle this task with as little code as possible? We are lazy, right?&lt;br&gt;
By using recursion, of course.&lt;br&gt;
Let's see how to do it without using any external libraries. Python has a nice &lt;a href="https://docs.python.org/3/library/xml.etree.elementtree.html" rel="noopener noreferrer"&gt;ElementTree XML API&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;xml.etree.ElementTree&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;ET&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;xml_to_dict_recursive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Recursively walk through the root and turn it into a dict.
    :param root: &amp;lt;class &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;xml.etree.ElementTree.Element&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;&amp;gt;
    :return: dict
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;children&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;iter&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xml_to_dict_recursive&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;))}&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;convert_xml_file_to_dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Process the kml file and return the dictionary.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ET&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getroot&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;xml_to_dict_recursive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;note.xml&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;xml_dict&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;convert_xml_file_to_dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Easier than leaving office on Friday! &lt;br&gt;
Python is a wonderful language for working with data. &lt;/p&gt;

</description>
      <category>python</category>
      <category>xml</category>
      <category>parsing</category>
      <category>elementtree</category>
    </item>
  </channel>
</rss>
