<?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>Forem: Peter Gašparík</title>
    <description>The latest articles on Forem by Peter Gašparík (@pipan).</description>
    <link>https://forem.com/pipan</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%2F135424%2Fe1ef01da-237c-4c14-82b9-6b76e16fc795.jpeg</url>
      <title>Forem: Peter Gašparík</title>
      <link>https://forem.com/pipan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/pipan"/>
    <language>en</language>
    <item>
      <title>Put Design Patterns on the Flavor Wheel</title>
      <dc:creator>Peter Gašparík</dc:creator>
      <pubDate>Wed, 09 Dec 2020 20:56:41 +0000</pubDate>
      <link>https://forem.com/pipan/put-design-patterns-on-the-flavor-wheel-1b3b</link>
      <guid>https://forem.com/pipan/put-design-patterns-on-the-flavor-wheel-1b3b</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@picoftasty?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Mae Mu&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/spinning-wheel?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Do you like coffee? &lt;em&gt;I do.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Do you like design patterns? &lt;em&gt;I do. Well, most of them.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So I brought &lt;a href="https://scanews.coffee/wp-content/uploads/2016/01/SCA-WCR-Flavor-Wheel-768x996.png"&gt;Coffee Tasters Flavor Wheel&lt;/a&gt; and &lt;a href="https://en.wikipedia.org/wiki/Design_Patterns"&gt;design patterns&lt;/a&gt; together with a &lt;a href="//www.designpatternswheel.com"&gt;design patterns wheel&lt;/a&gt;. Unlike flavor wheel, this wheel has only 2 layers. Inner layer represents pattern categories and outer layer represents concrete design patterns. I find this kind of category visualization quite nice.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/GHE74VClT7q5FiqoHY/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/GHE74VClT7q5FiqoHY/giphy.gif" alt="scroll rotation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/jg0EV57otEuLXRWrmK/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/jg0EV57otEuLXRWrmK/giphy.gif" alt="change themes"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>designpatterns</category>
    </item>
    <item>
      <title>Try implementing optimization algorithm from time to time 🤔</title>
      <dc:creator>Peter Gašparík</dc:creator>
      <pubDate>Mon, 05 Oct 2020 15:05:04 +0000</pubDate>
      <link>https://forem.com/pipan/try-implementing-optimization-algorithm-from-time-to-time-41fh</link>
      <guid>https://forem.com/pipan/try-implementing-optimization-algorithm-from-time-to-time-41fh</guid>
      <description>&lt;p&gt;I used to enjoy solving optimization problems in the collage. Then I graduated and moved from one webdev job to another and I realized, that there is not a lot of computer science in webdev. I think it's more of a architecture oriented field, which is not bad, just ... I sometimes miss a good brain twister. However, I came across a task, in work, that required me to solve a subset sum problem. I did not know that, it was a subset sum problem at a time. I tried to apply some greedy algorithm, which was good enough, so I considered this task done.&lt;/p&gt;

&lt;p&gt;Few weeks latter I came across the same code and I found a combination of inputs that would result in a wrong answer. Well, that's what you get by implementing a greedy algorithm, I thought, but I wasn't satisfied. The combination of inputs, was so primitive, that I had to search for better solution.&lt;/p&gt;

&lt;p&gt;I knew there was a perfect solution: run trough every combination. Not a great idea because of a thing called &lt;a href="https://en.wikipedia.org/wiki/Exponential_growth"&gt;exponential growth&lt;/a&gt;. You know, the thing that gets crazy big really fast. So, could an optimal algorithm, computed in a reasonable time, be reached?&lt;/p&gt;

&lt;p&gt;I searched around and found a wikipedia page about &lt;a href="https://en.wikipedia.org/wiki/Subset_sum_problem"&gt;subset sum problems&lt;/a&gt;. Subset sum problem is a problem of selecting a subset of items which sum equals to some integer. In general, the solution for this problem assumes, that items in subset cannot repeat. However, my problem could repeat items from the set of items. I updated my search query to &lt;em&gt;subset sum with repetition&lt;/em&gt; and there are other people wanting to solve the same problem as I do. However, I could not find any wikipedia page on this one.&lt;/p&gt;

&lt;p&gt;I read trough stackoverflow questions, various articles and came back to the original wikipedia page. Some sources were useful some less. In the end I came across a pseudo code for solving subset sum. To be honest, pseudo code got me good. After a lot of years of webdev work I realized, that my ability to follow pseudo code is much worse then during my collage years. Once I got a feel how to solve this problem with dynamic programing I implemented it, wrote tests and wrote documentation.&lt;/p&gt;

&lt;p&gt;It took me a week or so, to finish the dynamic programming algorithm, because I was doing it outside my work hours, but it was really an enriching journey.&lt;/p&gt;

&lt;p&gt;👉 Moral of the story is, try to &lt;strong&gt;solve a computer science problem&lt;/strong&gt; once in a while. It is so refreshing after months of parsing json and communicating with APIs. It also showed me, that my skill to read technical documentation is not as sharp as it used to be.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Experiment&lt;/strong&gt; and try some new technology or development technique. For example I tackled this problem with &lt;a href="https://en.wikipedia.org/wiki/Test-driven_development"&gt;TDD&lt;/a&gt; and I have to say, it was a perfect tool for this kind of a job. Job where you can define specific examples for inputs and outputs.&lt;/p&gt;

&lt;p&gt;👉 Also, if the problem is small enough, &lt;strong&gt;write a documentation&lt;/strong&gt; and try to explain the problem and your solution. This activity can also show you that you still have some gaps in your knowledge. Writing an understandable documentations, is much harder then it seems. It made me appreciate docs, that are easy to follow, more.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can also plot effectiveness of this solution against running trough all combinations. You may find some interesting results.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Of course, I put &lt;a href="https://github.com/pipan/subsetsum-php"&gt;my code&lt;/a&gt; on github.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>algorithms</category>
      <category>coding</category>
    </item>
    <item>
      <title>git + svn (both remote) in case you need it</title>
      <dc:creator>Peter Gašparík</dc:creator>
      <pubDate>Mon, 21 Sep 2020 15:19:53 +0000</pubDate>
      <link>https://forem.com/pipan/git-svn-both-remote-in-case-you-need-it-1ac5</link>
      <guid>https://forem.com/pipan/git-svn-both-remote-in-case-you-need-it-1ac5</guid>
      <description>&lt;p&gt;You may be traveling to work right now and reading this article wondering, is this worth to read? Well, for the majority of you, the answer is no. But in case you are in a situation, where your source code has to be stored in the svn (for example because of some legacy deployment process), but you, and your team, want to start using git and take advantage of pull requests and code reviews, then this article might be for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;The goal is to use git for everyday commits and update svn just before deployment (or when you need it). I found a lot of tutorials, on the internet, for running git and svn side by side, but they concentrate, on how to use git locally and still commit to remote svn. That means, you cannot use git with your team and git is just your own personal helper in this case. However, I want to be able to have remote git and remote svn and synchronize them.&lt;/p&gt;

&lt;p&gt;In the end we will have 2 workflows.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Feature flow&lt;/strong&gt; - this is a process for day-to-day programming. You can create new branches from master branch (to fix a bug or develop new feature) and in the end, you can merge changes back to the master branch. This workflow can be separated from svn, therefore it will be done solely in git.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Synchronization flow&lt;/strong&gt; - This flow is meant to synchronize changes between git and svn. It's quite easy to put this process into words, but it was much harder to actually make it work. In a nutshell, take all changes from svn and take all changes from git master branch. Mix them together and update them both (git master branch and svn) with the current source code. Easy, right?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;I will assume, that you have a git remote repository and svn remote repository up and running.&lt;/p&gt;

&lt;p&gt;Let's start by cloning git repository &lt;code&gt;git clone https:\\www.yourgit.com\path\to.git&lt;/code&gt;. Now open .git/config file and add these lines.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[svn-remote "svn"]
    url = https://www.yoursvn.com/url
    fetch = you_can_fetch_some_subdirectory_from_svn
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will create new remote named svn and git will know, that this is a svn remote. You can find full documentation for &lt;a href="https://git-scm.com/docs/git-svn"&gt;git-svn&lt;/a&gt;. That's it. You are all set up now, so let's take a look at synchronization process.&lt;/p&gt;

&lt;h3&gt;
  
  
  Synchronization
&lt;/h3&gt;

&lt;p&gt;You and your teammates will develop new features and fix bugs with git branches. You may create pull requests and merge all changes to the master branch. But there will come a time to synchronize all git changes with svn. One person on your team, should be able to do this job. These are the steps, that I follow when synchronizing changes with svn.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fetch all changes from svn repository and move them to our release branch. We will use &lt;code&gt;bridge&lt;/code&gt; branch to fetch svn changes. Bridge branch should be local, do not push it to git remote.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;checkout bridge
git svn rebase
git checkout -b release/&amp;lt;id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;merge all changes from master to this release branch
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git merge master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;If you encounter a conflict while merging, that means somebody changed something in svn and also in git and git cannot solve the issue. Resolve conflicts the same way as you would in standard git merge conflict scenario and then run &lt;code&gt;git add -A&lt;/code&gt; and &lt;code&gt;git commit -m "merge master"&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;update svn by committing all changes that are in release branch. That includes all changes from git.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git svn dcommit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Now is the right time to push release branch to git remote, but this step is optional &lt;code&gt;git push origin release/&amp;lt;id&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;update git master branch by merging all changes from release branch. That includes all changes from svn.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout master
git merge release/&amp;lt;id&amp;gt;
git push origin master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jazBnOVu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mpzkuivggrb8oie3409r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jazBnOVu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mpzkuivggrb8oie3409r.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, this sequence of steps can solve also special case, when someone still uses svn and commits changes to svn repository, but some people use git. That's achieved, when we take all changes from svn and move them to release branch.&lt;/p&gt;

</description>
      <category>niche</category>
      <category>git</category>
      <category>svn</category>
    </item>
    <item>
      <title>When to request data in SPA</title>
      <dc:creator>Peter Gašparík</dc:creator>
      <pubDate>Sat, 04 Jul 2020 15:45:44 +0000</pubDate>
      <link>https://forem.com/pipan/when-to-request-data-in-spa-1ad0</link>
      <guid>https://forem.com/pipan/when-to-request-data-in-spa-1ad0</guid>
      <description>&lt;p&gt;I came to &lt;a href="https://en.wikipedia.org/wiki/Single-page_application"&gt;SPA (single-page application)&lt;/a&gt; development from MPA (multi-page application). Surprise, surprise, they are not identical. SPA has some unique concepts, that you don't need to think about in MPA. One of them is the issue with requesting data from API. In MPA development, every user interaction is a new request to server and every URL, you put in the browser, is also a new request. But SPA has much more options. You can request some data at the start of your application, then there are moments (usually preceded with user interaction) when you have to request other data for you application.&lt;/p&gt;

&lt;p&gt;My understanding is that every application state should be represented by a URL (and vice versa, every URL should be able to provide correct content), no matter if you are building SPA or MPA. For example, if I had an application that allowed you to list books and view a detail of a book, I would probably have 2 kinds of URL:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;/books&lt;/li&gt;
&lt;li&gt;/books/:id&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, when I am building SPA it's not that obvious, when is the right time to request data from API and when to change URL. It seems to be all one atomic action in MAP (user interaction, URL change, request), but in SPA you have to choose what is the right sequence. I used Angular and Vue for my projects, but I cannot remember that I read about this in their documentation. They give you many tools, but they don't mention what is the correct tool for managing asynchronous data for your views.&lt;/p&gt;

&lt;h2&gt;
  
  
  API request first
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;user interaction -&amp;gt; API request -&amp;gt; change URL -&amp;gt; change view&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I thought, that most API requests should start with some user interaction (for example clicking a button). This idea was much easier to comprehend for me. User sees list of books, they click on a book and app will request a detailed information of this book and if this request is successful app will change the URL (and view) to the book detail. Then I noticed some other advantages. Your views don't have to handle an invalid state, when they don't have data, because app will change URL only if data is correct. This can reduce your &lt;em&gt;if&lt;/em&gt; statements in the view. But this approach is failing, if user just enters URL into the browser. This will be a special case, that will haunt you during entire development process. It was such a big issue for me, that I tried to think of an other way to request data from API.&lt;/p&gt;

&lt;h2&gt;
  
  
  URL change first
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;user interaction [optional] -&amp;gt; change URL -&amp;gt; change view -&amp;gt; API request&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I had to get rid of my assumption, that API request should follow user interaction. Instead, I made my special case my main use case. I have to be able to serve correct content to user if they enter URL to browser. In other words, I want to make a URL change to trigger API request. Angular is equiped with &lt;a href="https://angular.io/guide/router#milestone-5-route-guards"&gt;guards&lt;/a&gt; and &lt;a href="https://angular.io/guide/router#resolve-pre-fetching-component-data"&gt;resolvers&lt;/a&gt; and vue is equiped with &lt;a href="https://router.vuejs.org/guide/advanced/navigation-guards.html"&gt;guards&lt;/a&gt; and &lt;a href="https://vuejs.org/v2/guide/instance.html#Instance-Lifecycle-Hooks"&gt;component lifecycle&lt;/a&gt;. You will probably have to make your views more robust (you will have to handle invalid data, because API request will be asynchronous and view will be already rendered) but I found it a small price for easier data requesting. And let's be honest, you would probably want to handle invalid data in view anyway.&lt;/p&gt;

&lt;p&gt;Of course, you are still able to react to user input. When user clicks on a button, you will change URL and everything will continue as if user only inserted URL to browser.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Router can behave differently in each framework. For example Vue won't notify you if there is a change in URL parameter. This can be handled by watching URL parameter, but I found it a little bit odd. There is probably some good reason behind this design decision, but I'm yet to find that out.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I find the second approach, URL change first, much easeir to work with. I still strugle with some concepts, but I think it might take me some time to get used to them. Or maybe there is still something I am missing.&lt;/p&gt;

</description>
      <category>spa</category>
      <category>webdev</category>
      <category>client</category>
      <category>request</category>
    </item>
    <item>
      <title>Improve your website performance (gzip + cache)</title>
      <dc:creator>Peter Gašparík</dc:creator>
      <pubDate>Tue, 14 Apr 2020 12:07:17 +0000</pubDate>
      <link>https://forem.com/pipan/improve-your-website-performance-gzip-cache-4kef</link>
      <guid>https://forem.com/pipan/improve-your-website-performance-gzip-cache-4kef</guid>
      <description>&lt;p&gt;I always forget to pay attention to webpage load performance and size. I had a mindset, that it's complicated and that it requires a lot of effort. But that is not true. I want to share 2 easy steps how to improve your webpage load time and size.&lt;/p&gt;

&lt;p&gt;To verify, that changes I made had positive inpact I used two tools: &lt;code&gt;lighthouse&lt;/code&gt; and &lt;code&gt;gtmetrix&lt;/code&gt;. Graphs are at the end of the article.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compression
&lt;/h2&gt;

&lt;p&gt;All files, that are requested from your server, can be compressed. Size reduction depend on file content, but I think you can get pretty good results in general.&lt;/p&gt;

&lt;p&gt;Compression will reduce your page size and improve your page load time. And actually it's really simple. This is an example of my Nginx virtual host.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gzip on;
gzip_vary on;
gzip_types text/plain application/javascript application/font-woff text/css application/json;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;gzip&lt;/strong&gt; enables or disables compression&lt;br&gt;
&lt;strong&gt;gzip_types&lt;/strong&gt; set what types of files should be compressed&lt;br&gt;
&lt;strong&gt;gzip_vary&lt;/strong&gt; enables or disables &lt;code&gt;Vary&lt;/code&gt; header, that tells server to not serve cached gziped files if browser does not support gziped files.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The issue with Vary header might be a topic for another article. All you need to know, at this point, is that you should add this header if you use cache and compression.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Server cache
&lt;/h2&gt;

&lt;p&gt;Both tools (lighthouse and gtmetrix) will warn you about long caching of static files. It seems that you cannot improve that much after compression, but this change will bring you closer to 100% rating.&lt;/p&gt;

&lt;p&gt;You can cache your files in Nginx by adding these lines into your virtual host:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;location ~* \.(?:png|svg|css|ttf|woff)$ {
    expires 720d;
    add_header Pragma public;
    add_header Cache-COntrol "public";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;location ~* .(?:png|svg|css|ttf|woff)$&lt;/strong&gt; this line decides which files to cache. In my case its .png .svg .css .ttf .woff files.&lt;br&gt;
&lt;strong&gt;expires 720d;&lt;/strong&gt; i want to cache files for 720 days. It is recommended to go for &lt;a href="https://web.dev/uses-long-cache-ttl/#how-to-cache-static-resources-using-http-caching" rel="noopener noreferrer"&gt;more then a year&lt;/a&gt; (that's the "long" in long term cache).&lt;br&gt;
&lt;strong&gt;add_header&lt;/strong&gt; and set some headers&lt;/p&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;p&gt;For full disclosure, &lt;code&gt;fully loaded time&lt;/code&gt; can vary, quite a lot, so this value is not very accurate. Nevertheless, I tried to average 10 tests and get a value.&lt;/p&gt;

&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%2Fi%2Flpvs30wm6qegfcf32jd4.png" 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%2Fi%2Flpvs30wm6qegfcf32jd4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&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%2Fi%2F5djv9weqjksolfuf8uip.png" 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%2Fi%2F5djv9weqjksolfuf8uip.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&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%2Fi%2Fbjeeixdrdpid3kpjp6v8.png" 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%2Fi%2Fbjeeixdrdpid3kpjp6v8.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Other improvements
&lt;/h2&gt;

&lt;p&gt;You can never be truly done optimizing your webpage and steps that are right for you often depend on your website content and priorities. However, there is a list of some other areas to improve on.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;preconnect/preload resources&lt;/li&gt;
&lt;li&gt;http/2&lt;/li&gt;
&lt;li&gt;define image dimensions in HTML or CSS&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>performance</category>
      <category>webdev</category>
      <category>angular</category>
      <category>pwa</category>
    </item>
    <item>
      <title>File based database migration app</title>
      <dc:creator>Peter Gašparík</dc:creator>
      <pubDate>Thu, 31 Oct 2019 11:18:17 +0000</pubDate>
      <link>https://forem.com/pipan/file-based-database-migration-app-37af</link>
      <guid>https://forem.com/pipan/file-based-database-migration-app-37af</guid>
      <description>&lt;p&gt;I get frustrated if I have to do a task that can be automated or accomplished easier (with less brain activity). I think writing file based database migrations is one of those tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  File based database migrations
&lt;/h2&gt;

&lt;p&gt;For those, who don't know, what file based database migrations are. It's basically version control for databases. Every application, that uses database, and evolves over time, will eventually have to change database structure. We can use special files, &lt;code&gt;migrations&lt;/code&gt;, to share this change between developers and servers. Migration file is a SQL (or other language) code, that can apply database changes or undo those changes.&lt;/p&gt;

&lt;p&gt;Migration framework keeps track of already applied changes and not yet applied changes. You can update to the newest database scheme version or fallback to specific version in time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating migration file
&lt;/h2&gt;

&lt;p&gt;To create a migration file you have to know SQL really well or know specific migration framework commands. In my last job, we did 4-5 migrations in a month. It's not frequent enough to remember all the commands needed to create valid file, but frequent enough to make me angry each time I have to google correct commands.&lt;/p&gt;

&lt;h2&gt;
  
  
  Migrator
&lt;/h2&gt;

&lt;p&gt;I decided to create a desktop application, that generates this migration file for you. This application should be able to create, update and remove database tables with zero code. I think it's possible to create user interface, that will handle most migration cases.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;First of all, I tried to google if this kind of application already exists. I did not have any success finding one. If you know about existing application let me know&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The application is called &lt;code&gt;Migrator&lt;/code&gt;. It's written in java, so everyone should be able to run it. There might be some bugs and missing features, but I think it's enough to prove the concept. Also, some form labels might be confusing. Unfortunately, I did not add any hints for them, but it might be improved in the future.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/dY0y5gabkE5wKijvyr/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/dY0y5gabkE5wKijvyr/giphy.gif" alt="craete migration file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Download: &lt;a href="https://github.com/pipan/migrator/releases/download/v0.2.2/migrator.jar"&gt;https://github.com/pipan/migrator/releases/download/v0.2.2/migrator.jar&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Github: &lt;a href="https://github.com/pipan/migrator"&gt;https://github.com/pipan/migrator&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Current support
&lt;/h2&gt;

&lt;p&gt;Current version of the application supports only phinx migrations (PHP) and MySQL databases.&lt;/p&gt;

&lt;p&gt;Possible future support could be for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;flyway (java)&lt;/li&gt;
&lt;li&gt;db-migrate (nodejs)&lt;/li&gt;
&lt;li&gt;fluent (.net)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I will appreciate any feedback or contributions. The idea is to keep it open source and let community add other database drivers and language support.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You might need Java 12 and higher to run this application&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>showdev</category>
      <category>database</category>
      <category>java</category>
      <category>phinx</category>
    </item>
    <item>
      <title>Don't ignore caught exceptions</title>
      <dc:creator>Peter Gašparík</dc:creator>
      <pubDate>Wed, 28 Aug 2019 09:32:44 +0000</pubDate>
      <link>https://forem.com/pipan/don-t-ignore-caught-exceptions-4cg4</link>
      <guid>https://forem.com/pipan/don-t-ignore-caught-exceptions-4cg4</guid>
      <description>&lt;p&gt;I had a really bad day because of a function, that ignored all caught exceptions. Code looks something like this and it was part of a third party library, that I was using. I didn't know about implementation details at the time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;doSomething&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// some code&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Debugging function like this, that never crashes and never prints any error messages, is a nightmare. I usually trust third party libraries and at first assume that problem has to be with my code. That’s why I spent hours debugging this.&lt;/p&gt;

&lt;p&gt;So, what to do with exceptions? I think it's valid to let other programmers (those that use this library) to handle the exception. Especially, if you have no idea what to do with it.&lt;/p&gt;

&lt;p&gt;What do you think? Is there a situation where this is acceptable? Maybe production environment? I personally don't think so, because you want to know about errors in production and store them somewhere.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>exceptions</category>
      <category>debugging</category>
    </item>
  </channel>
</rss>
