<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Andrii Petrivskyi on Medium]]></title>
        <description><![CDATA[Stories by Andrii Petrivskyi on Medium]]></description>
        <link>https://medium.com/@a.petrivskyy?source=rss-1d7eae764eec------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wB8cqYNK8rLX-WE1HafYDw.jpeg</url>
            <title>Stories by Andrii Petrivskyi on Medium</title>
            <link>https://medium.com/@a.petrivskyy?source=rss-1d7eae764eec------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 17:29:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@a.petrivskyy/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Artifacts in Google Maps and wrong positioning of the URL status bubble in Chrome on Linux]]></title>
            <link>https://medium.com/@a.petrivskyy/artifacts-in-google-maps-and-wrong-positioning-of-the-url-status-bubble-in-chrome-on-linux-b4a91fa5724e?source=rss-1d7eae764eec------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4a91fa5724e</guid>
            <category><![CDATA[gnome]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[wayland]]></category>
            <category><![CDATA[vulkan]]></category>
            <category><![CDATA[chrome]]></category>
            <dc:creator><![CDATA[Andrii Petrivskyi]]></dc:creator>
            <pubDate>Tue, 16 Sep 2025 14:09:50 GMT</pubDate>
            <atom:updated>2025-09-16T14:09:50.560Z</atom:updated>
            <content:encoded><![CDATA[<h3>Artifacts in Google Maps and wrong positioning of the URL status bubble on Chrome, Linux, Gnome and Wayland</h3><p>My setup is the following:</p><ul><li><strong>Fedora 42</strong></li><li><strong>GNOME 48</strong></li><li><strong>Chrome 140.0.7339.127</strong></li><li><strong>Wayland</strong></li><li><strong>AMD GPU</strong></li></ul><p>After the latest update (on Sep 16, 2025) my Chrome became broken again :-)</p><h3>Problem 1 — Google Maps covered in artifacts like if your GPU was broken</h3><p>First thought was right, the issue is in video drivers, or to be precise, in how Chrome works with them. So, opening flags page:</p><blockquote>chrome://flags/</blockquote><p>And setting Vulkan (#enable-vulkan) to <em>Default</em> instead of <em>Enabled </em>helped to get rid off the artifacts without visible performance degradation. If you have similar problem, check this and other video/GPU related flags, try disabling them one by one.</p><h3>Problem 2 — wrong positioning of the URL status bubble</h3><p>I’m not sure if this is a correct name for this little label that normally appears in the bottom-left corner of the browser window when you are hovering a cursor over a hyper-link. ChatGPT insists on <em>status bubble, </em>another possible name is <em>URL preview</em> or <em>URL bar</em>.</p><p>So, instead of being popped-up in the bottom-left corner, it started to appear like 5 centimeters upper covering the page content, especially in the case of long URLs.</p><p>Some googling and ChatGPTing gave me a clue that the reason is in combination of software that I use, precisely, Chrome, Wayland, Gnome and <strong>fractional scaling factor</strong>.</p><p>But there is a trick, I used to use scaling factor 1.2 setting it in Fonts tab of the Gnome Tweaks tool. Changing it to <strong>integer scaling factor</strong> 1 fixed the issue, but everything became too small on the screen. The problem was solved by setting the Scale to 125% in a standard Gnome Settings tool on a Display tab. I haven’t dug deeper, but it looks like as some sort of a software conflict has led to this problem.</p><p>Did this article save you some headaches? Fuel my caffeine addiction ☕ — link for that is below. Yeah, a hand with a heart :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4a91fa5724e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to check if a text column in PostgreSQL contains valid JSON and why you shouldn’t blindly trust]]></title>
            <link>https://medium.com/@a.petrivskyy/how-to-check-if-text-column-in-postgresql-is-valid-json-and-why-you-shouldnt-blindly-trust-629043a56871?source=rss-1d7eae764eec------2</link>
            <guid isPermaLink="false">https://medium.com/p/629043a56871</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[json]]></category>
            <category><![CDATA[github-copilot]]></category>
            <dc:creator><![CDATA[Andrii Petrivskyi]]></dc:creator>
            <pubDate>Fri, 25 Jul 2025 18:43:21 GMT</pubDate>
            <atom:updated>2025-08-12T16:43:17.523Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to check if a text column in PostgreSQL contains valid JSON and why you shouldn’t blindly trust AI/LLM</h3><p><strong>Important remark:</strong> it’s valid for co-pilot plugin in IntelliJ Idea with GPT-4o model and PostgreSQL version 16</p><p>It’s been 3rd hour of debugging and searching for solution with my new developer buddy co-pilot. It feels like nowadays I only use google when I search for the news or the weather forecast, all other questions go directly to him/her/they/it :-)</p><p>The problem looked pretty simple at the first glance. There is a column in the table that contains (well, supposed to contain) valid JSON, but due to historical reasons, the column has type TEXT, not a JSON/JSONB which would probably helped to avoid this problem from the beginning. We need to search by this column, so the logical solution was to use something like this:</p><pre>jsonb_each_text(some_data::jsonb) kv WHERE kv.value ILIKE &#39;%some_value%&#39;</pre><p>And this worked well for a long time, until something happened to the values in this column. Either because of the bug in the code, or someone did something manually, but somehow, some values in the column became not valid JSONs, which led to different crashes, because neither <strong>::jsonb</strong> conversion nor <strong>jsonb_each_text</strong> function, couldn’t work with broken JSON.</p><p>Nobody googling error messages these days, ha?</p><p>co-pilot suggestions varied from different variations of CASE-checks to writing my own function that will use PL/pgSQL exception handler. Well, nothing of that worked or was hardly maintainable in my setup, probably because I’m just a bad PROMPT-engineer and didn’t give him enough details :-)</p><p>First request to Google worked like a charm, giving me this 10 year old StackOverflow <a href="https://stackoverflow.com/questions/30187554/how-to-verify-a-string-is-valid-json-in-postgresql">post</a> where I easily found out that since version 16 PostgreSQL supports all sorts of JSON-related checks, although finding them in their <a href="https://www.postgresql.org/docs/16/functions-json.html#FUNCTIONS-SQLJSON-MISC">doc</a> is also not a trivial task. But wasn’t LLM supposed to help us with that?</p><p>Long story short, the query transformed to the following form and continued to work:</p><pre>jsonb_each_text(some_data::jsonb) kv WHERE some_data IS JSON OBJECT AND kv.value ILIKE &#39;%some_value%&#39;</pre><p>Of course, it only returns the data where JSON is valid, and I still have to investigate who broke the values in the first place, but at least it doesn’t crash the whole query anymore</p><p>Did this article save you some headaches? Fuel my caffeine addiction ☕ — link for that is below. Yeah, a hand with a heart :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=629043a56871" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Spark configs in Amazon EMR]]></title>
            <link>https://medium.com/@a.petrivskyy/how-to-find-apache-thrift-server-port-and-other-configs-in-amazon-emr-8c90f94664f6?source=rss-1d7eae764eec------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c90f94664f6</guid>
            <category><![CDATA[spark-thrift-server]]></category>
            <category><![CDATA[aws-emr]]></category>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[hadoop]]></category>
            <dc:creator><![CDATA[Andrii Petrivskyi]]></dc:creator>
            <pubDate>Wed, 14 May 2025 14:57:09 GMT</pubDate>
            <atom:updated>2025-09-16T14:03:49.184Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Valid for: emr-7.8.0, Spark 3.5.4, Hive 3.1.3, Hadoop 3.4.1</strong></p><p><strong>Disclaimer:</strong></p><blockquote>It’s a rather humorous story, but it reflects a pain point of how difficult it might be to find anything in Amazon EMR. Try not to kill your EMR, sometimes it’s surprisingly fragile. Execute commands only if you understand what they do.</blockquote><p>So, the pre-requisite:</p><p>Amazon EMR is up and running, Apache Thrift Server is running in it and waiting for connection, and the essential part of a connection is port, right? So, how do find one?</p><p>Strange thing, you can’t find it anywhere in EMR UI</p><h3>Standard way for normal people</h3><p>RTFM?! Ask ChatGPT? Yeah :-)</p><p>Open an URL: <a href="https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-service-ports.html">https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-service-ports.html</a></p><p>And here it’s HiveServer2 Thrift / HiveServer2 HTTP, so it’s either 10000 or 10001</p><p>But, who trusts the doc, right?</p><h3>Spark way</h3><p>But what can we actually find in EMR UI?</p><p>In Application tab we can find the Resource Manager URL, that looks like this: <a href="http://ip-172-27-33-210.ec2.internal:8088/">http://ip-111-22-33–4444.ec2.internal:8088/</a></p><p>Try to open it, you might need to drop some stuff of it and make it look like this 111<a href="http://ip-172-27-33-210.ec2.internal:8088/">.22.33.444:8088</a></p><p>You should see Hadoop UI and Thrift Server is basically just a Hadoop app. Go to Applications, find your Thrift, click on ApplicationMaster in the Tracking UI column, do the IP trick again if necessary and you should see <strong>Thrift JDBC/ODBC Server</strong> application UI. Easy ha? Yes, if you know how, everything is easy ;-)</p><p>Now go to Environment tab, which has tons of properties, search for hive.server2.thrift.url and ta-dam jdbc:hive2://ip-111–22–33–444.ec2.internal:10000 here is our port</p><p>Now jokes aside, the hardest way</p><h3>Developer traumatized by Linux in childhood way</h3><p>Find a <strong>pem</strong> file used to create a cluster. If you managed to create it by yourself, you should have it. Otherwise, go to the most friendliest DevOps and exchange it for a beer or cookie</p><p>On Amazon EMR page find master node IP under “<strong>Primary node private DNS</strong>”, do the IP trick mentioned previously if needed, then connect to it using <strong>pem</strong> certificate:</p><blockquote>ssh -i ~/emr-ssh.pem hadoop@111.22.33.444</blockquote><p>You logged-in, <em>now do “sudo rm -rf /” and leave the building</em></p><p>Well, if you really did that, don’t worry, nothing bad happened, it’s just another EC2 node, AWS has a lot of them. Hopefully it wasn’t your production EMR :-)</p><p>On a serious note:</p><blockquote>$ cat /etc/hive/conf.dist/hive-site.xml | grep -A 2 -B 2 hive.server2.thrift</blockquote><p>There you find your port and other useful properties</p><p>If that didn’t help, desperately do:</p><blockquote>$ sudo grep -i -r ‘hive.server2.thrift’ /</blockquote><p>That will for sure give you something</p><p>BTW: Thrift Logs are located here: /var/log/spark/spark-root-org.apache.spark.sql.hive.thriftserver.HiveThriftServer2–1-ip-111–22–3–444.ec2.internal.out</p><p>Did this article save you some headaches? Fuel my caffeine addiction ☕ — link for that is below. Yeah, a hand with a heart :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c90f94664f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to get a new IP from rotating proxy at every request]]></title>
            <link>https://medium.com/@a.petrivskyy/how-to-get-a-new-ip-from-storm-proxy-at-every-request-4f5c72cdb30b?source=rss-1d7eae764eec------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f5c72cdb30b</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[crawling]]></category>
            <category><![CDATA[proxy]]></category>
            <category><![CDATA[jsoup]]></category>
            <category><![CDATA[spring]]></category>
            <dc:creator><![CDATA[Andrii Petrivskyi]]></dc:creator>
            <pubDate>Sat, 17 Aug 2024 17:47:02 GMT</pubDate>
            <atom:updated>2025-08-12T16:40:18.989Z</atom:updated>
            <content:encoded><![CDATA[<p>Don’t ask my why I need it :-) (though, if you are reading this, you probably already have a pretty good idea)</p><p>In some unknown app needed for who knows what purpose, the following stack is used:</p><ul><li>Java 11</li><li>Spring Boot</li><li>JSoup</li><li>Storm Proxies</li></ul><p>For some activities that JSoup is usually used for, I had to retry failed calls some number of times. Initial thought was, that every call like this one:</p><pre>Document doc = Jsoup<br>    .connect(url)<br>    .proxy(proxyUrl, proxyPort())<br>    .get();</pre><p>will use different IP obtained from proxy. Naive me …</p><p>Man, what didn’t I try. Created a new crawler object before the call, experimented with headers, investigated where JSoup, Spring or Java (URLConnection in particular, that JSoup uses under the hood) may cache connections, nothing helped. After first failed attempt I was getting the same IP from proxy, which was already got banned after the first call.</p><p>Accidentally, I found this forgotten StackOverflow question: <a href="https://stackoverflow.com/questions/65467447/rotating-proxy-storm-smart-not-giving-unique-ip-in-each-scrapy-request">https://stackoverflow.com/questions/65467447/rotating-proxy-storm-smart-not-giving-unique-ip-in-each-scrapy-request</a></p><p>And everything worked, just had to add one header:</p><pre>Document doc = Jsoup<br>  .connect(url)<br>  .proxy(proxyUrl, proxyPort())<br>  .header(&quot;Connection&quot;, &quot;close&quot;)<br>  .get();</pre><p>This header does exactly what you may think looking at it:</p><blockquote>This “close” connection directive indicates that the client wants to close the connection after sending the response message. In HTTP 1.0, by default, the connection gets closed. But in HTTP 1.1, you need to include it in the header if you want your connection to close.</blockquote><blockquote>Source: <a href="https://www.geeksforgeeks.org/http-headers-connection/">https://www.geeksforgeeks.org/http-headers-connection/</a></blockquote><p>It’s still not 100% clear to me, how storm proxy determines whether it should close the connection or keep it alive, maybe by IP of the host machine, I’m not sure. For example, curl, sends “Connection: keep-alive” and still gets new IP for every call</p><p>Anyway, problem was solved, hope it helps someone else as well</p><p>Did this article save you some headaches? Fuel my caffeine addiction ☕ — link for that is below. Yeah, a hand with a heart :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f5c72cdb30b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JSON formatting in Geany, an easy way]]></title>
            <link>https://medium.com/@a.petrivskyy/json-formatting-in-geany-an-easy-way-e8ccffa3e4f1?source=rss-1d7eae764eec------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8ccffa3e4f1</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[geany]]></category>
            <category><![CDATA[yaml]]></category>
            <category><![CDATA[json]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Andrii Petrivskyi]]></dc:creator>
            <pubDate>Fri, 01 Mar 2024 13:30:29 GMT</pubDate>
            <atom:updated>2025-07-25T19:00:46.570Z</atom:updated>
            <content:encoded><![CDATA[<p>In Linux, I’m using Geany as my text editor for making notes and other day-to-day developer stuff (and I’m really missing Notepad++ and its ability to deal with different programming and markup languages out of the box)</p><p>The most popular thing that I need almost every day is an ability to take a piece of non-formatted JSON and pretty-print it quickly, so it’s readable.</p><p>I know there is a plug-in for Geany for that purpose <a href="https://github.com/zhgzhg/Geany-JSON-Prettifier">https://github.com/zhgzhg/Geany-JSON-Prettifier</a> but unfortunately one has to compile it ourselves which requires installing all kinds of C/C++ stuff, like dev libs, headers, tools etc. … long story short, I wasn’t able to do that on my system (Fedora 39)</p><p>So, there is another way:</p><ol><li>Install jq (<a href="https://jqlang.github.io/jq/">https://jqlang.github.io/jq/</a>) -&gt; sudo dnf install jq</li><li>In Geany, go to Edit -&gt; Format -&gt; Send selection to -&gt; Set custom commands and add JQ there like this</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*eiPW84IjeKwfZX-f1GCW8A.png" /></figure><p>3. Now if you need to format raw JSON like this one:</p><blockquote>{“prop1”:[{“prop2”:1,”prop3&quot;:2,”prop4&quot;:3}]}</blockquote><p>just insert it into your document in Geany, select it, do a right-click, then “Format -&gt; Send Selection to -&gt; jq” or just press the automatically assigned hotkey (Ctrl + 1 on my system) and you should get it formatted.</p><p>The same approach will probably work with YAML/yq, but I haven’t tested it myself yet</p><p>Happy coding everyone!</p><p>BTW: I use Geany version 2.0:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*qsK85m9fabcs5CQsNXClbw.png" /></figure><p>Did this article save you some headaches? Fuel my caffeine addiction ☕ — link for that is below. Yeah, a hand with a heart :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8ccffa3e4f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using java.util.logging and SLF4J together]]></title>
            <link>https://medium.com/@a.petrivskyy/using-java-util-logging-and-slf4j-together-e7f2ee1d712b?source=rss-1d7eae764eec------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7f2ee1d712b</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[redirect]]></category>
            <category><![CDATA[slf4j]]></category>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[libraries]]></category>
            <dc:creator><![CDATA[Andrii Petrivskyi]]></dc:creator>
            <pubDate>Mon, 13 Jun 2022 21:55:53 GMT</pubDate>
            <atom:updated>2025-07-25T19:00:14.848Z</atom:updated>
            <content:encoded><![CDATA[<h3>Motivation</h3><p>I’ve been reading a book <em>High-Performance Java Persistence</em> by <em>Vlad Mihalcea, </em>a nice book BTW<em>, </em>and usually when reading a technical book it’s useful to test what you are reading about. So, I’ve got a Docker image of PostgreSQL, initialized a simple Java project with Gradle and started experimenting in order to understand what is going on “under the hood”. At some point I realized that I need to see the logs from a PostgreSQL driver and getting them was not that trivial as it may seem to be. Later I also realized that those logs are almost useless for me :-) Anyway, that may be interesting to someone, probably …</p><h3>The Problem</h3><p>Usually, in Java projects, for the purpose of logging, the common practice is to use SLF4J + Log4J or Logback. But, some other libraries that you may need in your project, don’t necessarily use this approach and instead are using Java’s standard java.util.logging package, which has its own logging capabilities. We’d like to redirect those logs to SLF4J.</p><h3>The Solution</h3><p>So we need to redirect logs from some library, through SLF4J, to the logging library that we are actually using in our project. For that purpose, you need to include in your project <em>org.slf4j:jul-to-slf4j</em> library e.g. by putting the following line in your build.gradle.kts:</p><pre><em>implementation</em>(&quot;org.slf4j:jul-to-slf4j:1.7.36&quot;)</pre><p><em>jul-to-slf4j</em> basically provides just one class that we need. This class is <em>SLF4JBridgeHandler</em></p><p>Then we have to create our own <em>logging.properties, </em>the file that is used by default by java.util.logging. We may as well skip this step and load the logging configuration from the code. The content of the file is the following:</p><pre>handlers = org.slf4j.bridge.SLF4JBridgeHandler</pre><pre><em># Default global logging level</em><br>.level = FINEST</pre><p>That means that once loaded, <em>SLF4JBridgeHandler </em>will redirect all logs to SLF4J. If you plan to use this handler in production, please read its JavaDoc carefully, because there are some very serious performance considerations to take into account.</p><p>Once a file is created, we need to load it and “replace” the system’s default configuration. There are many ways well explained here <a href="https://mkyong.com/logging/how-to-load-logging-properties-for-java-util-logging/">https://mkyong.com/logging/how-to-load-logging-properties-for-java-util-logging/</a></p><p>I’ve used this one:</p><pre>static {<em><br>    </em>try (InputStream is = SomeClass.class.getClassLoader().getResourceAsStream(&quot;logging.properties&quot;)) {<br>        LogManager.<em>getLogManager</em>().readConfiguration(is);<br>    } catch (IOException e) {<br>        e.printStackTrace();<br>    }<br>}</pre><p>Now you may configure logs from java.util.logging in the usual place, e.g. <em>logback.xml,</em> by setting the desired level, appender etc.:</p><pre>&lt;logger name=&quot;org.postgresql&quot; level=&quot;trace&quot;&gt;<br>    &lt;appender-ref ref=&quot;STDOUT&quot; /&gt;<br>&lt;/logger&gt;</pre><p>As a result, I’ve got logs from the PostgreSQL driver in the console just like all other logs, e.g.:</p><blockquote>23:49:22.327 [main] DEBUG org.postgresql.Driver — Connecting with URL: jdbc:postgresql://localhost/test_db<br>23:49:22.327 [main] DEBUG org.postgresql.Driver — Connecting with URL: jdbc:postgresql://localhost/test_db<br>23:49:22.334 [main] DEBUG org.postgresql.jdbc.PgConnection — PostgreSQL JDBC Driver 42.4.0<br>23:49:22.334 [main] DEBUG org.postgresql.jdbc.PgConnection — PostgreSQL JDBC Driver 42.4.0<br>23:49:22.335 [main] DEBUG org.postgresql.jdbc.PgConnection — setDefaultFetchSize = 0<br>23:49:22.335 [main] DEBUG org.postgresql.jdbc.PgConnection — setDefaultFetchSize = 0<br>23:49:22.336 [main] DEBUG org.postgresql.jdbc.PgConnection — setPrepareThreshold = 5<br>23:49:22.336 [main] DEBUG org.postgresql.jdbc.PgConnection — setPrepareThreshold = 5</blockquote><p>Did this article save you some headaches? Fuel my caffeine addiction ☕ — link for that is below. Yeah, a hand with a heart :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7f2ee1d712b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>