teleren/devto huggingface dataset:
Clojure 101 / destructuring
Tags: clojure, functional, tutorial
Published: 2020-07-04 02:55:04

Destructuring is the process of unpacking items from collection types such as maps and vectors.

If you're coming from JavaScript land, you might have done something like this:

```js
const [x,y] = [1,2] // vector destructuring

const { flavor } = { flavor: "cherry" taste: "sweet" } // map destructuring
``` 

In Clojure, the syntax is similar!

### Destructuring vectors/lists

By the way, if you're new to Clojure, think of vectors and lists as arrays `[ ]` and maps as non-null, non-array type objects, aka `{ }`.

Ordered collection types such as vectors are naturally destructured by index.

```clojure
(let [[flavor taste] 
      ["orange" "sour"]]
     (str "The " flavor " juice tastes " taste))
```

This is what it would have looked like had we not used destructuring.

```clojure
(let [my-juice ["orange", "sour"]
      flavor (first my-juice)
      taste (second my-juice)]
     (str "The " flavor " juice tastes " taste))
```

Do you have a nested data structure you are working with? No problem.

```clojure
(let [[flavor, [taste]] 
      ["orange" ["sour"]]]
     (str "The " flavor " juice tastes " taste))
```

### Destructuring maps

As you can imagine, maps are destructured by key. Let's introduce some Korean named variables to spice things up!

```clojure
(let [{flavor :종류 taste :맛}
      {:종류 "orange" :맛 "sour"}]
     (str "The " flavor " juice tastes " taste))
```

Most of the time you will probably want to give the same name of the binding as the key. With the advent of ES6, we use this pattern pretty gratuitously in JavaScript - especially when using a front-end library such as React or Vue.

```js
const { taste } = { taste: "sour" }
console.log(taste); // "sour"
```

In Clojure, we want to use the `:keys` directive, which will take a vector of keys that we want to pull.

```clojure
(let [{:keys [flavor taste]}
      {:flavor "orange" :taste "sour"}]
     (str "The " flavor  " juice tastes " taste))
```

### Destructuring function arguments

Yes, you can also do this.

```clojure
(defn sip-juice [{:keys [flavor taste]}]
  (str "The " flavor " juice tastes " taste))

(sip-juice {:flavor "orange" :taste "sour"})
```

Admittedly, I'm getting a bit thirsty. I might grab a cup of orange juice. And yes, the orange juice tastes sour.

PS: If you're allergic to parentheses, I feel bad for you son, I got ninety nine problems but Clojure ain't one...

Warmly,
DH
Beginners guide to Virtual Routing & Forwarding
Tags: vrf
Published: 2020-07-04 02:42:25

What is VRF?

Virtual routing and forwarding (VRF) is a technology that allows multiple instances of a routing table to co-exist within the same router at the same time.

Because the routing instances are independent, overlapping IP addresses can be used without conflicting with each other.

The multiple Routing instances can be made to traverse different path (ie take different outgoing interfaces).

VRFs are the same methods of network isolation/virtualization as VLANs.

Know more about VRF Basics - https://ipwithease.com/vrf-basics/
LeetCode's Two Sum challenge
Tags: javascript, challenge
Published: 2020-07-04 01:42:57


Welcome to the Two Sum code challenge.

Instructions -

Given an array of integers, return indices of the two numbers such that they add up to a specific target.

You may assume that each input would have exactly one solution, and you may NOT use the same element twice.

Let’s break down these instructions really quick, there’s something important here.

The first part is self explanatory, however there is a catch in the second line.

“You may assume that each input would have exactly one solution, and you may NOT use the same element twice.”

There could be multiple items that, when added, would equivalate to the target. 

We only have to worry about the first one that matches. However, the rules state that you may not reference the same item’s index more than once when comparing the item’s sum to the target value.

Putting It In Simple Terms -

If two items from an array, when added together, have same value as the target value- return the index of those items. 

Meaning that we want to keep reference of the items index when doing the comparison.

It’s pretty simple, really. So without further ado, let’s get to the solution.

Implementation -

The first issue I ran into with this challenge is that I wanted to make use of the JS method indexOf() to get the index of my items. The problem is that indexOf() only returns the index of the FIRST index that matches that value- meaning that it wouldn’t pass the test because it breaks the “same element twice” rule.

So how can we get around this?

Let’s get to coding.

We know that we have to loop through this array at least once to see all of its contents.

We also know that we’ll want to make a second loop to compare one item to the rest of the entire array.

I decided to go with a traditional for loop so that I can reference my index directly from the variables that I created when initiating the for loop. (i and second)

NOTICE- My second variable is not used the same way as my i variable. It’s actually set to i + 1 so that I can assure that I never compare the same item to itself. 

Solving the ‘same element twice’ issue.

Now that we have that out of the way, let’s look at the condition.

if (nums[i] + nums[second] == target)

So in this example if 2 + 7 == 9 (which it does)

{ return the counter variables in the form of an array }

Which in this case it would look like [i, second]

And that’s pretty much it! I felt like the same element rule was quite a curve ball, and if you found a different way of solving it comment below!

I’d love to look at another solution and compare it to the way that I initially thought about it.

I hope this post was helpful, thanks for reading!
Day 33 - #100DaysofCode - Setting up my app on Heroku
Tags: 100daysofcode
Published: 2020-07-04 01:41:06

Guess what! I deployed the Sinatra app that I built on <a href="https://dashboard.heroku.com/"> Heroku</a>. 

I thought it would be a simple task, it was not. 

I used the following blogs as references:

<ul>

<li> <a href="https://postgresapp.com/downloads.html"> Guide on how to download the Postgress app </a></li>

<li> <a href="https://dev.to/prisma/how-to-setup-a-free-postgresql-database-on-heroku-1dc1"> How To Setup A Free Postgresql Database On Heroku </a></li>

<li> <a href="http://jgtr.github.io/blog/2013/07/28/deploying-a-sqlite3-database-to-heroku-for-production-using-postgres/"> Deploying a sqlite3 database to Heroku for Production using Postgres </a> </li>

<li> <a href="https://github.com/Enoch2k2/sinatrabook"> Enoch2k2/sinatrabook </a> </li>

<li> <a href="https://devcenter.heroku.com/articles/config-vars"> Where to set your API Keys/ Config Vars in Heroku </a> </li> 

</ul>

<h1><center>
<a href="https://sinatra-stock-watchlist.herokuapp.com/watchlists"> CHECK OUT MY DEPLOYED SINATRA APP </a></center></h1>


Song of the day: 


{% youtube 67AxwEV-uh8 %}
How I made my first Full Stack App and Got a Certification from Harvard University and how you can too.
Tags: webdev, javascript, python, html
Published: 2020-07-04 01:37:35

Hey DEV community members, 

A few weeks ago, I completed my first ever Full stack app using:

> ##### HTML( Jinja actually)
##### CSS
##### JAVASCRIPT
##### Flask (Python Framework)
##### PostgreSQL.
##### Heroku
 
It is an online book management system similar to Goodreads. 

You can add books to you shelf as 
*Read* ,  *To read* and *In progress*.


Check it out live here:

> https://startreading.herokuapp.com/

I submitted this project as part of Cs50 course taught by David Malan by Harvard University and earned the Certification. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/j1wnfi8q17mm20hj5sf2.jpg)

Link to the Course on CS50's website:
> https://cs50.harvard.edu/summer/2020/

Link to the course on Edx Website :
> https://www.edx.org/course/cs50s-introduction-to-computer-science#.VNYLwvnF_0c

The project is hosted at [Heroku](https://www.heroku.com) and Database I used was from this very cool Website [Elephant SQL](https://www.elephantsql.com).

Would love your reviews and feedback on this one. 

If you have any specific query regarding this project, CS50 course or anything else, feel free to reach out to me through [Twitter](https://mobile.twitter.com/aditya___pandey) Or Connect to me on  [LinkedIn](https://www.linkedin.com/in/aditya-p-782103105) 
You can also check out my [Github](https://github.com/aditya-pandey) . 


Thank you, and again, feel free to reach out. 😊😇
Graphing the daily challenge
Tags: dlang
Published: 2020-07-04 01:18:42

When one of the daily challenges came through my feed, I did not want to solve the problem but I thought it might be interesting to check performance on the different implementations. 

I keep needing to start by saying, this is all written in D and only uses the language because of the source of style. 

This ended up being a bigger exercise in figuring out gnu plotting and later found out the D library I originally wanted to use was called [ggplotd](https://github.com/BlackEdder/ggplotd). 

{% github https://github.com/JesseKPhillips/devto-challenge259-dupencoder %}

Anyway, I ended up focusing on the Haskell implementation. This is because it originally had the worst performance and I already knew the biggest offending cause. Of all the implementations it had the best chance of working with unicode where ever other would clearly fail.
Apache Flink SQL Demo (FLaNK Series)
Published: 2020-07-07 15:29:15

---
title: Apache Flink SQL Demo (FLaNK Series)
published: true
date: 2020-07-04 00:59:00 UTC
tags: 
canonical_url: 
---

https://www.youtube.com/embed/7cuQgmi4Ufs
Weekly Links #216
Published: 2020-07-04 16:06:43

---
title: Weekly Links #216
published: true
date: 2020-07-04 00:00:00 UTC
tags: 
canonical_url: https://yearn2learn.netlify.com/weekly-links/2020-07-04/
---

## Articles



**[When I follow TDD](https://kentcdodds.com/blog/when-i-follow-tdd)**

  - When you have a bug to solve, you should first write a test that covers it.
  - You should try TDD for complex utility pure functions.
  - [Testing Library](https://testing-library.com/) tools enable you to write TDD because you don’t have to know implementation details.
 

**[The Double-Bang (!!) Operator And A Misunderstanding Of How JavaScript Handles Truthy / Falsy Values](https://www.bennadel.com//blog/3858-the-double-bang-operator-and-a-misunderstanding-of-how-javascript-handles-truthy-falsy-values.htm)**

  - Avoid casting to boolean during condition statements.
  - Avoid casting to boolean in Array’s filter method.
  - Cast to boolean only if you need a strict boolean value or you need to send it to an API that you don’t have control about.


**[A deep dive into queues in Node.js](https://dev.to/bnevilleoneill/a-deep-dive-into-queues-in-node-js-25no-temp-slug-9893175)**

  - There are multiple callback queues, not a single one.
  - There is an order when each queue is running.
  - When the call stack is empty, the event loop picks up a callback from a callback queue and add it to the call stack.

## News



**[Launching docs.github.com](https://github.blog/2020-07-01-launching-docs-github-com/)**

  - New unified GitHub documentation.
  - Includes information about using GitHub and using GitHub API.
  - Also in GitHub, [a new secret option to customize your profile page](https://twitter.com/chandrikadeb7/status/1278948765269803009).
 

**[Tooling.Report](https://bundlers.tooling.report/)**

  - A report that compares build tools.
  - There are a lot of tests on a variety of features. You can check your current tool or which tool has a specific feature.
  - Overall, [Rollup](https://rollupjs.org/guide/en/) has a slight advantage over [Webpack](https://webpack.js.org/), while [Browserify](http://browserify.org/) and [Parcel](https://parceljs.org/getting_started.html) are behind.


**[New in Chrome: CSS Overview](https://css-tricks.com/new-in-chrome-css-overview/)**

  - New experimental feature in Chrome Developer Tools.
  - It contains a summary of the number of elements, external stylesheets, inline style elements, media queries, and selectors on the current page.
  - Each kind of data has its own section with more details.
Hi!
Tags: python, javascript, arabic, codenewbie
Published: 2020-07-03 23:27:31

This is my first post, as you see. Hopefully this is going to be my code-related blog-like place. My posts would be about Python and HTML/CSS/JS (for beginner/intermediate levels).
Posts would be in Arabic (as I hope more people of my friends, e.t.c learn to code) and English.
See you soon!
```js
console.log("See ya!");
```
[PT-BR] OLAP: O que é?
Tags: bi, intelligence, database, olap
Published: 2020-07-03 22:33:40

Primeiramente os dados são tratados, as regras são aplicadas, os dados estão limpos e armazenados. Esse processo nós chamamos de ETL (extrair, tratar e carregar), eu falei um pouco sobre [aqui](https://dev.to/mgabrielacuenca/pt-br-data-warehouse-e-alguns-conceitos-4m26). Posteriormente vem a outra parte, a criação do OLAP.


#**Afinal, o que é o OLAP?**#

OLAP é a sigla para On-Line Analytical Processing (Processamento Analítico On-Line). Trata-se da capacidade de analisar grandes volumes de dados em diversas perspectivas dentro de um Data Warehouse. Enquanto o DW guarda os dados de forma eficiente, o OLAP deve trazer os dados com a mesma eficiência, mas com muita rapidez.

**Algumas características do OLAP**

Dentre as características do OLAP, estão o Drill Down e o Drill Up. 

O Drill Down é quando o usuário aumenta o nível de detalhe da informação, diminuindo o grau de granularidade. O Drill Up é o contrário do Drill Down, é quando o usuário aumenta o grau de granularidade, diminuindo o nível de detalhamento da informação.

Por exemplo: a dimensão tempo é composta por ano, semestre, trimestre, mês e dia. O usuário fará um Drill Down quando ele passar de trimestre para mês, de mês pra dia.

![](https://media.giphy.com/media/SskhZtpOCgE37ashYI/source.gif)

**Arquitetura do OLAP**

**ROLAP (Relational Online Analytical Processing):** Nesse caso a consulta é feita e enviada ao servidor de banco de dados relacional e processada no mesmo, ou seja, o cubo fica no Servidor.

**MOLAP (Multidimensional Online Analytical Processing):** O servidor gera consultas que são processadas em dados que já estão armazenados de forma multidimensional.

**HOLAP (Hybrid Online Analytical Processing):** Combinação do MOLAP com ROLAP. Com a mistura dessas tecnologias podemos pegar o que há de melhor em cada uma, no caso a boa performance do MOLAP com a escalabilidade melhor do ROLAP.


Por hoje é isso aí :) Fiquem à vontade para perguntar em caso de dúvidas.
Do you think Roblox help kids to learn coding with LUA.rbxl?
Published: 2020-07-03 22:26:36

First, what is Roblox?

Roblox is a global platform where millions of people gather together every day to imagine, create, and share experiences with each other in immersive, user-generated 3D worlds. The types of gameplay on Roblox are just as limitless as the imagination of the creators themselves.

Roblox has been around since 2004, but officially lunched in 2006.

Well, what do you think about Roblox and Roblox Studio?
NG Build - Module not found again? (argh!)
Published: 2020-07-03 22:24:39

**Module not found: Error:**

Can't resolve 'moduleName' in 'D:\Source\node_modules\libraryName\fesm2015'

We've all seen this a thousand times using NG Build. It usually happens after some type of install.

```
 npm install
 npm install moduleName
 npm clean-install
 
```
Usually preceded by deleting node_modules either locally or globally all in attempt to fix one or more (but small) dependency issues.

For any dependency that you were responsible for installing prior to seeing this error. An easy fix is to run npm install. But alas, we find that the message is coming back to haunt us.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/57f9me6td6k91mxozn8i.jpg)

Don't feel too bad because any library in NPM which doesn't list peer-dependencies, causes this error! That's right, the package itself of which we have no control is the source!

No matter how many times you try NPM Install or NPM Install packageName it will not work.

**How to fix**

The only way to cover for missed package dependencies is to install each one manually! When this is done, both the local package.json file and the package-lock.json file receive a new entry.

In essence you are forced to atone for other's lack of effort! However; note that because the pacakge-lock.json file keeps records of all the installs, it too can restore bad packages you don't want. In that case just delete it, type in npm install and you get a fresh start!

Should be easy right?  Well just remember one thing with NPM anything is likely and will happen. You will eventually obtain your master degree in NPM.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/70028w947jdzrdvhqs7c.jpg)

Don't let NPM stop you! Start looking at Deno?

JWP 2020
Learn c# through console App
Published: 2020-07-03 22:07:50

Blood Bank Management Software:
The software must meet the following requirements:

Register a new user.
Store key data such as blood group,donor’s name, address, telephone number.
Retrieve above data through search.
Find appropriate match for a particular blood group.
Display amount of different blood types currently in storage.
You can make this application much more complex by asking for the donor’s prior medical history 
and showing a positive match only if certain medical conditions are found to be absent, sending a message
to the donor if storage levels for his/her blood type are low, etc.

Source: https://github.com/prag-wicked/BloodBankManagementSoftware
ActionController:: InvalidAuthenticityToken — What's Going On Here?
Tags: ruby, rails, errorexplained, beginners
Published: 2020-07-03 21:23:01

There are a few things going on with `ActionController::InvalidAuthenticityToken`, let's get in to it!

First of all, `ActionController` is the class which all "controllers" in Ruby on Rails inherit from, and it comes with a lot of functionality built in, such as "checking whether an authenticity token is valid". Because Rails prefers convention over configuration and is highly opinionated, this behavior is the default, rather than having to import the functionality.

We get this error when the controller detects that we have not properly passed a CSRF (Cross Site Request Forgery) token in with a `POST`, `PUT`, `PATCH`, or `DELETE` request. These are the type of requests where we typically send new data to the server and need to verify that this is done legitimately on behalf of a user using the website.

Read more about CSRF and related vulnerabilities here...

{% link https://dev.to/maleta/cors-xss-and-csrf-with-examples-in-10-minutes-35k3 %}

When we use a `form_for` or related tag in Rails, we magically pass an `authenticity_token` as a parameter along with the request. So if you try to submit a regular HTML form without manually adding a properly generated CSRF authenticity token as generated by the initial request you're going to get the the `InvalidAuthenticityToken` error.

Sometimes we'll want to legitimately skip this behavior if we know we don't need to make this check. That can be done, with caution, like this...

```ruby
skip_before_action :verify_authenticity_token
```

For a bit more information on some concepts outlined here, check out this post...

{% link https://dev.to/teekay/understanding-the-basics-of-ruby-on-rails-http-mvc-androutes-37j4 %}

Happy coding ❤️
Learning to code by doing essential little projects
Tags: beginners, tutorial, codenewbie
Published: 2020-07-03 21:21:25

---
title: Learning to code by doing essential little projects
published: true
description: I want to make learning to code fun again. To make it about learning the fundamentals.
tags: beginners,tutorial,codenewbie
cover_image: https://images.unsplash.com/photo-1531498860502-7c67cf02f657
---

_Photo from [Unsplash](https://unsplash.com/photos/YgOCJz9uGMk)_

When I was learning to code for the first time, I was always eager to find tutorials out on the wild to follow in order to better understand concepts that I was not familiar with.

I was selective though. Not just any tutorial would do. I wanted by the end of my sit to have something to show. Something that would make sense.

I remember learning PHP and my favorite tutorial would be a login page. I learned a lot by following lots of different tutorials that were about a simple form. I learned about authenticating users, correctly hashing and storing passwords, common security-related issues, and more just by doing a simple login page. I had learned about the authentication system.

It was fun!

![Fun!](https://media.giphy.com/media/XOXdQszYm4I3m/giphy.gif)

But I can't find that any more. Tutorials nowadays are all about common libraries and technologies that even if you learn to use, you would still not have an understanding of the fundamentals. Just the fundamentals to use that specific library.

I want to fix this. 

> **I want to make learning to code fun again. To make it about learning the fundamentals.**

I want to build a mailing list. I will send you an exercise every week. A simple little project with a clear objective and of essential use. If you stuck or you have any questions, I will be right behind my inbox to assist you.

This is for beginners to start upskilling by doing useful projects that can actually show. Even for intermediates that are looking for motivation to sharpen their existing skills.

> **Let's make code fun again**

Are you interested? Send me an email to <a href="mailto:kostas@bariotis.com">kostas@bariotis.com</a>. I will start sending out the first projects in a few weeks.

Thank you. Speak to you soon.

![Dog on a jet ski](https://media.giphy.com/media/aiE3JQU3vLqTK/giphy.gif)