<?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[Hackages Blog - Medium]]></title>
        <description><![CDATA[Hackages Blog is your home for tech related content. The place to be for articles on developer issues &amp; solutions by Hackages software engineers. Bonus: JS tips &amp; tricks, info on training and EdTech. We&#39;re tech-passionate &amp; want to share that with you. Happy Hacking! - Medium]]></description>
        <link>https://medium.com/hackages?source=rss----ac50bd715f02---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Hackages Blog - Medium</title>
            <link>https://medium.com/hackages?source=rss----ac50bd715f02---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 04:24:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/hackages" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Meet the sponsors of Workshop Summit]]></title>
            <link>https://medium.com/hackages/meet-the-sponsors-of-workshop-summit-be8365590f1b?source=rss----ac50bd715f02---4</link>
            <guid isPermaLink="false">https://medium.com/p/be8365590f1b</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[conference]]></category>
            <category><![CDATA[sponsorship]]></category>
            <category><![CDATA[workshop]]></category>
            <category><![CDATA[tech-events]]></category>
            <dc:creator><![CDATA[Marta Moliz]]></dc:creator>
            <pubDate>Wed, 15 Jan 2020 09:34:19 GMT</pubDate>
            <atom:updated>2020-01-29T14:13:42.906Z</atom:updated>
            <content:encoded><![CDATA[<h3>A shoutout to the supporters of the first edition</h3><p>The preparations for the first edition of <a href="http://workshop-summit.com/">Workshop Summi</a>t in Brussels are well underway! With less than 2 months before kicking-off the event, the <a href="https://www.google.com/maps/place/Hackages/@50.8486151,4.3674944,17z/data=!3m1!4b1!4m5!3m4!1s0x47c3c4899585207f:0xc8e0ba2f0ff6d7f0!8m2!3d50.8486117!4d4.3696831">Hackages Lab</a> is getting ready to welcome our mentors &amp; participants and the evening programme is being shaped as you read this blog.</p><p>But there are some actors who play a very important role as well and have not being on the spotlight yet: our <strong>sponsors</strong></p><p>In the coming weeks you will get to know them, their engagement in tech and what they offer!</p><p>Let’s start with our <strong>PLATINUM partner</strong>: <a href="https://www.gaming1.com/">GAMING1</a></p><p>GAMING1, with over 1.000 employees — including 250 in its Belgian’s headquarters — is the Belgian leader in gambling both terrestrial and online. GAMING1 aims to become a global reference in the regulated markets of online gaming thanks to the development of its own technology and its omnichannel approach.</p><p>GAMING1 is part of the portfolio of <a href="https://www.ardent-group.com/en">Ardent Group</a>, whose vocation is to participate actively and responsibly in the economic redeployment of Wallonia through entrepreneurial projects and societal. This Group is active in several activities including gambling, computer development, real estate, led display, energy or beer and has nearly 1.500 employees.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8gUUtgZdH_KA-S0Ob_9Yeg.png" /></figure><p>Next onto our GOLD partner: Exellys</p><p><a href="http://exellys.com/">Exellys</a> is a tech talent incubator and a science- based training &amp; coaching company. Exellys’ is moved by questions such as <em>‘Are you ready to drive the innovations of tomorrow? Ready to make an impact and become a future-proof digital leader and expert?</em>’</p><p>Exellys unlocks🔓 your full potential as Tech talent. We guide you to challenging projects that perfectly match your personality, expectations and ambitions. Through intensive training and coaching, you’ll gain the essential skills, competencies and knowledge necessary to become the highly effective and successful professional you aim to be.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gBTi-Pv_AlqQk1yjFy136A.png" /></figure><p><a href="https://www.wework.com/l/belgium">T</a>ime for our <strong>Silver sponsor</strong>: <a href="https://www.wework.com/en-GB/l/brussels">WeWork</a>!</p><p><a href="https://www.wework.com/en-GB/l/brussels">WeWork</a> is a shared workspace company present across 111 cities around the world. That’s a global network of individuals, startups or large enterprise companies who connect through our space, their bespoke events and via their app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RJn7K_yv-BfeZ1Prn7ZS8A.png" /></figure><p>Next up is our <strong>Bronze Sponsor</strong>: <a href="https://optis.be/">Optis</a>!</p><p>Optis delivers software development consulting for business applications.The team of the #optisfamily consultants becomes part of the organisation they work with to develop their digital ambitions.</p><p>The solid bond between team members is the beating heart of <a href="http://optis.be/">Optis</a>. They offer plenty of opportunities to meet and mix: events, parties, BBQ’s and tons of fun tech-projects. When it comes to creating plenty of learning opportunities, they take it to the next level by offering each employee an individual training budget that consultants can fully tailor to their wishes and needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vpjUSi2VfyiJExd244M_fQ.png" /></figure><p>And last, but not least: <a href="http://rtl.be/"><strong>RTL</strong></a><strong> </strong>as Bronze sponsor!</p><p><a href="http://rtl.be/">RTL</a> is a telecommunications group operating TV channels and radio stations in Germany, France, Belgium, the Netherlands, Luxembourg, Switzerland, Spain, Hungary, and Croatia. Particularly in Belgium, they are the main French-speaking referent on news.</p><p>Their engaged team makes sure the website and other platforms run smoothly. Want to know more? Meet them at #Workshop Summit!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NFq90KNx5om7aUPQj7vnZA.png" /></figure><p>Interested in <a href="https://workshop-summit.com/">Workshop Summit</a>? Check out the full line-up and book your ticket now!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be8365590f1b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackages/meet-the-sponsors-of-workshop-summit-be8365590f1b">Meet the sponsors of Workshop Summit</a> was originally published in <a href="https://medium.com/hackages">Hackages Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You can’t beat this algorithm]]></title>
            <link>https://medium.com/hackages/you-cant-beat-this-algorithm-df132ad753e7?source=rss----ac50bd715f02---4</link>
            <guid isPermaLink="false">https://medium.com/p/df132ad753e7</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Timothée Simon]]></dc:creator>
            <pubDate>Wed, 27 Nov 2019 10:01:01 GMT</pubDate>
            <atom:updated>2019-12-02T10:41:47.087Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*rIF5Vux6PtWU8u8NTMJZtA.png" /></figure><p>At my company (<a href="https://hackages.io/">Hackages</a>) we organise <strong>HackFridays</strong>. Every other Friday, we get one full day to experiment with tech we want to discover or learn more about. For me, the choice was deep learning. But as a frontend dev I discovered it is quite hard to implement in the frontend. And this is how IRMA was born.</p><h3>IRMA</h3><p>IRMA (Invisible Rock-Paper-Scissors Medium Algorithm) is a fortune teller that can predict with an accuracy of ~70% your next move at rock-paper-scissors game. You can try it <a href="https://irma.netlify.com/">here</a>, but be careful of the spell that could be cast on you if you beat her…<br>You can also use the <strong>j-k-l buttons</strong> on your keyboard to play faster.</p><h3>The technical side</h3><p>IRMA is just a statistical computing algorithm that learns from the player. It remembers every move and tries to predict the next one based on the previous successions. If you think you can be smarter than IRMA and generate random moves, try to stay below 50% accuracy after 100 moves. <br>Human beings are not able to deliver true randomness, and IRMA knows it!</p><p>Let’s take for example the 20 first moves an user (me) made:</p><pre>[&quot;📝&quot;, &quot;✂️&quot;, &quot;✂️&quot;, &quot;🗿&quot;, &quot;✂️&quot;, &quot;📝&quot;, &quot;🗿&quot;, &quot;📝&quot;, &quot;🗿&quot;, &quot;🗿&quot;, &quot;✂️&quot;, &quot;🗿&quot;, &quot;📝&quot;, &quot;✂️&quot;, &quot;📝&quot;, &quot;🗿&quot;, &quot;✂️&quot;, &quot;📝&quot;, &quot;🗿&quot;, &quot;✂️&quot;]</pre><p>It looks pretty random and it seems like it would be really difficult to predict my next move.<br>Now let’s try to divide this list in 3-grams. The 3-grams is the list of all successions of 3 choices that were made by the user. <br>This is not the same as dividing the list by groups of 3, for example the list [a, b, c, d] would produce 2 grams: [a, b, c]and [b, c, d].</p><p>Here we have:</p><pre>[&quot;📝&quot;, &quot;✂️&quot;, &quot;✂️&quot;]<br>[&quot;✂️&quot;, &quot;✂️&quot;, &quot;🗿&quot;]<br>[&quot;✂️&quot;, &quot;🗿&quot;, &quot;✂️&quot;]<br>[&quot;🗿&quot;, &quot;✂️&quot;, &quot;📝&quot;]<br>[&quot;✂️&quot;, &quot;📝&quot;, &quot;🗿&quot;]<br>[&quot;📝&quot;, &quot;🗿&quot;, &quot;📝&quot;]<br>[&quot;🗿&quot;, &quot;📝&quot;, &quot;🗿&quot;]<br>[&quot;📝&quot;, &quot;🗿&quot;, &quot;🗿&quot;]<br>[&quot;🗿&quot;, &quot;🗿&quot;, &quot;✂️&quot;]<br>[&quot;🗿&quot;, &quot;✂️&quot;, &quot;🗿&quot;]<br>[&quot;✂️&quot;, &quot;🗿&quot;, &quot;📝&quot;]<br>[&quot;🗿&quot;, &quot;📝&quot;, &quot;✂️&quot;]<br>[&quot;📝&quot;, &quot;✂️&quot;, &quot;📝&quot;]<br>[&quot;✂️&quot;, &quot;📝&quot;, &quot;🗿&quot;]<br>[&quot;📝&quot;, &quot;🗿&quot;, &quot;✂️&quot;]<br>[&quot;🗿&quot;, &quot;✂️&quot;, &quot;📝&quot;]<br>[&quot;✂️&quot;, &quot;📝&quot;, &quot;🗿&quot;]<br>[&quot;📝&quot;, &quot;🗿&quot;, &quot;✂️&quot;]</pre><p>Still looks pretty random, but maybe you can already spot some patterns. This is because, even for only 20 values I struggled to create random data, fearing to repeat myself, and yet I still did without realising it.</p><p>Now let’s take the last 2 values : [&quot;🗿&quot;, &quot;✂️&quot;] and filter out all the grams that do not start with those values:</p><pre>[&quot;🗿&quot;, &quot;✂️&quot;, &quot;📝&quot;]<br>[&quot;🗿&quot;, &quot;✂️&quot;, &quot;🗿&quot;]<br>[&quot;🗿&quot;, &quot;✂️&quot;, &quot;📝&quot;]</pre><p>As we can see, I have the tendency to put a &quot;📝&quot; after writing [&quot;🗿&quot;, &quot;✂️&quot;], so IRMA will play &quot;✂️&quot;. If you do this with a lot of data and several grams sizes , you will have a fully functioning IRMA.</p><h3>Conclusion</h3><p>IRMA is not deep learning, but can still be considered machine learning. Unlike deep learning, it does not require a lot of computing power. To prove this, IRMA runs solely in the frontend with Javascript.<br>It can be a good alternative for developers who want to implement a bit of “magical” intelligence to their frontend easily without extreme statistical knowledge and without some of the disadvantages of deep learning.</p><p>If you have idea to improve IRMA or idea of real world adaptation don’t hesitate to leave a comment ;)</p><p>Want to have a look at how HackFriday looks like? Have a look at our <a href="https://www.youtube.com/watch?v=llzBzq0LMUQ&amp;list=PLCeF70ymovbXNYr9P4rAYm60WjOXMiGXl&amp;index=2&amp;t=4s">video</a>!</p><p>Curious about Hackages? Check out our <a href="https://hackages.io/">website </a>and drop us a line if you have any questions!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df132ad753e7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackages/you-cant-beat-this-algorithm-df132ad753e7">You can’t beat this algorithm</a> was originally published in <a href="https://medium.com/hackages">Hackages Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 reasons to attend Workshop Summit]]></title>
            <link>https://medium.com/hackages/5-reasons-to-attend-workshop-summit-815052ac3163?source=rss----ac50bd715f02---4</link>
            <guid isPermaLink="false">https://medium.com/p/815052ac3163</guid>
            <category><![CDATA[community]]></category>
            <category><![CDATA[conference]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[brussels]]></category>
            <category><![CDATA[workshop]]></category>
            <dc:creator><![CDATA[Marta Moliz]]></dc:creator>
            <pubDate>Fri, 13 Sep 2019 07:16:28 GMT</pubDate>
            <atom:updated>2019-09-18T08:35:14.682Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why you should be there and book your ticket ASAP</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*ZSF5HsjI4cfIkDP_0ym27g.png" /></figure><p>You may have heard (or not yet) that here at <a href="http://hackages.io/">Hackages</a> we are organising a new non-profit event for the community in the first months of 2020: <a href="http://workshop-summit.com/">Workshop Summit</a>.</p><p>We think that the best way to learn is with the hands-on approach. That is how we organise our trainings and HackJams, and so we decided to follow our mantra when thinking about organising something else. And we came up with the idea of Workshop Summit.</p><p>What is the format, you may ask?</p><p>Simple: 1 week of hands-on interactive workshops with mentors coming from all around Europe. You may know some of them, as they are very active in their respective communities and in conferences around the globe.</p><p>The mentors line-up and topics are:</p><ul><li><a href="https://t.sidekickopen10.com/s1t/c/5/f18dQhb0SdYj8bGch0W2n0x6l2B9nMJW7t69v64XrfJRW63BwQj16gGDTf9lx88Q01?t=https%3A%2F%2Ftwitter.com%2FThe_GhostDog&amp;si=311535030&amp;pi=bad4b620-7f07-4a68-e708-8a4bba64d33f">Fabio di Vita</a> presenting Kubernetes</li><li><a href="https://t.sidekickopen10.com/s1t/c/5/f18dQhb0SdYj8bGch0W2n0x6l2B9nMJW7t69v64XrfJRW63BwQj16gGDTf9lx88Q01?t=https%3A%2F%2Ftwitter.com%2FAkryum&amp;si=311535030&amp;pi=bad4b620-7f07-4a68-e708-8a4bba64d33f">Guillaume Chau</a> on VueJS and Apollo</li><li><a href="https://t.sidekickopen78.com/s1t/c/5/f18dQhb0S7lM8dDMPbW2n0x6l2B9nMJN7t5X-FfhMynW4WJbsq64zw5-N56dTdkvYGrP102?te=W3R5hFj4cm2zwW4fQ47l4fGCmnW3Fbt5S3F4G0LF3SZzxrW1v41&amp;si=7000000001460518&amp;pi=b533882b-c40f-4deb-f547-65e58decf6b9">Cassie Evans</a> on SVG Animation</li><li><a href="https://t.sidekickopen10.com/s1t/c/5/f18dQhb0SdYj8bGch0W2n0x6l2B9nMJW7t69v64XrfJRW63BwQj16gGDTf9lx88Q01?t=https%3A%2F%2Ftwitter.com%2Fbrechtbilliet&amp;si=311535030&amp;pi=bad4b620-7f07-4a68-e708-8a4bba64d33f">Brecht Billiet </a>and <a href="https://t.sidekickopen10.com/s1t/c/5/f18dQhb0SdYj8bGch0W2n0x6l2B9nMJW7t69v64XrfJRW63BwQj16gGDTf9lx88Q01?t=https%3A%2F%2Ftwitter.com%2FKwintenP&amp;si=311535030&amp;pi=bad4b620-7f07-4a68-e708-8a4bba64d33f">Kwinten Pisman</a> with Advanced Angular &amp; RxJS</li><li><a href="https://t.sidekickopen10.com/s1t/c/5/f18dQhb0SdYj8bGch0W2n0x6l2B9nMJW7t69v64XrfJRW63BwQj16gGDTf9lx88Q01?t=https%3A%2F%2Ftwitter.com%2Fsaniyusuf&amp;si=311535030&amp;pi=bad4b620-7f07-4a68-e708-8a4bba64d33f">Sani Yusuf </a>with a workshop on Ionic</li><li><a href="https://t.sidekickopen10.com/s1t/c/5/f18dQhb0SdYj8bGch0W2n0x6l2B9nMJW7t69v64XrfJRW63BwQj16gGDTf9lx88Q01?t=https%3A%2F%2Ftwitter.com%2Fagoncal%3Flang%3Den&amp;si=311535030&amp;pi=bad4b620-7f07-4a68-e708-8a4bba64d33f">Antonio Goncalves</a> introducing Quarkus (Java)</li><li><a href="https://t.sidekickopen10.com/s1t/c/5/f18dQhb0SdYj8bGch0W2n0x6l2B9nMJW7t69v64XrfJRW63BwQj16gGDTf9lx88Q01?t=https%3A%2F%2Ftwitter.com%2Fnikolasburk%3Flang%3Den&amp;si=311535030&amp;pi=bad4b620-7f07-4a68-e708-8a4bba64d33f">Nikolas Burk </a>with a workshop on GraphQL and TypeScript</li><li><a href="https://t.sidekickopen10.com/s1t/c/5/f18dQhb0SdYj8bGch0W2n0x6l2B9nMJW7t69v64XrfJRW63BwQj16gGDTf9lx88Q01?t=https%3A%2F%2Ftwitter.com%2FManfredSteyer%3Flang%3Den&amp;si=311535030&amp;pi=bad4b620-7f07-4a68-e708-8a4bba64d33f">Manfred Steyer</a> with a workshop on Software Architecture</li><li><a href="https://t.sidekickopen10.com/s1t/c/5/f18dQhb0SdYj8bGch0W2n0x6l2B9nMJW7t69v64XrfJRW63BwQj16gGDTf9lx88Q01?t=https%3A%2F%2Ftwitter.com%2Fthekitze%3Flang%3Den&amp;si=311535030&amp;pi=bad4b620-7f07-4a68-e708-8a4bba64d33f">Kristijan Ristovski Kitze</a> with a focus on (Advanced) React<br><a href="https://t.sidekickopen10.com/s1t/c/5/f18dQhb0SdYj8bGch0W2n0x6l2B9nMJW7t69v64XrfJRW63BwQj16gGDTf9lx88Q01?t=https%3A%2F%2Ftwitter.com%2FBnJ25%3Flang%3Den&amp;si=311535030&amp;pi=bad4b620-7f07-4a68-e708-8a4bba64d33f">Benjamin Coenen </a>with two workshops: one on Golang and another one Continuous Delivery</li><li><a href="https://twitter.com/WalterStephanie">Stéphanie Walter</a> on UX Mobile</li><li><a href="https://t.sidekickopen10.com/s1t/c/5/f18dQhb0SdYj8bGch0W2n0x6l2B9nMJW7t69v64XrfJRW63BwQj16gGDTf9lx88Q01?t=https%3A%2F%2Ftwitter.com%2Fjawache%3Flang%3Den&amp;si=311535030&amp;pi=bad4b620-7f07-4a68-e708-8a4bba64d33f">Asim Hussain</a> with a workshop on Machine Learning &amp; Tensorflow</li><li><a href="https://t.sidekickopen10.com/s1t/c/5/f18dQhb0SdYj8bGch0W2n0x6l2B9nMJW7t69v64XrfJRW63BwQj16gGDTf9lx88Q01?t=https%3A%2F%2Ftwitter.com%2Fgillcleeren&amp;si=311535030&amp;pi=bad4b620-7f07-4a68-e708-8a4bba64d33f">Gill Cleerens</a> on .NET Core 3.0</li><li><a href="https://twitter.com/joe_elway">Aidan Finn</a> on Azure Secure Networking</li></ul><h4>Why should you join?</h4><ol><li><strong>Only workshops</strong> are in the agenda: there will no no 30 minutes’ talks here ,but full days to get immersed in the topic you choose. Go deep and learn valuable insights</li><li>The workshops are taught by <strong>industry experts and active members of the community</strong>. We have curated the trainers &amp; topics keeping in mind trendy topics and have invited some of those we believe can share their passion and make your 8 hours worthy.</li><li>It is a <strong>non-profit event</strong>, so we here at Hackages do not get any business out of organising it. The mentors have been guaranteed a fee for their workshop, and the rest of the fees acquired by sales &amp; sponsors will be devoted to make the event a success in terms of catering, logistics, marketing and all other aspects you can think of. The money left after covering the expenses related to organising the event will be distributed by the mentors (or they will be given the option to donate it to an Open Source project or other cause they believe in)</li><li>It is a new opportunity to strengthen and <strong>grow the tech community</strong> in Belgium. As a new event, your participation and specially your feedback will help us make this event better and curate an even better programme for the second edition.</li><li>Because it will be <strong>fun</strong>! Get out of your routine, join other developers, devOps and designers willing to learn and network a bit if you feel like! All this in just one day:)</li></ol><p>Sounds like you? Or you want to learn more about the topics &amp; mentors? Go and check our <a href="https://workshop-summit.com/">site</a> NOW! Super Early Bird tickets are available now for only 2️⃣5️⃣0️⃣ euros for one workshop! (until sold out or until 30 September, noon)</p><p>Want to know more? <a href="http://community@hackages.io/">Contact us</a> and let’s have a chat!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=815052ac3163" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackages/5-reasons-to-attend-workshop-summit-815052ac3163">5 reasons to attend Workshop Summit</a> was originally published in <a href="https://medium.com/hackages">Hackages Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a simple payment flow with Stripe]]></title>
            <link>https://medium.com/hackages/create-a-simple-payment-flow-with-stripe-b1d0f0f94337?source=rss----ac50bd715f02---4</link>
            <guid isPermaLink="false">https://medium.com/p/b1d0f0f94337</guid>
            <category><![CDATA[payments]]></category>
            <category><![CDATA[stripe]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nest]]></category>
            <dc:creator><![CDATA[Aylin Gokalp]]></dc:creator>
            <pubDate>Wed, 15 May 2019 10:01:00 GMT</pubDate>
            <atom:updated>2019-05-15T10:01:00.844Z</atom:updated>
            <content:encoded><![CDATA[<p>Learn how to easily set up a payment flow on your web application using a ReactJs frontend, a NestJs backend, and Stripe’s payment Intents!</p><p>The Stripe API allows you to create a payment flow. They propose different ways to achieve your goal, each with their ups and downs.</p><p>The one we will use is the payment Intent for two reasons: First, the credit card payment is really easy to set-up. Second, because of the new law for payment security, you now have to monitor the entire process of checking out and the payment Intents is perfect for this purpose!</p><p>Let’s start easy: <strong>How to create your payment form?</strong> We will use React on our frontend with the react-stripe-elements package to construct our checkout form:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7b34b450c077e019194be7c3c4c9ce1/href">https://medium.com/media/f7b34b450c077e019194be7c3c4c9ce1/href</a></iframe><p>There are several components provided by React Stripe Elements:</p><p>&lt;<strong>StripeProvider</strong>&gt; creates a stripe instance for your frontend app, with it you can contact the Stripe API to create Intents and carry out payments. It takes one <em>stripe </em>prop that contains an object with your unique API key and a key indicating that you are using payment Intents and not another Stripe APIs.</p><p>Your API key is provided in your dashboard after creating a stripe account. Make sure to use the test key (‘pk_test_…’) and not the live one used for production !</p><p>&lt;<strong>Elements</strong>&gt; will contain all your checkout form components, wether your have one (like here) or multiple fragmented pieces, they should always be inside an <strong>Elements </strong>component.</p><p>Finally, we use a &lt;<strong>CardElement</strong>&gt; to create a form containing the card, CVC, zip-code and date of expiry inputs. Of course no one is stopping you from creating your own custom form or use other elements from React Stripe Elements.</p><p>Note: Don’t forget to add &lt;<strong>script src=”</strong><a href="https://js.stripe.com/v3/"><strong>https://js.stripe.com/v3/</strong></a><strong>&quot; </strong>/&gt; to your <em>public/index.html</em></p><p>Here’s the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*yOsizwQ4jQGbu6qxm2_lJQ.png" /></figure><p>For now, we just created a static form and created a stripe instance. We now have to actually get a payment Intent from our server and handle the payment. We will extract the payment logic to a different component so we don’t pollute our <strong>App</strong> component with too specific code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c74284d58cbe53a912679f1ece32ab66/href">https://medium.com/media/c74284d58cbe53a912679f1ece32ab66/href</a></iframe><p>Here’s whats inside &lt;<strong>CheckoutForm</strong>&gt;:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0abd4fcfba7226873e1868a89a700d5f/href">https://medium.com/media/0abd4fcfba7226873e1868a89a700d5f/href</a></iframe><p>First, we have to inject the Stripe instance we created into our component. For that, we use the higher-order component<strong> injectStripe() </strong>that will return <strong>CheckoutForm</strong> with the stripe instance.</p><p>Then, create a click handler function for the <em>&lt;</em><strong>button</strong>&gt; and a ready handler function for the &lt;<strong>CardElement</strong>&gt;.</p><p>In <strong>handleReady()</strong>, we just save the reference to the checkout form in the state, we will see why later.</p><p>In<strong> submit()</strong>, we have to do a payment with the <strong>handleCardPayment() </strong>method<strong> </strong>from the <em>stripe</em> prop we recovered with <strong>injectStripe()</strong>. To do so we need two parameters: the client secret and the checkout form reference (the one we just saved in state !).</p><p>To get a client secret, we have to create a payment Intent. The client secret is a unique key that we will use to create a charge.</p><p>Here we leave it’s creation to the server so it may store all data pertaining to the payment flow. In the end, we can just fetch the client secret from our server with an<strong> Axios.post() </strong>to<strong> </strong>which we will give the amount to pay and the payment method.</p><p>Now that we have all the information required, we can handle the payment really easily with <strong>handleCardPayment()</strong>. By giving it the <strong>CardElement </strong>component’s reference — with all the client’s information and the client secret from the payment Intent, Stripe can create a payment at the right bank account.</p><p>If you followed the process correctly, you will have noticed that the server doesn’t receive any critical information from the client, as the actual payment to the bank is done by a third-party: <a href="https://stripe.com/">Stripe</a>. Your server will only create a payment Intent, so you can have a secure payment flow.</p><p>Now on to the fun part with our server! We will create two endpoints: one for creating a payment Intent and the other to listen for webhook events from Stripe.</p><p>Here’s how the payment flow works:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*1380x8iqFlXB8-e_R7KXVw.png" /></figure><p>First we need to connect our backend to the Stripe API to recover a Stripe instance. To keep the same unique instance for the entire backend, we will create a custom provider. Create a stripe token in your constants, set up your custom provider and add your Stripe API key to your <em>.env file.</em></p><p>For the controller part: <em>payment.controller.js</em> will contain our two endpoints. The routing prefix of the controller will be ‘payments’.</p><p>To create the Intent, we create a <strong>Post()</strong> route under the name <em>create</em> with ‘/intent’ as a prefix. Then call a create service that will handle the Intent creation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2bd689172eb333578811f2aab96c5b3f/href">https://medium.com/media/2bd689172eb333578811f2aab96c5b3f/href</a></iframe><p>Create the DTO for the <em>create</em> route:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/98e6aad341ae86d331b6c87d93fb0770/href">https://medium.com/media/98e6aad341ae86d331b6c87d93fb0770/href</a></iframe><p>In your <em>payment.service.ts</em>, first inject the Stripe instance from your custom provider, then create the Intent with the <strong>paymentIntents.create()</strong> method. This can take multiple parameters, see the documentation for more info. We will give it the amount, the card type and the currency for now.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/10e3bfba9237c001efde5f4bda2f341b/href">https://medium.com/media/10e3bfba9237c001efde5f4bda2f341b/href</a></iframe><p>You can then call a DAL service to write the payment Intent in your database and return the result to your controller.</p><p>Now, in the frontend, the client can receive the client secret and issue a payment. With payment Intents, you can monitor the entire process with Stripe’s Webhooks:</p><p>In your payment controller, create a second<strong> Post()</strong> route called ‘validation’ with the prefix ‘/validate-payment’. This will receive events from Stripe whenever you do one of the following: create an intent, update it, create a payment and/or the status (success or error) of that payment.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5772b68fa6b056d253ac7e0e125d33f0/href">https://medium.com/media/5772b68fa6b056d253ac7e0e125d33f0/href</a></iframe><p>We need the raw body of the request — we will see why later. If your body parser is set to JSON for example, you can recover the raw value by adding a ‘rawBody’ key on the request with the body-parser middleware:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2621497a0ec2f0d37376c259fac6626b/href">https://medium.com/media/2621497a0ec2f0d37376c259fac6626b/href</a></iframe><p>Create the DTO for the validation, then add a paymentValidation service in<em> payment.service.ts</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37a1382cc2de0a6bb4e69d70a48a4dda/href">https://medium.com/media/37a1382cc2de0a6bb4e69d70a48a4dda/href</a></iframe><p>Here we check the type of event received, if the charge is a success, with a DAL service we change the status of the payment in the database from ‘pending’ to ‘success’, however if we receive a payment failure event, we change the status to ‘error’.</p><p>This is all good, but how can we verify the events received on our endpoint? Can we really trust that the request comes from Stripe?</p><p>No worries, here is how you can check the integrity of the request and the identity of the sender:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/426c927477f0b28035f6c9e75c971f45/href">https://medium.com/media/426c927477f0b28035f6c9e75c971f45/href</a></iframe><p>The <strong>constructEvent() </strong>method checks the validity of the signature from the body of the request against your Webhook secret, if the body was tempered with or fabricated by a third-party, an error will be thrown. You can get your Webhook secret from your Stripe Dashboard.</p><p>Now that the app is setup, go into your Stripe Dashboard and create the Webhook endpoint with the name of your validation route: <a href="https://your-website.com/payments/validate-payment"><em>https://your-website.com/payments/validate-payment</em></a>. You can choose the events you want to receive or take them all.</p><p>Note that you need to respond to all Webhook events with a status code or a {received: true} so that Stripe is made aware that the event was received. The controller automatically sends a status code 200.</p><p>You have learned a quick and easy way to set-up credit card payments for a React.Js frontend and Nest.Js Backend with Stripe’s payment Intents. Hope this quick tutorial was helpful, and do not hesitate to ask your questions in the comments below!</p><p><strong><em>You can find more information about</em></strong><a href="https://hackages.io/about"><strong><em> Hackages</em></strong></a><strong><em> on our </em></strong><a href="https://hackages.io/"><strong><em>learning platform</em></strong></a><strong><em>. We’re a community-driven company that offers high-level training on the latest frameworks and technologies around JavaScript. We also love to contribute to open source and to organise free community events all around Europe!</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zYBVJb1fSA-ztf2-QyivnQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1d0f0f94337" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackages/create-a-simple-payment-flow-with-stripe-b1d0f0f94337">Create a simple payment flow with Stripe</a> was originally published in <a href="https://medium.com/hackages">Hackages Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tech Terms Explained: Programming Paradigms]]></title>
            <link>https://medium.com/hackages/tech-terms-explained-programming-paradigms-8c4072404f8e?source=rss----ac50bd715f02---4</link>
            <guid isPermaLink="false">https://medium.com/p/8c4072404f8e</guid>
            <category><![CDATA[procedural-programming]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[jargon]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[programming-paradigms]]></category>
            <dc:creator><![CDATA[David Deren]]></dc:creator>
            <pubDate>Fri, 10 May 2019 08:01:00 GMT</pubDate>
            <atom:updated>2019-05-10T08:01:00.820Z</atom:updated>
            <content:encoded><![CDATA[<p>Programming is about solving problems and problems can usually be solved in a variety of ways. <strong>A programming paradigm is a way to approach a problem.</strong> While some programming languages allow you to use only one approach, most popular languages today allow developers to use a combination of them.</p><p>On the highest level, we can differentiate between 2 types of programming paradigms: <strong>imperative</strong> and <strong>declarative</strong>.</p><p>When we program in an <strong>imperative<em> </em>way</strong>, we tell the computer <strong>how to solve a problem.</strong></p><p>When we program in a <strong>declarative way</strong>, we tell the computer <strong>what we want as a result.</strong></p><p>In this article, we’ll focus on 3 of the most popular approaches: <strong>procedural programming</strong> and <strong>object-oriented programming</strong>, which are both examples of imperative paradigms; and <strong>functional programming,</strong> which is an example of a declarative paradigm.</p><p>Don’t worry if this all sounds a little bit abstract right now. I will illustrate their differences using small snippets of Javascript code. Don’t panic! You don’t need any programming experience. I will walk you through each example and explain exactly what happens step by step. The main goal here is to give you a general idea of what the differences are between the 3 approaches.</p><h3><strong>The Problem</strong></h3><p>Things are not going well in the hip new startup <em>MyYummeeFoods</em>. The company cannot launch their IPO until they add one last feature: they need to be able to calculate the total amount their users have to pay at checkout. The 3 lead developers, Athos, Porthos and Aramis; are debating on the best way to solve the issue.</p><p>First for some setup: The following snippets of code will operate on the same collection of items:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e06512e73b5d7b95cdc82869c1b2a79/href">https://medium.com/media/9e06512e73b5d7b95cdc82869c1b2a79/href</a></iframe><p><strong>cartItems </strong>is just a collection of items that the customer has put in his cart. Each item has a name and corresponding price. The problem we then have to solve is: calculate the total amount to be paid based on the items in the shopping cart.</p><h3>The Procedural Approach</h3><p>Our first developer, Athos, proposes the following solution:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/afdad4ffb871904502bed25310b86511/href">https://medium.com/media/afdad4ffb871904502bed25310b86511/href</a></iframe><p>When you solve a problem in a procedural way, you tell the computer exactly which steps to go through in order to solve it. In this example, we tell the computer to go through the following steps:</p><ul><li>Create a new variable <strong>total, </strong>and set its value to 0.</li><li>Check how much items are in <strong>cartItems</strong></li><li>If the cart is not empty, get the first item in <strong>cartItems</strong> and add its price to the running <strong>total</strong></li><li>If the cart contains more than 1 item, get the second item and add its price to the running <strong>total</strong>, continue doing this until you’ve gone through all the items</li><li>Finally, we assign the value of <strong>total </strong>to<strong> result</strong></li></ul><p>You can imagine how it might sometimes get tedious to solve problems in a procedural way, with you having to create temporary variables, keep track of indexes (= the position of an item in a collection),…</p><h3>The Object-Oriented Approach</h3><p>This isn’t Porthos’ first gig. He knows how complex applications become over time and doesn’t think Athos’ procedural solution will be maintainable in the long run. He comes up with the following solution:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7db9f54663a92b7c1b557f8469e71e3/href">https://medium.com/media/c7db9f54663a92b7c1b557f8469e71e3/href</a></iframe><p>Porthos’ program solves the issue following these steps:</p><ul><li>First it declares a class <strong>Cart</strong>, which acts as a kind of blueprint describing which things a cart can contain and what it can do</li><li>It then creates a new cart called <strong>myCart</strong>, by combining the blueprint that was created earlier with the actual items we want our cart to contain. If you ever heard a developer talk about an instance, this is what she was talking about.</li><li>This newly created <strong>myCart</strong> has a property <strong>total</strong>, whose value we assign to the final <strong>result</strong>.</li></ul><p>While still being an imperative approach, the added value of Object-Oriented programming is that it groups related data and functionality. You create objects that reflect real things, making some problems easier to reason about.</p><h3>The Functional Approach</h3><p>Aramis likes his programs to be as <em>descriptive</em> as possible. He doesn’t care too much about a telling a computer <em>how</em> to solve an issue. He prefers to tell the computer exactly <em>what</em> he wants.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c37fe1b54f624d05f9c31de96e9eac2/href">https://medium.com/media/6c37fe1b54f624d05f9c31de96e9eac2/href</a></iframe><p>Aramis remembers he already wrote a <strong>sum</strong> function when developing the counters in the shopping cart. As he doesn’t want to reinvent the wheel, he decides to reuse the same generic <strong>sum</strong> function here. In functional programming, functions are to be as reusable and generic as possible.</p><p>The only value Aramis cares about is that final result. He describes it as the sum (using reduce) of all the cartItems’ prices (using map). Even without knowing exactly what map and reduce do, this piece of code should give you a good idea of what is happening here.</p><h3>The Solution</h3><p>After extended discussions, our 3 developers decide there are good elements in each of their proposed solutions (except for Athos’ procedural solution, poor guy!). They want to keep using elements from Orthos’ object-oriented approach, as that would make the front-end code easier to understand for the Java team and will make the code easier to maintain in the long run; but they also like how the functional approach makes their code more descriptive and easier to reason about.</p><p>As they are writing their application in Javascript, they can mix and match and use the best of both worlds. They come up with this solution:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0065e4d047550b99706f1e93bb07f256/href">https://medium.com/media/0065e4d047550b99706f1e93bb07f256/href</a></iframe><p><em>MyYummyFood’s</em> founder is ecstatic. The IPO is saved and the shares’ prices go through the roof 🎉</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fo5cemUjLDstpe%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fo5cemUjLDstpe%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2Fo5cemUjLDstpe%2Fgiphy-downsized-large.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="245" frameborder="0" scrolling="no"><a href="https://medium.com/media/31ce24ddb4db940f0f636dcdf3a59158/href">https://medium.com/media/31ce24ddb4db940f0f636dcdf3a59158/href</a></iframe><p>I hope you now have a better understanding of what a programming paradigm is and of the differences between the 3 main ones. If you’d like to have other tech terms explained to you in a friendly way, check out the following articles:</p><ul><li><a href="https://blog.hackages.io/tech-terms-explained-pwa-vs-native-vs-cross-platform-apps-414bccf83c18">Tech Terms Explained: PWA vs Native vs Cross-Platform Apps</a></li><li><a href="https://blog.hackages.io/tech-terms-explained-frontend-javascript-frameworks-a66ae31f0e8">Tech Terms Explained: Frontend JavaScript frameworks</a></li><li><a href="https://blog.hackages.io/docker-is-just-lasagna-b726777b72d6">Tech Terms Explained: Docker is just like lasagna</a></li></ul><p><strong><em>You can find more information about Hackages on our </em></strong><a href="http://hackages.io/"><strong><em>learning platform</em></strong></a><strong><em>. We offer high-level training on the latest frameworks and technologies and Tech Jargon training for non-tech profiles working in the IT sector to understand the terms used in the field and improve their daily tasks.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zYBVJb1fSA-ztf2-QyivnQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c4072404f8e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackages/tech-terms-explained-programming-paradigms-8c4072404f8e">Tech Terms Explained: Programming Paradigms</a> was originally published in <a href="https://medium.com/hackages">Hackages Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I stopped using for loops and started mapping instead]]></title>
            <link>https://medium.com/hackages/why-i-stopped-using-for-loops-and-started-mapping-instead-5f6b579a0525?source=rss----ac50bd715f02---4</link>
            <guid isPermaLink="false">https://medium.com/p/5f6b579a0525</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[for-loop]]></category>
            <category><![CDATA[mapping]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Aylin Gokalp]]></dc:creator>
            <pubDate>Tue, 07 May 2019 07:16:03 GMT</pubDate>
            <atom:updated>2019-05-07T07:16:03.284Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why I stopped using ‘for’ loops and started mapping instead</h3><p>I’m new to Javascript and React, so in the beginning, when I needed to iterate over an array, I would use a ‘for’ loop and call it a day. However, with JavaScript and more specifically React, this isn’t always a good method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZzuiuVGNDRKJjqS-IMlkKA.png" /></figure><p>In this article, I will show how in React, the ‘map’ method is often the recommended one to use.</p><p>First an overview of all the methods for looping over iterable values in JavaScript:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23ea33bef7c0b69ba9cf526a34b4768f/href">https://medium.com/media/23ea33bef7c0b69ba9cf526a34b4768f/href</a></iframe><p>Now, let’s say we have a component we wish to render multiple times, a beginner would probably do this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b935e771ae4ba994684882fc5810b599/href">https://medium.com/media/b935e771ae4ba994684882fc5810b599/href</a></iframe><p>Since you can’t return a ‘for’ loop directly, you need to create a new array that will contain the components to return.</p><p>So if your goal is just to render UI, a ‘for’ loop is fine. However, if your goal is to create a complex re-usable component, the preferred method is ‘map’:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f65c71552012741d80fa08cc41157ced/href">https://medium.com/media/f65c71552012741d80fa08cc41157ced/href</a></iframe><p>This method takes a callback function with three parameters: the current value while iterating, the current index and the array on which you iterate. Then it returns a new array of the resulting components. The key prop makes it so each ‘ChildComponent’ created is unique, so when you update a value from one component, others won’t be re-rendered either.</p><p>You can’t exit a ‘map’ with a break condition like you would with a ‘for’ loop. However, since the ‘map’ function returns an array, you can chain the result with other functions such as ‘filter’:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09534010c81b5a315b5eed7c6003009b/href">https://medium.com/media/09534010c81b5a315b5eed7c6003009b/href</a></iframe><p>Note: The filter method takes a function in its parameters and returns a new array with all elements that validate the test from the function.</p><p>The ‘map’ function will always return an array while the ‘for loop’ approach you define the return value — if there is any.</p><p>As you can see, it’s not quicker because of the callback function that is called on every item, but the code is cleaner, quicker to implement and more powerful.</p><p>In my opinion, ‘map’ really shines when you need to extract specific data from the result of an API call. Let’s say you need to extract the rating value for a specific movie from an API:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d829ed67710df9bc074b83602ce38769/href">https://medium.com/media/d829ed67710df9bc074b83602ce38769/href</a></iframe><p>Here we will retrieve the <em>Rotten Tomatoes </em>rating for this movie using the ‘map’ method:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27fc8a0fc2cd91c408bec679b72602d7/href">https://medium.com/media/27fc8a0fc2cd91c408bec679b72602d7/href</a></iframe><p>The same code with ‘for’:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5e25d02ddef1a471b43aa48eb488b21/href">https://medium.com/media/a5e25d02ddef1a471b43aa48eb488b21/href</a></iframe><p>As you can see, you cannot return a ‘for’ loop directly. That is why you have to create a variable that holds the extracted value. As an aside, you cannot check the values inside this loop with an ‘if’ since conditional operators (‘&amp;&amp;’) won’t work, making the code less readable than just using ‘map’ directly.</p><p>Now you know about JavaScript array iteration and the differences between ‘map’ and ‘for’.</p><p><strong><em>You can find more information about</em></strong><a href="https://hackages.io/about"><strong><em> Hackages</em></strong></a><strong><em> on our </em></strong><a href="https://hackages.io/"><strong><em>learning platform</em></strong></a><strong><em>. We’re a community-driven company that offers high-level training on the latest frameworks and technologies around JavaScript. We also love to contribute to open source and to organise free community events all around Europe!</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zYBVJb1fSA-ztf2-QyivnQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f6b579a0525" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackages/why-i-stopped-using-for-loops-and-started-mapping-instead-5f6b579a0525">Why I stopped using for loops and started mapping instead</a> was originally published in <a href="https://medium.com/hackages">Hackages Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Conditionally wrap an element in React]]></title>
            <link>https://medium.com/hackages/conditionally-wrap-an-element-in-react-a8b9a47fab2?source=rss----ac50bd715f02---4</link>
            <guid isPermaLink="false">https://medium.com/p/a8b9a47fab2</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[conditional-wrapping]]></category>
            <category><![CDATA[rendering]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Olivier Steufken]]></dc:creator>
            <pubDate>Tue, 30 Apr 2019 08:01:00 GMT</pubDate>
            <atom:updated>2019-04-30T08:01:00.699Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong><em>How to conditionally wrap an element in React</em></strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2y8UhdHTnoSR-aCKLWgPuA.jpeg" /></figure><h3>PREAMBLE</h3><p>While working on a React project, I faced a problem I didn’t encounter before: the need to have a different wrapping element based on a condition.</p><p>I went through different ideas and eventually ended up creating a specific component mimicking the behaviour of a Higher Order Component.</p><p>Searching the web for improvement, I found out <a href="https://github.com/kitze"><strong>Kitze</strong></a> had shared a similar implementation a while ago.</p><p>I hope this article can help you understand how it works.</p><p><strong>TL;DR</strong> at the end.</p><h3>CASE STUDY</h3><p>Here is a very simple mock-up of an online garage with cards for cars:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f294c7b8299ade961f70d44b0ca61c9/href">https://medium.com/media/1f294c7b8299ade961f70d44b0ca61c9/href</a></iframe><h3>PROBLEM</h3><p>Let’s imagine that the link prop is not mandatory and some cars don’t have it.</p><p>The way it is written right now, we would have an empty “href” attribute on our wrapping link. While it’s valid semantically, we’re adding a useless node to the DOM, which isn’t a best-practice. So let’s find a way to render it only when we actually have a link defined.</p><p>Ok we’re talking conditional rendering here and there are many ways to do that in React. For now, we’ll just use the most common technique: the ternary operator.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d0c888fa1dda7e2bb62f99afd8a5f5c/href">https://medium.com/media/0d0c888fa1dda7e2bb62f99afd8a5f5c/href</a></iframe><p>We check out if we have a link prop. If so, we display the card wrapped in a link, else, we wrap it in a simple div.</p><p>Done and dusted, see ya! …</p><p>… Wait a minute. There’s something really annoying here.</p><p><strong>Duplicate code.</strong> Bummer!</p><p>I hope I don’t have to convince you how bad duplicate code is. Otherwise, just remember this quote from the ’90s:</p><blockquote>“Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” (John Woods)</blockquote><p>In order to avoid duplicate code here, we want to conditionally render the wrapping element. Let’s call that <strong>Conditional Wrapping</strong>.</p><h3>SOLUTION</h3><p>Let’s lay down the foundations. We have:</p><ul><li>a <strong>condition</strong> (the link variable)</li><li>a <strong>wrapper</strong> (the link tag)</li><li>the <strong>children</strong> (the part of the code that will remain in both cases)</li></ul><p>Now we’ll simply create another reusable component that will receive those 3 arguments and return a different output based on the condition. Et voilà!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d19660ae3e74553ab0ba0e8398eea6a/href">https://medium.com/media/9d19660ae3e74553ab0ba0e8398eea6a/href</a></iframe><p>Doesn’t it look nice and clean with ES6 syntax?</p><p>Small precision here is that the children prop is actually a React feature. Each component receives an implicit prop called <strong>children</strong> that contains all the elements contained between the opening tag and the closing tag where it is called. You’ll find more information here: <a href="https://reactjs.org/docs/composition-vs-inheritance.html">https://reactjs.org/docs/composition-vs-inheritance.html</a></p><p>Let’s now implement it in our component:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/138a384951be733ceb5c3c5aefc56f60/href">https://medium.com/media/138a384951be733ceb5c3c5aefc56f60/href</a></iframe><p>Ok, this deserves a bit of explanation.</p><p>As you can see, we now wrap the content into our new ConditionalWrapper component. Thus automatically giving it the role of <strong>children.</strong></p><p>Note that we wrapped the children in a <a href="https://reactjs.org/docs/fragments.html">React Fragment</a> to avoid returning multiple elements. This could be done on the functional component itself too but I chose to kept it simple and pure. 🤷🏻‍♂️</p><p>The <strong>condition</strong> part is quite self-explanatory.</p><p>Then the tricky part is the <strong>wrapper</strong>.</p><p>It receives a function that will be called in the ConditionalWrapper component itself when the condition is true.</p><p>There it will receive the <em>implicit</em> children as argument. And will return what it receives wrapped in <strong>whatever we want</strong>; in this case, a link.</p><p>This small implementation is quite powerful and, though it might be a bit hard to read at first, fixes our problem of duplicate code.</p><h3>TL;DR</h3><p>To render a different wrapping element based on a condition, we can use this one line functional component and determine in our component <strong>when</strong>(condition) and <strong>how</strong>(wrapper) should the <strong>children</strong> be wrapped.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d19660ae3e74553ab0ba0e8398eea6a/href">https://medium.com/media/9d19660ae3e74553ab0ba0e8398eea6a/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/138a384951be733ceb5c3c5aefc56f60/href">https://medium.com/media/138a384951be733ceb5c3c5aefc56f60/href</a></iframe><p><strong><em>You can find more information about</em></strong><a href="https://hackages.io/about"><strong><em> Hackages</em></strong></a><strong><em> on our </em></strong><a href="https://hackages.io/"><strong><em>learning platform</em></strong></a><strong><em>. We’re a community-driven company that offers high-level training on the latest frameworks and technologies around JavaScript. We also love to contribute to open source and to organise free community events all around Europe!</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zYBVJb1fSA-ztf2-QyivnQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8b9a47fab2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackages/conditionally-wrap-an-element-in-react-a8b9a47fab2">Conditionally wrap an element in React</a> was originally published in <a href="https://medium.com/hackages">Hackages Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Portals: How does it work?]]></title>
            <link>https://medium.com/hackages/react-portals-how-does-it-work-afa79dccc555?source=rss----ac50bd715f02---4</link>
            <guid isPermaLink="false">https://medium.com/p/afa79dccc555</guid>
            <category><![CDATA[portal]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Hamza Aarab]]></dc:creator>
            <pubDate>Tue, 23 Apr 2019 08:06:00 GMT</pubDate>
            <atom:updated>2019-04-23T08:06:00.803Z</atom:updated>
            <content:encoded><![CDATA[<p>Since React 16, it is now possible to use <strong>portals.</strong></p><h4>What is a portal?</h4><p>A portal allows you to render an element of a child component outside the DOM hierarchy by creating another top-level tree and injecting this component inside it.</p><h4>When do we use portals?</h4><p>In general, portals are used when we want to position or style an element correctly. Sometimes, a modal is in a child that is nested a dozen level-deep. Then, modifying the style of the child without breaking the one from the parent can be really difficult… This is why we want to take this modal out of this hierarchy so we can manipulate it without affecting the parents.</p><h4>How do we use it?</h4><p>Well, let’s create a simple React app that will display a modal when we click on a button. The whole app is in the root DOM hierarchy but the modal will be outside these three.</p><h4>Let’s get started!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/0*JcGCLURF6ZXjGZn8.jpg" /></figure><p>First, go to your <em>index.html.</em> You can see that there is already a div which contains an ‘app-root’. That’s the main DOM tree. But we want to display our modal outside of this tree. So let’s create another top-level div and call it ‘modal-root’.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4ceba17b834bc3fb70a3efdeae11cf2/href">https://medium.com/media/f4ceba17b834bc3fb70a3efdeae11cf2/href</a></iframe><p>Then, in our <em>App.js </em>file, we will have a button that will toggle the modal and another button inside the modal, that will close it. We need to create and render these first.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd322c1decba69063d550f75c005aa83/href">https://medium.com/media/cd322c1decba69063d550f75c005aa83/href</a></iframe><p>If you have carefully read the code, you can see that the modal that will be displayed is between the <em>&lt;Modal&gt; </em>tag. So we have to create this component, which <strong>will be the one that creates the portal to our modal-root div.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0c7ed238e5ea2e3a9d2fc8ddfa1c4a0/href">https://medium.com/media/c0c7ed238e5ea2e3a9d2fc8ddfa1c4a0/href</a></iframe><p>To give you a brief explanation, the <em>createPortal() function </em>takes two arguments. The first one is the child that will be rendered. In our case, that’s the Modal. The second argument is the <em>container</em><strong><em> </em></strong>which represents the DOM element. That’s the <em>modal-root</em>.</p><p>Now the only thing left to do is to not forget to render the parent (In our case, that is the <em>&lt;App /&gt;</em>) into the root div. Check on line 39 of the code now.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/844a05b840ad28d3e255548a5a6600a9/href">https://medium.com/media/844a05b840ad28d3e255548a5a6600a9/href</a></iframe><p>Like the <em>createPortal() function</em>, The <em>render()</em> function from the reactDOM here takes also two arguments. The first argument is the whole application, represented by the <em>&lt;App&gt;</em> tag. The second one is also a container. Here it is our main root.</p><p>And you have finished!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/0*GADbrcBGuOL5eDk_.jpg" /></figure><p>The modal is no longer nested inside our main DOM hierarchy. You can style it without worrying about the parent(s).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RyE3OwDAzSkT_J4lXzhf_A.jpeg" /></figure><p>If you liked it, don’t forget to encourage by clapping!</p><p><strong><em>You can find more information about</em></strong><a href="https://hackages.io/about"><strong><em> Hackages</em></strong></a><strong><em> on our </em></strong><a href="https://hackages.io/"><strong><em>learning platform</em></strong></a><strong><em>. We’re a community-driven company that offers high-level training on the latest frameworks and technologies around JavaScript. We also love to contribute to open source and to organise free community events all around Europe!</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zYBVJb1fSA-ztf2-QyivnQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afa79dccc555" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackages/react-portals-how-does-it-work-afa79dccc555">React Portals: How does it work?</a> was originally published in <a href="https://medium.com/hackages">Hackages Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tech Jargon Series: GraphQL as a pizza menu]]></title>
            <link>https://medium.com/hackages/tech-terms-explained-graphql-as-a-pizza-menu-a8f655a348da?source=rss----ac50bd715f02---4</link>
            <guid isPermaLink="false">https://medium.com/p/a8f655a348da</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[jargon]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[rest]]></category>
            <dc:creator><![CDATA[tatchi]]></dc:creator>
            <pubDate>Fri, 19 Apr 2019 07:16:00 GMT</pubDate>
            <atom:updated>2019-04-30T14:52:42.112Z</atom:updated>
            <content:encoded><![CDATA[<p>GraphQL is a query language created by Facebook. It’s a way for an entity to request and get back exactly the data it needs.</p><p>Sounds like Chinese? No worries, we’ve got you covered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*DRRyHbpyCaTOXpHc3-PCMw.png" /><figcaption>GraphQL logo</figcaption></figure><p>Imagine you want to order a pizza, but you have a really specific taste for toppings: tomato sauce, cheese, onions, capsicum, olives, and an egg. The way you would go with a traditional restaurant (or a <em>Rest API</em> in IT terms) is to browse the menu and select the pizza that resembles your preferred pizza the most. You might get some ingredients that you did not ask for, but at least it contains the main toppings you wanted.</p><p>With GraphQL, however, instead of asking for a pizza on the menu, you can order a pizza with exactly the ingredients that you want. This saves you time looking for a pizza on the menu and helps you to get rid of the ingredients you didn’t really want.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*vF5oxOhz4Ci1pNDr8kKKKA.jpeg" /><figcaption>Pizza menu</figcaption></figure><p>For development, we could imagine a web application, Medium for example, that should display the name of an author and the title of the articles this author has written.</p><p>Typically, the client (the Medium frontend) would ask the server (the Medium backend) via a Rest API for the details of the specific author. The server then sends <em>all</em> the author’s details back to the client. So much like the pizza, the client will receive a lot of ingredients (data) it doesn’t need to show in this page. This could be the publication date of the articles, the author’s date of birth, etc.</p><p>With GraphQL, however, the client can ask exactly the information he needs on that page. In our case, the Medium frontend could just ask for the name of the author and the titles of the articles he has written. Needless to say, GraphQL allows to have more control over what information is sent, which means that we can optimise the amount of data which is transferred between these entities and get a more efficient communication.</p><p>Hope you liked it! Do not hesitate to clap away and comment if you have questions!</p><p><strong><em>Check out our </em></strong><a href="https://techjargon.io/"><strong><em>page</em></strong></a><strong><em> to discover the latest updates on tech jargon and try our game to discover the IT terminology in an easy and fun way!</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zYBVJb1fSA-ztf2-QyivnQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8f655a348da" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackages/tech-terms-explained-graphql-as-a-pizza-menu-a8f655a348da">Tech Jargon Series: GraphQL as a pizza menu</a> was originally published in <a href="https://medium.com/hackages">Hackages Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vue.js async components]]></title>
            <link>https://medium.com/hackages/vue-js-async-components-f55a353bf73f?source=rss----ac50bd715f02---4</link>
            <guid isPermaLink="false">https://medium.com/p/f55a353bf73f</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[lazy-loading]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Victor]]></dc:creator>
            <pubDate>Wed, 17 Apr 2019 06:06:01 GMT</pubDate>
            <atom:updated>2019-04-17T06:06:00.928Z</atom:updated>
            <content:encoded><![CDATA[<p>Just like React and Angular, Vue.js gives you the possibility to lazy load some parts of your application.</p><p>But to start: what is lazy loading? When you have a large application, you do not want to load everything at the same time. Doing that will make your application slower and load data that the user might not even need. To solve that problem, you will split your application in smaller chunks and only load them when needed.</p><p>And, how can you do that? <em>Easy peasy!</em> In the code where you want to define your component, you just need to provide a function that returns a dynamic import of your component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*8D4x2HE7feMUoUE299WrDQ.png" /></figure><p>Now I will show you two ways to use it in your application:</p><ol><li>Route based</li></ol><p>If you use the package vue-router, when defining the different routes you can just easily pass a dynamic import:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*4QQ_h8gE1nT_Um-HqB0m2g.png" /></figure><p>2. Local Registration</p><p>Here you can directly see that I use dynamic import to register my component:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*BGT4rUGdSrBuCgIUWw61hQ.png" /></figure><p>Now, let’s take a look at a more advanced way to handle async components. Instead of returning directly the dynamic import, you can also use an object that has multiple keys.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rL1i-yU7rFe0fPBD-d19yA.png" /><figcaption><a href="https://vuejs.org/v2/guide/components-dynamic-async.html#Async-Components">https://vuejs.org/v2/guide/components-dynamic-async.html#Async-Components</a></figcaption></figure><p>In the example below, I have defined the component with a promise and a setTimout to show the utility of this format. Normally you use a dynamic import:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2F94p2qrwnr%3Ffontsize%3D14%26module%3D%252Fsrc%252FApp.vue&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2F94p2qrwnr%3Ffontsize%3D14%26module%3D%252Fsrc%252FApp.vue&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F94p2qrwnr%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/9221b0aa694d7cba150c6e94df21ee75/href">https://medium.com/media/9221b0aa694d7cba150c6e94df21ee75/href</a></iframe><p>&gt; If you liked what you just read: clap it away, share this post &amp; feel free to leave me your comments or contact me at victor@hackages.io if you have any questions.</p><blockquote><strong>You can find more information about </strong><a href="https://hackages.io/about"><strong>Hackages</strong></a><strong> on our </strong><a href="https://hackages.io/"><strong>website</strong></a><strong>. We’re a community driven company that offers </strong><a href="https://hackages.io/training"><strong>high level training</strong></a><strong> on the latests frameworks and technologies around JavaScript. We also love to </strong><a href="https://github.com/hackages"><strong>contribute to open source</strong></a><strong> and to organise free community events all around Europe! Check our upcoming training and events near you at </strong><a href="https://hackages.io/"><strong>https://hackages.io</strong></a><strong>.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zYBVJb1fSA-ztf2-QyivnQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f55a353bf73f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackages/vue-js-async-components-f55a353bf73f">Vue.js async components</a> was originally published in <a href="https://medium.com/hackages">Hackages Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>