teleren/devto huggingface dataset:
How to switch AWS Profiles with ease
Tags: deno, aws, cli
Published: 2022-08-25 15:35:58

Towards the start of the year, I was introduced to the following command line utility: [awsp](https://github.com/johnnyopao/awsp) - A very handy way to switch AWS profiles from the command line.

However, I needed more, I needed to be able to switch profiles and then launch straight in to a deployment process.

Around a similar time, I also started looking at Deno, so I decided to use Deno to rewrite awsp so that I was able to satisfy my needs of switching profiles and then go straight into said deployment.

I chose Deno because I wanted to be able to have it compile to a single executable that I could use without having to globally install yet another NPM package.

I creatively named this little cli tool [awsd](https://github.com/damiensedgwick/awsd)

Now this version does not contain the additional code I added to go straight into deploying an application, but it does allow for easy switching of AWS profiles from the command line as the original tool intended.

![Choosing an AWS profile using awsd](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/68lq9uhc3huga85x0gri.png)

![After a AWS profile choice has been made](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/atuc4z23tw64pul06908.png)

How easy is that!

For closing I would like to give full props to Johnny for creating the original [awsp](https://github.com/johnnyopao/awsp) tool and would urge you to go and take a look if you want to making switching profiles, a tad quicker and easier.

You can of course go and visit [awsd](https://github.com/damiensedgwick/awsd) if you would like to look at the Deno version.
Build on AWS Weekly - S1 E6 - Local Development Everywhere
Tags: aws, development, brewfile, ide
Published: 2022-08-25 15:09:16

Welcome to episode 6 of Build On Weekly! 🥳 

Today [Jacquie](https://twitter.com/devopsjacquie) shows all of us and [Darko](https://twitter.com/darkosubotica) how she configures her local development environment on her Macbook. On top of that she shows off some tips and tricks on how to automate said configuration for easy migrations between systems! 

We will be posting here, on dev.to, to share **show notes, links, socials, code, and any other things mentioned** during the live stream with you! 🚀

![Jacquie and Darko Episode 6](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/166dozw2np73kamhu5np.png)

If you have any questions, feedback or comments - feel free to put them in the comments of this post! 😇

## Deployed Weekly 

{% embed https://www.youtube.com/watch?v=8TE-VCaPp1E %}

Today on Deployed Weekly we kick off with a warm welcome to the 500 new Community Builders we welcomed globally before taking a look at Cloud Glance, a tool that helps you navigate multiple AWS Environments with ease. Next up is the first Amazon CodeWhisperer workshop we’ve encountered while we share some of our thoughts about tools that help you to generate code. We then highlight Amazon Cloudfront’s added HTTP/3 QUIC support. Finally, we shared a link to open roles here at AWS DevRel if you’d like to come work with like us!

**Links from the discussion:**
- [AWS Community Builders Program](https://aws.amazon.com/developer/community/community-builders/)
- [Cloud Glance](https://cloudglance.dev/)
- [Amazon Codewhisperer Workshop](https://github.com/aws-samples/amazon-codewhisperer-workshop)
- [AWS Cloudfront HTTP/3 QUIC Support](https://aws.amazon.com/about-aws/whats-new/2022/08/amazon-cloudfront-supports-http-3-quic/)
- [Come and work with Jacquie and Darko in DevRel](https://www.linkedin.com/pulse/open-roles-join-aws-devrel-felipe-lemaitre/
)

## Weekly Builds

{% embed https://www.youtube.com/watch?v=OrlBvPrHFXk %}

Today we go on an interactive live tour with Jacquie through her terminal and IDE setup and share tips to make your environment portable between your different mac laptops. Also some cool automation steps she took to make it very easy to migrate between different workstations. 

Some things we discuss: 
1. Set up scripts
2. Package management using Brew and Brewfiles
3. Favorite fonts and theme templates 

**Links from the discussion**
- [Jacquie’s Mac Setup Files](https://github.com/gogococo/mac-setup-files)
- [Using Brewfiles](https://medium.com/@satorusasozaki/automate-mac-os-x-configuration-by-using-brewfile-58a78ce5cc53)
- [Jacquie's favorite font](https://rubjo.github.io/victor-mono/)

**🐦 Reach out to the hosts and guests:**

Jacquie: [https://twitter.com/devopsjacquie](https://twitter.com/devopsjacquie)
Darko: [https://twitter.com/darkosubotica](https://twitter.com/darkosubotica)
Remove the Last Char from a PHP String
Tags: php, webdev, beginners, programming
Published: 2022-08-25 14:51:11

In this article, you will understand more than one way to remove the last char from the PHP string.

Anyway, the question is how to use [PHP to remove the last character from the string](https://codedtag.com/php/php-remove-last-character-from-string/). In the following sections, I am going to cover 2 ways that are doing that.

## Using the Substr Replace Function
The substr_replace is a predefined PHP function used to replace a part from text with another one.

It takes four parameters, such as

- the $string variable is for the PHP string sentence
- the $replace variable is for the needed string that would replace on the old part.
- $offset to select the started index from left to right and if it take a negative value that means it will start from the right.
- And the final is an optional parameter with $length.

Let's take an example.
```php
<?php
$string  = "My Office behind the Door..";
$replace = "";
$offset  = -1; 
echo substr_replace( $string, $replace, $offset );  
// The output: My Office behind the Door.
?>
```

As you saw, the value was printed is the full sentence but deleted the last dot from the string. But how to replace a word instead of another word.

To do that, you have to select the first char from the target word and know the index number and then set a new value with the $replace variable

Let's see that with the following code.
```php
<?php 
  $string  = "Hello World";
  $replace = "Petter";
  $offset  = 6; // is the begining of the Wolrd word. 
  echo substr_replace( $string, $replace, $offset );
  // The output: Hello Peter 
?>
```

## Remove the Last Character using the Mb Substr Function
The mb_substr is only getting a part from the target string. That means, we need only to return the need part without the last Character.

Let's see that in the following PHP code.
```php
<?php 
  $string = "Am I Doing That ?";
  echo mb_substr( $string , 0, -1 ); // Am I Doing That
?>
```

## Wrapping Up
In this article, you understood what is substr_replace function and how to use it to replace a string from a sentence. Also you learned how to remove the last char from a PHP string using two predefined PHP functions.

To learn more ways, follow the [CodedTag ](https://codedtag.com/) tutorils

Thanks for reading, stay tuned for my next tutorials
Create multiple docs with Docusaurus
Tags: docusaurus
Published: 2022-08-25 14:33:11


[Docusaurus](https://docusaurus.io/) is an open source framework developed by Facebook and based on react. It allows you to create clean, versionable and multilingual documentation with a very small configuration.

## Create your project

Initialize your project with the following command:

```javascript
npx @docusaurus/init@latest init my-website classic --typescript
```

You can then start your development mode.

```javascript
cd my-websiteyarn start
```

## Project structure

In the same philosophy as [Jekyll](https://jekyllrb.com/) you will be able to generate a static site based on markdown files but you can also create pages directly in jsx.

> Docs file The docs file contains all the chapters of your documentation. We will see how to configure it to have two distinct documentations.

## Create a second documentation

### Docusaurus Config

We want to create two documentations, one `Guide` and the other `Api`. We will add an item in the navbar configuration.

```javascript
navbar: {
 {
  type: 'doc',
  docId: 'guide/intro',
  position: 'left',
  label: 'Docs',
 },
 {
  type: 'doc',
  docId: 'api/intro',
  position: 'left',
  label: 'Api',
 },
}
```
### Sidebars

We modify the Sidebars to include the two documentation and set their `dirName` to subfolders that we will create in the `docs` folder.

```javascript
module.exports = {
	docSidebar: [{ type: 'autogenerated', dirName: 'guide' }],
	apiSidebar: [{ type: 'autogenerated', dirName: 'api' }],
};
```
### Writing documentation

Now you have to create two folders `docs/guide` and `docs/api` in which you can create your two documentations.
Quickly toggle Copilot suggestions on and off with your keyboard
Tags: vscode, productivity
Published: 2022-09-13 20:11:46

---
title: Quickly toggle Copilot suggestions on and off with your keyboard
published: true
date: 2022-08-25 14:31:00 UTC
tags: vscode, productivity
canonical_url: https://rachsmith.com/quickly-toggle-copilot/
---

Overall, [I'm a fan of GitHub Copilot](https://rachsmith.com/maybe-im-in-the-sweet-spot/). Sometimes I just want it to get out of the way. I wanted to figure out how to toggle it off and on again with my keyboard.

At first I figured I could assign the extension's enable/disable command to a [VSCode](https://code.visualstudio.com/) keyboard shortcut.

##### keybindings.json

```
[
  {
    "key": "ctrl+c",
    "command": "github.copilot.toggleCopilot",
    "when": "editorFocus"
  }
]

```

But then when I went to use the shortcut to disable it, the extension popped up this confirmation dialog in the corner. The focus was still in the editor so there was no way to select 'Disable Globally' without using my mouse. Super annoying.

![a dialog message asking \](https://rachsmith.com/images/copilot-dialog.png)
_why?_

  

I went to the [GitHub community discussions] to see if anyone had requested a change to this behaviour. It turns out there were multiple posts asking about this, but [one of them](https://github.com/community/community/discussions/7553) included a workaround from [Dan Davidson](https://github.com/dandavison).

It turns out we can attach a keyboard command to update the workspace setting `github.copilot.inlineSuggest.enable`. When that setting is set to false, Copilot will stop with the inline suggestions.

By using the [Settings Cycler](https://marketplace.visualstudio.com/items?itemName=hoovercj.vscode-settings-cycler) extension (first time I'd heard about this one, btw) we can assign a keyboard shortcut to toggle the setting on and off. Here's mine (I chose to use `ctrl+c`):

##### keybindings.json

```
{
  "key": "ctrl+c",
  "command": "settings.cycle.copilot",
  "when": "editorFocus"
}

```

##### settings.json

```
"settings.cycle": [{
   id": "copilot",
     "overrideWorkspaceSettings": true,
     "values": [{
       "github.copilot.inlineSuggest.enable": false
     },
     {
       "github.copilot.inlineSuggest.enable": true
     }
  ]},
],

```
Hot take on password login in MFA : wrong factor
Tags: security, authentication, mfa, password
Published: 2022-08-25 14:25:06

I was looking at documentation about 2FA, and MFA in general for an application that I'm working on. And I felt something was not totally right when describing the different factors, specifically the *Knowledge* one.

Let's take the wikipedia (not the best source but not the worst) page as a reference : https://en.wikipedia.org/wiki/Multi-factor_authentication#Knowledge

If you read it like me, the password login is on the Knowledge factor.
And it's not specifically written but Magic Links are supposed to be in the Possession one[¹].
Even if it's theorically true I strongly disagree with that. And since we're talking about security, it's important to understand why.

### What is the flow of a magic link ?

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

If you consider that you possess the email account, it's indeeed a Possession factor that we use here. And the security of this flow is as secure as the one of the email account.

### What is the flow of a password login ?

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

And yeah it's indeed a Knowledge factor, case closed !!
Thanks for listening to my podcast and don't forget to subsc.... HEY WAIT STOP !!
It doesn't happen like that in real life !

I had a discussion with a DPO recently (so more a legal expert than a tech one) who told me that magic links are less secure than password logins because emails accounts can be hacked.
Hmmm... ok but have you seen recently a public password login without a password recovery process ?

Let's make our sequence diagram again. (because [Mermaid](https://mermaid-js.github.io/mermaid/) is a very nice tool that I just discovered)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mu6mdx8vpc4zyacz5azy.png)
At the last steps the app server can ask the user to login fully again but it's quite the same.

So what is the difference betweend password login and magic links in terms of security ? Some unuseful steps and reticences about weak passwords[²].

## My conclusion

Password login is both a Knowledge and a Possession factor and I think that, since the recovery can bypass the Knowledge, it should be considered more like a Possession.
Combining password login with SMS, Authenticator or email magic link should not be considered as a "multi"-factor authentication. 

Of course I may have missed some arguments, and if you have a different point of view, I'd be glad to read it. :smile:

[¹] even if there is a debate whether soft tokens should be in this factor
[²] too simple, used on multiple websites, written on a piece of paper or in a .txt file, etc. 

Cover photo by [Micah Williams on Unsplash](https://unsplash.com/@mr_williams_photography?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)
10 Useful vim commands for coders
Tags: vim, linux, ubuntu, ide
Published: 2022-08-25 14:23:42

You need to be in command mode (pres `Esc` for that) to use these commands.

## 1. Add a new line

Press `o` (small) to add new line below cursor, or `O` (big) to add new line above cursor.

## 2. Comment multiple lines

1. Press `Ctrl + v`
2. Select lines with arrows keys
3. Press `Shift + i`
4. Input commenting symbol(s) (e.g. "//")
5. Press `Esc`

## 3. Delete line

Press `dd` to delete current line.

## 4. Delete word

Press `dw` to delete current word (cursor should be placed at the beginning of the word to delete).

## 5. Disable line wrap:

```text
:set nowrap
```

## 6. Enable autoindent

```text
:set smartindent
```

## 7. Go to the end of current line

Press `$` to to the end of line.

## 8. Go to the end of file

```bash
:$
```

## 9. Go to specific line

E.g. to go to line number 51:

```bash
:51
```


## 10. Open file in a new tab

```text
:tabnew <filename>
```

More useful [Vim commands](https://onelinerhub.com/vim), add [your commands](https://github.com/Onelinerhub/onelinerhub/tree/main/vim) on Github.
Set up Jenkins server on a digital ocean droplet.
Published: 2022-08-28 15:00:11

---
title: Set up Jenkins server on a digital ocean droplet.
published: true
date: 2022-08-25 12:33:03 UTC
tags: 
canonical_url: 
---

This article will go through the steps needed to set up a Jenkins instance on a digital ocean droplet

What is Jenkins?

Jenkins is an open-source automation server that helps development teams to automate repetitive tasks in CI/CD

Let's now head to set up our Jenkins server.

### 1. Register for a digital ocean account [here](https://cloud.digitalocean.com/registrations/new)

### 2. Create a droplet with the following specs.

- An image - Ubuntu: the Lts tag
- Plan - 4GB 2 AMD CPUs
- Datacenter region - (preferably one close to your location)
- Authentication method - (ssh keys) and copy your public key to Digital Ocean. follow this link to create ssh keys.

### 3. Configure firewall rules to open ports 22 and 8080 that our Jenkin server will use.

Click on the newly created droplet and navigate to the networking tab.

![Screenshot from 2022-08-25 14-23-51.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1661426646409/P3u2vJplq.png)

```
Ensure that ports 22 and 8080 are open to receive requests.

```

![Screenshot from 2022-08-25 14-25-59.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1661426794377/0CS249Q8V.png)

### 4. Install docker and run Jenkin as a docker container.

#### 4.1 ssh into the droplet by using the command

```
         ```
            ssh root@YOUR_IP
         

#### 4.2. Update the server by using the command.

```
 apt update

```

#### 4.3. Install recommended upgrades.

```
 apt upgrade -y

```

#### 4.4. Install docker runtime engine.

```
apt install docker.io -y

```

## 5. Run Jenkins as a docker container using the following command

```
docker run -p 8080:8080 -p 50000:50000 -d \ 
-v jenkins_home:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(which docker):/usr/bin/docker jenkins/jenkins:lts

```

### 6. Access the Jenkins server on the web using the server's public IP as shown below

```
134.xxx.xx.xxx:8080

```

After a successful installation of Jenkins in the Docker container, you should see a screen similar to the one below that will prompt you for an administrator password

```
#use this command to get the initialAdminPassword
cat /var/lib/docker/volumes/jenkins_home/_data/secrets/initialAdminPassword

```

copy the password and login into Jenkins. We can now create our first Jenkins user.

![Screenshot from 2022-08-25 15-07-43.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1661429412236/lz0Kc6M0H.png)

We have now successfully installed Jenkins.

In our next article, we shall go through how to deploy a Django application to an ec2 instance using the Jenkins server we have set up.
The Best Free Learning Resources for Python and Django
Tags: python, django, webdev, beginners
Published: 2022-08-25 14:02:05

Hey there, How are you? In this article, you’ll see the best free learning resources for Python and Django.

## Python

We will divide this section into two parts.

Courses
- [Fork Python Programming - Self Paced (Geeks For Geeks)](https://practice.geeksforgeeks.org/courses/fork-python) ⭐4.7
- [Introduction to Python (Microsoft)](https://docs.microsoft.com/en-us/learn/modules/intro-to-python/)  ⭐4.7
- [An Introduction to Interactive Programming in Python (Part 1) (Coursera)](https://www.coursera.org/learn/interactive-python-1) ⭐4.8
- [An Introduction to Interactive Programming in Python (Part 2) (Coursera)](https://www.coursera.org/learn/interactive-python-2) ⭐4.9

Books
- [Python Tutorial - Introduction (Codes Dope)](https://www.codesdope.com/course/python-introduction/)
- [100 Page Python Intro (Learn By Example)](https://learnbyexample.github.io/100_page_python_intro/cover.html)
- [A Practical Introduction to Python Programming](https://www.brianheinold.net/python/python_book.html#chapter_start)
 
## Django

We will divide this section into three parts.

Courses
- [Python Django Web Framework (Free Code Camp)](https://www.freecodecamp.org/news/python-django-course/)
- [Building Web Applications in Django (Coursera)](https://www.coursera.org/learn/django-build-web-apps?irclickid=yE90IL0xixyNU7sXl92I7WbRUkDUf2zj1WwJ0Y0&irgwc=1&utm_medium=partners&utm_source=impact&utm_campaign=3294490&utm_content=b2c)⭐ 4.7
- [Django Features and Libraries (Coursera)](https://www.coursera.org/learn/django-features-libraries?irclickid=yE90IL0xixyNU7sXl92I7WbRUkDUf2wS1WwJ0Y0&irgwc=1&utm_medium=partners&utm_source=impact&utm_campaign=3294490&utm_content=b2c#syllabus)⭐4.8
- [Walkthrough Django's Official Tutorial: Django Version 2.2 (Udemy)](https://www.udemy.com/course/django-official-tutorial-2-2/?ranMID=39197&ranEAID=JVFxdTr9V80&ranSiteID=JVFxdTr9V80-TtrrfL_LIk9cidIHFu2twQ&LSNPUBID=JVFxdTr9V80&utm_source=aff-campaign&utm_medium=udemyads) ⭐4.5
 

Books
- [A Complete Beginner's Guide to Django (Series)](https://simpleisbetterthancomplex.com/series/)
- [Django Web Framework (MDN)](https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django)
- [Django Documentation 3.2 (PDF)](https://buildmedia.readthedocs.org/media/pdf/django/3.2.x/django.pdf)
Creating Distributed Tasks using Python+Celery+Docker
Tags: docker, webdev, beginners, codenewbie
Published: 2022-08-25 13:59:00

I have written a small and fun project for anyone who wants to learn how to build webapps from the ground up.

Today I want to share the infrastructure documentation about the project.

With this project, you will learn how to build a webapp to convert YouTube videos to MP3.

https://gdi3d.github.io/learning-to-build/#/docker/architecture
SOLID - Development principles
Tags: beginners, tutorial, productivity, writing
Published: 2022-08-25 13:57:42

![https://www.youtube.com/watch?v=Tk9HVv8ZcOU](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wlk27zmuf1ro0zic2pgq.png)
 

Object-oriented programming has its principles, and it is not just turning everything into objects and using them when we need them. It's important to create understandable objects.

**Question #1**
Is it important? Why?

Yes, It's important and makes more sense when the application grows and becomes bigger.
Design principles encourage us to make maintainable and flexible software.

**Question #2**
How?

In every work, if you have some principles and standards, your project will get a great structure to itself.
Like using a framework, here should follow some principles.

**Question #3**
So, What is SOLID?

- S: Single responsibility principle
- O: Open/Close principle
- L: Liskov substitution principle
- I: Interface segregation principle
- D: Dependency inversion principle

**Question #4**
What do they mean?

- S: Single responsibility principle

A class should only have one responsibility.
It should have one reason to change.


Benefits:
Testing: A class with fewer test cases is better.
Lower coupling: Less functionality in a single class will have fewer dependencies.
Organization: Smaller and more well-organized classes are better than monolithic ones. (For example, don't create a single class for both car and its functionality, create two separates class, one for car and one for car functions)


- O: Open/Close principle

Open for extension, close for modification.
We are not allowed to modify existing class codes, because it creates new bugs.
For example, when a new type of car has to implement into the system, you should not modify the car class, the right way is to extend the car class.


- L: Liskov substitution principle

A class and its subclass should be able to be replaced by each other. If you have a car and racing car class, and the racing car class is a subclass of car class, you should be able to change or replace them without disrupting the behavior of the program.


- I: Interface segregation principle

Larger interfaces should be split into smaller ones.
For example, your barber interface consists of cutting the hair, shaving, and washing.
It can happen that you hire someone for just washing and shaving, not cutting hair, and he is not a barber.
So? It's really better if you split it into small pieces, don't put it all in one interface.


- D: Dependency inversion principle

High-level and Low-level modules should both depend on abstraction, not each other. In another form, a class should depend on abstraction.