teleren/devto huggingface dataset:
Be attention to replace a key pair for EC2
Tags: aws, ec2, ssh
Published: 2021-08-09 02:34:15

---
title: 'Be attention to replace a key pair for EC2'
published: true
description:
tags: aws, ec2, ssh
---

## Introduction

I will share points to note about replace a key pair for EC2.

## About key pair

When you launch the instance, you select the key pair to connect with SSH. ![image1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dn2ypob1sn2x6ugmpne0.png)

EC2 instance cannot allow to be connected to with SSH by password authentication in initial settings.

```bash
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication no
```

Once you select a key pair and launch EC2 instance, you can connect to it with public key authentication.

```bash
ssh -i ./NewWindows.pem ec2-user@18.182.24.156
Last login: Mon Aug  2 13:36:42 2021

       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/
```

## Replace a key pair

You create an Amazon Machine Image(AMI) based on running EC2 instance and you launch EC2 instance from that AMI. Then, select a key pair. ![Image2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5rdd7g3irkdhlotloxvd.png)

There is a case that you need to replace a key pair attached EC2 instance because of security, review of operations and so on.

In this case, you change a new key pair from existing key pair. Also, you can connect to EC2 instance with another secret key.

```bash
ssh -i .\tepkey.pem ec2-user@18.183.44.42
Last login: Mon Aug  2 13:45:37 2021

       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/
```

At first, I expected that only new public key exists in the file, `~/.ssh/authorized_keys`. But, it was wrong and an old public key existed there, too.

```bash
ssh-rsa ~~~~~~~~~~~~~~~~~~~XXXX~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NewWindows
ssh-rsa ~~~~~~~~~~~~~~~~~~~XXXX~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tepkey
```

Actually, I confirm that I can connect to EC2 instance with SSH by the former secret key.

```bash
ssh -i .\NewWindows.pem ec2-user@18.183.44.42
Last login: Mon Aug  2 15:07:23 2021

       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/
```

According to the AWS documentation, you have to remove an old public key in `~/.ssh/authorized_keys` manually when you replace a key pair.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#replacing-key-pair

## Conclusion

I research replace a key pair for EC2 instance. I'm surprised at the specification and concerned about security🤔

If you disclosure an old secret key which is not used and not managed, your EC2 instances may be illegally accessed.

How does everyone do an operation? Let me hear your what you think.

## Original

https://zenn.dev/yuta28/articles/ec2-keypair-replace
Ruby Self
Published: 2021-08-09 02:13:47

---
title: Ruby Self
published: true
description: 
tags: 
//cover_image: https://direct_url_to_image.jpg
---


The keyword `self` in ruby gives you access to the current object

**Class**

In the context of a class `self` refers to the current class

```ruby
class Dog
  p self # the Dog class
end
```

Defining a method on self creates a class method

**Instance Method**

Within an instance method self refers to the instance itself
```ruby
class Dog
  def bark
    self
  end
end
 
p Dog.new.bark # an instance of the Dog class
```

**Implicit Self**
When you call a method without an explicit recieving object, the method is called implicitely on self. In plain english this means that if there is nothing on the left hand side of the function call then the left hand side is self. 

```ruby
class Person
  attr_reader :first_name, :last_name
 
  def initialize(first_name, last_name)
    @first_name = first_name
    @last_name = last_name
  end
 
  def full_name
    "#{first_name} #{last_name}" #implied self. Instance of person
  end
end
```


**Top Level**

At the top level self refers to the main ruby object

```ruby
p self # the main object
```

**Modules**


When self is used **within an instance method of a module** it refers to the **instance of the class in which the module is included**

When you see self **outside of an instance method inside a module** it **refers to the module**


If you were wondering what `p` by itself is. Its a kernel method that behaves similar to obj.inspect. Try calling it on some objects :)
How does pick work in typescript ⛏️
Tags: beginners, typescript, algorithms, javascript
Published: 2021-08-09 02:09:39

**Hi everyone**, how are you today? Hope you all are doing well!

![Rick and Morty](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tox757fyljf2vbycaslb.gif)

<hr>

####Preface

Today we are going to understand how the pick utility works and how it is built!

<hr>

####Concepts

First, it is important to understand that the
**Typescript** is considered a
superset of Javascript, is responsible for adding static type definitions.

Types provide a way to describe the shape of objects, allowing TypeScript to verify that the code is working correctly.

<hr>

####To work

The pick utility builds a new type based on the set of properties chosen in the second generic position.See an example: 

```
type Water = {
  hydrogen: number;
  oxygen: number;
};

type Electrolysis = Pick<Water, "hydrogen">;

const electrolysis: Electrolysis = {
  hydrogen: 2,
};

```

In this case, we are extracting hydrogen from the water type to create a new type, in this case electrolysis

*This produces an exothermic reaction. In the case of hydrogen and oxygen, the energy released is almost impossible to control, and most often leads to an explosion.* 

<br>
<hr>

#### But how does the pick do it?

First, we must understand what mapping functions are.

**A mapped type is a generic type that uses a union of key properties to iterate through keys to create a new type.**

See an example: 

![example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vg83l3bohha1eqaq0u0.png)

P will interact about id and name. T[P] returns the readonly type of iterated position.

**keyof** produces a string or numeric literal union of keys of type. 

<br>
<hr>

#### Deconstructing the pick utility

![Pick](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i72wgjoxhft0kdnpxfev.png)

In this case we use a generic to capture the keys we want and restrict with extends, after that we use the mapping function to traverse all K (parameters passed to generic)!

![happy face](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h9psqiuvagm57g4iit0y.gif)

<center>this is magic!</center>

<br>
<hr>


<center>Time is very important, thanks for sharing a little bit of yours with me 😊.</center>

<a style="float: left;" href="https://github.com/devneto">![image](https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white)</a>

<a style="float: left;" href="https://twitter.com/_devneto">![image](https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)</a>
Fun Ruby tricks I learned in codewars
Tags: codewars, ruby, fun
Published: 2021-08-09 02:08:44

---
title: Fun Ruby tricks I learned in codewars
published: true
description: 
tags: #codewars #ruby #fun
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/smocpdjn8b79627nci0m.png
---


 
I have been playing around with codewars a lot lately. (www.codewars.com) I like working with code challenges they are pretty fun. One thing that is great about playing with codewars is that I got to use a lot of tools and methods I would have never else thought of for example


**delete**

This comes in handy for challenges that ask you to remove a series of elements from a string.
For example, if you need to remove some vowels from a string
```ruby
 my_string = "This is such a wonderful method"
 my_string.delete("aeiou") 
 
 => Ths s sch  wndrfl mthd
 ```
 
 This is much easier than using gsub!


**to_str(base)**

So most everyone knows how to_s works, you are converting a non string object to a string representation of that object. But one thing a lot of people forget is that you can pass in an argument to to_s when its placed on a Fixnum. This argument represents a numerical base which by default is 10. Therefore, this method can be used to convert numbers to different bases
```ruby
  35.to_s(2)
  
  => "100011"
```

**partition**

This is a great way to split up some data. It accepts a block and creates 2 arrays. For the elements that are true, they are first array, while the rest are placed in the second array.  Imagine we have a problem where we need to seperate some evens and odds

```ruby
  my_array = [1,2,3,4,5,6]
	my_array.partition{|i| i.even?}
	
	=> [[2, 4, 6], [1, 3, 5]] 
```


**even? odd?**

Which reminds me, I have a tendency to forget about these ruby methods. They work just as you expect. The question mark signify's this method returns some sort of boolean.

```ruby
  4.even?
  => true
	
	4.odd?
	=> false
```

Its a shame how often I resort to modulo to check for evens and odds knowing this exists

**chars**

chars will split a string into an array of chars

```ruby
 "This is my string".chars
 => ["T", "h", "i", "s", " ", "i", "s", " ", "m", "y", " ", "s", "t", "r", "i", "n", "g"] 
```
of course split('') would do the same, but I like this better


Code challenges are super fun, and its great to learn new tricks. I recomment trying codwars sometime or even hacker rank or leetcode. I think Im going to go do some SQL challenges now!
Cara Mencari Inspirasi Menulis dengan Mudah
Tags: writing, tutorial
Published: 2021-08-09 01:45:40

Sebagai orang yang yang sering ditunjuk menjadi moderator acara literasi, saya sering mendapati pertanyaan begini, "Bagaimana cara mencari inspirasi menulis?"

Seorang penulis buku yang berada di samping saya, saya rasa--dan saya yakin-- dia sudah kenyang ditanya seperti itu. Pun saya sebagai moderator, entah sudah berapa banyak pertanyaan tersebut muncul.

Saya tidak risih sama pertanyaan klasik semacam itu. Tapi, saya pikir, menanyakan tentang isi buku jauh lebih bagus daripada bertanya inspirasi menulis.

Mengapa? 

Sebab, tiap penulis tentu berbeda-beda dalam memunculkan inspirasi. Dan ketika Anda bertanya tentang inspirasi menulis, apakah Anda benar-benar ingin mengetahui inspirasi menulis si penulis yang ada di hadapan Anda atau hanya untuk formalitas saja supaya Anda dapat hadiah dari panitia acara? Haha.

Jika saja pertanyaan itu dilontarkan kepada saya, berikut beberapa cara saya dalam menghadirkan inspirasi menulis. Dan ini sangat mudah.

1. Minum kopi (saat menulis artikel ini, ini saya lagi menyesap kopi)

2. Mendengarkan lagu (saat saya memutar lagu, saya sambil membayangkan pertanyaan-pertanyaan klasik dari audience yang pernah bertanya tentang inspirasi menulis)

3. Melamun

4. Memikirkan kata kunci untuk artikel selanjutnya

5. Menatap layar laptop dan terus menulis

6. Menertawakan redaktur media online yang so bagus tulisannya

7. Chattingan dengan sesama penulis

8. Duduk dikelilingi beberapa buku

9. Rebahan

10. Ingin tidur

Betapa mudahnya, kan, saya mencari inspirasi menulis?

Sebenarnya ada dua lagi: di sini https://www.penulisgarut.web.id/2020/06/tips-untuk-mencari-inspirasi-dalam-menulis.html

Terima kasih telah membaca artikel ini, tidak berfaedah sekali, ya, ya betul..seperti pertanyaan, "Bagaimana cara mencari inspirasi menulis?" ini sangat tidak berfaedah.
Quick Tip: 302, 303, or 307? Which HTTP response status code should be used to redirect?
Tags: temporaryredirect, httpstatus, redirect
Published: 2021-08-09 01:42:04

---
title: Quick Tip: 302, 303, or 307? Which HTTP response status code should be used to redirect?
published: true
description: 
tags: TemporaryRedirect, HTTPStatus, Redirect
//cover_image: https://direct_url_to_image.jpg
---

Quick Tip on Redirecting:

![Which HTTP response status code should be used to redirect?](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y4ki1iipacz3gwgh21tf.png)

Reference:
https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#:~:text=Note:%20RFC%201945%20and,expected%20of%20the%20client
Best Practices for First Job as a Software Engineer
Published: 2021-08-09 00:34:47

Getting your first software engineering job can be somewhat tricky. If you don’t have good skills with multiple tools then it becomes worse. But learning with strategy can be helpful. Have a future mind, think about what you want to major in, then perfect in your area of specialization. Just make sure you have a linked profile, GitHub account, and a good resume. Here are some tips for you.Let's Go!

1. Be Ready & Organized
First and foremost, apply for any vacancy you meet, even if you are not good at it. There are various steps to take when you have applied for a job or internship. Always be ready for an interview, however hard it will be. Some interviews might take various turns before being hired.  Keep track of the next steps like making follow-ups, tips online, or anything you have ever read about the interviews. Get to know more about the company and its working conditions. Google calendar is useful to remind you about an interview.

2. Get a referral
Referrals are good. Most top companies will prefer taking a referred candidate over other candidates. It's okay not to have a network, but throw the shame away and approach anyone from local area, or schoolmate who graduated before you. Make friends who have great connections. Attend meetups and connect with engineers at that company. Thank them after the meeting and let  them know how much you yearn to work at their company. Meeting people in person is perfect. You can join groups on Facebook where you will meet large communities of coders.

3. Message Recruiters / Agencies
On linkedIn, you can notice the job of a person and the company he/she is working with. Design engaging messaging for most of them. It’s a powerful social media site if you have no connection. Visit top companies and look at recruiters. Look for any connection. Try as much as possible. You can pick their emails and send grammatical text.

4. Apprenticeship programs
If you don’t have a degree in CS or industry experience, then this is the best place to be. The apprenticeship might offer certificates. At times they offer a full scholarship learning free courses to sharpen your skills. Make friends with the company holding the programs. Sometimes they offer internships and their projects might be appealing on your resume.

5. Target Smaller Companies
Most software engineers will look for large tech companies. But when it comes to small companies, their vacancies have fewer applicants. If you are very ambitious, remember you are new to the job, a small company might offer you perfect skills. The interview in these minor companies is much easier compared to big tech companies like Google. If you get the job, sharpen your skills, increase your technology tools and get ready for big interviews.

Software engineering jobs are abundant. The world of technology is still growing wide. Work on personal projects and make your GitHub green. The certifications are sometimes worthwhile. Let your resume talk about what you can do.
NFT
Published: 2021-08-09 00:08:37

The blockchain space has been really popular lately and you might here about  all of these different terms and its kind of hard to keep up with what is going on. Today I am going to talk about one of the buzz words NFT.

**What is a NFT anyway?**
You may have heard NFT, but what is a NFT exactly? NFT is a non-fungible token. You can think of it as like a piece of art or digital collectable that cant be exchange for something else, like bitcoin for example.

**How do NFT's work?**

At a high level NFT's are part of the Ethereum blockchain. The Ethereum blockchain is used to build things. ERC-721 is the standard for a NFT, you can read more about this topic [here](https://ethereum.org/en/developers/docs/standards/tokens/erc-721/)

**What are people using NFT's for?**

NFT's can pretty much be anything. You can create music, digital art,  or various things. You might have heard of crypto punks. These NFT's are pretty popular and cost a lot. I notice the  people that are within the Ethereum network, are using the crypto punks as there profile pictures, especially on twitter.

**So why own a NFT?**
With blockchain technology you are storing your information on a public ledger. This means that when you purchase a NFT it will show that you are the original owner. Therefore, if you decide to sell your NFT that also will be documented on the blockchain. You will always know if something is real or not. 

*Gaming NFT what??*

Another cool thing about NFT's is that gaming is really big in the blockchain space right now and NFT's are part  of it. You can collect NFT's from certain games and trade them in and out of games in some instances. Check out this cool game [here](https://axieinfinity.com/?__cf_chl_managed_tk__=pmd_07c155e12981919d4530f96f45d2e0432729706d-1628467323-0-gqNtZGzNA2KjcnBszQ_6)

NFT's are really hot right now. I would definitely check them out. If you would like to see various collections click [here](https://opensea.io/) and [here](https://rarible.com/)

I hope this was helpful.

Happy coding!
How to see all the commands executed so far or the history of commands executed in the Linux terminal?
Tags: resource
Published: 2021-08-09 00:00:00

---
  title: How to see all the commands executed so far or the history of commands executed in the Linux terminal?
  published: true
  tags: Resource
  date: Mon Aug 09 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/see-all-commands-executed-or-history-in-terminal-linux
  cover_image: https://melvingeorge.me/_next/static/images/main-e3e3ba7b81c0bd967d2dbb82a6166c5e.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/see-all-commands-executed-or-history-in-terminal-linux)
  
To see all the commands you have executed so far in the terminal as a list, you can use the `history` command in the Linux terminal.

```bash
# See all the commands executed
# so far in the Linux terminal
history
```

- Running the above command will show the list of commands the user has executed till that point in time.

For example, the output of executing the above `history` command may look like this,

```bash
# OUTPUT

 9276  ls
 9277  mkdir hello-world
 9278  cd hello-world
 9279  ls -a
 9280  touch myfile.txt
 ..
 ..
 ..
```

See the execution of the above command live in [repl.it](https://replit.com/@melvin2016/see-all-the-commands-executed-in-the-linux-terminal#main.sh).

That's all 😃!

### Feel free to share if you found this useful 😃.

---
Null vs Undefined vs Undeclared
Published: 2021-08-08 23:17:03

If you've been programming for a while, these terms might be familiar to you and not in the good sense. Usually we find these words written in red text with a whole bunch of errors. Now this article won't be focused on those errors but more so on what these 3 keywords mean and how they differ from each other. 

Let's start off with <em>`null`</em>. null is an actual value that can be given to a variable. It is similar to saying a variable is empty. 

Secondly we have <em>`undefined`</em>. Undefined is an error that is thrown when the programmer is trying to assign or use a variable without having first declared it. Nowadays with ES6's new `let` and `const`, these `undefined`'s are much easier to spot. Back before ES6, there would be a lot of silent errors that would occur with the `var` keyword and how it hoisted itself. 

Lastly, we have a more uncommon error, <em>`undeclared`</em>. With the release of ES6, these errors have been seen a lot less as for this error occurs when you try to assign a value to a variable that has not been declared with var.
Dev log for Wonder Wanderer 2: Day 8 #LOWREZJAM 😁
Tags: javascript, challenge, devjournal, gamedev
Published: 2021-08-08 22:39:48

### What have I done today? ###
Now I can say more things about my project. I have 6 days for finishing it, and I'll finish tomorrow to do the conclusive touches about mechanisms and level design.
I hope to have the time for finish the game, but I feel the game will be rushed unfortunately. I'll need to remake it one day, maybe with a sequel. Today I finished to make bouncy blocks, gravity changer button (you can have top down controls or side-scroller ones. You will need to use both for finishing a level) and also a change level block as well. I only hope this will be good.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9bdwaq5578lq4n6isx82.gif)
<figcaption> Another test level showing more the new mechanics!</figcaption>
More HTML Elements
Tags: html, beginners, codenewbie
Published: 2021-08-08 22:13:07

HTML elements are used to structure your webpage. For example, where text should be bolded or italicized, to create paragraphs, to line break, how quotations appear, etc.

I'll go over a few of them here.

`<b>the text inside the element will be bolded</b>`

`<i>the text here will be italicized</i>`

`<sup>` stands for superscript, so if you need some letters in a word to be raised up like the '4th' of July you would code it the following way:
`<p>On the 4<sup>th</sup>of July.`

`<sub>` stands for subscript and will be used in the same fashion. So for CO2...

`<p>CO<sub>2</sub></p>`

`<hr />puts a horizontal rule in between topics or themes.` 

```<p>Eggs are delicious.</p>
<hr />
<p>Bacon if LIFE.</p>```

The result is:

Eggs are delicious.
(there would be a line here)
Bacon is LIFE.

Happy Coding!