teleren/devto huggingface dataset:
Implementing Polymorphism in Rust
Tags: rust, polymorphism, oop
Published: 2020-07-02 03:02:03

In this post we will be implementing Polymorphism in Rust.

**But what is Polymorphism?**
In simple terms, it is the ability to pass an argument that can be of different types, to a function with only one implementation, instead of separate ones for each different type.

Code: [Online Demo Link](https://repl.it/repls/PerfectSandybrownCarat)
```rust
// Polymorphism in Rust
// Online Demo: https://repl.it/repls/PerfectSandybrownCarat

const PI: f64 = 3.1416;

struct Circle {
  radius: f64
}

struct Rectangle {
  height: f64,
  width: f64
}

// Since both Circle and Rectangle are shapes,
// we can label common behavior in a `trait` type.
// A `trait` is basically a type that groups
// certain behaviors that are similar in meaning
// but can be different in implementation. e.g. a
// dog and a human, both can walk, but they walk
// differently. You can also think of traits as 
// kind of similar to interfaces in other languages.
trait Shape {
  fn area(&self) -> f64;
}

// Although both shapes have an area
// but their ways of calculating it
// are different. e.g. (dog human walking analogy)
impl Shape for Circle {
  fn area(&self) -> f64 {
    PI * self.radius * self.radius
  }
}
impl Shape for Rectangle {
  fn area(&self) -> f64 {
    self.height * self.width
  }
}

// Here, we are saying, hey accept
// any type that implements a `trait`
// called Shape. e.g. any object that
// can walk (from dog human analogy).
fn print_area(shape: &dyn Shape) {
  println!("{}", shape.area());
}

// Or we can also make a generic function.
// This is similar to `print_area` but may
// have the benifits of static type checking,
// since it's a generic, so two versions of the
// same function get generated with relevant
// absolute/concrete types. (not sure though)
fn print_area_generic<T: Shape> (shape: &T) {
  println!("{}", shape.area());
}

fn main() {
  let circle = Circle{radius: 2.0};
  let rectangle = Rectangle{height: 3.0, width: 5.0};

  print_area(&circle); // 12.5664
  print_area(&rectangle); // 15

  print_area_generic(&circle); // 12.5664
  print_area_generic(&rectangle); // 15
}
```

I hope this has been interesting for you.
Take Care && Good Bye. 😊
SLIDES - understanding python *args and **kwargs
Tags: python
Published: 2020-07-03 02:38:55

---
title: SLIDES - understanding python *args and **kwargs
published: true
date: 2020-07-02 05:00:00 UTC
tags: python
canonical_url: https://waylonwalker.com/blog/python-args-kwargs-slides/
cover_image: https://waylonwalker.com/python-args-kwargs-slides.png
---

I generally post these as a carousel on [LinkedIn](https://www.linkedin.com/feed/update/urn:li:activity:6678285915770642432/) based on a full article. Let me know what you think of it shown inside of a blog in the comments section below.

[![python args and kwargs](https://waylonwalker.com/python-args-kwargs.png)](https://waylonwalker.com/blog/python-args-kwargs)

> See the full article [here](https://waylonwalker.com/blog/python-args-kwargs)

## Slides

* * *

![1](https://waylonwalker.com/args-kwargs-slide-1.png)

* * *

![2](https://waylonwalker.com/args-kwargs-slide-2.png)

* * *

![3](https://waylonwalker.com/args-kwargs-slide-3.png)

* * *

![4](https://waylonwalker.com/args-kwargs-slide-4.png)

* * *

![5](https://waylonwalker.com/args-kwargs-slide-5.png)

* * *

![6](https://waylonwalker.com/args-kwargs-slide-6.png)

* * *

![7](https://waylonwalker.com/args-kwargs-slide-7.png)

* * *

![8](https://waylonwalker.com/args-kwargs-slide-8.png)

* * *

![9](https://waylonwalker.com/args-kwargs-slide-9.png)

* * *

![10](https://waylonwalker.com/args-kwargs-slide-10.png)

* * *
  
👀 see an issue, edit this post on [GitHub](https://github.com/WaylonWalker/waylonwalkerv2/edit/main/src/pages/blog/python-args-kwargs-slides.md "edit this post")  

* * *

I have been writing short snippets about my mentality breaking into the tech/data industry in my newsletter, 👇 check it out and lets get the conversation started.

 

[![Sign up for my Newsletter](https://res.cloudinary.com/practicaldev/image/fetch/s--uOcrEpdd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://waylonwalker.com/waylon-walker-newsletter.png)](https://waylonwalker.com/newsletter)
On Decentralization and "Next Gen Web" Wannabes
Tags: web, decentralization
Published: 2020-07-02 04:59:59

Decentralization is not a virtue per se. The Web did not become ubiquitous and successful because it was decentralized. Another attempt at decentralization for decentralization's sake will not succeed.

In the context of early internet (ARPANet), decentralization meant eliminating single points of failure, in the face of a nuclear threat. In the context of bitcoin, decentralization means eliminating single points of responsibility, in the face of legal threats. In the context of smart contracts, decentralization means eliminating enforcement bottlenecks, in the face of shortage of court resources. In each case decentralization serves a use case other than for the sake of decentralization.

What has made the world wide web as we know it so successful? It was not the fact that it could still remain in operation after a nuclear strike. Ironically now we have built such a brittle network that a BGP configuration mistake can cripple half of it. No, it was Netscape and Internet Explorer, popularizing web browsing. It was AOL, Yahoo, Google, Wikipedia, helping laypeople reach into and make use of the information on the WWW. It was Adobe Flash, Chrome, iPhone, pushing the limit of what use cases the WWW can deliver.

IPv6 had all the resources in the world to replace IPv4. To this day IPv6 adoption has just climbed to around 40%, mostly in internal networks, and IPv4 has seen no decline, with [prices for IPv4 addresses increasing](https://www.heficed.com/press-releases/prices-of-ipv4-addresses). That was an **official** effort to replace the Internet. Nothing else has even come close to it. Ethereum is still an experiment after 4 years. IPFS is a glorified archive.org. Is anyone still using [Namecoin](https://www.namecoin.org/)? How many know [ZeroNet](https://zeronet.io/)?

Research it, push the distributed system frontier forward, cool. Like [ZeroTier](https://www.zerotier.com/), maybe you can make a better VPN. Just don't expect it to be "the next generation internet".

------

Originally under:

{% post jdorfman/building-a-decentralized-web-is-hard-who-s-in-e99 %}

at:

{% devcomment 119jn %}
FCC: Technical Documentation Page
Tags: codepen, css, html, beginners
Published: 2020-07-02 03:04:24

{% codepen https://codepen.io/notalexpareja/pen/oNbormb %}

Once again, drawing inspiration from Elite Dangerous, I turned FCCs tech doc about Javascript into a cockpit interface manual. Biggest take away here is that I really need to get better at understanding media queries. I bit off more than I can chew with the menu. I kinda copped-out with the responsiveness there, and FCCs example code did not work for my particular build.

I need to find a way, using HTML and CSS only, to hide and toggle the menu, or place it in a way that is still accessible to the user on a small screen, instead of just straight-up hiding the menu and forcing the end user to scroll. Perhaps the next shot I take ill try a mobile first approach.

I did, however, really enjoy laying out Elites "amber at night" color palette.
CI/CD de Julia y Docker ¿Qué hacer?
Tags: devops, julia, docker
Published: 2020-07-02 02:56:08

Preparando el CI/CD para un proyecto con Julia y Docker en AWS me encontré con el problema de que [AWS Code Stars](https://aws.amazon.com/es/codestar/) no tenía ninguna plantilla preconfigurada para elegir, por lo decidí hacer toda la configuración del sistema por mí mismo.

Cómo primera opción pensé en administrar todo desde Jenkins, tanto el pipeline cómo los testeos y el proceso de compilación. Investigando un poco ví que AWS contaba con dos herramientas que podían ayudarme en estas tareas: [CodePipeline](https://aws.amazon.com/es/codepipeline/) y [CodeBuild](https://aws.amazon.com/es/codebuild/).

Al ser un sistema funcionando con docker en una estructura de microservicios, decidí que el deploy esté a cargo de [Beanstalk](https://aws.amazon.com/es/elasticbeanstalk/) + [Elastic Container Service](https://aws.amazon.com/es/ecs/). El Staging del producto funcionará sobre un cluster de instancias EC2 mientras que producción sobre Fargate.

¿Qué opinan? Creo que es una configuración prometedora, aunque me interesa escucharlos.
Quick Demo! Four months of building.
Tags: supabase, javascript, postgres, elixir
Published: 2020-07-02 02:10:50


This is also available as a full [blog post](https://supabase.io/blog/2020/07/01/supabase-alpha-june-2020) with videos.

We're now 4 months into building [Supabase](https://supabase.io), which means another major update. Let's check out a few thing we think you'll love in this release.


### View relational data

We're sometimes asked how we will make Postgres as simple as Firebase, since Postgres is a relational database. This month we're making our first steps to prove that relational databases can be even easier to use than document stores. We're releasing an excel-like editing interface which can drill down into your relational data.

<img width="1386" alt="image" src="https://user-images.githubusercontent.com/10214025/86233775-89531c00-bbc8-11ea-973b-40b2d0c2b51f.png">

### Manage JSON data

Postgres is an amazing database, giving the flexibility of a document store with the power of a RDBMS. If you use `JSON` data in Postgres, then we want to make that easy too. Supabase detects when your column is `JSON` or `JSONB`, and provides an easy way to edit and view your data. More improvements coming soon for this feature!

<img width="1386" alt="image" src="https://user-images.githubusercontent.com/10214025/86233663-59a41400-bbc8-11ea-836a-a28cce91a210.png">

### Choose your region

If you noticed a bit of latency on Supabase, it's because your projects were previously set up in Singapore. It was always our intention that you'd be able to choose your database region, and this month we've delivered it. In the next releases we'll even allow you to go multi-region, instantly replicating your database close to your customers.

<img width="1386" alt="image" src="https://user-images.githubusercontent.com/10214025/86233841-9bcd5580-bbc8-11ea-9cc9-eaee309c8384.png">

### Backups

A guiding principle at Supabase is zero lock-in. So this month we are exposing your daily database backups on the dashboard, giving you a simple way to migrate off Supabase. We have a lot more to build in this space (`WAL-G!`), so watch this space.

<img width="1386" alt="image" src="https://user-images.githubusercontent.com/10214025/86233456-04680280-bbc8-11ea-988b-914902658857.png">

### Get started

- Start using Supabase today: [app.supabase.io](https://app.supabase.io)
- Make sure to [star us on GitHub](https://github.com/supabase/supabase)
- Follow us [on Twitter](https://twitter.com/supabase_io)
- Become a [sponsor](https://github.com/sponsors/supabase)
How are you keeping in touch with your team while working from home?
Tags: watercooler, discuss
Published: 2020-07-02 02:04:06

_Photo by [Daniel Cheung](https://unsplash.com/@danielkcheung) on [Unsplash](https://unsplash.com)_

---

Over these past few months, COVID has turned many of us into remote employees for the first time. This is quite a change for those used to working colocated with their teams from a busy office.

No more group lunches with coworkers, ping pong breaks, or serendipitous chit-chat. Without these things it can be tougher to bond or build camaraderie.

* **What are some techniques or activities that you or your team has started doing to make up for this?**

* **If you were already working as part of a distributed team before all of this, what has been working for you?**
Server-Side Rendering (SSR) and isomorphic-fetch for SEO
Tags: ssr, seo, webdev, react
Published: 2020-07-02 02:00:12


{% youtube 66owdRkc8pI %}

Server-Side Rendering (SSR) and isomorphic-fetch for SEO - Everything you need to know about.

Tried to explain with live example.

Feel Free to share.



#ssr #serversiderendering #seo #searchengineoptimization #isomorphicfetch #react #next.js #dynamicRendering #webcrawler #csr #firebase #webdevelopment
Keeping workplace connections warm and genuine with Teamo
Tags: showdev, career, womenintech
Published: 2020-07-02 01:45:01

Hi DEV community! As a NodeJS and React developer, I've been building a platform for teams to stay connected, happy and appreciated: [Teamo](https://teamo.team/). 

These days, most teams are working remotely. Remote work can be bittersweet – staying connected and feeling that sense of camaraderie may become harder when work calls become mostly work. 

Teamo aims to help build a sense of camaraderie and genuine workplace connections when you celebrate another teammate with more than just a Slack message – and instead, a lively social group card with thoughtful messages.

A little appreciation and shoutout goes a long way. We want to help teams stay strong, build genuine connections, and make work fun and fulfilling for all  🎉

Feel free to ask me anything about Teamo, how I built it, etc!
How I run through a tutorial and actually remember things
Tags: devdiary, swiftui, programming
Published: 2020-07-02 01:24:28

*This post is part of a (hopefully) long-running series of Dev Diary entires on my process of teaching myself Swift and Swift UI in order to build an app.*

As I mentioned before, Apple has some [amazing tutorials](https://developer.apple.com/tutorials) dedicated to Swift UI. The presentation of these is the best I've ever seen, broken down step-by-step with clear diffs and explanations on what you're doing, and even a quick quiz at the end to make sure you actually understood what you've done.

When doing these types of tutorials, you might often find that you've gotten to the end to that quiz having retained almost nothing. It's ok, it happens. Here's what I do that oftentimes helps to make sure I'm paying attention and actually learning, not just regurgitating.

1. Re-read every instruction/step more than once. It's too easy to just skim and not really take in what they're saying. Forcing yourself to do it at least twice, or maybe even once out-loud, forces you to slow down and pay attention
2. Never copy-paste the sample code. I learned this one the hard way from having done these types of tutorials from a text book back in the day. Copying and pasting has the same issue as skimming: you're not actually retaining anything. Forcing yourself to write the lines at least gives you a shot at remembering, just like note-taking helps retain a lecture
3. Try to do the tutorial step yourself before you copy the step. I can't stress this one enough. When I read an instruction that wants me to do something, I immediately ignore the code they're asking me to write and try and write the code myself. Nine times out of 10 I fail miserably, but that's ok! Eventually I start getting the hang of it and I start being able to complete the example just from its description, without referring to the sample code at all. That's when I know I've nailed it.
Day 31 - #100DaysofCode - Rails Routes 101
Tags: 100daysofcode, codenewbie
Published: 2020-07-02 01:12:49

Understanding the rails routes is something I seem to be struggling with and after walking through a few labs and watching youtube videos, I think the concept is beginning to make sense. 

A route in Rails is just a ruby method. A method that takes two arguments. The first argument is a string and the second is a hash. 

For example, using the items example from my past post:

``` 
Rails.application.routes.draw do

get '/items', controller: 'items', action:'index'

end
```

The above is just a method that says when the user goes to ``'/items'`` we want to go to the items controller and then we want to go to the index action within that items controller. 

Another way you may see it written is like this: 

``` 
Rails.application.routes.draw do

get('/items', {:controller => 'items', :action => 'index'})

end
```

The above says the same thing, it is still taking two arguments, a string argument ``'/items'`` and a hash with a key-value pair ``{:controller => 'items', :action => 'index'}``

But the conventional way of seeing it in Rails is like this:

``` 
Rails.application.routes.draw do

#get ({'/items' => 'items#index'})
get   '/items' => 'items#index'

end
```

All three ways of writing the method will work. 

But you will need more than one route right? Well, of course. 

Another important route to know and understand is a dynamic route. For example, when you want to view an item, you most likely will want to go to ``items/1`` for the first item in your db and ``items/10293`` for the 10293 item in your db. 

In order to create that route in Rails you need the following:

``` 
Rails.application.routes.draw do

get '/items/:id' => 'items#show'

end
```

The the colon is essentially creating a variable named id. It can be named anything but is usually referred to as an id because you will fetch the id attribute within your database. After creating the route we need to create a show action within the items controller and a show view.  

Within your show method you should have the following code:

```
def show
  item = item.find(params[:id])
end

```

The above code along with the route allows us to find the information in the database associated with a particular id. 

How does this happen? 

Well, because of routes and rails. 

To break it down the best that I can, when the user visits a site and goes to a dynamic route like ``items/1``, they are sending data. The data in this case is a hash holding a key of ``1`` aka ``{"id" => 1}``. That is automatically generated and sent with the params so that we are able to use it in our controller to search the db and give/show the user what they requested.

Rails is not magic but it is very impressive. 

When checking what routes you have available to you try visiting www.localhost/3000/rails/info/routes when you are on your local computer or running ``rails routes`` in your terminal. 

Also, another useful website for using rails restful routes is <a href="http://www.restular.com/"> restular </a>

Song of the day:

{% youtube XhZ5_kuJZBA %}
Anatomy of a reusable component in React
Tags: react, javascript, webdev
Published: 2020-07-02 00:53:43

Hi there, I'm going to explain you how to decompose into peaces a component, like the one I'm using right now.

![maincp](https://i.ibb.co/N93vnLy/Screen-Shot-2020-07-01-at-7-26-55-PM.png)

The component will have several selects, the goal is to use the same select component with different parameters, so we actually do ourselves the favor of not having to write the same test more than once and reduce our codebase.

#Imports
![imports](https://i.ibb.co/PDYcK19/Screen-Shot-2020-07-01-at-4-39-41-PM.png)

Imports at the first lines of every js file is a thumb rule, I've seen people using *dinamic imports* but... well I haven't have the use case for now. So we'll write them at the beginning.


##Component Declaration
![component declaration](https://i.ibb.co/rHSKzJ6/Screen-Shot-2020-07-01-at-7-47-44-PM.png)
Here is where the composition begins. 

###Declaration 
we declare the component as a function or a const, I prefer const so I have my chance of a 1 line declaration with return.

###Parameters
the parameters inside the ({ }) have general names, that's because we plan to use this component for different types of data that fit the description. This case is the already selected names of descriptive items that create a new pool in the database.

## Logic
![logic](https://i.ibb.co/VSgCxhD/Screen-Shot-2020-07-01-at-4-41-01-PM.png)
This function "useFetchData" will fetch some data from the database (in my case is firestore). And will update the state, from this state we can part to the UI section of this component.

## Return (UI)
![return statement](https://i.ibb.co/X8RbWYx/Screen-Shot-2020-07-01-at-4-42-16-PM.png)
This is it, here's were we actually serve some UI to the app. We'll use some already written/tested components from @material-ui, which gets really mad if you don't control a form component, so we are going to use the controlledValue state and onChange method written in the component declaration.

### < Select >some some < /Select >
![select](https://i.ibb.co/SBSSJfp/Screen-Shot-2020-07-01-at-6-01-17-PM.png)
The select tag will display in a dropdown style N options we write inside them, as we are using react and plan to make this component reusable, we are going to display the options from the recently updated state that fit the collection written in the composition of this component.

## That's it
We did it, we wrote a reusable component in React.

## Full Component
![component](https://i.ibb.co/K0ksJB9/Screen-Shot-2020-07-01-at-7-51-28-PM.png)

## First Picture 
![multiples uses of component](https://i.ibb.co/2yz4QSr/Screen-Shot-2020-07-01-at-6-02-23-PM.png)



#Thanks for your time!
If you want to chat about javascript || apps, please, feel free to write me a message✌️

Jesus Cova
*Full Stack Developer*
[jesusc.dev](https://jesusc.dev)
[twitter](https://twitter.com/jesusacova)
A Spotify Playlist Based on your Horoscope!
Tags: react, node, javascript
Published: 2020-07-02 00:28:47

Last month, I collaborated with another web developer/designer to create [Astrofy](https://astrofy.live), a simple app that creates a playlist based on your Horoscope. 

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

[Check it out!](https://astrofy.live)

## Tech 
We used the Spotify API for this, and the backend code was written in Node (via Expressjs). 

Some modules that made this possible were aztro.js and horoscope.js. I should mention that we used the `web-spotify-api` npm module, which made it significantly easier to use the Spotify API in the backend. 

In the frontend, I used React, with a few basic hooks, namely: `useState` and `useEffect`.
Light Mode or Dark Mode, which do you prefer?
Tags: watercooler, discuss, css
Published: 2020-07-02 00:01:48

Do you put all of you apps in dark mode if possible? Do you think every website should have an option for this, or at least integrate with your device's settings, such as with the [`prefers-color-scheme`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) CSS property? Is your IDE an exception to your preference? 

I thought it would be interesting to hear what others have to say. I do try to put everything in dark mode, including my IDE, and for some devices with OLED screens, that means better battery performance. Some people I talk to mention that it's harder to read text with dark backgrounds and could affect accessibility. While it's great to always have the options, that means extra work for the UI designers to create a secondary color scheme for it.

Facebook has jumped on the bandwagon with their new design, as well as YouTube and a plethora of apps which have had it for years. What are your thoughts?