<?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: Honza Černý</title>
    <description>The latest articles on DEV Community by Honza Černý (@chemix).</description>
    <link>https://dev.to/chemix</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%2F227043%2Fd50779a7-5a05-4572-b6f5-92b2c28362e9.jpg</url>
      <title>DEV Community: Honza Černý</title>
      <link>https://dev.to/chemix</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chemix"/>
    <language>en</language>
    <item>
      <title>Enhance PhpStorm File Templates with Velocity 🧪</title>
      <dc:creator>Honza Černý</dc:creator>
      <pubDate>Sat, 22 Jun 2024 12:24:38 +0000</pubDate>
      <link>https://dev.to/chemix/enhance-phpstorm-file-templates-with-velocity-4n1g</link>
      <guid>https://dev.to/chemix/enhance-phpstorm-file-templates-with-velocity-4n1g</guid>
      <description>&lt;p&gt;Using PhpStorm’s File Templates makes it easier to create linked files in frameworks like presenters/controlers and their templates. By setting up custom templates, you can quickly generate these files with the right structure. Using Velocity variables like &lt;code&gt;${NAME}&lt;/code&gt; and &lt;code&gt;${DIR_PATH}&lt;/code&gt; can helps automatically create file names and paths, reducing mistakes.&lt;/p&gt;

&lt;h2&gt;
  
  
  🜁
&lt;/h2&gt;

&lt;p&gt;In my case, I use the &lt;a href="https://www.nette.org"&gt;Nette Framework&lt;/a&gt;. There is a Presenter (HomepagePresenter.php) connected with a Template (Homepage.default.latte) in a Module (Admin):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/app/modules/Admin/Homepage/templates/Homepage.default
/app/modules/Admin/Homepage/HomepagePresenter.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I want a File Template that asks for just one name and prepares everything else 💥&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqox0ioomyfl8g6hxqh1u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqox0ioomyfl8g6hxqh1u.png" alt="Wizard dialog with input field" width="640" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to: Settings → Editor → File and Code Templates&lt;/li&gt;
&lt;li&gt;Create a new Template and use the variable &lt;code&gt;${NAME}&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  🜛
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;use variables in both the code and the path&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmufkhta9sd4x1zb3cfyg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmufkhta9sd4x1zb3cfyg.png" alt="code example with variable" width="800" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the second file, use “Create Child Template File”🜔&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjuf92dws49789f8vs3sp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjuf92dws49789f8vs3sp.png" alt="icon of Create Child Template File" width="60" height="66"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnzyqmjxij9elzemz3fin.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnzyqmjxij9elzemz3fin.png" alt="example of template file with velocity variable" width="800" height="159"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can create another variable named &lt;code&gt;${MODULE}&lt;/code&gt; for setting the namespace like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;namespace App\\${MODULE}Module\Presenters;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But ...&lt;/p&gt;

&lt;h2&gt;
  
  
  🜇 / 🜂 = 🜸 + 🜍🜞
&lt;/h2&gt;

&lt;p&gt;when you study a little bit of &lt;a href="https://velocity.apache.org/engine/devel/user-guide.html"&gt;Velocity templates&lt;/a&gt; and the variables that &lt;a href="https://www.jetbrains.com/help/idea/file-template-variables.html#predefined_template_variables"&gt;PhpStorm provides&lt;/a&gt;, you can combine them to automate some processes.&lt;/p&gt;

&lt;p&gt;In Velocity, &lt;code&gt;#set&lt;/code&gt; is used for variable settings, and PhpStorm suggests the variable &lt;code&gt;${DIR_PATH}&lt;/code&gt; – the path to the directory of the new file (relative to the project root).&lt;/p&gt;

&lt;p&gt;So we can start our Presenter template with this power 🜣 and use new variable &lt;code&gt;${moduleName}&lt;/code&gt; in the code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#set($dirPath = ${DIR_PATH})
#set($parentDirPath = $dirPath.substring(0, $dirPath.lastIndexOf("/")))
#set($moduleName = $parentDirPath.substring($parentDirPath.lastIndexOf("/") + 1))
&amp;lt;?php

namespace App\\${moduleName}Module\Presenters;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that’s it. Just a few lines of Velocity and more automated creation of File Templates is done. There is no magic, just digital alchemy 👨‍🔬⚗️&lt;/p&gt;

</description>
      <category>phpstorm</category>
      <category>templates</category>
      <category>howto</category>
      <category>nettefw</category>
    </item>
    <item>
      <title>Composer install in CI job</title>
      <dc:creator>Honza Černý</dc:creator>
      <pubDate>Sat, 29 Aug 2020 17:23:19 +0000</pubDate>
      <link>https://dev.to/chemix/composer-install-in-ci-job-2f0i</link>
      <guid>https://dev.to/chemix/composer-install-in-ci-job-2f0i</guid>
      <description>&lt;p&gt;Don't forget &lt;/p&gt;

&lt;p&gt;in &lt;em&gt;composer.json&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
"config": {
    "discard-changes": true
},
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;in &lt;em&gt;command line&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;composer install --no-dev --no-interaction --optimize-autoloader&lt;/code&gt;&lt;/p&gt;

</description>
      <category>php</category>
    </item>
    <item>
      <title>Convert pdf slides to png images</title>
      <dc:creator>Honza Černý</dc:creator>
      <pubDate>Sat, 29 Aug 2020 16:31:38 +0000</pubDate>
      <link>https://dev.to/chemix/convert-pdf-slides-to-png-images-2do0</link>
      <guid>https://dev.to/chemix/convert-pdf-slides-to-png-images-2do0</guid>
      <description>&lt;p&gt;Quick tip for converting pdf slides on MacOS. Good for video editing.&lt;/p&gt;

&lt;h2&gt;
  
  
  preparation
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://brew.sh"&gt;brew&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;brew install libpng&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;brew install libjpeg&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;brew install imagemagick&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;brew install ghostscript&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  usage
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;convert -density 144 my-presentation.pdf presentation-image.png&lt;/code&gt;&lt;/p&gt;

</description>
      <category>bash</category>
    </item>
  </channel>
</rss>
