teleren/devto huggingface dataset:
Avent of Code - Day 01 - Calorie Counting
Tags: programming, adventofcode, coding, algorithms
Published: 2022-12-01 23:11:28

[Advent of Code](https://adventofcode.com/) occurs at Dec 01 to 25 where each day, you will need to solve a puzzle. It is Festival and the problem statement is mostly related to Christmas.

![image.png](https://cdn.steemitimages.com/DQmdx8TUEZXywNNdTfz2TpMMx2iqmwqJSQywYpKkPQ2cuyB/image.png)

You can join my leaderboard by entering this code `1019229-a302d391`

## Day 01 - Calorie Counting
Finding the Largest Sum of a Group
The first few days are usually simple/easy/trivial. You don't need to submit code, but you would probably need to write code to get the answer. Some people can solve easy ones in Excel.

### Q1 - the largest sum
```python
file1 = open("0.txt", "r")
ans = []
cur = 0
while True:
        line = file1.readline()
        if not line:
                break
        line = line.strip()
        if not line:
                ans.append(cur)
                cur = 0
        else:
                cur += int(line)

ans.sort()
print(ans[-1] + ans[-2] + ans[-3])
```

### Q2 - the largest 3 sums
```python
file1 = open("0.txt", "r")
ans = []
cur = 0
while True:
        line = file1.readline()
        if not line:
                break
        line = line.strip()
        if not line:
                ans.append(cur)
                cur = 0
        else:
                cur += int(line)

ans.sort()
print(ans[-1] + ans[-2] + ans[-3])
```

<hr/>

### [Steem](https://steemyy.com) to the Moon!
Day 659 : Free
Tags: hiphop, code, coding, lifelongdev
Published: 2022-12-01 22:56:06

_liner notes_:
- Professional : Had a meeting with the team today. It was good seeing everyone. Got some good feedback on the recording and edit I did on a video yesterday. Didn't have to change anything. Nice. Just added the company's intro and outro. Finished the timestamps. Added the script I used to the ticket. Started reviewing a co-worker's blog post, then I passed out. haha I guess I was tired from meetup last night.

- Personal : Went to the meetup last night. Had a really good time. Got to catch up with folks I haven't seen in a while and met new people. I got to do a quick lightning talk about my latest side project. Also, the livestream setup worked! It wasn't totally problem free (a person's browser would share their screen, so we had to use another browser). You can see the recording here: https://otech.events/event/289839377 Looking forward to doing more livestreams.

![A large hill on an island in Clew Bay, Ireland with a mountain in a distance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/79xhixeqpumbbbftp474.jpg)

Going to go through some tracks for this week's radio show. After that, I want to check out the new "Wednesday" show on Netflix and maybe some anime.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube QFi4YNorvVI %}
Thankfulness 2022
Tags: random
Published: 2022-12-01 22:41:44

---
title: Thankfulness 2022
published: true
description: My yearly post of things I am thankful for.
tags: random
# cover_image: https://www.pexels.com/photo/letter-tiles-on-flat-surface-5912586/
# Use a ratio of 100:42 for best results.
# published_at: 2022-12-01 22:37 +0000
---
I've been quiet here - my life has taken a turn for the better with a new job that keeps me challenged and learning. I've been quietly thankful for many things this year. And with all the changes that have happened, it's time to share them.

This will be a short post - with many stories and people behind the words here.

To all of you who I've crafted for: know that you are a blessing, and I'm glad I could contribute to your lives in this manner.

To those generous folks who have created and allowed me to have some of your work: thank you. These are placed around the house, and nearly always bring a smile and a thought of you.

To those who have worked with me, formally or informally: your patience, ability to explain things, and help me find the answers on my own is a great gift. I love having you in my world - and am thankful that we could share ideas.

And last but very not least. . . 

Those I have worked with professionally this year: You have been a needed source of so much more than income. Thank you for sharing your skills, knowledge, and -at times - frustration to help me stay on track, growing, and contributing.
how to create an end to end encrypted server data transfer
Published: 2022-12-01 22:08:17

To create an end-to-end encrypted server data transfer, you can use a combination of public-key cryptography and symmetric-key cryptography. This will allow you to securely transfer data from the client to the server, and vice versa, without either party knowing the decryption key.

Here is an example of how you can use public-key cryptography and symmetric-key cryptography to create an end-to-end encrypted server data transfer in Node.js:

```nodejs
const crypto = require('crypto');

// Generate a pair of public and private keys for the server
const { publicKey, privateKey } = crypto.generateKeyPairSync('rsa', {
  modulusLength: 2048,
  publicKeyEncoding: {
    type: 'spki',
    format: 'pem'
  },
  privateKeyEncoding: {
    type: 'pkcs8',
    format: 'pem'
  }
});

// Send the server's public key to the client
sendServerPublicKeyToClient(publicKey);

// On the client-side, generate a random key for encrypting the data
const key = crypto.randomBytes(32);

// Encrypt the data using the key
const data = 'your data goes here';
const encryptedData = crypto.createCipher('aes-256-cbc', key).update(data, 'utf8', 'hex');

// Encrypt the key using the server's public key
const encryptedKey = crypto.publicEncrypt(publicKey, key);

// Send the encrypted data and the encrypted key to the server
sendEncryptedDataAndKeyToServer(encryptedData, encryptedKey);

// On the server-side, decrypt the key using the server's private key
const key = crypto.privateDecrypt(privateKey, encryptedKey);

// Decrypt the data using the key
const decryptedData = crypto.createDecipher('aes-256-cbc', key).update(encryptedData, 'hex', 'utf8');

```

In this example, the server generates a pair of public and private keys, and it sends the public key to the client. The client generates a random key, encrypts the data using the key, and then encrypts the key using the server's public key. The client sends the encrypted data and the encrypted key to the server. The server uses its private key to decrypt the key, and then uses the decrypted key to decrypt the data.

This way, neither the client nor the server knows the decryption key, because the key is encrypted using the server's public key, and only the server has the private key that can be used to decrypt it. This provides end-to-end encryption of the data, because the data is encrypted on the client-side using a key that is only known to the client, and it is decrypted on the server-side using a key that is only known to the server.
How JavaScript works ?
Tags: javascript, executioncontext
Published: 2022-12-01 21:51:22

Hey, let's talk about how JS works. 

To the very base level every single execution that happening in JavaScript is happening inside the 'Execution Context'. It is responsible for executing the code line by line with the available context. Before going further, consider the following illustration to get good idea of how execution context look like and works.


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

You can assume execution context as a container having 2 parts.
1. Code also known as thread of execution
2. Memory also known as variable environment.

Code is basically a place in execution context where generally our JS code resides. It will make the program line by line and so that is why JavaScript is called as single threaded language. In addition to this, JavaScript also executes the code in specific manner or way, it is called single threaded synchronous programming language as well. 

Memory is responsible for storing variable, functions and etc. While executing the program, JS will consume these variables and functions from the memory. Most importantly all of these stored variable, functions and etc are being stored as a key value pair. 

So this is how JS works basically.
Apache .htaccess
Published: 2022-12-01 21:39:02

# Htaccess file
Htaccess stands for Hypertext Access. It is a configuration file. This file is very handy when a user doesn't have access to the server configuration file. Users are allowed to change the name from .htaccess to something else.

[Repository about apache](https://github.com/abkarim/apache)

## Change or view access file name
file configurations are located here `/etc/apache2/apache2.conf`. 
```
//...
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#
AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
        Require all denied
</FilesMatch>
//...
```

## How to enable
It is possible that rewrite rule is not enabled by default.  <br />
**1.** Enable Apache mod_rewrite module
```
sudo a2enmod rewrite
```
**2.** Enable overwrite in `/etc/apache2/apache2.conf`. Find `<Directory /var/www/> //...Some content</Directory>` and set `AllowOverride All`
```
//...
<Directory /var/www/>
//...
AllowOverride All
//...
</Directory>
//...
```
**Now restart**


## How to use
You can use one `.htaccess` file inside a folder and fortunately, there is no limit. Using multiple `.htaccess` files in a project is so handy.
- Create a .htaccess file
- Enable the rewrite engine by writing `RewriteEngine On`
 
### Comment
Comments are started with `#`
_Example_: `# This is a comment`

### RewriteCond
`RewriteCond` allows executing an action with a condition. It is similar to `if` in a programming language. 
_Example_: We want to redirect user to a specific page if requested url is not a file and also not a folder
```
# Turn on rewrite engine
RewriteEngine On
# Is a file?
RewriteCond %{REQUEST_FILENAME} !-f
# Is a folder
RewriteCond %{REQUEST_FILENAME} !-d
# Condition matched
# Redirect to index.php then it will do something with this request
RewriteRule ^(.*)$ /index.php
```

## RewiteRule
`RewriteRule` is used to rewrite requests.
```
//...
# Redirect to index.php
RewriteRule ^(.*)$ /index.php
```
## Common use cases
- Block directory listing
- Redirect users to another location
- Force HTTPS
- And more...


## Example
Redirect any URL to a specific file. In this case, I’m redirecting to index.php. Here, we cannot access a file or folder since we don't use any conditions.
```
RewriteEngine On
# Redirect all request to index.php file
RewriteRule ^(.+)$ index.php
```

**_Note:_** When we use a `.htaccess` file in the project root folder to redirect all requests to a specific file (e.g. `api.php`), and there is no condition. Unfortunately at some point we figure out that, we have a folder called `public` and users need to access it for files eg: `image.img`, we can do that by just creating a empty `.htaccess` file with `RewriteEngine On`. _This file will overwrite all of the previous conditions_. **Horray**, now users can access the `public` folder `https://www.example.com/public`.
Let's Connect on Twitter
Tags: community, support, engagement
Published: 2022-12-01 20:57:28

---
title: Let's Connect on Twitter
published: true
description: 
tags: community, support, engagement 
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2022-12-01 20:52 +0000
---

I have a new account on twitter and looking for engineers and open minded people to connect with.
Whoever follows I will follow back :).

Twitter is a great platform to meet new people, share ideas, and stay up-to-date with the latest news. I'm always looking for new connections and conversations, so come join me and let's get connected!

You can find me on Twitter [@slmdiar](https://twitter.com/slmdiar), and I look forward to connecting with you soon.
Como escrever boas documentações na empresa
Published: 2022-12-01 20:41:27

Estou criando este post baseado no [The documentation system](https://documentation.divio.com/), mas por ele ser um artigo longo resolvi fazer um resumo dele com mais algumas coisas. Mas recomendo que você leia e estude este artigo, ele possui mais conteúdo e casos específicos com explicação e contexto para eles.

## Tópicos
Uma boa documentação deve ter 4 tópicos principais:

- Explicação: explicação discursiva
- Referência: descrição seca
- Tutorial: uma lição
- Como fazer: uma série de passos

![Descrição da imagem](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wkose03lxqde4bjke2qq.png)
_créditos: [The documentation system](https://documentation.divio.com/)_


## Como fazemos na Highsoft?

Depois de escolher um tópico para escrever e documentar, a primeira coisa a fazer é a *referência* e a *explicação*. Primeiro deve-se fazer uma explicação literal do termo, e depois explicar como tal tópico funciona em nosso sistema.

Para criar o *tutorial*, pegamos o tópico em questão e explicamos o procedimento de ponta a ponta, de forma simples, rápida, básica e útil.

Devemos complementar então com o *como fazer*, onde tratamos de assuntos mais específicos e nos aprofundamos nas explicações

Adicionamos mais um tópico para possíveis avisos e a explicação deles. Como somos um ERP, é normal dispararmos avisos nas telas para informar o que está acontecendo, e temos um tópico para descrever esses avisos e apontar possíveis problemas que podem ocorrer.

Por final, temos isso:


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



Lembre-se de sempre se colocar no lugar do cliente e tentar entender as possíveis respostas que ele precisa:
- como fazer isso?
- O que é isso?
- o que eu faço quando...?
- por quê isso aconteceu?

Se sua documentação tem a resposta para essas perguntas, você tem uma boa documentação. Se não, basta adicioná-lo!
How to write good company docs
Published: 2022-12-01 20:41:23

I'm creating this post based in [The documentation system](https://documentation.divio.com/) but since it is a long article I decided to create a summary with of it and a few more things. But I recommend you to read and study this article, it has more contents and specific cases with explanation and context for them.

## Topics
A good documentation must have 4 main topics: 

- Explanation: discursive explanation
- Reference: dry description
- Tutorial: a lesson
- How to Guide: a series of steps

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wkose03lxqde4bjke2qq.png)
_credits: [The documentation system](https://documentation.divio.com/)_


## How we starting at Highsoft?

After picking a topic to write and document, the first thing to do is *reference* and *explanation*, which we did together. First we take a literal explanation of the term, and after that we explain how such a topic works in our system.

To create the *tutorial*, we took the topic in question and explained the procedure from end to end, in a simple, quick, basic and useful way

We must complement then with the *how to guide*, where we deal with more specific subjects and go deeper in the explanations

We added one more thread for possible warnings and the explanation of them. As we are an ERP, it is normal for us to trigger warnings on the screens to inform what is happening, and we have a topic to describe these warnings and point out possible problems that may occur.

Finally we have this: 


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


Remember to always put yourself in the customer's shoes and try to understand the possible answers he needs:
- how to do this?
- what is it?
- what do i do when...?
- why did this happen?

If your documentation has the answer to these questions, you have a good documentation . If not, just add it!
useMemo and useCallback
Published: 2022-12-01 20:26:19

##Main reason to use it

The essential idea with [useMemo](https://reactjs.org/docs/hooks-reference.html#usememo) and [useCallback](https://reactjs.org/docs/hooks-reference.html#usecallback) is that it makes possible to "remember" a computed value / callback between renders. So we want to use it as a prevention against re-rendering which can use resources in a unwanted way.

##useMemo

```javascript
const calculation = useMemo(()=>{
   heavyCalculation(count)
},[count])
```
The useMemo Hook accepts a second parameter to declare dependencies. The expensive heavyCalculation function will only run when its dependencies have changed. It will check if the parameter "count" has changed. If not the function will not be re-rendered.

##useCallback 

```javascript
const calculation = useCallback((id)=>{
   setUsers(users.filter((user) => user.id !== id))
},[users])
```
The useCallback Hook also accepts a second parameter to declare dependencies. That's the biggest difference between useMemo and useCallbackis are that the first one get function and return memoized value, the second get function and returns memoized callback.
Issue Using Vue Components
Published: 2022-12-01 20:05:40

I am using a main vue component in my astro app and I would like to break it down into smaller components by importing them into the main component. This doesn't seem to work. as it "can't be found". Is this possible? What is the Astro way to achieve this?

example:

```
# pages/about.astro
---
import MyVueComponent from '../components/MyVueComponent.vue';
---
<html>
  <body>
    <h1 class="editable">Use Vue components directly in Astro!</h1>
    <MyVueComponent />
  </body>
</html>
```

```
# components/MyVueComponent.vue

... Can't find SubComponent error

<script lang="ts">
import SubComponent from '../components/shared/SubComponent.vue'
export default {
  components: {
    SubComponent
  }
}
</script>
```
Fixing broken code
Tags: beginners, webdev, html, css
Published: 2022-12-01 20:03:03

I noticed **earlier** this week in class that my image was not matched yo to my instructor's display. 
![My incorrect photo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zhfmq46ir5lkruk0es7g.png)
The above image was my coded page and below was my instructor's.
![Instructor's correct photo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6o9pzlgqilsvyr3vu4kl.png)

In order to correct this mistake, I immediately thought
###**OH NO! I RUINED MY CODE**

*Thankfully*, that was not the case.In order to fix this, I looked at my HTML/CSS and my instructor's HTML/CSS line by line to figure out what the problem was. 
Conclusion:
1. I see **I DID NOT** create a relative class in my HTML for this photo.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kbvgym3p71r78b3a3d2s.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tr4nvu8s3r6fry4ckdba.png)
2. Therefore, **MY CSS** was not reading the **HTML** because there was a proponent that was **UNASSIGNED**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9h2dr9z2nsndxrtjtkp.png)
How to Build Bots Via APIs with ElectroNeek
Tags: robotics, rpa, api, automation
Published: 2022-12-01 19:17:56

**What Are Bots?**

Bots are intelligent software programs designed to optimize business processes. These programs may be designed to perform one or more automated tasks or even simulate human interaction with customers and users. Bots can be used to automate repetitive tasks performed by humans

**What is Automation?**

Automation is the technique of performing tasks and processes with minimal human assistance. The objective of automation is to achieve a greater level of productivity and quality in human work. Automation has evolved from a mere job to a critical business tool that allows you to do more with less. The art of automation applies to most sectors. With automation, you set up the system to do predictable things automatically, enabling people to focus on more important activities like creating new ideas or building relationships with customers.


You can use automation to automate your organization's tasks, from automating your email activities to your Excel activities. If you would like to learn how you can automate your email activities, you can navigate to this [article](https://forum.electroneek.com/t/email-automation/1102) that I did recently.

There are many types of bots for businesses. For example, bots can be built to automate any repetitive tasks in your business. Your bot is going to be used to save you time and revenue while improving your ROI, so think about what services and tasks you want the bot to perform for your business.

Building your first bot on the ElectroNeek platform is simple. There are multiple ways to build a bot on our platform. Learn how you can build bots via APIs using ElectroNeek here:
https://forum.electroneek.com/t/how-to-build-bots-via-api/902

Don’t be left out; join our community here: https://forum.electroneek.com

**Happy Automation!!**
just 2 words: NPM i <packageName> --save
Tags: dicuss, npm, node, webdev
Published: 2022-12-01 19:16:56

Hi!
I wanted to write the difference between the --save flags while installing your node dependencies

1-This installs the package and updates the dependencies in your package.json.
 
``` powershell 
npm install <package_name> --save 
```

2- This installs the package but does not update the dependencies as listed in your package.json.

``` powershell 
npm install <package_name> --no-save
```

3- And this updates the dev Dependencies in your package. These are only used for local testing and development.

``` powershell 
npm install <package_name> ---save-dev 
```


Thanks and see you in the next
Best,
Bek
AWS re:Invent 2022 Crossworld
Tags: cloud, aws, beginners, jokes
Published: 2022-12-01 19:09:41


Did you pay attention to all the keynotes at re:Invent? Did you follow the AWS blogs for the latest news or were you too busy partying in Vegas?

Show your manager that your time in Nevada or watching the conference online was well spent. Certify your knowledge of the key announcements from this year’s cloud computing conference with a crossword! All names are without the “AWS” or “Amazon” prefix, because I am nice.

Let me know what you think, before you go and [start playing!](https://puzzel.org/crossword/embed?p=-NIDNDKyoF6pjSSUomwg)
Advent.js🎅🏼| Reto #1: ¡Automatizando envolver regalos de navidad!
Tags: javascript, typescript, spanish, adventofcode
Published: 2022-12-01 18:58:58

## [¡Automatizando envolver regalos de navidad!](https://adventjs.dev/es/challenges/2022/1)

Este año los elfos han comprado una máquina que envuelve regalos. Pero... ¡no viene programada! Necesitamos crear un algoritmo que le ayude en la tarea.

A la máquina se le pasa un array con los regalos. Cada regalo es un string. Necesitamos que la máquina envuelva cada regalo en papel de regalo y lo coloque en un array de regalos envueltos.

El papel de regalo es el símbolo `*` y para envolver un regalo se coloca el símbolo `*` de forma que rodee totalmente al string por todos los lados. Por ejemplo:

```js
const gifts = ['book', 'game', 'socks']
const wrapped = wrapping(gifts)
console.log(wrapped)
/* [
     "******\n*book*\n******",
     "******\n*game*\n******",
     "*******\n*socks*\n*******"
   ] */
```

Como ves, el papel de regalo envuelve el string. Por arriba y por abajo, para no dejar ningún hueco, las esquinas también están cubiertas por el papel de regalo.

¡Suerte!

Completa el reto!

---

Puedes seguir a @midudev y estar pendiente de los retos de Advent.js 

{% twitter 1597965996383412225 %} 

---

Mi solución:


{% jsitor https://jsitor.com/embed/wLeSvjdED7 %}