teleren/devto huggingface dataset:
A Super Basic CRM for Pet Professionals
Published: 2022-08-15 00:01:30

My journey to building an app that Dog Groomers can use to run an effective business has reached another little milestone.  I have decided to work on small components that will be used in the bigger application and press on with the whole package at the same time; alternating between them.  As I learn new things, often times use cases come to mind and I am excited to build them out.  

![Picture of app with dog](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8tdgt8wh77mo0r6crb6p.png)

So this basic CRM uses React on the front end and Ruby, Sinatra, Active Record on the back end.  This stack is super fun to work with and I am proud of what a rookie was able to accomplish in a week!  As you may know I am attending a coding bootcamp and it is a boot camp for sure.....  There is always so much to learn and it is great to have a little time to showcase your ideas.

![Website with pictures of clients](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nqa9njwevujchahqur9v.png)

It has two basic tables, one for clients and one for dogs.  It has a one to many design where each client can have many dogs and every dog belongs to a client.  Migrations took care of building out the backend and then some Models that inherited ActiveRecord::Base made it super easy to make some routes that my React front end could hit up for some info.


![Website with pictures of dogs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tq8wyvxwp7nhfk0k9z3p.png)

The Dog page is built in a similar way.  A "card" component takes care of displaying the data in a clean way after the good 'ole map function iterates what comes back from my no pun intended FETCH!  Another cool thing I got to practice was using the Faker Gem to seed the database.  They even had fake info that I used to create the dogs.  It is super helpful to be able to edit and delete things on the fly and then run $ rake db:reset or db:reseed to just start over with fresh meaningful data.


![Webpage to edit client](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k8iv2wdg5mikt0nca011.png)

Let's face it with no update there is no CRUD!  This snip shows a page that displays the client's dog and the ability to edit the clients info.  This was interesting because I really understand the idea behind reusable code in react.  In about 3 lines the Dog Card component came to life on this page!

Overall I am happy with the initial version of my pipe dream.  It lacks most every feature I want lol; but you have to start somewhere.  It is funny how you go back and look at code you wrote just a few days before and pat yourself on the back, "Wow I can't believe I figured out that filter method".  I can only imagine how the pros feel when they accomplish something I probably don't even know is possible at this point!!

Version 2.0 is going to have Ruby on Rails and I plan on practicing my deployment skills.  I am sure it would be nice for those reading this to have something to play around with.... stayed tuned I'm on it!!
Handling container shutdowns in app code
Published: 2022-09-20 17:07:55

---
title: Handling container shutdowns in app code
published: true
date: 2022-08-15 00:00:00 UTC
tags: 
canonical_url: https://jonfriesen.ca/articles/handling-container-shutdown
---

Most small apps start out running on a PaaS these days such as [DigitalOcean App Platform](https://www.digitalocean.com/products/app-platform). Platforms like these control the environment pre and post app execution. This isn't a problem when it comes to pre-execution as you can run your startup tasks when your app is started.

However, running clean up code when the app, or more specifically the container is being shutdown isn't as straightforward. This is where we can feed two birds with one slice of bread using [Linux Signals](https://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html).

The signal I use personally is `SIGTERM` -- which indicates intent to terminate the process. This signal is sent by the operating service when the client container is going to be shutdown. While you _can_ catch this signal and prevent shutdown, most of services will send a `SIGKILL` signal forcing shutdown of the app after a certain time duration. In some cases this is configurable.

We feed two birds because using `SIGTERM` an app can:

1. execute clean up code
2. gracefully shutdown the application

This ensures that any operations an app is in the middle of, have _some_ time to exit. So what does that look like?

```
// javascript
process.on('SIGTERM', () => {
    console.info('SIGTERM signal received.');

    /**
     * This is where cleanup code can be run. For example, closing down the http server.
     */
    console.log('Closing http server.');
    server.close(() => {
        console.log('Http server closed.');
    });

    process.exit(0)
});

```

This example snippet runs in a nodejs environment, attaching an anonymous function `() => {...}` to the process when `SIGTERM` signal occurs. The clean up code will run and the `server` which is an http server in this example, but could be any service time, is closed, and `process.exit(0)` is fired.

> Note: Exit code `0` means the process exited successfully, any other exit code indicates an error of some type.

## Further reading

[Kubernetes best practices: terminating with grace](https://cloud.google.com/blog/products/containers-kubernetes/kubernetes-best-practices-terminating-with-grace) is a great article which overlaps heavily with the content above with additional detail on expanding the durations and how these signals work in Kubernetes.
Javascript Tagalog - For of Loop
Tags: javascript, tagalog, pinoy, forof
Published: 2022-08-14 23:35:19

**Ano ngaba ang For of Loop sa Javascript?**
yung for of loop ay parang shorter version lang siya ng regular na for loop. I think the best way para matutunan niyo is to just look at these pictures

![Javascript Pinoy Tagalog Object For Loops For of](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hfcli9s4et531mhqkfx9.png)
pwede mo palitan yung "elementName" sa gusto mong name tapos yun yung variable name na gagamitin mo sa loop, for ex. if "x" yung lalagay ko sa element name, then para ma access ko yung variable gagamitin ko yung "x" `Console.log(x)`

---

**Deconstruction works also dito sa for of loop**

![Javascript Pinoy Tagalog Object For Loops For of](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/23bc4tfkmhs6iy2whl6n.png)

**Eto using for of loop sa objects**

![Javascript Pinoy Tagalog Object For Loops For of](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6y61bjth3nzqsbqndmcj.png)

---
**More tagalog Javascript Learning Resources:**
https://javascript-methods-in-tagalog.vercel.app/
Approaching my Ikigai
Tags: personalgrowth
Published: 2022-08-14 23:03:37

I do think becoming a developer is my Ikigai. The point is I need to work harder. Here I open this dev.to account to log my personal growth and it is less about technical side of stuff. I will log my projects at work and opensource projects involving. I will write down my learning plan. I will review books I read. I will share [other's/my] opinion and tweets related to coding.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yau9b0tz1ve5g1bdp2tw.png) 
[source: https://uxmastery.com/your-design-ikigai/]
Javascript Tagalog - Alert
Tags: javascript, pinoy, tagalog, alert
Published: 2022-08-14 23:01:58

**Ano ngaba ang Alert sa Javascript?**
naranasan niyo na ba na may nag po pop-up na message sa browsers?
yun yung "Alert" ng javascript isa siyang dialog na lilitaw sa taas.


![Javascript Pinoy Tagalog Filipino Alert](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lvm61k0rgj1nft7do5xu.png)
![Javascript Pinoy Tagalog Filipino Alert](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rqpuz6slsbyxgu65907d.png)
pa-pause ni javascript ang execution until maalis ng user yung dialog box so wag niyo i over-use tong feature na to as much as possible.

**Return Value is "undefined"**

![Javascript Pinoy Tagalog Filipino Alert](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5jhva50s82gqko4o1bpi.png)

---

**More tagalog Javascript Learning Resources:**
https://javascript-methods-in-tagalog.vercel.app/
Swoole Benchmark in Laravel
Tags: swoole, laravel, php
Published: 2022-08-07 02:01:19

Ola pessoas tudo bem?

Hoje trago um teste que eu fiz quando fiquei sabendo do Swoole.

**O que é Swoole?**
Traduzindo da documentação oficial: Swoole é uma estrutura de rede de alto desempenho que usa um modelo de E / S sem bloqueio, assíncrono e orientado a eventos. Pode ser usado para desenvolver TCP, UDP, socket Unix, HTTP, serviços Websocket simultâneos de alto desempenho, escalonáveis.

Entendeu nada? Em poucas palavras o Swoole é um servidor PHP assíncrono.

**O Setup do Teste**
Testei na minha própria máquina. Windows 10, I7 1.8 GHz 16 GB de RAM.

Testei em um projeto brásico usando Laravel com um model chamado empresa com 4 campos.

Criei 3 ambientes distintos, um rodando no windows mesmo com o php artisan serve (para gerar o servidor via php), os outros dentro do Debian (WSL), um rodando php artisan serve e outro rodando no Swoole

Criei um Crud normal e cadastrei 100 empresas.

O banco de dados usado foi o SQLITE mesmo. Preguiça de instalar o mysql.

O teste era somente chamar 100 vezes (de uma vez só) as 100 empresas e ver quanto tempo levaria para retornar todos os requests

**O Resultado**
Em primeiro lugar………………….SWOOLE. os 100 requests com 100 empresas cada levou somente 6.71s para retorar todos os requests


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

Em segundo lugar ficou no Debian puro sem Swoole, com 15 seg.


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

E em último lugar obviamente ficou o windows levando os longos 34.54 seg para retornar todos os requests


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

**Conclusões**
A diferença entre windows e o swoole foi de 566%. Maior que eu eu imaginei.

E o que me surpreendeu foi que somente colocando no Linux o tempo levando metade do tempo do windows.
small NodeJS project
Tags: personalgrowth
Published: 2022-08-14 22:55:29

I am developing a WhatsApp Chatbot in NodeJS for my employer. I prefer to use heroku as the server. Here are some basic commands used:

`
heroku login
npm init
npm install
heroku local web

git add ./
git commit -m "xxxxxx"
git push heroku master

heroku logs --tail
`
Drupal Seed Data
Tags: deupal, php, programming
Published: 2022-08-14 22:47:09

**Seed Data**
You use seeding to provide initial values for lookup lists,
for demo purposes, proof of concepts and of course for development.

To **modules\custom\my_module\src** we add a directory called **SeedData**. We add a file
called **SeedDataGenerator.php** to modules\custom\offer\src\SeedData.
The class will for now just create a dummy user.

```php
<?php

namespace Drupal\my_module\SeedData;

use Drupal\user\Entity\User;
use Drush\Drush;

/**
 * SeedDataGenerator.
 *
 * @package Drupal\my_module
 */
class SeedDataGenerator {

  /**
   * Function to create a seed data.
   *
   * @param string $entity
   *   The type of entity that needs to be created.
   *
   * @return null|int
   *   The number of entities created.
   */
  public function generate(string $entity){
    $count = 0;
    switch ($entity) {
      case 'user':
        $count = $this->seedUser();
        break;
    }
    return $count;
  }

  /**
   * @return int
   *   The number of users created.
   * @throws \Drupal\Core\Entity\EntityStorageException
   */
  private function seedUser() {
    $count = 0;
    
    $user = User::create();
    $user->setUsername('testUser');
    $user->setPassword('P@ssw0rd');
    $user->activate();
    $user->enforceIsNew();
    Drush::output()->writeln('<comment>Creating user test</comment>' );
    if ($user->save()) {
      $count++;
    }
    return $count;
  }
}

```

Proceed with adding a drush command that will trigger the class:
Add **custom/my_module/src/Commands/SeedGeneratorCommand.php** and configure
further. The final file looks like this:

```php
<?php

namespace Drupal\my_module\Commands;

use Drupal\my_module\SeedData\SeedDataGenerator;
use Drush\Commands\DrushCommands;
use Drush\Drush;

/**
 * Class SeedGeneratorCommand.
 *
 * @package Drupal\my_module\Commands
 */
class SeedGeneratorCommand extends DrushCommands {

  /**
   * Runs the mymoduleCreateSeeds command.
   *
   * @command mymodule-create-seeds
   * @aliases mymodulecs
   * @usage drush mymodule-create-seeds
   * Display 'Seed data created'
   */
  public function mymoduleCreateSeeds():void {
    $seed = new SeedDataGenerator();
    $count = $seed->generate('user');
    Drush::output()->writeln('<info>'. $count . ' user(s) created</info>' );
  }

}

```
One more thing. Add a file **custom/my_module/my_module.services.yml** and add:

```yml
services:
  offer.commands:
    class: Drupal\offer\Commands\SeedGeneratorCommand
    tags:
      - { name: drush.command }
```

That’s it! Clear cache and see if our system has registered our command

```bash
$drush offer-create-seeds
```

References:

- [Learning drupal 9 as a framework](https://stefvanlooveren.me/courses/drupal-9-framework)
Kubernetes for beginners
Tags: kubernetes, devops, devjournal, tutorial
Published: 2022-08-14 22:15:00

Before Jumping into Kubernetes, you need to have a good understanding in Docker. And you can checkout Here: [Link](https://dev.to/sandeepv1404/docker-for-beginners-13n5)

### What is Kubernetes?

Kubernetes or K8S is an Open-Source Container Orchestration Tool which was originally developed by Google. It is useful for managing container applications in different deployment environments.

### What are its uses?

- It is useful for building microservice applications.
- It is useful for managing n number of containers.

### What are the benefits of K8S ?

- It has high availability
- It gives high performance
- Flexibility for developing applications and its components with different stacks. 
- It is helpful for Backup/Restoring the data.


### Kubernetes Components

#### Pod:

- Its smallest unit of K8S
- Its useful for building one applicaton
- Each Pod has its own IP address

#### Service:

- It has Permanent IP Address
- Lifecycle of Service and Pod are not connected
- It is useful in Load Balancing

#### Ingress:

- Its useful for hiding the IP Adrress and replacing it with Domain


#### ConfigMap:

- It is useful for storing external configuration of the application.
- The text is stored in plain text format, so for storing credentials we have Secret, which is a component in K8S.

#### Secret:

- It is used to store secret data.
- The text is stored in base64 format.

#### Storage:

- It can be used in pod and can store in local machine.
- Also, outside of the K8S cluster. 


#### Deployment:

- It is a blueprint for creating pods.

#### StatefulSet:

- It is useful for building stateful applications or databases.  
- Its difficult to deploy Applications with StatefulSet.

## Kubernetes Architecture:

### Node Processes:

- Each node has multiple pods.
- Each node must be installed with 3 processes.
- It acts like worker node to the actual network.
- 3 processes are Kubelet, Kubeproxy, Container Runtime.
- Kubelet interacts with both container and node
- Kubelet starts the pod with a container inside.
- Kubeproxy forwards the requests.

### Master Processes:

- There will be four processes running on every master node.
Created a CLI tool to backup Slack export data in Excel
Tags: go, slack, excel
Published: 2022-08-14 22:09:33

Starting September 1, 2022, the retention period for messages in Slack will be limited to 90 days.
https://slack.com/blog/news/pricing-and-plan-updates

I had been using Slack with my family on a free plan, but decided to back these up because message exchanges prior to 90 days would be lost.

There was a way to use the Slack API, but this time decided to use exported data that can be downloaded from the Slack GUI.
(Since it is not via the API, it does not seem feasible to do something like automatic backups on a regular monthly basis, but oh well.)
I chose Go as our language because wanted to learn Go.


Here is the actual CLI tool created.

https://github.com/shinshin86/slack-export-data-to-excel

(Oh, the package name is not Go-like...😅)

Installation is done with the following command.
(It is assumed that Go is installed on your machine)

```sh
go install github.com/shinshin86/slack-export-data-to-excel@latest
```

## How to backup slack export data

Follow the documentation below to download the Slack export data.
https://slack.com/help/articles/201658943-Export-your-workspace-data

Next, unzip it in an appropriate directory and run the following command to generate an Excel file based on the exported data.
Enter the directory of the exported data in the `<export data path>` field.

```sh
slack-export-data-to-excel <export data path>
```

Since backups are generated based solely on Slack export data, data not included in the export data will naturally not be backed up.
For example, private messages and DMs cannot be backed up.

## PR is welcome!
As you can see from the repository, I am still new to writing Go.
If you have a trick to make it better, please send me a PR.
Question - Add values from an array brought from firebase and display them in a label
Tags: typescript, html, firebase, angular
Published: 2022-08-14 22:07:30

I am doing my project in ionic 6 with angular and a firebase database. I need a typescript function that adds the values fetched from an array that are extracted from a collection in firebase.

```
   async getGastos() {
        const uid = await this.auth.getUid();
        const ruta = 'Usuarios/' + uid + '/Gastos';
        this.firebaseService.getCollection<Gasto>(ruta).subscribe(res => {
            this.gastos = res;
            // this.gastos.forEach(gasto => {
            //     gasto.monto_gasto;
            // });
        });
        this.setTransc()
           }
```

//Function to fetch the data from the "expenses" collection, the "expense_amount" column and add this data to the "setTransc" function

```
    async getIngresos() {
        const uid = await this.auth.getUid();
        const ruta = 'Usuarios/' + uid + '/Ingresos';
        this.firebaseService.getCollection<Ingreso>(ruta).subscribe(res => {
            this.ingresos = res;
            // this.ingresos.forEach(ingreso => {
            //     ingreso.monto_ingreso
            // });
        this.setTransc()
        });
    }
```
//Function to fetch the data from the "income" collection, the "expense_amount" column and add this data to the "setTransc" function

```
    setTransc() {
        let sumaGastos = 0;
        this.gastos.forEach(gasto => {
            sumaGastos += gasto.monto_gasto
            console.log("ggg", sumaGastos);
        });

        let sumaIngresos = 0;
        this.ingresos.forEach((ingreso, i) => {
            sumaIngresos += ingreso.monto_ingreso
            console.log("iii", sumaIngresos);
        });
    }

    async todo(){
        await this.getGastos();
        await this.getIngresos();
    }
```
"setTransc()" function to sum the values of the array, then the "todo()" function has an await since the elements return a promise before being displayed.

It should be noted that I need to press a button for the values to be operated because I don't know how to do it in the background to show it directly in the next view.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jguyv0xv07uxdazs5rdy.png)
Thanks in advance and sorry for my bad English.
socket.on ('private_chat) Render multiple
Published: 2022-08-14 20:54:14


import {View, Text} from 'react-native';
import React from 'react';
import socketio from 'socket.io-client';
const SOInput = () => {
  const socket = socketio.connect('url');
  React.useEffect(() => {
    socket.on('connect', () => {
      console.log('This is Soket id' + socket.id);
      socket.emit('register', 'number');
    });
  });

  socket.on('private_chat', function (msg) {
    console.log(msg.friend);
  });

  return (
    <View>
      <Text>SOInput</Text>
    </View>
  );
};

export default SOInput;
Day 127: Family reunion
Published: 2022-08-14 20:31:04

Hi!
As promised yesterday today there was no coding instead I got a chance for reconnecting with some family member which was great since It had been a while since I had even meet some of those people mainly due to much time I invest in coding related stuff and spending time with people we care about is very very important. But I read a bit about Setting Husky and lint staged which is one of the task I have to do on the personal project I'm working on.
Tomorrow I think I will focus on implementation plan documentation and the week plan but currently I don't have like big plans planned for the upcoming week but I will see what to do 

Signing off...
What's one mistake you've made in your career you can't forget?
Tags: webdev, discuss, programming, career
Published: 2022-08-14 20:28:02

In course of our journey as software developers,  we've encountered so many moments that'll forever stay in our hearts.

And so for this week , I would like to ask what's that mistake you made that has a spot forever in your journey.

Was is by deleting a database?
Crashing a code in production?

Let's hear you.
Thanks .
เที่ยวเชียงใหม่กับรถตู้เชียงใหม่
Published: 2022-08-14 19:23:00

เราเชื่อมั่นในการให้บริการรถตู้เช่าที่เชียงใหม่ที่จะมอบความสุขให้กับคุณและเดินทางท่องเที่ยวได้อย่งามีความสุขและการบริการที่เป็นหนึ่งในการพาทุกท่านท่องเที่ยวพร้อมทีมงาน[รถตู้เช่าเชียงใหม่](https://www.xn--72cfa6be4efd2f2c8a7b0fc3c5djf.com)ใส่ใจคุณกับทีมงานที่เป็นมืออาชีพเรามั่นใจว่าเราจะได้ต้อนรับทุกท่านเป็นอย่างดีในการให้บริการของเราทีมากด้วยประสบการณ์และมืออาชีพที่จะนำพาความสุขและความท่องเที่ยวให้กับทุกคนขอเพียงไว้ใจเราในการเดินทางครับจะทำให้ทุกท่านไม่ผิดหวังแน่นอน
What is the best way to read directories in Nodejs?
Tags: node, nodejstip, javascript, webdev
Published: 2022-08-14 19:04:00

Different ways to read directories in Nodejs!
Which way do you use? Why?

Let me know what you think in the comments


![readdir vs opendir](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hnkak7kq73l1jtk95mwn.png)

-----------

Make sure to check my profile for more tips from the Nodejs world
Top 6 Github Repos for JavaScript Developers...
Tags: javascript, webdev, tutorial, beginners
Published: 2022-08-14 18:08:00

# ✨ Master JavaScript from these Repositories


1. trekhleb/javascript-algorithms

https://github.com/trekhleb/javascript-algorithms


2. lydiahallie/javascript-questions

https://github.com/lydiahallie/javascript-questions


3. leonardomso/33-js-concepts

https://github.com/leonardomso/33-js-concepts


4. ryanmcdermott/clean-code-javascript

https://github.com/ryanmcdermott/clean-code-javascript


5. getify/You-Dont-Know-JS

https://github.com/getify/You-Dont-Know-JS


6. sorrycc/awesome-javascript

https://github.com/sorrycc/awesome-javascript



If you found helpful,

Please consider following @keshavgbpecdel for more contents