teleren/devto huggingface dataset:
Chatting with the Cloud: Setting up a ChatGPT Service on AWS
Tags: aws, chatgpt
Published: 2023-02-11 17:28:10

Are you interested in setting up a ChatGPT service in the cloud? In this tutorial, I'll walk you through the steps of getting a ChatGPT service up and running on Amazon Web Services (AWS).

Here's what you'll need before you get started:

- An AWS account
- An OpenAI API key
- An SSH client like PuTTY or Terminal (if you're using a Windows machine)

## Step 1: Launch an EC2 Instance

The first step is to launch an EC2 instance, which is essentially a virtual machine in the cloud that you can use to run your ChatGPT service. Here's how:

1. Log in to the AWS Management Console and navigate to the EC2 dashboard.
2. Click the "Launch Instance" button.
3. Choose the Amazon Linux 2 AMI.
4. Select an instance type that meets the requirements for OpenAI's GPT-3 API. OpenAI recommends using an instance with at least 16 GB of RAM and 2 vCPUs, such as the c5.large instance type.
5. Follow the steps to configure your instance and launch it.

## Step 2: Connect to Your Instance

Once your instance is up and running, you'll need to connect to it using an SSH client. Here's how:

1. Open your SSH client.
2. Enter the public DNS or IP address of your EC2 instance.
3. Log in as the `ec2-user` user.


## Step 3: Install Dependencies

Once you're connected to your EC2 instance, you'll need to install Git, Docker, and the dependencies required to run OpenAI's GPT-3 API. Here's the code you'll need to run:

```
# Install Git
sudo yum install git -y

# Install Docker
sudo amazon-linux-extras install docker
sudo service docker start
sudo usermod -a -G docker ec2-user

# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

# Install pip
sudo yum install python3-pip -y
```

## Step 4: Clone the OpenAI Repository

Now that you've installed the necessary dependencies, you can clone the OpenAI repository and install the dependencies required to run the API. Here's the code you'll need to run:

```
# Clone the OpenAI repository
git clone https://github.com/openai/api
cd api

# Install the dependencies
pip install -r requirements.txt
```

## Step 5: Start the API

Finally, you can start the API by running the following command:

```
docker-compose up -d

```
This will start the API in the background. To test that your API is working, you can make a request to the endpoint `http://your-instance-ip:8080/request` and provide your OpenAI API key in the `Key `header. You should receive a response from the model!

And that's it! You now have a fully functional ChatGPT service running on AWS. Start building your conversational applications today!
How to specify tuple contents' type without knowing tuple's size for function parameter?
Tags: python
Published: 2023-02-11 17:20:27

Hi, I'd like to specify a parameter in function as tuple whose contents are int type and I don't know tuple's size in advance. But when I code like this:

```
def func(t: tuple[int]):
    pass
```

which may specify the size of t to 1.
I'd like to know how to resolve this question for not knowing the size of t when I define the function?

Thanks a lot.
Learning more about functions
Published: 2023-02-11 16:54:11

Functions: 

- they are declared with the funciton key word
- then comes the name of the function
- then the input, these are called the parameters
- the parameters are passed into the funciton's body which is held between two {}

so here is the basic syntax

funciton dillon(this is where the parameters go!) {
console.log(what is input in the parameter);
}
dillon(4)

running the function dillon(4) would cause the console to log out 4  

BIG THING - functions can access outer variables, but what happens in the function kind of stays in the function... meaning that you can't create a variable and then call it outside the function. This is what's called function scoped.
CSS Fundamentals Explained
Tags: css, webdev, beginners
Published: 2023-02-11 16:41:56

Have you ever visited a website that made your eyes bleed? Chances are, it was missing one crucial ingredient: CSS.

CSS, or Cascading Style Sheets, is the magic sauce that takes your boring HTML page and transforms it into a visually stunning masterpiece... or at least, makes it look less like a 90s Geocities page.

But where do you start with CSS? Fear not, my friend, because I'm here to guide you through the basics.
## Selectors: The Key to Unlocking Your Inner Designer

CSS selectors are like the X-Men of the web development world. They have special powers that allow you to target specific HTML elements and apply styles to them.

For example, you can target all `<h1>` elements on your page and make them blue and fluffy, like this:

```css
h1 {
  color: blue;
  text-shadow: 0 0 10px #ffffff;
}
```

Or you can make all links on your page turn into cute little puppies, like this:

```css
a {
  background-image: url(puppy.jpg);
  background-size: cover;
}
```

<br>

## Properties: The Building Blocks of Style

CSS properties are like the bricks that make up a building. They allow you to control the look and feel of your HTML elements.

For example, you can control the font size, color, and family of your text like this:

```css
p {
  font-size: 16px;
  color: #333;
  font-family: Arial, sans-serif;
}
```
Or you can control the size and color of your cute little puppy links, like this:

```css
a {
  width: 200px;
  height: 200px;
  background-color: #ffc0cb;
}
```

<br>

## Final Thoughts

With CSS, the possibilities are endless. You can make your website look like a fairy tale, a futuristic sci-fi epic, or even a page straight out of a Lisa Frank notebook. So go forth and unleash your inner designer! The world of bland, eye-bleeding websites needs you.
Chedoku, a chess/sudoku based puzzle game
Tags: gamedev, webdev, javascript, productivity
Published: 2023-02-11 16:41:24

I just launched 🔗[Chedoku puzzle](https://www.chedoku.com)🔗 which is a Chess based puzzle game that is very similar to minesweeper and sudoku. I prefer not to explain more and invite you to try the [Chedoku puzzle](https://www.chedoku.com) instead.
Convert variable font to static font using Python
Tags: python, font, design, tooling
Published: 2023-02-11 16:39:14

## fonttools

A library to manipulate font files from Python[^1].

[^1]: https://github.com/fonttools/fonttools.

### Install

```bash
pip install fonttools
```

### Convert Font

```bash
fonttools varLib.mutator ./font.ttf wght=400 wdth=85
```

Documentation: https://fonttools.readthedocs.io/en/latest/varLib/mutator.html#module-fontTools.varLib.mutator
React State Management Survey
Tags: react, webdev, javascript, typescript
Published: 2023-02-11 16:34:41

Hello, I am a last years student Applied Informatics who is currently doing some research on state management tools/technologies for my Bachelors thesis. The research will mostly be focused on React. To support my own research, I would love to see how other developers feel about different state management tools! As I am only a student and have a modest amount of experience, I can only base myself on small projects and sources. Therefore I would love to hear from you!

I set up this form where there will be some questions asked about state management tools. Would you be so kind to fill this out? By doing so, I'll have additional information I can write about in my Bachelors thesis.

Link: https://form.jotform.com/230465362415351

If you want, I can enable sharing the results so you too could see the results.

Thanks in advance!
**NOTE**: I **DON'T** collect your email address! I enabled **one response only**, therefore you might need to enter your email address. Everything **IS ** anonymous.
AND, OR operatorlari
Tags: programming, python
Published: 2023-02-11 16:07:51

if - elif - else zanjirida shartlaring biri bajarilishi bilan, Python qolgan shartlarni tekshirmaydi va ularni bajarmaydi. Lekin ba'zida biz 2 yoki undan ko'p shartlarni tekshirishni talab qilishimiz mumkin, buning uchun _AND_ va _OR_ operatorlaridan foydalanamiza.  

_OR_ inglis tilidan _"yoki"_ deb tarjima qilinadi.
_AND_ ingli tilidan _"va"_ deb tarjima qilinadi.
_AND_ operatori bilan yozilgan shartlarning barchasi bajarilgandagina _TRUE _qiymati qaytaradi, agar shartlardan biri bajarilmay qolsa ham _FALSE_ qiymati qaytadi.
Customize prompt in Zsh: prompt in Z shell
Tags: zsh, prompt, customization
Published: 2023-02-11 16:07:03

Prompt customization is good to relieve stress from hard work. Follow the simple steps below to customize your Zsh prompt.




##TL;DR
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ci5c2kqu3hdv6aan6nro.jpg)
`PROMPT='%F{green}%n%f@%F{blue}%m%f %(?.>.[%?]>) '`

Customize user name color from green
Customize hostname color from blue




## Add prompt contents
First, choose contents

- %n  User name
- %m  Hostname(First field only, divide by '.')
- %M  Hostname(Full)
- %B%i~%b Last i level of current directory, replace i with number

Conditional content can also be added, such as an error code from previous command.
`%(?.a.b)`

- If the previous command return zero, print 'a'
- If the previous command return non-zero, print 'b', replace 'b' with '%?' to show an error code

Other [ASCII Characters](https://www.cs.cmu.edu/~pattis/15-1XX/common/handouts/ascii.html) can be inserted directly

Put everything together and assign to PROMPT

```
sukkarin@M-208 >> PROMPT='%n@%M >> '
sukkarin@M-208 >>
```

To show the error code, add '%(?.>>.[%?]>>)'
Listing the non-existing-file results to an error code [2]
```
sukkarin@M-208 >> PROMPT='%n@%M %(?.>>.[%?]>>) '
sukkarin@M-208 >> ls not-existing-file
ls: cannot access 'not-existing-file': No such file or directory
sukkarin@M-208 [2]>>
```




## Customize colors

- %K{}  Set background color from this point, put desired color code inside {}
- %k    Set background color to default, start from this point
- %F{}  Set character color from this point
- %f    Reset character color to default, start from this point

Color can be set by %F{blue} or %F{012}
See full list of [XTerm Color Numbers](https://en.wikipedia.org/wiki/Xterm#Protocols)

From the previous command. Set user name to green and hostname to blue.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ci5c2kqu3hdv6aan6nro.jpg)
Redux-like state container in SwiftUI. Usage.
Tags: swift, ios, mobile, programming
Published: 2023-02-11 16:03:50

We can finish our [repos search app](https://dev.to/sergeyleschev/redux-like-state-container-in-swiftui-basics-single-source-of-truth-2lpc) that calls Github API asynchronously and fetches repositories matching a query.

```swift
typealias AppStore = Store<AppState, AppAction, AppEnvironment>

struct SearchContainerView: View {
    @EnvironmentObject var store: AppStore
    @State private var query: String = "Swift"

    var body: some View {
        SearchView(
            query: $query,
            repos: store.state.searchResult,
            onCommit: fetch
        ).onAppear(perform: fetch)
    }

    private func fetch() {
        store.send(.search(query: query))
    }
}

struct SearchView : View {
    @Binding var query: String
    let repos: [Repo]
    let onCommit: () -> Void

    var body: some View {
        NavigationView {
            List {
                TextField("Type something", text: $query, onCommit: onCommit)

                if repos.isEmpty {
                    Text("Loading...")
                } else {
                    ForEach(repos) { repo in
                        RepoRow(repo: repo)
                    }
                }
            }.navigationBarTitle(Text("Search"))
        }
    }
}
```

We divide our screen into two views: `Container View` and `Rendering View`. `Container View` handles the actions and retrieves the needed piece of state from the global state. `Rendering View` accepts the data and renders it.

---

- [Basics](https://dev.to/sergeyleschev/redux-like-state-container-in-swiftui-basics-single-source-of-truth-2lpc)
- [Reducer and Actions](https://dev.to/sergeyleschev/redux-like-state-container-in-swiftui-basics-reducer-and-actions-flg)
- [Unidirectional flow](https://dev.to/sergeyleschev/redux-like-state-container-in-swiftui-basics-unidirectional-flow-3f2p)
- [Side effects](https://dev.to/sergeyleschev/redux-like-state-container-in-swiftui-side-effects-3l23)
- [Usage](https://dev.to/sergeyleschev/redux-like-state-container-in-swiftui-usage-k1i)

---

**Contacts**
I have a clear focus on time-to-market and don't prioritize technical debt. And I took part in the Pre-Sale/RFX activity as a System Architect, assessment efforts for Mobile (iOS-Swift, Android-Kotlin), Frontend (React-TypeScript) and Backend (NodeJS-.NET-PHP-Kafka-SQL-NoSQL). And I also formed the work of Pre-Sale as a CTO from Opportunity to Proposal via knowledge transfer to Successful Delivery.

🛩️ #startups #management #cto #swift #typescript #database
📧 Email: sergey.leschev@gmail.com
👋 LinkedIn: https://linkedin.com/in/sergeyleschev/
👋 LeetCode: https://leetcode.com/sergeyleschev/
👋 Twitter: https://twitter.com/sergeyleschev
👋 Github: https://github.com/sergeyleschev
🌎 Website: https://sergeyleschev.github.io
🌎 Reddit: https://reddit.com/user/sergeyleschev
🌎 Quora: https://quora.com/sergey-leschev
🌎 Medium: https://medium.com/@sergeyleschev
Polaris bank code 2023
Published: 2023-02-11 16:00:13

[https://www.bankfanz.com/polaris-bank-transfer-code/](https://www.bankfanz.com/polaris-bank-transfer-code/#utm_source=backlinks&utm_medium=search&utm_campaign=darry+ring+us&utm_content=Michelle)

https://plaza.rakuten.co.jp/polarisbankcode1/diary/202302110000/
https://peatix.com/user/15919885/
https://www.provenexpert.com/polaris-bank-code-to-check-balance3/
https://www.producthunt.com/@polarisbank5
https://www.divephotoguide.com/user/polarisbankcode5
https://wakelet.com/@Polarisbankcodetocheckbalance254
https://vocal.media/authors/polaris-bank-code-to-check-balance-5sn7nl0rjd
https://www.lifeofpix.com/photographers/polarisbank5/
https://seedandspark.com/user/polaris-bank-code-to-check-balance-3
https://rosalind.info/users/Polarisbankcode5/
http://phillipsservices.net/UserProfile/tabid/43/userId/198584/Default.aspx
https://app.roll20.net/users/11617678/polaris-bank-code-to-check-b
https://speakerdeck.com/polarisbankcode5
https://social.msdn.microsoft.com/Profile/Polaris%20bank%20code%20to%20check%20balance%202023%205
https://camp-fire.jp/profile/polarisbank5
https://plazapublica.cdmx.gob.mx/profiles/Polarisbankcode5/activity
https://www.metal-archives.com/users/polarisbankcode5
https://storium.com/user/polarisbankcode5
https://trabajo.merca20.com/author/polarisbankcode5/
https://www.intensedebate.com/people/Polarisbank5
https://www.mifare.net/support/forum/users/polarisbankcode5/
https://pinshape.com/users/2572548-polarisbank5
http://foxsheets.com/UserProfile/tabid/57/userId/120672/Default.aspx
https://www.kompasiana.com/polarisbankcode5
https://www.credly.com/users/polaris-bank-code-to-check-balance-2023/badges
https://www.myminifactory.com/users/polarisbankcode5
https://www.sqlservercentral.com/forums/user/polarisbankcode5
https://www.longisland.com/profile/polarisbankcode5
https://guides.co/a/polaris-bank-3460
https://myanimelist.net/profile/Polarisbankcode5
Latin x Python: 11/02/23
Tags: webdev, programming, python, latin
Published: 2023-02-11 16:00:00

It's been more than 2 weeks since I started ~~Latin is Fun~~ Discipulis, a website whose ultimate aim is to help children around the world learn Latin in a fun way.
My aim for now though is to create a website which can easily generate questions like English-Latin, Latin-English or grammar questions (eg. what case a word is in).
I've added some major updates to the website since then!

---

Features that have been added since the 1st of February:
- I have changed the name to Discipulis! This literally means "for the students".
- Clicking the cells show/hide the content
- Added a test mode function, so you can fill in the table yourself
- @mattdestroyer added an animation for the flipping of the cells
- I added SEO optimisation by adding meta tags and using various website graders for tips
- I made the navbar and website more responsive
- @mattdestroyer added a hover effect to the cells
- I added a sets feature (sets are groups of words that can be used in quizzes)
- I added a quiz function where you can use different sets for quizzes. The quizzes include multiple choice and written answers, and questions on cases and tenses
- I added a set page so you can view the set and all its vocab
- A favicon has been added. Discipulis has a logo!

---

To test out the website yourself, visit https://discipulis.vulcanwm.repl.co
Comment below if you have any feedback or feature requests.
I’m not going to include any demos as you can check those out on the website.

---

Thanks for reading.
If you want to support me with this project, make sure to follow me and like this post!
good practices for your software projects
Tags: git, webdev, collaboration
Published: 2023-02-11 15:54:17


For opensource projects, choose a license
- https://choosealicense.com/

Create a good README for your projects
- https://www.makeareadme.com/ 

Keep a Change log for your project
- https://keepachangelog.com/en/1.0.0/

A way to manage project versions
- https://semver.org/ 

How to write Release Notes (Release Notes are different from Change Log)
- https://theproductmanager.com/topics/software-release-notes/
谷歌面试题: 迷宫随机生成算法
Tags: cn, google, interview, maze
Published: 2023-02-11 15:46:28

<iframe width="560" height="315" src="https://www.youtube.com/embed/3Q7-9CWbE5w" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

据说这个是<a href="https://justyy.com/archives/47640" title="用谷歌地图 (Google Map) 创建: 英国去过的地方">谷歌 Google</a> 的第一轮面试题. 一般这种题目就是: 设计一个迷宫算法 (Design a Maze). 面试中应该先问清楚需求 (Ask Clarifying Questions): 迷宫需要有几条出路? (假定至少1条), 多大的迷宫? 多复杂的迷宫等等. 

最容易想到的就是随机生成1和0的地图，其中1是墙，0是空路，不过这种方法生成随机的效率实在是太低，你可以跑了半天也无法生成一个有效的迷宫，我们假定有效的迷宫是至少含一条路径。

```python
def maze(width, height):
    m = None
    while not check(m):
        m = generate_random_matrix(width, height)
    return m
```

当迷宫无效的时候我们还可以随机的把一些墙变成空格，这样在进行若干次后肯定有路径，不过这样的迷宫不可控，因为很有可能生成的迷宫很稀疏 (Sparse)，一点也不像迷宫。 

```python
def maze(width, height):
    m = generate_random_matrix(width, height)
    while not check(m):
       m = remove_a_random_wall(m)
    return m
```

效率比较高的一种算法是：先随机生成一条或者几条有效路径，然后生成若干条干扰路径，然后再把剩下的填成墙。

在生成路径的时候我们可以从顶部（然后可以旋转或者水平垂直镜像生成其它可能）随机往下左或者右三个方向走，并且我们需要记录走过的格子(<a href="https://justyy.com/archives/4987" title="软件工程师面试技巧之 使用哈希表降复杂度">哈希</a>集合)，这样就不会重复走。随机走然后直到走出界。生成干扰路径只需要最后面随机在路么中间加堵墙（或者多个）。

当然需要避免在生成干扰路径的时候加的墙也同时把我们需要的有效路径给堵死了，只需要避免在岔口填墙就可以了。

以下是 OpenAI/ChatGPT 给出的解决方案。

<ul>
<li>创建一个迷宫: 创建一个二维数组, 用来表示迷宫的每个位置, 0表示可以通过, 1表示不可以通过. </li>
<li>随机生成迷宫: 使用随机数来生成迷宫, 将一定比例的位置设置为1, 其余位置设置为0. </li>
<li>添加起点和终点: 将起点和终点的位置设置为0, 以便可以通过. </li>
<li>添加障碍物: 在迷宫中添加一些障碍物, 使得起点和终点之间的路径更加复杂. </li>
<li>添加传送门: 在迷宫中添加一些传送门, 使得玩家可以从一个位置跳转到另一个位置, 从而更加有趣. </li>
</ul>

[caption id="attachment_151919" align="alignnone" width="580"]<a href="https://helloacm.com/wp-content/uploads/2023/01/generate-a-random-maze.jpg"><img src="https://helloacm.com/wp-content/uploads/2023/01/generate-a-random-maze.jpg" alt="Random Maze Generate Algorithm" width="580" height="751" class="size-full wp-image-151919" /></a> Random Maze Generate Algorithm[/caption]
 
英文: <a href="https://helloacm.com/teaching-kids-programming-maze-design-algorithm-how-to-generate-a-random-maze/" target="_blank" rel="noopener">Teaching Kids Programming – How to Design a Random Maze? Random Maze Generation Algorithm</a>

博文: [https://justyy.com/archives/61133](https://justyy.com/archives/61133)
04: Set Up Test Docker Registry
Published: 2023-02-11 15:46:28

The aim of this step is to set up a test container registry, so that when I start the dev work I have little to worry on the IAC side.

## ✅ Create IAM Roles for ECR Access - [PR 2](https://github.com/rmayore/FakeST-DevOps/pull/2)
A Read Access role to be used by any application that will be pulling the images, with the below permissions:
```
- ecr:GetAuthorizationToken,
- ecr:BatchCheckLayerAvailability,
- ecr:GetDownloadUrlForLayer,
- ecr:GetRepositoryPolicy,
- ecr:DescribeRepositories,
- ecr:ListImages,
- ecr:DescribeImages,
- ecr:BatchGetImage,
- ecr:GetLifecyclePolicy,
- ecr:GetLifecyclePolicyPreview,
- ecr:ListTagsForResource,
- ecr:DescribeImageScanFindings
```

A Read & Write role to be used by whatever agent that will be building the images, with the permissions: 
```
- ecr:GetAuthorizationToken,
- ecr:BatchCheckLayerAvailability,
- ecr:GetDownloadUrlForLayer,
- ecr:GetRepositoryPolicy,
- ecr:DescribeRepositories,
- ecr:ListImages,
- ecr:DescribeImages,
- ecr:BatchGetImage,
- ecr:GetLifecyclePolicy,
- ecr:GetLifecyclePolicyPreview,
- ecr:ListTagsForResource,
- ecr:DescribeImageScanFindings,
- ecr:PutImage,
- ecr:InitiateLayerUpload,
- ecr:UploadLayerPart,
- ecr:CompleteLayerUpload,
- ecr:DeleteRepository,
- ecr:BatchDeleteImage,
- ecr:SetRepositoryPolicy,
- ecr:DeleteRepositoryPolicy
```

I set these 2 roles with Pricipals as a wildcard (*) to be as permissive as possible, then later I'll figure out further restrictions.

## ✅ Create a Test ECR Repo - [PR 3](https://github.com/rmayore/FakeST-DevOps/pull/3)
This proved a challenge as it's my first time working with Terragrunt, but I was able to get the dependencies (on the above roles) working for this module.

I also checked on S3 and confirmed that out terragrunt remote state is working fine!