<?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: Cristian Popescu</title>
    <description>The latest articles on DEV Community by Cristian Popescu (@cripstian).</description>
    <link>https://dev.to/cripstian</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%2F80859%2F692d688d-50e6-4d28-852e-662585b3ed0d.jpeg</url>
      <title>DEV Community: Cristian Popescu</title>
      <link>https://dev.to/cripstian</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cripstian"/>
    <language>en</language>
    <item>
      <title>Free SSL for your remote website with Certbot</title>
      <dc:creator>Cristian Popescu</dc:creator>
      <pubDate>Wed, 29 Jan 2020 21:03:50 +0000</pubDate>
      <link>https://dev.to/cripstian/free-ssl-for-your-remote-website-with-certbot-2if7</link>
      <guid>https://dev.to/cripstian/free-ssl-for-your-remote-website-with-certbot-2if7</guid>
      <description>&lt;p&gt;To get your website on the right path, you must have a professional look and inspire trust. What is a better way to do that other than get a certificate to attest that you are who you are telling everyone you are?&lt;br&gt;
After you have this, your customers will be able to trust that they are barking at the right tree, so to speak, especially if you sell dog food, or cats 🐱, from a tree.&lt;br&gt;
Not to bore you with any more details... here is how I managed to generate my SSL certificate for free with &lt;a href="https://certbot.eff.org/"&gt;Certbot&lt;/a&gt; and &lt;a href="https://letsencrypt.org/"&gt;Let's Encrypt&lt;/a&gt;, having only FTP access to a &lt;a href="https://cpanel.net/"&gt;cPanel&lt;/a&gt; hosting platform, like most of basic hosting providers offer.&lt;/p&gt;
&lt;h2&gt;
  
  
  Walkthrough
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Step 1 - Installing Certbot
&lt;/h3&gt;

&lt;p&gt;extracted from &lt;a href="https://certbot.eff.org/lets-encrypt/ubuntubionic-nginx"&gt;here&lt;/a&gt;&lt;br&gt;
Adding Certbot install source&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;    &lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get update
    &lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;software-properties-common
    &lt;span class="nb"&gt;sudo &lt;/span&gt;add-apt-repository universe
    &lt;span class="nb"&gt;sudo &lt;/span&gt;add-apt-repository ppa:certbot/certbot
    &lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get update
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Actually install Certbot&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;certbot
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2 - Start process
&lt;/h3&gt;

&lt;p&gt;Trigger the process for obtaining a certificate&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;certbot certonly &lt;span class="nt"&gt;--manual&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You will be asked some questions that will help the process like domain name, and confirmation that your IP can be logged and stored.&lt;br&gt;
In the end you will get this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Create a file containing just this data:

3somCsUrL5gqQ1dpEZH-cdunbOh0s4EopDqeAL8bGEQ.ZBWPX1wW-bZycJUQEVL0PxqWb7WbBG0XdbWHQqgERwA

And make it available on your web server at this URL:

http://test.com/.well-known/acme-challenge/3somCsUrL5gqQ1dpEZH-cdunbOh0s4EopDqeAL8bGEQ

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Leave this console as it is, &lt;span class="k"&gt;until &lt;/span&gt;you are &lt;span class="k"&gt;done &lt;/span&gt;with the next steps.

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



&lt;h3&gt;
  
  
  Step 3 - Create the file locally
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"3somCsUrL5gqQ1dpEZH-cdunbOh0s4EopDqeAL8bGEQ.ZBWPX1wW-bZycJUQEVL0PxqWb7WbBG0XdbWHQqgERwA"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; 3somCsUrL5gqQ1dpEZH-cdunbOh0s4EopDqeAL8bGEQ
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will create the required folder on your local machine&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4 - Create the required directory tree and copy the file up to the FTP server
&lt;/h3&gt;

&lt;p&gt;As in the above example, you need to create the structure of urls that are requested. So login via FTP and create everything:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;ftp ftp.test.com
// use your credentials that you were provided with from your hosting provider
// create &lt;span class="k"&gt;if &lt;/span&gt;not present the .well-known folder
mkd .well-known
// change directory
&lt;span class="nb"&gt;cd&lt;/span&gt; .well-known
//create the acme-challange folder
// IMPORTANT: copy the text from the &lt;span class="nb"&gt;link &lt;/span&gt;&lt;span class="k"&gt;in &lt;/span&gt;the console
// I ran into multiple issues by writing the folder name myself
mkd acme-challange
// change directory
&lt;span class="nb"&gt;cd &lt;/span&gt;acme-challange
// upload file
put 3somCsUrL5gqQ1dpEZH-cdunbOh0s4EopDqeAL8bGEQ
// &lt;span class="nb"&gt;exit &lt;/span&gt;ftp
bye
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can now go back to your previous console and hit ENTER, so you can finish up with the process.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5 - You are done... almost
&lt;/h3&gt;

&lt;p&gt;After successfully finishing up the process, you will be provided with the path of the generated certificates and keys, something starting with &lt;code&gt;cd /etc/letsencrypt/live/&lt;/code&gt;. Go there by switching to the super user on your local machine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;su
&lt;span class="nb"&gt;cd&lt;/span&gt; /etc/letsencrypt/live/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Go into your cPanel and find SSL/TLS shortcut and manage your certificates. Select your domain and fill up the required form with CRT (&lt;code&gt;cert.pem&lt;/code&gt;) and KEY (&lt;code&gt;privkey.pem&lt;/code&gt;).&lt;br&gt;
Now you can click &lt;code&gt;Install certificate&lt;/code&gt; and...&lt;/p&gt;

&lt;p&gt;Your're DONE! Congrats!&lt;/p&gt;

&lt;h3&gt;
  
  
  Important Note
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;I.&lt;/em&gt;&lt;/strong&gt; Keep in mind the &lt;code&gt;acme-challange&lt;/code&gt; folder name, it must be copied from the console since it has unusual characters encoding, which fails the test of Certbot.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;II.&lt;/em&gt;&lt;/strong&gt; Having the most basic plan, I do not have SSH access to my remote host, so I can only access it via FTP. If SSH was present, this thing would be much easier by installing certbot on the server machine.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;III.&lt;/em&gt;&lt;/strong&gt; Do not forget to add a permanent redirect from the root to your brand new &lt;code&gt;https://&lt;/code&gt; domain.&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>certbot</category>
      <category>letsencrypt</category>
      <category>ssl</category>
      <category>cpanel</category>
    </item>
    <item>
      <title>Kotlin and it's extenstions</title>
      <dc:creator>Cristian Popescu</dc:creator>
      <pubDate>Wed, 15 Jan 2020 05:02:13 +0000</pubDate>
      <link>https://dev.to/cripstian/kotlin-and-it-s-extenstions-5106</link>
      <guid>https://dev.to/cripstian/kotlin-and-it-s-extenstions-5106</guid>
      <description>&lt;p&gt;Here are a few of my favourite shortcuts to work with Kotlin. If you have others, don't hesitate to mention them.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. chunked &lt;a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/chunked.html"&gt;doc&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;Works on Iterables that are most common to us, like &lt;code&gt;List&lt;/code&gt;s or &lt;code&gt;Sequence&lt;/code&gt;s.&lt;br&gt;
It does exactly what it sounds like, splits a collection in equal parts (if possible) and enables us to transform each resulting sublist, all in the same operation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;initialList&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;listOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"chair"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"table"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"couch"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;chunkedTwo&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;initialList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chunked&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// chunkedTwo -&amp;gt; [["chair", "table"], ["couch"]]&lt;/span&gt;
&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;transform&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;initialList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chunked&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;subList&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;subList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;last&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// transform -&amp;gt; ["table", "couch"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You may have needed this or not, but it's nice to know it's there. Sometimes when you think about it, it's not that difficult to do, but reimplementing the same things may cause you to slip up somewhere, somehow.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. with &lt;a href="https://kotlinlang.org/docs/reference/scope-functions.html#with"&gt;doc&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;Scoped functions like &lt;code&gt;with&lt;/code&gt; enable us to write more verbose code. This one can cut down on the length of the line by scoping to a nested variable in your object. But I think an example is most fit here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;data class&lt;/span&gt; &lt;span class="nc"&gt;Birthday&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;year&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;month&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;day&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;data class&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;BirthDay&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;data class&lt;/span&gt; &lt;span class="nc"&gt;Employee&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;person&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// having a method that receives an employee and computes a string&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;nameAndBirth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;employee&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Employee&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;with&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;employee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// in here, the scope is actually Birthday&lt;/span&gt;
    &lt;span class="s"&gt;"${employee.person.name}: $day/$month/$year"&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;Another cool fact about &lt;code&gt;with&lt;/code&gt; is that, like the other functions &lt;code&gt;run&lt;/code&gt;, &lt;code&gt;let&lt;/code&gt; and so on, it will return the last value that was computed. In our case, the &lt;code&gt;String&lt;/code&gt; that contains the name and birth of the employee.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. associateBy &lt;a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/associate-by.html"&gt;doc&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;This is a great shortcut to create maps for objects that you need to find later on, by certain keys (id, name, length and so on). You could find it really useful, since this, in many cases is repeatable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="kd"&gt;data class&lt;/span&gt; &lt;span class="nc"&gt;Room&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Long&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;area&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Double&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;rooms&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;listOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Room&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"living"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;40.5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nc"&gt;Room&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"living"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;39.3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;associated&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rooms&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;associateBy&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// associated -&amp;gt; { "living"=Room(2, "living", 39.3)}&lt;/span&gt;
&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;associated2&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rooms&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;associateBy&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// associated2 -&amp;gt; { 1=Room(1, "living", 40.5), 2=Room(2, "living", 39.3)}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Be careful since if two keys match, only the last one will be present in the resulted map.&lt;/p&gt;

&lt;p&gt;Hope you can try these out if you didn't already.&lt;/p&gt;

&lt;p&gt;Thanks for Reading&lt;/p&gt;

</description>
      <category>kotlin</category>
      <category>kotlinlanguage</category>
      <category>firstarticle</category>
    </item>
  </channel>
</rss>
