<?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 Luca Giuberti on Medium]]></title>
        <description><![CDATA[Stories by Luca Giuberti on Medium]]></description>
        <link>https://medium.com/@gix_lg?source=rss-4fcf2c91bdb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uScMx4Lkd4wG8ZWV67A5HQ.jpeg</url>
            <title>Stories by Luca Giuberti on Medium</title>
            <link>https://medium.com/@gix_lg?source=rss-4fcf2c91bdb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 18:44:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gix_lg/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[I’m a developer, I love automation]]></title>
            <link>https://medium.com/@gix_lg/im-a-developer-i-love-automation-975a56852f07?source=rss-4fcf2c91bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/975a56852f07</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[google-app-script]]></category>
            <dc:creator><![CDATA[Luca Giuberti]]></dc:creator>
            <pubDate>Wed, 27 Feb 2019 18:13:46 GMT</pubDate>
            <atom:updated>2019-02-27T18:13:46.808Z</atom:updated>
            <content:encoded><![CDATA[<p>27 Feb 2019</p><p>In these days a lot of people live in a rented house and I’m one of them.<br> Every month I receive an email with attached the fees about gas or electricity power for the apartment where I live, and every time I do these operations:</p><ol><li>label it with a specific name with the corresponding year and month;</li><li>save the attachments in a Dropbox folder;</li><li>insert that information in a Google Drive sheet on a table like the following:<br> (The value of fees and rent are fake 😜 )</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dlrq5_BNKh1mZpZ-.png" /></figure><p>I’ve done these operations several times.</p><p>As all good developer, <strong>I’m lazy</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*dmMwPC5veuT8wiyf.gif" /></figure><p>So I asked myself: “Why I have to do the same operation manually every month? <br> Can I automate this stuff?”.</p><p>In the first step, I tried with IFTTT, but is not so powerful to do what I had in mind (or maybe I simply don’t know it much 😅️).</p><p>After some research, I tried with <a href="https://script.google.com/home">Google App Script</a>.<br> Basically, it is a service that allows writing an application in Javascript with the possibility to use Google Service’s API like GMail and Drive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*2201R8IKpIOl4PeI.png" /></figure><p>Using Google App Script I’ve done this small experiment:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f0cdddced9c05ec9b06bb1f27831f47/href">https://medium.com/media/0f0cdddced9c05ec9b06bb1f27831f47/href</a></iframe><p>With these few lines of code, <strong>I’m able to search into all my Gmail account for the mails Threads that have a specific label</strong>.<br> In order to do that, is necessary to give to the application the access to the Gmail API.</p><p>Ok Great! It seems promising.<br> Now let’s try to do something more useful, like the first task that I mentioned before.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a967b28bc0108b2e4adc4f0377c33830/href">https://medium.com/media/a967b28bc0108b2e4adc4f0377c33830/href</a></iframe><p>A lot of stuff in there, but still pretty simple.</p><p>Let me do just a few comments.<br> I added a flag [1] (to be precise the label Processed by Google Script) that allow identifying if a thread it is been already processed in order to avoid useless elaboration. <br> In the function getYearAndMonthStringFromDate I did a month +1 because, for example, the fee on January should be paid in February [2].<br> In the code I create a label like Home staff/2019-02 to create a hierarchy, so 2019-02 is a sublabel of Home staff [3].</p><p>Well, with this code I’m able to do the <strong>first step of my checklist</strong> <strong>1. label it with a specific name with the corresponding year and month.</strong></p><p>Now the goal is to do the second step! So ideally our code can evolve on this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/946ac76ef2c4b78f9bed5dc65eac5b6c/href">https://medium.com/media/946ac76ef2c4b78f9bed5dc65eac5b6c/href</a></iframe><p>Nothing particular here; the code is pretty straightforward.</p><p>To really upload the files on Dropbox, I lean on the amazing Dropbox API and, in particular, I used this one: <a href="https://www.dropbox.com/developers/documentation/http/documentation#files-upload">file upload</a>.</p><p>Here’s the piece of code that calls the API:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2045d349be0512f1ecaf14dd01f6ec9/href">https://medium.com/media/e2045d349be0512f1ecaf14dd01f6ec9/href</a></iframe><p>Dropbox Access Token can be created from this <a href="https://www.dropbox.com/developers/apps">page</a> (and it shouldn’t be shared).</p><p>Now we can delete the second point as well:<br> <strong>2. save the attachments in a Dropbox folder</strong></p><p>Ok good, we miss the last level 😀.</p><p>At this point, the hard part is not to insert the information in a Google sheet, but rather read the information.<br> The file that I receive through email is a pdf, hence is not easy to read it like a normal text file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*n2JjalX96UfybDtm.jpg" /></figure><p>After some research, I found an amazing script: <a href="https://stackoverflow.com/a/26623198/5945360">pdfToText</a>.<br> That script uses OCR feature, offered by Google, to convert a written document in a text. To activating this capability, we need to enable the Drive API under Resources &gt; Advanced Google Services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dBcI305fykFLJemo.png" /></figure><p>Using that, I was able to get from a pdf like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZhIhqBv5i4Ms4axe.png" /></figure><p>a text like this:</p><pre>&quot;&quot;RIEPILOGO BOLLETTA Codice Cliente ********** Codice Fiscale *************************** *** * ** * ****** CONSUMI Totale Energia kWh Elettrica: 70 ••••••...&quot;&quot;</pre><p>From that, assuming that the format of the pdf remains stable through the months with some text parsing, we can get all the info that we want.<br> In my case, from each invoice, I get the following info:</p><pre>var invoceData = {<br>   company: &quot;Enegan&quot;, <br>   type: &quot;Energia Elettrica&quot;, <br>   value: 99 <br>}</pre><p>The info from each invoice is combined together and returned by processesThread.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/76cc1502a5fed9ef6cce6789c86b61d2/href">https://medium.com/media/76cc1502a5fed9ef6cce6789c86b61d2/href</a></iframe><p>At this point, I have all the data that I need to fill up my sheet. As before, for taking advantage of the Sheets API, is necessary to give our authorization to the app.</p><p>And this is the final piece of code that I’ll show:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4257ab5e03b17df7d50235b9533a1ed7/href">https://medium.com/media/4257ab5e03b17df7d50235b9533a1ed7/href</a></iframe><p>Here the most difficult thing was to calculate the right row where write the content. To do that, I calculate the distance in terms of number of months between the first date in my table (so the 2018–02), to the date of the new entry.</p><p>When the row is known, is possible to write down all the info: the rent, the condominium fees, the total sum, a small description of the type of expense and so on.</p><p>Finally, we have automated also the last point.<br> <strong>3. insert that information in a sheet on Google Drive formatted like that.</strong></p><p>Now I have created a script that can do the operation that I did manually.<br> <strong>But still, I have to run this script manually!</strong></p><p>So to solve this issue I used a “Trigger”; this allows to execute my function under some condition. It is possible to set a trigger from <a href="https://script.google.com/home/">G Suite Developer Hub</a>. In my case was enough to set an execution one time for a month.</p><p>And… DONE!!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*2fEuvs__y_naglBo.gif" /></figure><h3>Conclusion</h3><p>Google App Script gives me a level of freedom that other preconfigured services can’t have. It’s a great solution for my use case. For sure, the ability to write code is what we, as developers, love and it gives the highest degree of flexibility: it’s a great plus!</p><p>The part that I didn’t like was the “IDE”, if we can call it. Writing code on a web page wasn’t comfortable at all, compared with VSCode or other tools.<br> Another negative part was the impossibility to use source control. It is possible to create different versions of our code but is totally different from what we are used to doing with git, for example.</p><p>These problems can be solved using <a href="https://github.com/google/clasp">CLASP</a>.<br> Indeed you can find all the code on my <a href="https://github.com/gixlg/GASP-Monthly-House-Fee-Calculator">GitHub Repo</a>.</p><p>Maybe I will talk about it in another post. 😁</p><p><em>Originally published at </em><a href="http://blog.gixlg.it/i-m-a-developer-i-love-automation/"><em>blog.gixlg.it</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=975a56852f07" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You don’t know DevTool]]></title>
            <link>https://medium.com/@gix_lg/you-dont-know-devtool-21d73511cc90?source=rss-4fcf2c91bdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/21d73511cc90</guid>
            <category><![CDATA[chrome]]></category>
            <category><![CDATA[console-log]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[devtools]]></category>
            <dc:creator><![CDATA[Luca Giuberti]]></dc:creator>
            <pubDate>Wed, 25 Jul 2018 08:24:07 GMT</pubDate>
            <atom:updated>2018-08-21T12:41:09.389Z</atom:updated>
            <content:encoded><![CDATA[<p>25 Jul 2018</p><p>How cool is chrome? From my point of view is the best browser actually on the scene.<br> It is <strong>simple</strong> and <strong>estensible</strong>.</p><p>Chrome doesn’t offer only a very nice browser but also an amazing Development Tool, the <strong>DevTool</strong>.<br> DevTool, is powerful and full of features, if you are a web developer or have a bit of experience on that field you would agree with me.</p><p>In this article (and I hope to show more tricks on next posts), I will show some nice features that maybe <strong>you don’t know</strong> about <strong>DevTool</strong>.<br> Let’s start from the basic. What is the function that you use most in chrome?</p><p>I bet <strong>console.log</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/191/0*N7y8AMq3-fk8MOMA.jpg" /></figure><p>I use it every time during the debug phase; is one of the most used and one of the most abused (but this is not the point now).</p><p>Console.log is more powerful that I thought.<br> I didn’t know that it’s <strong>similar to</strong> <em>printf</em> <strong>from c</strong>.<br> So, in a few words, the first argument is the string that is printed, but if it’s used some special character, they are replaced by the other argument of the method.</p><p>E.g</p><pre>console.log(&quot;An example is more %s than %i words&quot;, &quot;clear&quot;, 1000);</pre><p>will print out:</p><pre>&quot;An example is more clear than 1000 words&quot;.</pre><p>Lots of times if I wrote something like this:</p><pre>var object = {data: &quot;My data&quot;}; console.log(&quot;I received this object: &quot; + object);</pre><p>and I get this</p><pre>I received this object [object Object]</pre><p>and I could not see the value of the object.<br> So at the beginning I split che console log above in two separate calls.</p><p>Not so nice, right?!</p><p>This is a better way:</p><pre>var object = {data: &quot;My data&quot;} console.log(&quot;I received this object %o&quot; , object)</pre><p>and then it’s possible to see the text and the content of the object.</p><pre>I received this object {data: &quot;My data&quot;}</pre><p>If the object is a <strong>DOM element,</strong> it’s possible to choose if we want to see the <strong>DOM representation</strong> or the <strong>object representation.</strong></p><p>E.g.</p><pre>var domElement = document.querySelector(&quot;#you-got-it&quot;); console.log(&quot;The domElement can be show like this %o ...&quot;, domElement); console.log(&quot;... or like this %O ...&quot;, domElement);</pre><p>Note: feel free to open the console on this page and run this code :)<br>*For those that read from medium you should query for:</p><pre>document.querySelector(‘[data-image-id=”0*N7y8AMq3-fk8MOMA.jpg”]’)</pre><p>For closing this quick journey on console log features, I’ll show you a fun thing.</p><p>Do you know that you can style the console log output?</p><p>Yessss! It is possible!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*txzS8y5w8IJFF-W2.jpg" /><figcaption>88</figcaption></figure><p>With <strong>%c</strong> follow by a valid <strong>CSS</strong> syntax is possible to get a more original output into the console.<br> Let’s try it!</p><pre>console.log(&#39;%cLook how Amazing I am&#39;, &#39;background: #222; color: yellow; font-size: 50px; margin: 20px; padding: 30px&#39;);</pre><p>After this you can see something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c5x3H7P9uVC54TLO.png" /></figure><p>It is awesome, but <strong>it’s just a nerd thing</strong>, to be honest I’ve never used it in a real project.</p><p>So, that’s all guys. If you find something that you did’t know or just like it, watch this space.</p><p>PS. All this methods are also valid for console.error, console.warn.</p><p><em>Originally published at </em><a href="http://blog.gixlg.it/you-don-t-know-devtool/"><em>blog.gixlg.it</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21d73511cc90" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>