<?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: Pedro Pimenta</title>
    <description>The latest articles on DEV Community by Pedro Pimenta (@bitdweller).</description>
    <link>https://dev.to/bitdweller</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%2F26432%2Fd74161c1-4d3b-4563-9996-93449f900a52.png</url>
      <title>DEV Community: Pedro Pimenta</title>
      <link>https://dev.to/bitdweller</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bitdweller"/>
    <language>en</language>
    <item>
      <title>Responsive iframe without a parent container</title>
      <dc:creator>Pedro Pimenta</dc:creator>
      <pubDate>Tue, 14 Jul 2020 14:57:42 +0000</pubDate>
      <link>https://dev.to/bitdweller/responsive-iframe-without-a-parent-container-367k</link>
      <guid>https://dev.to/bitdweller/responsive-iframe-without-a-parent-container-367k</guid>
      <description>&lt;p&gt;If you've built a website you have had the problem: &lt;strong&gt;make an iframe responsive&lt;/strong&gt;. Maybe it was a YouTube video, maybe it was a Google Maps embed. Whatever it was, you probably did it the most popular way: wrap the iframe in a &lt;code&gt;div&lt;/code&gt; and use &lt;code&gt;padding&lt;/code&gt; to maintain the aspect ratio. Like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.videoWrapper&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;56.25%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* 16:9 */&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.videoWrapper&lt;/span&gt; &lt;span class="nt"&gt;iframe&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&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;h1&gt;
  
  
  What if you can't add the wrapper div?
&lt;/h1&gt;

&lt;p&gt;I was building the v2 of a blog with &lt;strong&gt;150+ articles in 3 languages&lt;/strong&gt; and v1 was not responsive. I had to build the front end with this in mind, trying to avoid having to edit the content everywhere possible. As expected, &lt;strong&gt;YouTube embeds weren't wrapped in any div&lt;/strong&gt; and changing them all would be &lt;del&gt;a pain in the ass&lt;/del&gt; &lt;strong&gt;difficult&lt;/strong&gt;. This was my solution:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;iframe&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;100vw&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--margin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="nl"&gt;max-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="m"&gt;100vw&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--margin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="m"&gt;1.7778&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c"&gt;/* 16:9 */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Of course, you do need to know how your container behaves and any margins you have. In this case I'm taking into account horizontal margins with &lt;code&gt;var(--margin)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here's a CodePen with a live example:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/pedrogpimenta/embed/abdWgaw?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;What do you think? What are the drawbacks? Do you see any potential problem with this solution?&lt;/p&gt;

</description>
      <category>css</category>
      <category>embed</category>
      <category>iframe</category>
    </item>
    <item>
      <title>Why did I build my portfolio website with GatsbyJS?</title>
      <dc:creator>Pedro Pimenta</dc:creator>
      <pubDate>Sat, 11 Jul 2020 19:25:15 +0000</pubDate>
      <link>https://dev.to/bitdweller/why-did-i-build-my-portfolio-website-with-gatsbyjs-3pp0</link>
      <guid>https://dev.to/bitdweller/why-did-i-build-my-portfolio-website-with-gatsbyjs-3pp0</guid>
      <description>&lt;p&gt;TL;DR at the bottom.&lt;/p&gt;




&lt;p&gt;I've just finished building my &lt;a href="https://pimenta.co"&gt;new portfolio&lt;/a&gt; and it's a simple one. Veeery simple (I'm a simple guy :). So simple that Gatsby is probably, definitely an over-kill, for the development side and for the client side as well. I don't need that much JavaScript.&lt;/p&gt;




&lt;h2&gt;
  
  
  So why did I do it?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;To learn.&lt;/strong&gt; I finally got the energy to really learn JavaScript and the ecosystem around it, starting with React. So when building my portfolio, I grabbed the chance to expand my knowledge on the subject a bit more.&lt;/p&gt;

&lt;p&gt;I also decided to add a few more things to the mix: &lt;a href="https://strapi.io/"&gt;Strapi&lt;/a&gt;, a Node.js CMS that I hosted on Heroku and an AWS S3 Bucket to store the images for Strapi.&lt;/p&gt;

&lt;p&gt;It has been a very fun journey on learning so many different technologies and how they work.&lt;/p&gt;




&lt;h2&gt;
  
  
  What am I saying
&lt;/h2&gt;

&lt;p&gt;With this I just want to share with you the idea of taking the opportunity to learn wherever you can, even if it wouldn't be your first choice.&lt;/p&gt;

&lt;p&gt;What do you think of this? Would you do the same or would you stick to the best tools for the job?&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;TL;DR: I overengineered my personal website to learn more JavaScript.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>portfolio</category>
      <category>gatsby</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Stop setting the language of your website based on user location</title>
      <dc:creator>Pedro Pimenta</dc:creator>
      <pubDate>Sun, 17 May 2020 23:20:31 +0000</pubDate>
      <link>https://dev.to/bitdweller/stop-setting-the-language-of-your-website-based-on-my-location-31h0</link>
      <guid>https://dev.to/bitdweller/stop-setting-the-language-of-your-website-based-on-my-location-31h0</guid>
      <description>&lt;p&gt;Please, stop!&lt;/p&gt;

&lt;h1&gt;
  
  
  Why
&lt;/h1&gt;

&lt;p&gt;Setting the language of your website based on the user's location is not the best user experience. People travel, people move and not always do they speak the language of the place they're in.&lt;/p&gt;

&lt;p&gt;I'm currently living in Germany for a while, and I know next to nothing of German, so it serves nothing showing me your content in German.&lt;/p&gt;

&lt;p&gt;The worst offenders are the ones that first load the default (most of the times, in my experience, English) and then reload or re-paint to show me a language I don't understand.&lt;/p&gt;

&lt;h1&gt;
  
  
  The solution
&lt;/h1&gt;

&lt;p&gt;A much better way (and probably easier) is to use the user's browser/system language. That's the language I want to read on 99% of the time. Otherwise, why would I have my machine in that language? And if it's not, I will change it myself.&lt;/p&gt;

&lt;p&gt;So if my preferred language is English, it doesn't matter where I am, the content will be delivered in that language and I will understand it.&lt;/p&gt;

&lt;p&gt;It's also super easy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var userLang = navigator.language || navigator.userLanguage; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Thank you. Signed,&lt;br&gt;
Everyone&lt;/p&gt;

</description>
      <category>language</category>
      <category>location</category>
      <category>webdev</category>
      <category>ux</category>
    </item>
    <item>
      <title>My first React webapp: Instatext</title>
      <dc:creator>Pedro Pimenta</dc:creator>
      <pubDate>Wed, 27 Mar 2019 17:45:36 +0000</pubDate>
      <link>https://dev.to/bitdweller/my-first-react-webapp-instatext-1c01</link>
      <guid>https://dev.to/bitdweller/my-first-react-webapp-instatext-1c01</guid>
      <description>&lt;p&gt;I am so proud of myself that I have to share this little insignificant app with everyone! It's a tool to help you format your content for Instagram and not lose your line breaks.&lt;/p&gt;

&lt;p&gt;We're sick and tired of the Instagram app removing our line breaks and replacing them with single spaces so I thought I could build this.&lt;/p&gt;

&lt;p&gt;I'm learning JS and React, this is the first personal project I have ever finished and published. By no means it is good but it's mine and it works, at least for me and my girlfriend :)&lt;/p&gt;

&lt;p&gt;Check it out: &lt;a href="https://instatext.pimenta.co"&gt;https://instatext.pimenta.co&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to use, share, comment, help or whatever.&lt;/p&gt;

</description>
      <category>react</category>
      <category>webapp</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Be careful when copying and pasting</title>
      <dc:creator>Pedro Pimenta</dc:creator>
      <pubDate>Sat, 02 Feb 2019 12:00:28 +0000</pubDate>
      <link>https://dev.to/bitdweller/be-careful-when-copying-and-pasting-4nng</link>
      <guid>https://dev.to/bitdweller/be-careful-when-copying-and-pasting-4nng</guid>
      <description>&lt;p&gt;At my job (and probably yours) we're always copying and pasting stuff. Be it little snippets, big chunks of code from old projects or from the web (of course &lt;a href="https://blog.codinghorror.com/a-modest-proposal-for-the-copy-and-paste-school-of-code-reuse/" rel="noopener noreferrer"&gt;you never do that&lt;/a&gt;), or just plain client content, we're doing it. This post focuses mainly on copying content because that's when you're copying from different sources, programs and interfaces, but it applies to everything.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where it began
&lt;/h2&gt;

&lt;p&gt;On one bug-fixing morning I got this screenshot, saying there was a bug with the word "código" on Firefox:&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%2Ftj1vo838oyc8d5beemu1.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%2Ftj1vo838oyc8d5beemu1.png" alt="First ocurrence of the bug" width="800" height="137"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As obvious and visible as a bug can be, I didn't see it. I opened the faulty page on my machine with Chromium: it looked OK. Weird. I opened Chrome, Safari and Firefox and it only ocurred on Firefox. I looked at the code on Sublime Text and it look fine: &lt;code&gt;código&lt;/code&gt;. Wow.&lt;/p&gt;

&lt;p&gt;So I got stuck looking at it, inspecting it with all the browser's tools I could, but couldn't find any lead. I wrote an &lt;code&gt;ó&lt;/code&gt; beside the word &lt;code&gt;código&lt;/code&gt; and it looked fine. It was definitely a problem with that specific &lt;code&gt;ó&lt;/code&gt;. I could delete the word and move on, but no, &lt;strong&gt;I need to get to the bottom of this&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So I copied the word from Sublime Text and searched the web for "translate unicode" and "copy characters reveal unicode" (you can see I was very lost on this) and I was brought to a couple of pages that helped.&lt;/p&gt;

&lt;p&gt;One is &lt;a href="https://r12a.github.io/apps/conversion/" rel="noopener noreferrer"&gt;r12a's Unicode code converter&lt;/a&gt; which converted the copied &lt;code&gt;ó&lt;/code&gt; to &lt;code&gt;o&amp;amp;amp;#x0301;&lt;/code&gt;. This is two characters, not one as intended. The other page is &lt;a href="http://www.mclean.net.nz/ucf/" rel="noopener noreferrer"&gt;Grant McLean's Unicode Character Finder&lt;/a&gt; which show this when I pasted the culprit character:&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%2Fge23ylfaaqscw0ohacff.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%2Fge23ylfaaqscw0ohacff.png" alt='The Unicode Character Finder shows a "Combining acute accent"' width="699" height="221"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It forgo the first "o" because when pasting in this box, it only shows the last character. Definitely two characters. How can this be? I don't know.&lt;/p&gt;

&lt;h2&gt;
  
  
  Suddenly it hit me
&lt;/h2&gt;

&lt;p&gt;This is client text, I &lt;strong&gt;copied&lt;/strong&gt; this from somewhere. I can't recall correctly but I think this particular text was forwarded from a client email. So it is weird character handling from either my end or the client's end or the man in the middle. And only Firefox show it incorrectly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; it seems that some fonts handle these characters in different ways. When writing this post I noticed that the font face I'm using on Sublime handles these two characters as the one it should be, but if I change it to, for example, &lt;a href="href="&gt;Inconsolata&lt;/a&gt;, it shows up different:&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%2Ft4gy4oujc7frpfyv9v02.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%2Ft4gy4oujc7frpfyv9v02.png" alt="Differences between Courier and Inconsolata" width="800" height="90"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is because Inconsolata doesn't have this character in its table so it switches to the default one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solutions?
&lt;/h2&gt;

&lt;p&gt;Of course I will always copy and paste client text, I will not rewrite everything, it would consume a lot of time.&lt;/p&gt;

&lt;p&gt;Is there anyway to sanitize text to avoid this kind of problems?&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>html</category>
      <category>unicode</category>
      <category>copyandpaste</category>
    </item>
  </channel>
</rss>
