teleren/devto huggingface dataset:
Kotlin Springboot -- Part 10 Port という interface を作って Usecase と Gateway をつなぐ
Tags: kotlin, springboot, ca
Published: 2022-09-21 14:53:38


## why

前回まで、CA で必須である Port を省略していた。

https://dev.to/kaede_io/kotlin-ji-chu-part-5-abstract-class-to-interface-nowei-i-aok

この Kotlin 基礎の回で Port で使われる interface の使い方を理解したので入れてみる。

## interface である Port を作る

```kotlin
package com.example.springboot

interface PersonPort {
    fun getAllPersons(): Persons
}
```

名前と返り値の型だけ定義

---

## Gateway をインターフェースから実装するようにする

Kotlin の文法に従って interface の中身を実装する。
クラスに実装元？の interface を書く。型みたいに。
override を関数につけて中身を書く。

クラスの引数では Driver のインスタンスを取れなくなる。
なのでクラス外部に Driver のインスタンスを作成して
そのインスタンスをクラスの内部の関数で使う。

```kotlin
package com.example.springboot

import org.springframework.stereotype.Component

val personsDriver = PersonsDriver()
@Component
class PersonsGateway: PersonPort {
  override fun getAllPersons():Persons {
    val persons = personsDriver.findAll()
    return Persons(persons.map { person ->
      Person(
        Name(person.name),
        Age(person.age)
      )
    })
  }
}
```

---

## Usecase で Port から Gateway の関数を呼び出す

```kotlin
class PersonsUsecase(
  private val personPort: PersonPort,
) {
  fun getAllPersons():Persons {
    println("Usecase/")
    println("getAllPersons/")
    return personPort.getAllPersons()
  }
  fun getPersonsByAge(age: Age):Persons {
    val persons = personPort.getAllPersons()
    return persons.filterByLessThan(age)
  }
}
```

Usecase では引数を Gateway のインスタンスから Port のインスタンスに変更する。

そして Port のインスタンスから呼ぶと、Gateway のインスタンスにつながる。

---

## Rest

```json
// 20220921234906
// http://localhost:8080/persons

{
  "persons": [
    {
      "name": "taro",
      "age": 3
    },
    {
      "name": "hana",
      "age": 5
    },
    {
      "name": "Dominique",
      "age": 11
    },
    {
      "name": "Jackson",
      "age": 11
    }
  ]
}
```

Rest は何も変わらず、これでクリーンに API が分離できた。

依存性逆転、中央に依存性を持ってくることができたのだ。

---

## まとめ

クリーンアーキテクチャで依存性逆転をしたい時は

Port にインターフェースを作って

そこから Gateway で実装を書いて

Usecase では `@Component` の依存性注入で Port を入れて
Port の関数を呼ぶようにする。それで Gateway が呼ばれる。


これでようやく


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tqqj9ehsy7by8z2de07n.png)



Rest > (Domain) > Usecase > Port > Domain > Gateway > Driver

というクリーンアーキテクチャの 6 層の分離ができた。
Do you stream on Twitch, YouTube or elsewhere?
Tags: discuss, twitch, youtube, learninpublic
Published: 2022-09-21 14:45:03

Learning in public is not a new concept, but in the past few years, folks like [Shawn Wang have really popularized it](https://www.swyx.io/learn-in-public).


Learning in public can take many forms, including streaming. If you stream to learn by interviewing folks or live code, go ahead and let everyone know where they can find you in the comments below!

Note: If you're curious about streaming, I have a series that might interest you.

{% embed https://dev.to/nickytonline/getting-started-with-streaming-on-twitch-4im7 %}

Photo by <a href="https://unsplash.com/@casparrubin?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Caspar Camille Rubin</a> on <a href="https://unsplash.com/s/photos/twitch-streamer?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
Drawing on top of an image with JavaScript
Tags: javascript, html, webdev, programming
Published: 2022-09-21 14:42:18

With Fabric.js you can draw, create different forms, and text - all in a HTML Canvas! In this video we will create free drawing, rectangles, circles, and editable text functionality. By setting a canvas background we are basically drawing on top of an image and this can all be exported to for example SVG!

{% youtube JgLpmqsHf8k %}
A Flow to Automatically Generate Shipping Labels and Email Them to Users
Tags: nocode, workflows, okta, ipaas
Published: 2022-09-21 14:55:49

---
title: A Flow to Automatically Generate Shipping Labels and Email Them to Users
published: true
date: 2022-09-21 14:32:20 UTC
tags: nocode, workflows, okta, ipaas
canonical_url: https://maxkatz.net/2022/09/21/a-flow-to-automatically-generate-shipping-labels-and-email-them-to-users/
---

[Okta Workflows](https://www.okta.com/platform/workflows/) community flows are flows shared by community members. These flows show how to solve a particular problem. You might have the same problem you are trying to solve or a similar one. Either way, these community flows will help you learn and build automations.

A directory of all other Okta Workflows community-created flows ⤵️
{% embed https://dev.to/oktaworkflows_staff/all-okta-workflows-community-created-flows-3kmm %}

_This workflow is from [Jacob Waters](https://www.linkedin.com/in/jacobdwaters/), [MacAdmins Slack Community](https://www.macadmins.org/) member, and a_ Senior IT Engineer at [Astronomer](https://www.astronomer.io/).

> If anyone is interested, attached is a workflow I put together for automatically generating shipping labels and emailing them to users. Can be helpful with dealing with offboarded users, device swaps, broken devices, etc. Can easily do this to generate labels for new hire shipments as well.
> 
> Will need a [ShipEngine](https://www.shipengine.com/) and courier (Fedex, UPS, etc) accounts to do so.
> 
> <cite><em><em> <a rel="noreferrer noopener" href="https://www.linkedin.com/in/jacobdwaters/" target="_blank">Jacob Waters</a></em></em></cite>

[Download](https://github.com/JacobDWaters/Okta-Workflows/tree/main/ShipEngine/Generate%20shipping%20labels%20with%20ShipEngine) the flow.

[![Generating shipping labels flow](https://katzmax.files.wordpress.com/2022/07/workflows_tips30_shipengine_flow.png?w=782)](https://katzmax.files.wordpress.com/2022/07/workflows_tips30_shipengine_flow.png)
<figcaption>Generating shipping labels flow</figcaption>

* * *

**More resources to help you learn** :

🎥 Short how-to [Workflows videos](https://youtube.com/playlist?list=PLIid085fSVdvyK8F4xuk49EchBPmAVNHG) to help you become a better automation builder.

🍿 A collection of helpful [Workflows tips](https://maxkatz.net/okta-workflows-tips/).
What are the differences between web designer and web developers?
Tags: webdev, programming, android, blockchain
Published: 2022-09-21 14:25:12

The difference is whatever you want the difference to be. Because those titles don't make me squat. They are the same job in some places. Elsewhere, the designer simulates it in Photoshop and the [developers](https://aspired.io/mobile-app-developer) encodes it in CSS and HTML. In some places, a designer executes the layout (HTML) and the developer executes the backend logic (PHP or something similar).
 
The titles mean nonsense in the web / software. Role and profile competencies matter. Even then, expect to do other random things based on requirements. The smaller the activity, the more likely you are to find other things to do.
Hacktoberfest 2022 is almost there! Get ready!
Tags: hacktoberfest, github, opensource, tutorial
Published: 2022-09-21 14:18:43

September is almost over and **Hacktoberfest** is to begin soon!

But what is [Hacktoberfest](https://hacktoberfest.com/)? It is not an Anonymous hacking anniversary, but a global event with the main goal to _raise awareness about Open Source and encourage as many developers as possible to participate_ regularly, not just in October.

Hacktoberfest also comes with a challenge and the first 40.000 participants to complete it, will be eligible to decide between two prizes: the official Hacktoberfest 2022 t-shirt, or a tree planted in their name.

Participation is bound to Open Source contributions, and starting from this year not only from code but also all the [other ways](https://dev.to/this-is-learning/open-source-is-not-only-writing-code-2hpj) we know are counting as contributes.

---

The entire event works thanks to maintainers of projects facilitating all the process and guess what, everyone is a winner!

Less-known projects have the chance of taking the spotlight and finding new contributors, as well as new developers approaching to Open Source have a large amount of repositories ready to welcome and guide them throughout their first steps in Open Source!

Rewards are not only for contributors, but also for maintainers are they're the ones making this event successful!

---

You can find in this video here below my take on how to participate and what to take from this year's edition:


[![Youtube Video!](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lac8ezvdr4spt3ln22u7.png)](https://youtu.be/P_YJ4CbuUs0)


---

Thanks for reading this post, I hope you found it interesting!
Feel free to follow me to get notified when new articles are out ;)
{% embed https://dev.to/balastrong %}

Do you like my content? You might consider subscribing to my YouTube channel! You can find it here:

[![YouTube](https://img.shields.io/badge/YouTube-FF0000?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/channel/UC-KqnO3ez7vF-kyIQ_22rdA?sub_confirmation=1)
Python-Multibar
Tags: python, showdev, tooling, programming
Published: 2022-09-21 14:18:15

**Python-Multibar**, flexible library for creating static progress bars.

**Github**: https://github.com/Animatea/python-multibar
**Documentation**: https://animatea.github.io/python-multibar/
**PyPi**: https://pypi.org/project/python-multibar/

**~ Quickstart**
```py
>>> import multibar

>>> writer = multibar.ProgressbarWriter()
>>> progressbar = writer.write(10, 100)
# Using __str__() method, we get a progressbar
# with a default signature.
Out: '+-----'

# Writer returns progressbar object.
>>> type(progressbar)
Out: <class 'multibar.impl.progressbars.Progressbar'>
```

For more examples see quickstart in documentation and github examples!

Example of discord leveling-bot, using python-multibar:
- https://github.com/Animatea/python-multibar/blob/main/examples/discord_example/
Gnarly Grid Challenge | CSS Grid
Tags: codepen
Published: 2022-09-21 14:08:46

---
title: Gnarly Grid Challenge | CSS Grid
published: true
tags: codepen
---

<p>The end result should be that the captioned photo grid flows seamlessly through different screen sizes, without uneven gaps between the columns or rows. </p>

{% codepen https://codepen.io/samudras_andra/pen/KKRvMOR %}
¿Por qué la programación es divertida?
Tags: books, spanish
Published: 2022-09-21 14:02:56

En la vida siempre estamos buscando diversión, sentirnos bien, contentos con las cosas que hacemos, aunque a medida que pasan los años, algunos en los cuáles me incluyo parcialmente vamos perdiendo el interés en hacer lo que nos divierte y empezamos a ver las cosas desde otro punto de vista, hoy vamos a recordar que satisfacciones nos trae la programación:

**1) La satisfacción de hacer cosas**
Así como un niño se deleita haciendo un pastel de lodo, así el adulto disfruta construyendo cosas aunque difieran un tanto del lodo, de modo que deseamos estar en actividad constante, de movernos continuamente, creo que quedarnos en un solo lugar sin poder mover una pestaña va en contra de nuestra naturaleza como seres humanos siempre estamos en movimiento no solo nuestro cuerpo visible como las extremidades(brazos, pies) sino también lo que no se ve como la sangre siempre está en circulación, hacer cosas y más aún si sirven para un propósito con recompensa nos llenará de alegría.


**2) Placer de hacer cosas útiles para los demás**
Todos anhelamos que otras personas usen lo que hemos creados y que claro está les sea de utilidad, nos agrada sentirnos que estamos sirviendo de aporte para algo más grande que podemos cambiar la vida de una persona, de la sociedad o del mundo entero, y a esto puede ayudarnos la programación podemos crear aplicaciones o sistemas que sean de gran utilidad, nuestro código puede llegar a hacer usado por miles, millones o billones de personas.

**3) La fascinación de crear objetos complejos**
Lograr reunir distintos esfuerzos, conocimientos, habilidades, investigaciones de otras personas en una sola suma, crea algo complejo que en un muchas ocasiones nos ha costado muchas horas de pensamiento profundo, de encontrar la pieza faltante en el rompecabezas de nuestro código, ocasiones de ponernos la bata de científicos y empezar a examinar objetivamente cada parte de nuestro trabajo para finalmente entregar algo a simple vista sencillo pero internamente complejo.

**4) La satisfacción del aprendizaje continuo**
La programación y el mundo IT en general tiene una naturaleza no repetitiva. Siempre hay un problema nuevo que resolver, lo cual abre nuestra curiosidad hacía nuevas fronteras, haciendo que una vez resuelto siempre se aprenda algo nuevo en ocasiones algo práctico, otras algo teórico y a veces ambos.


Para finalizar quiero expresar que en lo personal que programar es semejante a cualquier otro arte como, pintar, dibujar, cantar, y otras actividades más. Cada persona tendrá su forma de expresar el arte y en código se vuelve igual tiene esa flexibilidad de permitirnos hacer lo que deseamos, como un lienzo en blanco listo para empezar a pintar con nuestros óleos o como el barro listo para ser moldeado y darle la forma que deseamos.
One tool that can help you as a developer
Tags: discuss, programming, tooling, productivity
Published: 2022-09-21 13:54:27

From our code editors to version control systems, as developers we are all surrounded with tools built with the intentions of making our jobs easier.

And I think it is safe to say the more tools you know how to use, the easier and better your life become as a developer.

With that being said, I would like to introduce to you one of the tools I use whenever I code... or google (to be precise). Some of you may already know this while others may not, but I still feel it's worth sharing.

The name of this tool is [CodeGrepper](https://chrome.google.com/webstore/detail/grepper/amaaokahonnfjjemodnpmeenfpnnbkco?hl=en).

It is a chrome extension you can install, and once installed, whenever you search online for anything related to programming, if it has an answer to your query, it displays snippets of code or information based on what you have searched. And this information/code snippet is displayed on top of your search result.


![One tool that can help you as a developer
](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d6uimhb186oxy145h9by.PNG)

It saves me some time whenever I do research because I wouldn't have to sometimes go through a ton of websites to get the information I need. 

If it helps me, I feel like it may help you too.

What other tools do you use in your daily life as a developer?
The power of a good community
Tags: beginners, programming, devjournal, webdev
Published: 2022-09-21 07:28:08

If you're just starting out in tech, then you need to read this.

Shortly before I transitioned into tech, I always had this imposter syndrome. I didn't feel I was good enough. I thought people working for trillion-dollar companies and the like were like superhumans. To begin with, I didn't even own or know how to operate a laptop well until my final year in school. This made me think I wasn't good enough to be in tech. But one of the things that kept me going was my group of friends.

It was tough when starting out, especially for someone like me who took the path of self-learning. There were just too many resources that sometimes I felt overwhelmed. I wanted to learn everything to be at the level that I'd get into the big tech companies, I thought. The electricity situation wasn't any better. I could remember then that the power holding companies were more likely to restore power at night than at day, so I'd have to be awake mostly at night. It still helped to an extent because I could barely afford a data plan during the day to enable me to stream content on YouTube and the like, so I'd do night plans, which were relatively affordable some days thanks to the Telco anyway, but the constant battle with trading my sleep for learning was becoming tiring. Also, I had one of those laptops that would take an eternity to process a command, and it was very frustrating.

There were many reasons to give up in my head. Some days I did give up, but thanks to my friends and brothers who were in tech, they still pushed me. They were days we'd meet and they would just be talking tech and I couldn't contribute enough, so I'd feel challenged to go back and learn more. Luckily for me, it was the peak of COVID, so we were all home and I was disengaged from my place of primary assignment due to reality. All of these kept me going. They encouraged me to apply for internships and told me that I was never going to be too ready if I kept waiting. I landed my first tech internship, and from there it was another learning curve. 

The essence of this post is that if you're just starting out in tech, do not underestimate the power of having a community of tech friends. Tech can be tiring and overwhelming when starting out. You'll always have that imposter syndrome that you're not good enough, so giving up will always be imminent, but if you have a good community, you'll always find a way of pushing through or coming back. Also, have a niche. Don't try to learn everything. There are too many resources out there, but pick the ones that belong to your niche. Having a mentor can help in this aspect as well. Never wait to be too ready before you start applying for jobs and internships. If you attend the interview and fail, they'd also teach you something.
Second Year Group Project
Tags: webdev, javascript, beginners, php
Published: 2022-09-21 13:43:35

Recently our university assigned us with group projects. It's a group project and our team has four members. For that we thought about developing web based clinic management system. I myself have experience with web technologies to certain level and other members are beginners in web developing. For the project we can't use any frameworks because this project is a learning project to ready us for our next year project.
Therefore we decided to use HTML, CSS, JS for frontend and PHP and MySQL for backend. Anyone got suggestions on how the development should be started and best practices we should follow? any tips and tricks is also appreciated
P.S -: We are using MVC architecture
Sending Email from Node.js via Zoho & SMTP
Tags: javascript, programming, tutorial
Published: 2022-09-21 13:43:21

*I work for [Akkio](https://akkio.com), where I'm building out a no-code predictive AI platform. If you're looking to harness the power of AI without needing a data scientist, give us a try!*

## Prerequisites

You'll need a few things:

- `nodemailer`, an npm package for sending email. Install it with `npm install nodemailer`.
- A SMTP provider set up. I personally use Zoho's $12/yr plan, but any SMTP provider out there should work.

## The Code

We first put the SMTP credentials in a `.env` file, which we'll use to access them in our code. With Zoho, it's likely easiest to just use your main account login details here.

```plaintext
EMAIL = <put your email here>
PASSWORD = <put your password here>
```

We then import `dotenv` and `nodemailer` and use it's createTransport function to create a transporter object. We pass in the SMTP credentials as an object.

```javascript
import dotenv from 'dotenv'
import nodemailer from 'nodemailer'

const mailTransport = nodemailer.createTransport({
  host: 'smtp.zoho.com',
  port: 465,
  secure: true,
  auth: {
    user: process.env.EMAIL,
    pass: process.env.PASSWORD,
  },
})
```

Note that I'm using `import` instead of `require` here. This is because I'm using ES Modules, which is the (not so new, at this point) standard for JavaScript. You can read more about it [here](https://nodejs.org/api/esm.html).

Next, we define whatever HTML we're trying to send:

```javascript
let html = ''
let name = 'John Doe'
html += `<div>Hello <span style="color: blue">${name}</span>! This is HTML that you can do whatever with. You can use template strings to make it easier to write.</div>
```

After this, we can use the `sendMail` function to send an email. We pass in an object with the email's details.

```javascript
import { format } from 'date-fns'
const mailOptions = {
  from: process.env.EMAIL,
  to: emailAddress,
  subject: `Newsletter - ${format(new Date(), 'MMM d')}`,
  html: content,
}
mailTransport.sendMail(mailOptions, (error, info) => {
  if (error) {
    console.log(error)
  } else {
    console.log(`Email successfully sent to ${emailAddress}.`)
  }
})
```

A few notes:

- If you aren't using Zoho, most providers' SMTP details are well-documented. Note that free providers like Gmail have checks against some kinds of automated use which make this kind of thing more difficult. I recommend just getting a cheap provider like Zoho.
- The `sendMail` function has a `text` option as well, which lets you send just pure text.

## Conclusion

Hope you learned something! You can check out my other blog posts at [https://andenacitelli.com](https://andenacitelli.com).
Becoming a software engineer is good?
Tags: programming, javascript, webdev, beginners
Published: 2022-09-21 13:25:02

There is never been a better time to become a software engineer. The profession allows analytical thinkers to build the products and services that shape the world. solve problems that affect millions of people, and be at the forefront of technological innovation. Coding plays a big role in software engineering, but it is only one of many core skills software engineers possess.

The profession is consistently ranked among the top in the world for its number of job openings, future job prospects, and work-life balance. Software engineers enjoy competitive salaries—an entry-level software engineer in the United States has an average salary exceeding $100,000, according to Indeed.

So, is software engineering a good path for you to follow? I wouldn’t recommend it if you can’t find a job near home and don’t feel like moving or wasting time commuting. And I wouldn’t recommend it if you don’t like computers or screens, of course. But I suggest you try it if you think you’re up for a challenge and a new world of possibilities.
Can old dogs learn new tricks?
Published: 2022-09-21 13:02:47

Back then, the web universe was very simple. Just a bunch of tools here and there and jQuery was the new black and it was a mess. I was coding in Notepad++ the entire 9 years! WordPress was dominating the blogger sphere and it turned into a swiss-army knife of some sort and now turning into a big pile of cow dung.  

Today there's a dizzying array of IDEs, Frameworks and everything coder boys want to get their hands into. SPAs are white hot and JS frameworks are popping up like mushrooms.   

To be honest I let myself cruise along. Happy go lucky. I was earning a decent amount for me and my kids so I was flipping WP sites without ever touching Angular or React and I am paying the price. Competitiveness was thrown out the window.

I'm turning 39 next month and boy I feel old. I've been in the Web Dev business for almost 14 years to date. Started as a junior PHP and now tinkering with these fancy JavaScript toys. I've successfully rebuilt a site from AngularJS to Angular 11 (that's not a very pleasant experience) and I'm now playing around with react and hopefully finish up my craiglist-esque website.

I need to re-learn JavaScript fast. Yes, I can cough up a decent JS code but it's not enough. Questions like "What is the event loop" or "What is shadow DOM" are most likely to be asked during interviews. Like seriously there are those now?

With luck I found frontendinterviewhandbook.com and trying to get eloquent enough with JS and teach this old dog some new tricks.