teleren/devto huggingface dataset:
Everything is about filter, map and reduce
Tags: functional, beginners
Published: 2020-12-07 23:09:19

I'm after my first quarter worked as Elixir engineer. Does it was easy for me? No. Changing language from PHP to Java? Why not! PHP to C#? Let's go for it! But learning functional concepts is something more than changing your daily toolset from the wood hammer into the metal hammer. It's about **how are you looking at the problems from a higher level**.

In object-oriented languages, we think about the data encapsulated in the objects. They are connected by relations that describe the world around us. Sounds reasonable I hope.

In functional programming, **there is no more data in the heart of the problem**. There you need to think about the problem as to **how to transform something** into a different thing. 

Let's assume you’re working on an application where the main problem is to prepare a salad for your family. You have a few vegetables like tomato, cucumber, and red pepper. At first, you need to peel the cucumber. So... How to do that? You need to filter vegetables (you don't want to peel the pepper, trust me) to find cucumber, map it to take off the skin. Viola! The cucumber has been peeled! The code could look like below:
```elixir
vegetables |> filter(cucumber) |> map(&peel/1)
```

Okay, so now you have to slice all the vegetables like in the example, just without filtering because you want to do that for all the vegetables.
After everything, you would like to mix all these things into a tasty salad. How to do that functionally?
```elixir
prepared_vegetables |> reduce(&mix/2)
```

So... As you see the most important is to understand operations like **filter**, **map**, and **reduce**. Look - we’ve never worried about the state or something - the only significant operations are input transformations. Of course, **functional programming also has tons of academic terms** but you don’t need them to start your journey with FP!

I wrote this post as a short note for myself from the future. Most of my posts (like this one) were written on the iPhone in a bed. Please forgive me for typos and my poor English, lol. I hope I’ll find more motivation to write something more technical in the near time. I'm often posting my thoughts and interesting links that I found on [Twitter](twitter.com/patrykwozinski).
Material Form Design
Tags: webdev, design, html, css
Published: 2020-12-07 22:23:35


# Preview

Simple webform built with the MaterializeCSS framework. Illustration created by me with Inkscape. TBC!

![Material Form Design](https://dev-to-uploads.s3.amazonaws.com/i/bpnn0h6s499lkpx46vkm.PNG)
Periodic Table of Web APIs
Tags: webdev, javascript, html, css
Published: 2020-12-07 21:43:18

![Screen Shot 2020-12-07 at 8.11.48 PM](https://dev-to-uploads.s3.amazonaws.com/i/9uqpt2uuabegu8m77n91.png)
![Screen Shot 2020-12-07 at 8.44.18 PM](https://dev-to-uploads.s3.amazonaws.com/i/3v1bnvvh3gm6p4gj3so9.png) 
**[See it in full, clickable glory](https://wwwperiodictable.surge.sh/)**
**[Improve it by sending a pull request](https://github.com/CrazyPython/wwwpreiodictable)**

If you open the full table, it has links to guides to learn some of the APIs.

Please **like** and **unicorn** if this post informed you! Thanks.
TIL: You can restore the startup chimes on MacOS
Tags: mac, macos, macbook
Published: 2020-12-07 21:40:11

Early on during the covid-19 lockdown my computer fizzled and died.

I wasn't sure if it was the screen or if the whole computer had gone kaput. So I tried switching it on again to see if the startup chime played. But…no chimes.

Then I realized I hadn't heard the startup chime in forever, and got to googling (on my phone). Apple removed the chimes in 2016, but there is a way you can restore it.

Open Terminal and enter this:

```
sudo nvram StartupMute=%00
```

if you change your mind, you can mute the chime by entering

```
sudo nvram StartupMute=%01
```

Now if your screen suddenly goes black you'll be able to quickly tell if your computer is dead. Also it sounds nice.
Don’t force your objects to construct what they need
Tags: designprinciples, goodpractices, srp
Published: 2020-12-07 21:33:10

---
title: Don’t force your objects to construct what they need
published: true
date: 2020-12-07 21:29:05 UTC
tags: designprinciples,goodpractices,SRP
canonical_url: https://le0nidas.gr/2020/12/07/dont-force-your-objects-to-construct-what-they-need/
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/jtyc29mh4u2twekpvmpx.png
---

Let’s say we have an object that handles instances of `Person`. For example `PeopleScreen`:

{% gist https://gist.github.com/le0nidas/998a4574e50717e2dca39b33f0bda1d5 %}

`PeopleScreen` renders instances of `Person` so this should be the only format we provide to it. Let me explain.

#### Forced construction

There is a new flow that ends in opening `PeopleScreen` but all the information for the list of people are in a `Map<String, String>`. There is **no reason** to alter `PeopleScreen` in order to support this new format:

{% gist https://gist.github.com/le0nidas/d1e0da44e06876ba6abc3ed6f2009126 %}

<figcaption>the new format is passed through an overloaded constructor but the same goes if we use a setter method</figcaption>
#### Why we shouldn’t do it

We could argue that by doing so we tie the object with each special format making the code hard to maintain and scale but the real reason is that we violate the [SRP](https://en.wikipedia.org/wiki/Single-responsibility_principle) principle since `PeopleScreen` will have more than one reasons to change. One if something changes in the way we render and two if something changes in `Person`‘s construction.

#### What we should do

We should keep `PeopleScreen` only consuming `Person` and move all transformations to their own objects allowing a coordinator to transform and pass data around.
Declarative rendering with Apollo Client results
Tags: react, graphql, apolloclient
Published: 2020-12-07 21:25:17

[RedwoodJS](https://redwoodjs.com) introduces a great abstraction for dealing with query results from [Apollo Client](https://www.apollographql.com/docs/react/): [cells](https://redwoodjs.com/docs/cells).

If you've used Apollo Client before, you've probably written something like the following hundreds of times.

```tsx
const { loading, data } = useQuery(...)
if (loading) {
  return ...
}

if (data.length === 0) {
  return ...
}

return (
  ...
)
```

Am I wrong?

I love the idea of cells. I can tell it's a great abstraction because there's no need to port my whole app over to RedwoodJS to get the same immediate declarative improvements. Here is a Redwoods-y utility function to render the result of a GraphQL query in any codebase with Apollo Client query results.

```tsx
import * as React from "react";
import { ApolloError, QueryResult } from "@apollo/client";

const isEmpty = (data: NonNullable<QueryResult["data"]>): boolean => {
  const dataValue = data[Object.keys(data)[0]];
  return (
    dataValue === null || (Array.isArray(dataValue) && dataValue.length === 0)
  );
};

export const renderResult = <T extends QueryResult>(
  result: T,
  options: {
    isEmpty?: (data: NonNullable<T["data"]>) => boolean;
    Loading: React.FC;
    Failure: React.FC<{ error: ApolloError }>;
    Empty: React.FC;
    Success: React.FC<{ data: NonNullable<T["data"]> }>;
  }
): React.ReactElement => {
  return result.loading ? (
    <options.Loading />
  ) : result.error ? (
    <options.Failure error={result.error} />
  ) : (options.isEmpty ?? isEmpty)(result.data) ? (
    <options.Empty />
  ) : (
    <options.Success data={result.data} />
  );
};
```

We can pass a custom `isEmpty` function if the shape of our data is more unique than the basic case.

Example usage:

```tsx
import * as React from "react";

import { render } from "lib/render-result";

const MyComponent: React.FC = () => {
  const result = useQuery(...)
  return render(result, {
    Loading,
    Failure,
    Success,
    Empty,
    isEmpty: (data) => data.customPath.toCheck.length === 0
  });
};

export default MyComponent;

const Loading: React.FC = () => {
  return ...
};

const Empty: React.FC = () => {
  return ...
};

type Data = NonNullable<QueryResult["data"]>;
const Success: React.FC<{ data: Data }> = ({ data }) => {
  return ...
};

type FetchError = NonNullable<QueryResult["error"]>;
const Failure: React.FC<{ error: FetchError }> = ({ error }) => {
  console.error(error);
  return ...
};
```
:v:
Hello! Looking for early adopters for a new DevOps automation platform!
Tags: kubernetes, devops, automation, applicationdevelopment
Published: 2020-12-07 21:14:41

Zeero was created to allow development teams to just focus on code and innovation. There is too much time spent during the week around managing systems and tooling which hinders development and potential loss for your business. 

https://cornerstonets.io/zeero/
Bugout: Add checklists your GitHub pull requests
Tags: github, showdev
Published: 2020-12-07 20:57:13

Sometimes, you need human oversight on your pull requests before you can merge them.

This is especially true for pull requests that change database schema, introduce new environment variables, or introduce changes with security or legal implications.

Bugout adds a checklist to every pull request. To add a check to your checklist, just mention @bugout-dev on a PR comment:
```
@bugout-dev check require <something important>
```

To cross an item off the checklist:
```
@bugout-dev check accept <something important>
```

Here is a live PR where you can try it out: https://github.com/bugout-dev/github-demo/pull/2

Actively looking for feedback - missing features, similar to existing apps, anything. Thank you!
re:Invent Week 2: Data Sessions
Tags: aws, database, datascience, analytics
Published: 2020-12-07 20:56:05

Week 2 is starting soon so here are my picks of the data related sessions.

* Machine Learning Keynote
* Using Amazon QLDB as a system-of-trust database for core business apps
* Get started with Amazon SageMaker in minutes
* What’s new in Amazon RDS for SQL Server
* Fast distributed training and near-linear scaling with PyTorch on AWS
* Building a successful inventory planning solution with Amazon Forecast
* Get deep insights about your ML models during training
* Amazon Aurora Serverless v2: Instant scaling for demanding workloads
* Paving the way toward automated driving with BMW Group
* Migrating databases to Amazon DocumentDB (with MongoDB compatibility)
* Train large models with billions of parameters in TensorFlow 2.0 
* How New Relic is migrating its Apache Kafka cluster to Amazon MSK
* Deliver viewing experiences for super fans with Amazon Personalize
* Running Apache Cassandra workloads with Amazon Keyspaces
* Harness the power of data with AWS analytics
* What’s new with Amazon Redshift
* Power modern serverless applications with GraphQL and AWS AppSync
* How Amazon Redshift powers large-scale analytics for Amazon.com
* New use cases for Amazon Redshift
* Beyond AWS DMS: Programs and partners to ace your migration
* Amazon.com’s use of AI/ML to enhance the customer experience
* Migrating a legacy data warehouse to Amazon Redshift
* What’s new with Amazon EMR
* Choose the right machine learning algorithm in Amazon SageMaker
* Understanding AWS Lambda streaming events
* Infrastructure Keynote (ok not strictly data services but it's always interesting to see the scale of what is powering them)
* Serverless data preparation with AWS Glue
* Deep dive on Amazon Aurora with MySQL compatibility
* Under the hood: How Amazon uses AWS for analytics at petabyte scale
* Building real-time applications using Apache Flink
UI Dev Newsletter #34
Tags: webdev, html, css, javascript
Published: 2020-12-07 20:39:52

- [State Of CSS 2020](https://bit.ly/3lKN4Mg)
The results of the annual survey about the latest trends in CSS.


- [State of CSS 2020 Survey Results: Tailwind CSS Wins Most Adopted Technology, Utility-First CSS on the Rise](https://bit.ly/3gmsYHi)
Sarah Gooding summarizes some of the most noteworthy data from State of CSS 2020 survey.


- [How to Get Sticky and Full-Bleed Elements to Play Well Together](https://bit.ly/36HBhc4)
Silvestar Bistrović explains how to create a tricky non-centered layout with full-bleed and sticky elements.


- [How to Fix Issues With CSS Position Sticky Not Working?](https://bit.ly/3ggvvTh)
Daniyal Hamid compiles a list of things you can do to fix some common issues when using position sticky.


- [How to Add Text in Borders Using Basic HTML Elements](https://bit.ly/36HBhc4)
Preethi Sam shows how to use fieldset and legend to place text within borders.


- [100 lessons for the year to come](https://bit.ly/2JReDX0)
UX Collective shares a list of what to expect for User Experience (UX) Design in the next year.


- [Blogging for Devs](https://bit.ly/3lLf2Yn)
Monica Lent makes a site in which you could discover the best developer blogs on any tech stack.


- [Clean advertising](https://bit.ly/3lLqdjF)
Jeremy Keith describes where did web advertising go wrong and how to fix it.



Happy coding!

[Subscribe to the newsletter here!](https://bit.ly/34155z3)
Temos vagas! #JetBov
Tags: python, devops, hiring, vue
Published: 2020-12-07 20:39:25

Estamos contratando!

1 - Desenvolvedor(a) Pleno/Sênior FullStack Python;
2 - SRE/DEVOPS Python;
3 - Desenvolvedor(a) FrontEnd / Mobile (Ionic, VueJS) Sênior.
 
Todas vagas com disponibilidade para trabalho remoto!
 
Acesse o link e escolha a vaga para mais informações:
https://jetbov.enlizt.me/
 
Se interessou? Envie um e-mail para talentos@jetbov.com

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/h7ejvzdmxzb0o1905hnf.jpeg)
Markdown Blog Templates for Gatsby, Next, Nuxt, Gridsome, Scully and Sapper
Tags: gatsby, nextjs, nuxt, gridsome
Published: 2020-12-07 20:39:21

In my project generator tool, merced-spinup I have created a template for creating a markdown blog in each of the major frontend frameworks related static site generators.

**For all of the templates...**

- Markdown files go in a markdown folder in the root
- readme.md details where to go to make customizations

## Template Generation Commands

#### Scully/Angular

```npx merced-spinup scullymarkdown projectName```

#### Sapper/Svelte

```npx merced-spinup sappermarkdown projectName```

#### Gridsome/Vue

```npx merced-spinup gridsomemarkdown projectName```

#### Nuxt/Vue

```npx merced-spinup nuxtmarkdown projectName```

#### Next/React

```npx merced-spinup nextmarkdown projectName```

#### gatsby/react

```npx merced-spinup gatsbymarkdown projectName```
The Top 3 Things I've Learned in 2020
Published: 2020-12-07 20:27:11

1) Everything worth a damn is the result of hard work. 
2) Practice being uncomfortable. 
3) Be kind to your self. 

 Everything is easier said than done. That is what you might tell yourself when you do not WANT to put in the work. What you might notice is that the people you admire for their success are comfortable in uncomfortable situations. Because they were face to face with a challenge, looked it in the eyes, and accepted. At this point, they would be kind to themselves. Because they know, learning is more important than being right. So, do not bully yourself for coming up short. Own it, reflect on the experience, and make improvements.
Java didn't update?
Tags: java, help
Published: 2020-12-07 20:11:13

I tried to download Java 15.0.1, and when to command prompt, and checked `java -version`, it said the current installed version was `14.0.2`.

Does anyone know why this is?

<div>
##<b><center><b>Thanks!<br/>Cheers!</b></center></cheers>
</div>
The reason I want to become a software engineer
Published: 2020-12-07 19:54:12

   The reason I want to become a software engineer is because I want to get a job that I love and that I can put my creative side to use. I'm married with a son and want to support them as well as set a good example to my son that through education and hard work you can succeed. How did I grow to love to code? I got interested in coding through learning some basics in game building through a online video class on C++ and C#. I then thought that maybe I should start to learn full stack web development and learned HTML, CSS and Javascript. 

   I wanted to take on a new challenge and put all the skills that I have learned over the years into good use by taking on a bootcamp and scoring that job at the end of the road. Why did I decided to take on a coding bootcamp? Learning with a cohort and having a teacher there too support me on my road to code is something that I wont get out of self teaching. I love the structure that a online coding bootcamp has to help me grow to the point I got the job.
bind(), apply() and call() me maybe: Pt. 2
Published: 2020-12-07 19:50:55

Last week, I covered [bind()](https://dev.to/arynnboniface/-12bk) and this week I'll be going over `apply()`.

First thing, this is how [JavaScript's MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply) describes `apply()`:
```
The apply() method calls a function with a given this value, and arguments provided as an array (or an array-like object).
```

Let's say you just got a new job. There are a lot of new people to meet, so let's write some code that will make introducing yourself to everyone a little bit easier:

```
let aboutMe = {
  firstName: "Joe",
  lastName: "Coder",
  job: "web developer"
}

function sayHello(greeting, message) {
  return `${greeting}. I'm ${this.firstName} and I'm a 
  ${this.job}. ${message}`
}

let introduction = sayHello.apply(aboutMe, ["Hello!", "It's nice to meet you!"])

console.log(introduction)
// returns "Hello! I'm Joe and I'm a web developer. It's nice to meet you!"
```

Can you guess what happens without apply?

```
let introduction = sayHello(aboutMe, ["Hello!", "It's nice to meet you!"])

console.log(introduction)

// returns [object Object]. I'm undefined and I'm a undefined. Hello!,It's nice to meet you!

```

It's a good thing we remembered to use `apply()` or that would have been embarrassing.

That sounds pretty similar to `bind()`, but remember: `bind()` creates a new function and `apply()` does not. If we were to try: `console.log(introduction())` we would get an error that looks something like this: `TypeError: introduction is not a function`


`apply()` is similar to `call()`, which we'll be covering next week!
#Day 5: Circular Linked List
Tags: 100daysofcode
Published: 2020-12-07 19:42:26

Today I studied about circular Linked list. I found it quite easier compared to Doubly Linked List. I just did the implementation par, how we insert and delete the node.
Due to my end semester exams, I'm unable to give hors of time to it. Nevertheless, I'm trying to do whatever I can.
How to migrate your Redis database from one cloud provider to another
Tags: redis, devops, aws, azure
Published: 2020-12-07 19:34:10

I've been doing a migration of our whole infrastructure from AWS to Azure recently. One of the services we use is Redis, which we use for caching purposes and to send our background jobs to Sidekiq. Since I don't care much about the cache part, I don't want to migrate it. But we kinda do care about the background jobs being scheduled because we are killing the source Redis endpoint. 

We did use the Database Migration Service (both AWS and Azure have it, we used the Azure one since we are on Azure now) to migrate the Postgres database, which I'll be touching on in another post. But the DMS doesn't support Redis which meant I was SOOL on that front.

There is an option of backing up the whole Redis server into an _rdb_ file and then restoring that file in Azure, but since the database would include cache data, and the backup takes longer than I want the site to be in maintenance mode, I went looking for a more elegant solution.

And the solution arrived packed into an npm package. [Redis dump](https://www.npmjs.com/package/redis-dump) npm package allow you to dump the redis database of choice into _SET_ commands txt format. The text format is acceptable as input to redis-cli which means you can import the Redis data pretty fast. This even allows you to import the data into a different Redis _database_, which wouldn't be an option with above mentioned _rdb_ dump. 

Using the tool is pretty straightforward, you first have to install the `redis-dump` npm package with `npm install redis-dump -g`. After that you run the command with your Redis server configuration, and it outputs the set commands into _STDOUT_.
```
redis-dump -h some-redis-host -p 6379 -d 7 -p REDIS_PASSWORD > redis_db.txt
```
This command will output the contents of your Redis database as Redis _SET_ commands, which you can load into the `redis-cli` binary directly. To import the backup you have to run `cat redis_db.txt | redis-cli _target_redis_connection_options_`.
#Day 4: Searching and Sorting in Singly Linked List
Tags: 100daysofcode
Published: 2020-12-07 19:24:52

It was a really busy day yesterday. I was unable to get surplus time to code yet I have firmly decided to code everyday. I love how each day I'm exposed to this world and I get to learn so much. Hence, I learnt how to search and sort in a Singly Linked List. Sorry, I wasn't able to update it on DEV yesterday.

Okay bye.
Page Loading Animation with EasyGrid
Tags: javascript, webdev
Published: 2020-12-07 19:20:36

Hey guys!
 
There are many things you can do with EasyGrid besides the obvious, but using your imagination combined with how easy to use and versatile EG is, you can take it to another level.

I made a page loading animation with just a few lines of code.

<br>
<img src="https://dev-to-uploads.s3.amazonaws.com/i/595zc6gydxsj2mxqqpyb.gif">
Check my <a href="https://dev.to/bmsvieira/easygrid-examples-of-what-you-can-do-3k17">last post</a> to see other examples. If you are interested in EG, check <a href="https://github.com/BMSVieira/EasyGrid">GitHub</a> page.

Feel free to try it! 
Thank you!
Criptografia para DB
Published: 2020-12-07 19:13:26

--Criar master
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '314159265359'
GO

--Criar certificado
CREATE CERTIFICATE [CertificadoT1] WITH SUBJECT = 'CERTIFICADO teste1', EXPIRY_DATE = '9999/12/31 23:59:59.997'
GO

--Criar chave
CREATE SYMMETRIC KEY ChaveT1  WITH ALGORITHM = AES_256  ENCRYPTION BY CERTIFICATE [CertificadoT1];
GO


--adiciona o campo varbinary na tabela para gravar o criptografado
ALTER TABLE [dbo].[tab01]  ADD senha varbinary(256); 




---inserindo o valor criptografado

-- Abro a chave
OPEN SYMMETRIC KEY ChaveT1  DECRYPTION BY CERTIFICATE [CertificadoT1];

 ---Pego o guid da chave
 DECLARE @GUID UNIQUEIDENTIFIER = (SELECT KEY_GUID('ChaveT1'))

 --insiro na base o valor criptografado
 insert into [dbo].[tab01] (cod,[nome],[senha])
 values(3,'testeCertificadoT1',ENCRYPTBYKEY(@GUID, 'xxxxxteste123'))

--fecho a chave do sistema
CLOSE SYMMETRIC KEY ChaveT1



---lendo o valor criptografado

OPEN SYMMETRIC KEY ChaveT1  DECRYPTION BY CERTIFICATE [CertificadoT1];

 SELECT
   cod,
   nome,
 CONVERT(varchar, DecryptByKey(senha)) senha
  FROM [dbo].[tab01]

CLOSE SYMMETRIC KEY ChaveT1




---Salvando o certificado para exportar

BACKUP CERTIFICATE [CertificadoT1]
TO FILE = 'C:\certificacao\CertificadoT1.CER'
WITH PRIVATE KEY (FILE = 'C:\certificacao\ChaveT1.PVK',
 ENCRYPTION BY PASSWORD = '16180')