<?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: Leny</title>
    <description>The latest articles on DEV Community by Leny (@leny).</description>
    <link>https://dev.to/leny</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%2F228130%2Fcaa5f126-93f2-45f4-a447-606c96f6bb8b.jpeg</url>
      <title>DEV Community: Leny</title>
      <link>https://dev.to/leny</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/leny"/>
    <language>en</language>
    <item>
      <title>You should never use sudo (while coding)!</title>
      <dc:creator>Leny</dc:creator>
      <pubDate>Tue, 14 Jan 2020 13:49:02 +0000</pubDate>
      <link>https://dev.to/becodeorg/you-should-never-use-sudo-while-coding-4fa0</link>
      <guid>https://dev.to/becodeorg/you-should-never-use-sudo-while-coding-4fa0</guid>
      <description>&lt;p&gt;Yeah, I know, &lt;em&gt;bold move&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;As a coder, I read a lot of &lt;em&gt;great&lt;/em&gt; articles on DEV, Medium, &lt;em&gt;any-other-place on the internet&lt;/em&gt;. Those articles are filled with commands to type to "solve problem" (cargo cult, yeay!).&lt;/p&gt;

&lt;p&gt;As a bootcamp coach, I see a lot of my learners typing those commands &lt;em&gt;"because you know, it can't be worse"&lt;/em&gt; (cargo cult, yeay!).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/SWdRKrNVg8YVz1w3EF/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/SWdRKrNVg8YVz1w3EF/giphy.gif" alt="Cargo cult, yeah!"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And most of those commands begin with &lt;code&gt;sudo&lt;/code&gt;. Or, worse, I often hear this: "it didn't work without &lt;code&gt;sudo&lt;/code&gt;, so... let's try to add it".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgflip.com%2F3m2qr4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgflip.com%2F3m2qr4.jpg" alt="that damned sudo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's &lt;strong&gt;never&lt;/strong&gt; a good idea. Like, never, never.&lt;/p&gt;

&lt;p&gt;I will focus on two common missuses of sudo when coding that you should avoid (and are easy to fix).&lt;/p&gt;

&lt;h2&gt;
  
  
  Usecase one: npm (&lt;code&gt;npm install -g any-global-package&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;Most of those packages don't need the admin rights. But, by default, your system try to write the global npm package into a folder that requires admin right to be written. So... &lt;code&gt;sudo&lt;/code&gt; it is. NO!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/d10dMmzqCYqQ0/giphy-downsized.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/d10dMmzqCYqQ0/giphy-downsized.gif" alt="NO!"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You're lucky, you have two solutions for that. &lt;/p&gt;

&lt;p&gt;The first one is to use &lt;a href="https://www.npmjs.com/package/npx" rel="noopener noreferrer"&gt;&lt;code&gt;npx&lt;/code&gt;&lt;/a&gt;, which will download and add to cache the latest version of the tool you need and then execute it. No need for admin rights. &lt;strong&gt;BONUS MOVE&lt;/strong&gt;, &lt;code&gt;npx&lt;/code&gt; will firstly look inside the current project and use the local version of the tool if it's installed. Damn, I love npx (thanks, &lt;a href="https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b" rel="noopener noreferrer"&gt;Kat Marchán&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;The second one, but you &lt;em&gt;should&lt;/em&gt; use npx, is to indicate to npm to store the global package in your home folder. Just &lt;a href="https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally#manually-change-npms-default-directory" rel="noopener noreferrer"&gt;follow the steps in this article&lt;/a&gt;, and you will never need to type &lt;code&gt;sudo&lt;/code&gt; before an &lt;code&gt;npm install -g&lt;/code&gt; command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Usecase two: docker (&lt;code&gt;docker run --way --too --many --options wonderful-image&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;I know, docker is all about &lt;em&gt;isolating&lt;/em&gt; things. And it's great. And since it's so great, why should we give it admin rights? You don't need to.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/4TcVFG7EYvp3Yvbu9j/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/4TcVFG7EYvp3Yvbu9j/giphy.gif" alt="You don't need this"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you install docker, the best way to try if your install is right, is to use this command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run hello-world
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And then it didn't work, and you type &lt;code&gt;sudo docker run hello-world&lt;/code&gt;, and you're happy. And somewhere, someone kills a baby koala. And you should be ashamed.&lt;br&gt;&lt;br&gt;
Because you know what? It's in the &lt;em&gt;freakin'&lt;/em&gt; documentation! You know, the stuff we didn't read?! (Yeah, me too).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/vX9WcCiWwUF7G/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/vX9WcCiWwUF7G/giphy.gif" alt="We all should be ashamed"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the install procedure of docker, they ask you to type this command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo usermod -a -G docker $USER
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This adds your user in the docker group, allowing you to use the docker command without admin rights. Which is, yeah... right what we wanted.&lt;/p&gt;




&lt;p&gt;It's two simple examples. And I know, I shouldn't be &lt;del&gt;&lt;em&gt;so melodramatic&lt;/em&gt;&lt;/del&gt; &lt;em&gt;such a diva&lt;/em&gt;. But, hey, I do what I want, and you shouldn't use sudo on daily basis.&lt;/p&gt;

&lt;p&gt;Except if you are really sure of what you're doing. &lt;/p&gt;

&lt;p&gt;It's probably the only thing you need to remember from this article:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you don't know why you need &lt;code&gt;sudo&lt;/code&gt; to run a command... don't do it. Or do it, break stuffs, learn things. YOLO!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/SWjCswum5dc0E/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/SWjCswum5dc0E/giphy.gif" alt="YOLOOOO!"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>sudo</category>
      <category>admin</category>
      <category>shame</category>
    </item>
    <item>
      <title>Introducing Oto, the man in the middle.</title>
      <dc:creator>Leny</dc:creator>
      <pubDate>Sat, 12 Oct 2019 21:37:12 +0000</pubDate>
      <link>https://dev.to/becodeorg/introducing-oto-the-man-in-the-middle-52go</link>
      <guid>https://dev.to/becodeorg/introducing-oto-the-man-in-the-middle-52go</guid>
      <description>&lt;p&gt;☝️ &lt;strong&gt;NOTE:&lt;/strong&gt; this article is an &lt;em&gt;revised&lt;/em&gt; version of one of my &lt;a href="https://medium.com/becode/introducing-oto-the-man-in-the-middle-581311962a6d"&gt;previous article&lt;/a&gt; on Medium.&lt;/p&gt;




&lt;p&gt;As a developer, I love to use APIs.&lt;br&gt;&lt;br&gt;
Moreover, I love to use others’ APIs, and integrate them in my apps.&lt;br&gt;&lt;br&gt;
Like getting stuffs from GitHub, LinkedIN, allowing my users to see their data in my tools.&lt;/p&gt;

&lt;p&gt;But I don’t want to ask my users their credentials for these services (and they wouldn’t probably give them!).&lt;br&gt;&lt;br&gt;
So, I have to use the &lt;strong&gt;OAuth2&lt;/strong&gt; protocol.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OAuth2&lt;/strong&gt; is a tool used by services to allow third-party apps’ developers (like me! I’m a third-party developer! &lt;em&gt;Woot!&lt;/em&gt;) to access the services’ data of users, with their approval.&lt;/p&gt;

&lt;p&gt;I will not describe OAuth2 in depth, but here’s the big picture: when you create an app, you need to register it on the service you want to use the API.&lt;br&gt;&lt;br&gt;
They will give you two important things: a public access id, which is not secret and can be stored in your code ; and a private access key, which is, huh, secret, and can’t be shared.&lt;br&gt;&lt;br&gt;
When one of your user needs to use the API in your app, they will be redirected on a login page outside your site, on the original service (the login page of GitHub, for instance). The user log himself, and the service redirect him on your app, with a unique code.&lt;br&gt;&lt;br&gt;
Then, your app will contact the service, with the unique code, your public access id and your private access key. The service know that everything’s okay, and will respond you with a token, that you will use for any request to the API.&lt;/p&gt;

&lt;p&gt;And that’s all. It sounds complicated, but it’s quite easy.&lt;/p&gt;




&lt;p&gt;But there’s a small problem: OAuth2 is not really designed to be used on &lt;em&gt;client-side only&lt;/em&gt; apps, like SPA.&lt;br&gt;&lt;br&gt;
As I said, the &lt;em&gt;private access key&lt;/em&gt; needs to stay… huh, &lt;em&gt;private&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;So… we need a server. But we don’t really &lt;em&gt;want&lt;/em&gt; one, since we would like to have static apps.&lt;br&gt;&lt;br&gt;
That’s a tough one.&lt;/p&gt;

&lt;p&gt;But what if I told you we can have a server… &lt;em&gt;without&lt;/em&gt; a server?&lt;br&gt;&lt;br&gt;
We can use a &lt;em&gt;serverless platform&lt;/em&gt;, like &lt;strong&gt;AWS Lambda&lt;/strong&gt;: it’s basically a simple piece of code (a function), bound to an URL, that will be executed when the URL is touched. Simple as &lt;em&gt;f*%&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;And then, we can have a small piece of code that will know our &lt;em&gt;private access key&lt;/em&gt; for OAuth2, and will make the last step of the challenge.&lt;br&gt;
Let me introduce you &lt;a href="https://github.com/becodeorg/oto"&gt;oto&lt;/a&gt;, the man in the middle, the little piece of code to run that.&lt;/p&gt;

&lt;p&gt;For now, it supports GitHub &amp;amp; LinkedIn, but I will add more services in the future.&lt;br&gt;
You can run it locally, or simple use the &lt;a href="https://serverless.com/"&gt;serverless framework&lt;/a&gt; to deploy it on your AWS account.&lt;br&gt;&lt;br&gt;
And, last but not least, its able to handle multiple services and keys at once, simplifying your workflow!&lt;/p&gt;

</description>
      <category>oauth</category>
      <category>spa</category>
      <category>becode</category>
      <category>authentication</category>
    </item>
    <item>
      <title>Do you even alias, bro?</title>
      <dc:creator>Leny</dc:creator>
      <pubDate>Sat, 12 Oct 2019 15:26:49 +0000</pubDate>
      <link>https://dev.to/leny/do-you-even-alias-bro-183k</link>
      <guid>https://dev.to/leny/do-you-even-alias-bro-183k</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;I'm proud of the pun in the title. Sorry not sorry ;)&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;It's a fact, we &lt;em&gt;live&lt;/em&gt; in the command-line. &lt;/p&gt;

&lt;p&gt;There was a time (and I &lt;em&gt;don't&lt;/em&gt; regret that) where using the command line for web development was a "strange thing"; the console was for the &lt;em&gt;sysadmins&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;But &lt;em&gt;the times are a changin'&lt;/em&gt;, and between git, npm, webpack and all that marvellous tools, we live in the command line.&lt;/p&gt;

&lt;p&gt;There's plenty tools to help you take the better of your terminal, such as a &lt;em&gt;better&lt;/em&gt; shell than bash, like &lt;a href="https://en.wikipedia.org/wiki/Z_shell"&gt;zsh&lt;/a&gt; or &lt;a href="https://en.wikipedia.org/wiki/Friendly_interactive_shell"&gt;fish&lt;/a&gt;, multiplexers, like &lt;a href="https://en.wikipedia.org/wiki/Tmux"&gt;tmux&lt;/a&gt;, and even &lt;a href="https://ohmyz.sh"&gt;complete frameworks&lt;/a&gt; to enhance your experience.&lt;/p&gt;

&lt;p&gt;But the most useful feature of a terminal, hands down, are the aliases.&lt;/p&gt;

&lt;p&gt;An alias is as simple as it sounds: it's a command you type as a shortcut for a longer command. Like typing &lt;code&gt;l&lt;/code&gt; for &lt;code&gt;ls -FalH&lt;/code&gt;, or &lt;code&gt;..&lt;/code&gt; for &lt;code&gt;cd ..&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Creating aliases is easy: for &lt;a href="https://ss64.com/bash/alias.html"&gt;bash&lt;/a&gt;, &lt;a href="http://zsh.sourceforge.net/Intro/intro_8.html"&gt;zsh&lt;/a&gt; or &lt;a href="https://fishshell.com/docs/current/commands.html#alias"&gt;fish&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I can't recommend you enough to create your own aliases, since they tend to be &lt;em&gt;personal&lt;/em&gt;, but when you take a look at &lt;a href="https://github.com/webpro/awesome-dotfiles"&gt;&lt;em&gt;dotfiles&lt;/em&gt;&lt;/a&gt;, you'll see many common aliases.&lt;/p&gt;




&lt;p&gt;Here's a list of some of my favorite aliases. You can find a &lt;a href="https://github.com/leny/pwendok/tree/master/fish/functions"&gt;complete list&lt;/a&gt; in &lt;a href="https://github.com/leny/pwendok"&gt;my dotfiles repository&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Navigation &amp;amp; listing
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;..&lt;/code&gt; = &lt;code&gt;cd ..&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;...&lt;/code&gt; = &lt;code&gt;cd -&lt;/code&gt; (jumping back to the previous directory you visited)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;c&lt;/code&gt; = &lt;code&gt;clear&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cat&lt;/code&gt; = &lt;code&gt;bat&lt;/code&gt; (a &lt;a href="https://github.com/sharkdp/bat"&gt;better cat&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ll&lt;/code&gt; = &lt;code&gt;ls -FalH&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;l&lt;/code&gt; = &lt;code&gt;exa&lt;/code&gt; (a &lt;a href="https://the.exa.website"&gt;modern replacement for ls&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Git aliases
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git&lt;/code&gt; = &lt;code&gt;hub&lt;/code&gt; (not &lt;a href="https://github.com/github/hub"&gt;really an alias&lt;/a&gt;, but if you work with GitHub a lot, it's wonderful)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gs&lt;/code&gt; = &lt;code&gt;git status -sb&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gap&lt;/code&gt; = &lt;code&gt;git add -p&lt;/code&gt; (git add with &lt;em&gt;patch mode&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;grhh&lt;/code&gt; = &lt;code&gt;git reset HEAD --hard&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gcdf&lt;/code&gt; = &lt;code&gt;git clean -fd&lt;/code&gt; (clean untracked files)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cdg&lt;/code&gt; = &lt;code&gt;cd $(git rev-parse --show-toplevel)&lt;/code&gt; (cd to the root of the repository)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  npm aliases
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ni&lt;/code&gt; = &lt;code&gt;npm install&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;nid&lt;/code&gt; = &lt;code&gt;npm install --only=dev&lt;/code&gt; (only devDepencies)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;nip&lt;/code&gt; = &lt;code&gt;npm install --only=prod&lt;/code&gt; (only dependencies)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;nis&lt;/code&gt; = &lt;code&gt;npm install --save&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;nisd&lt;/code&gt; = &lt;code&gt;npm install --save-dev&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;nci&lt;/code&gt; = &lt;a href="https://docs.npmjs.com/cli/ci.html"&gt;&lt;code&gt;npm ci&lt;/code&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  misc
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ping&lt;/code&gt; = &lt;a href="https://github.com/denilsonsa/prettyping"&gt;&lt;code&gt;prettyping&lt;/code&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;I hope some of these can be as useful to you that they are for me.&lt;/p&gt;

&lt;p&gt;Don't hesitate to submit your favorite aliases here or in an article on your own! It's always interesting to see what are the best shortcuts of others!&lt;/p&gt;

</description>
      <category>becode</category>
      <category>zsh</category>
      <category>fish</category>
      <category>alias</category>
    </item>
    <item>
      <title>Collecting squares together!</title>
      <dc:creator>Leny</dc:creator>
      <pubDate>Thu, 12 Sep 2019 06:11:17 +0000</pubDate>
      <link>https://dev.to/becodeorg/collecting-squares-together-updated-4l22</link>
      <guid>https://dev.to/becodeorg/collecting-squares-together-updated-4l22</guid>
      <description>&lt;p&gt;☝️ &lt;strong&gt;NOTE:&lt;/strong&gt; this article is an &lt;em&gt;updated version&lt;/em&gt; of &lt;a href="https://medium.com/becode/collecting-squares-together-cc3177a65c86"&gt;one of my previous article on Medium&lt;/a&gt;, augmented with some updates. Also my first post on &lt;strong&gt;dev.to&lt;/strong&gt;!&lt;/p&gt;




&lt;p&gt;I love &lt;em&gt;gamification&lt;/em&gt;. Really. Collecting achievement just for the sake of it, as any rpg-player.&lt;br&gt;
It’s why I really love the &lt;em&gt;green squares&lt;/em&gt; of the &lt;em&gt;contribution graph&lt;/em&gt; on GitHub profiles.&lt;/p&gt;

&lt;p&gt;But the green squares are personal by essence: it’s &lt;em&gt;your&lt;/em&gt; commits, &lt;em&gt;your&lt;/em&gt; activity on GitHub. There’s no data for teams or organisation.&lt;br&gt;&lt;br&gt;
At BeCode, &lt;a href="https://www.youtube.com/watch?v=pGFGD5pj03M"&gt;we work as a team, we live as a team&lt;/a&gt;. Everything we do, we do as a team!&lt;/p&gt;

&lt;p&gt;It’s why I wanted to create a &lt;em&gt;contribution graph&lt;/em&gt; with informations of all the &lt;em&gt;BeCodians&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Using green squares felt a bit &lt;em&gt;wrong&lt;/em&gt;, so I use the blue tones of BeCode’s identity, and created &lt;a href="https://kareble.becode.xyz"&gt;Kareble&lt;/a&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  Fetching the data
&lt;/h2&gt;

&lt;p&gt;I already known about the &lt;a href="https://developer.github.com/v4/"&gt;GraphQL API&lt;/a&gt; of GitHub &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Did I tell you that I really love &lt;a href="https://graphql.org/"&gt;GraphQL&lt;/a&gt;? I love GraphQL. So much. For real. It’s the future, &lt;em&gt;deal with it&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But unfortunately, the information are deeply hidden in all the data that GitHub serves. And fetching all the data I needed is very slow, so I can’t do it in real time.&lt;br&gt;&lt;br&gt;
The idea is to create a script to fetch the data, and running it once a week.&lt;/p&gt;

&lt;p&gt;After some tests, I ended with this graphql query:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;It gives me all the contributions from the last year, by weeks, for 25 users of our organization. Then, I created a &lt;a href="https://github.com/becodeorg/kareble/blob/master/scripts/fetch-data.js"&gt;small script&lt;/a&gt; to fetch the data of all our users, 10 at a time (I don't care about the time it takes, it's all automated on a CI, will talk about it later).&lt;br&gt;&lt;br&gt;
The script also assemble and clean the data, then set the color of each day, regarding of the quantity of contributions.&lt;br&gt;&lt;br&gt;
It finally writes all the data in a JSON that will be used by our website.&lt;/p&gt;

&lt;p&gt;At the time of the redaction (september 2019), the script fetches the data in 74 batches of 10 users, performing all its tasks in about 2min 30s.&lt;/p&gt;


&lt;h2&gt;
  
  
  Displaying the data
&lt;/h2&gt;

&lt;p&gt;For this little project, I wanted to change my habits.&lt;br&gt;&lt;br&gt;
I could have done it with &lt;strong&gt;React&lt;/strong&gt; or &lt;strong&gt;VueJS&lt;/strong&gt;, but I wanted to use this project as a good pretext to test and discover something I never used before.&lt;/p&gt;

&lt;p&gt;My choice went on &lt;a href="https://svelte.dev"&gt;Svelte&lt;/a&gt;. The version 3 was quite new when I started working on kareble and some podcasters I listen made very &lt;a href="https://shoptalkshow.com/episodes/349/"&gt;enthusiastic&lt;/a&gt; &lt;a href="https://spec.fm/podcasts/toolsday/293076"&gt;episodes&lt;/a&gt; about it.&lt;/p&gt;

&lt;p&gt;Svelte is a very great tool, similar to React or VueJS (working with components), but also quite different - the creator of Svelte describe it as a &lt;em&gt;disappearing framework&lt;/em&gt;: when compiled, the code doesn’t need to include a runtime like React or Vue.&lt;br&gt;&lt;br&gt;
Svelte is also constructed around HTML: you defined components by their markup (svelte components are like small HTML fragments), and a small chunk of scripts to operate with them.&lt;/p&gt;

&lt;p&gt;Svelte is really fast and easy to use, and for small projects, it’s a very good surprise.&lt;/p&gt;

&lt;p&gt;The coding part was really straightforward, you can dig around the code &lt;a href="https://github.com/becodeorg/kareble"&gt;on the repository&lt;/a&gt;.&lt;br&gt;&lt;br&gt;
If you’ve already played with a modern front-end framework like React, you’ll see that Svelte is really easy to understand.&lt;/p&gt;


&lt;h2&gt;
  
  
  Build &amp;amp; deploy
&lt;/h2&gt;

&lt;p&gt;Compiling Svelte is really easy, thanks to &lt;a href="http://rollupjs.org"&gt;rollup&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To host and deploy, since we can’t fetch the data in real time, we can host the website on any static platform, like &lt;strong&gt;netlify&lt;/strong&gt; or &lt;strong&gt;github-pages&lt;/strong&gt;. For Kareble, I use github-pages.&lt;/p&gt;

&lt;p&gt;At the moment of releasing Kareble, the only missing part was &lt;strong&gt;automation&lt;/strong&gt; - I needed to run three npm scripts to fetch, build and deploy the website each week. A strange &lt;em&gt;sunday morning routine&lt;/em&gt;, but, hey... 😋&lt;/p&gt;

&lt;p&gt;I really wanted to use &lt;a href="https://github.com/features/actions"&gt;GitHub Actions&lt;/a&gt;, which I was testing in beta on my personal GitHub account, but didn't had the beta access on the BeCode organisation... until this september.&lt;/p&gt;

&lt;p&gt;With the newly introduced syntax, I came out with this workflow:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Thanks to the &lt;em&gt;cron syntax&lt;/em&gt;, this runs every sunday at 8am (while I &lt;em&gt;hope&lt;/em&gt; my son let me sleep a little longer), prepare a node environment, install dependencies (the &lt;a href="https://docs.npmjs.com/cli/ci.html"&gt;&lt;code&gt;npm ci&lt;/code&gt;&lt;/a&gt; is a better/faster &lt;code&gt;npm install&lt;/code&gt; alternative in this case), then publish the result of the build on the &lt;code&gt;gh-pages&lt;/code&gt; branch.&lt;/p&gt;




&lt;p&gt;It was a really nice and fun little project to code.&lt;/p&gt;

&lt;p&gt;You can see the result on &lt;a href="https://kareble.becode.xyz"&gt;kareble.becode.xyz&lt;/a&gt;, and dig in the code on the &lt;a href="https://github.com/becodeorg/kareble"&gt;GitHub repository&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>github</category>
      <category>svelte</category>
      <category>becode</category>
    </item>
  </channel>
</rss>
