teleren/devto huggingface dataset:
How to Run VS Code Terminal as Administrator
Published: 2023-03-09 01:20:50

To run the VS Code Terminal as an administrator, follow the steps below:

1.Open VS Code and click on the "Terminal" tab in the top menu.

2.Click on "New Terminal" to open a new terminal window.

3.In the terminal window, type the following command:

" sudo code . "

4.Press enter and you will be prompted to enter your administrator password.

5.Enter your password and press enter. VS Code will now launch with administrator privileges.


**Note: If you are using Windows, the process may differ slightly. You can try the following steps:**


1.Right-click on the VS Code icon on your [desktop](https://bestpcdesign.com/best-pc-design-store/).

2.Select "Run as administrator" from the context menu.

3.Click on the "Terminal" tab in the top menu.

4.Click on "New Terminal" to open a new terminal window.

5.The terminal window will now run as an administrator.
Calling the ChatGPT API interactively from Crystal language
Tags: chatgpt, crystal
Published: 2023-03-09 00:53:31



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

```crystal
require "http/client"
require "json"
require "colorize"

struct PostData
  include JSON::Serializable
  property model : String
  property messages : Array(Hash(String, String))
  property temperature : Float64
  property top_p : Float64
  property n : Int32

  def initialize
    @model = "gpt-3.5-turbo"
    @messages = [] of Hash(String, String)
    @n = 1
    @temperature = 1.0
    @top_p = 1.0
  end
end

data = PostData.new

url = "https://api.openai.com/v1/chat/completions"
api_key = ENV["OPENAI_API_KEY"]
headers = HTTP::Headers{
  "Authorization" => "Bearer #{api_key}",
  "Content-Type"  => "application/json",
}

def get_input(prompt)
  print prompt
  STDIN.gets.to_s.chomp
end

def send_chat_request(url, data, headers)
  STDERR.puts data.pretty_inspect.colorize(:dark_gray) # comment out here!
  HTTP::Client.post(url, body: data.to_json, headers: headers)
end

loop do
  msg = get_input("> ")
  break if msg.empty?
  data.messages << {"role" => "user", "content" => msg}

  response = send_chat_request(url, data, headers)
  response_data = JSON.parse(response.body)

  if response.status.success?
    result = response_data["choices"][0]["message"]["content"]
    data.messages << {"role" => "assistant", "content" => result.to_s}
    puts result.colorize(:green)
  else
    STDERR.puts "Error: #{response.status_code} #{response.status}".colorize(:yellow).mode(:bold)
    STDERR.puts response.body.colorize(:yellow)
    exit 1
  end
end
```

According to ChatGPT, the description of this code is as follows

---

The code is a program written in the Crystal language that uses the OpenAI ChatGPT API to conduct a chat conversation.

The first few lines import the required libraries - HTTP client, JSON parser, and colorize (for terminal color highlighting). The next part defines a struct named PostData that represents the data to be sent in the API request. It has several properties, including the model name, messages array, and temperature and top_p values, which are used to configure the behavior of the ChatGPT model.

The get_input function is defined to prompt the user for input, and the send_chat_request function is used to send the request to the API endpoint, using the data provided as the request body.

The main part of the program is a loop that iteratively prompts the user for input, sends the input to the API endpoint using the send_chat_request function, and then processes the response. If the response is successful, it extracts the result from the response data and displays it to the user in green color. If there is an error in the response, it displays an error message in yellow color and exits the program.

Overall, the program provides a simple command-line interface for conducting a chat conversation using the OpenAI ChatGPT API.

---

Wonderful. I can't explain what I wrote in my code very well, but ChatGPT does it very well.

Have a nice day!
Beginner in Tech
Tags: wecoded
Published: 2023-03-08 23:26:35

Hello DEV community,

I am very new to the behind the scenes tech world. I am currently going through courses for Front End and Design.

I really wish I would have looked sooner to the options I had available, this is the most exciting and fun career I have ever found. I am now 40 and have had a lot of careers from reception to construction. Everything you can think of, I have done except doctor or tech stuff. 

I have always lived the life of find what truly makes you happy and to never settle. Along the way there was definitely challenges and even thinking about starting a career as a developer was a decision I wasn’t sure about because I always thought of it as a male dominated industry. While I did do construction and it was very hard being a women in a very male dominated environment, I did fit myself in and dealt with men that were mean and disgusting. So I moved on to the next career. 

So far I feel very welcomed in the industry so I pledge to embrace equality in tech by being very welcoming and helping anyway I can to make everyone feel comfortable, there is no reason for anyone to work hard to do the job they love just to be treated poorly. 

As I move forward in my new career I hope that anyone starting out can feel as excited as I am and as welcomed as I have been to be in the tech world!
Streamline Your Content Creation with GoCharlie: The Ultimate AI Content Creator
Tags: ai, chatgpt, gocharlie
Published: 2023-03-08 23:15:56

Content creation has become a crucial component of any effective marketing strategy in the fast-paced world we live in today. But creating top-notch content that appeals to and resonates with your target audience can be difficult and time-consuming.

[GoCharlie](https://gocharlie.ai?fpr=theophilus42), an AI-driven content creator, steps in at this point. [GoCharlie](https://gocharlie.ai?fpr=theophilus42) is a tool that generates expert and personable content for a range of purposes, including blog posts, articles, social media posts, and product descriptions, using sophisticated algorithms. The many advantages of using [GoCharlie](https://gocharlie.ai?fpr=theophilus42) as a content creation tool will be discussed in this blog post, along with the reasons it is quickly becoming a top choice for companies and individuals looking to streamline their content creation procedures.

[TRY GOCHARLIE FOR FREE](https://gocharlie.ai?fpr=theophilus42)

Utilizing [GoCharlie](https://gocharlie.ai?fpr=theophilus42) has a number of benefits, one of which is its capacity to produce excellent content quickly and effectively. Businesses and individuals no longer need to spend hours creating content from scratch thanks to [GoCharlie](https://gocharlie.ai?fpr=theophilus42). They can instead enter their specifications into the tool and let [GoCharlie](https://gocharlie.ai?fpr=theophilus42) take care of the rest. The tool analyzes language patterns using natural language processing algorithms to produce content that is not only grammatically accurate but also engaging and human-sounding.

The ability to customize [GoCharlie](https://gocharlie.ai?fpr=theophilus42) is another benefit. By modifying the tone, style, or length of the content, users can modify the generated content to suit their particular needs. As a result, the content will be consistent with the user’s brand voice and messaging, creating a more effective and cohesive content strategy.
Additionally, GoCharlie’s capacity to learn and modify itself over time is a game-changer for both individuals and companies. The tool improves its comprehension of the user’s preferences and style as it produces more content, leading to the creation of more tailored and useful content.

In conclusion, [GoCharlie](https://gocharlie.ai?fpr=theophilus42) is a creative, user-friendly, and professional solution for content creation. It is an invaluable tool for companies and individuals looking to improve their content strategy because of its capacity to produce high-quality content quickly and effectively while remaining highly adaptable and customizable. Content creation is now an easy and streamlined process thanks to [GoCharlie](https://gocharlie.ai?fpr=theophilus42) rather than a difficult and time-consuming task.

[TRY GOCHARLIE FOR FREE](https://gocharlie.ai?fpr=theophilus42)
How To Create A Custom Hooks In React.
Published: 2023-03-08 22:52:51

Custom hooks are reusable functions used for stateful logic. A custom Hook is a JavaScript function whose function starts with ”use”.

In this tutorial, we will learn how to "how to create a customhooks in react"

**Prerequisite**
Before we begin, these are technologies you should be familiar with and have installed on your local machine to follow up these guides:

1. Nodejs v18+

2. React Knowledge

In this tutorial, we will build a simple e-commerce store that fetches data from FakeStoreAPI

Let's start by running this in our terminal.

1. Open your terminal and run
npx create-react-app reactapp

2. Navigate to the folder
 cd reactapp

3. Run
 npm start

Now our app is running locally, let's get started by:

Creating a customhooks folder

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

Inside the customhooks folder create a Usefetch.js file and input this code.

```
import { useState, useEffect } from "react";

 const Usefetch = (url) => {
   const [images, setData] = useState([]);

   useEffect(() => {
     fetch(url)

       .then((res) => res.json())
       .then((images) => setData(images));
   }, [url]);

   return [images];
 };

 export default Usefetch;
```
Now create a imageHolder.js file and input this code.

```
 import React from "react";

 const imageHolder = () => {

   return (
     <>
       {
         images.map((item) => {
           return <p key= {item.id}>
              <img src={item.image}/>
             <h4>{item.title}</h4>
             <h1>{item.price}</h1>
             </p>
         })}
     </>
   );

 };

 export default imageHolder;

```

Now let's import our useFetch custom hooks into our ImageHolder.js file.

```
 import React from "react";
 import Usefetch from "../customhooks/Usefetch";

 const imageHolder = () => {

   // Fetching images from fakestoreApi
   const [images] = Usefetch("https://fakestoreapi.com/products");

   return (
     <>
       {
         images.map((item) => {
           return <p key= {item.id}>
             <img src={item.image}/>
             <h4>{item.title}</h4>
             <h1>{item.price}</h1>
             </p>
         })}
     </>
   );

 };

 export default imageHolder;

```
Now let's import the ImageHolder into our App.js file

```
 import React from "react";
 import ImageHolder from "./ImageHolder";

 function App() {

   return (
     <div className="">
       <ImageHolder />
       </div>

           )

   }
 export default App;

```
**Conclusion**
Custom hooks are reusable functions that aid code reusability. I can say this is the best hack ever, react developers should know when creating a large or small project.

Thanks for reading.
Prosody vs Synapse
Tags: xmpp, jabber, linux, matrix
Published: 2023-03-08 22:27:16

---
title: Prosody vs Synapse
published: true
date: 2023-03-08 22:21:05 UTC
tags: xmpp,jabber,linux,matrix
canonical_url: https://toby.ink/blog/2023/03/08/prosody-vs-synapse/
---

I recently decided to experiment by setting up a [Matrix](https://www.matrix.org/) account. And because I always dive head first into things, I of course set up my own Matrix server rather than making an account on a public one. At the same time, I noticed my Jabber/XMPP account had stopped working, so I decided to self-host an XMPP server too.

For Matrix, I used [Synapse](https://matrix.org/docs/projects/server/synapse) as that seems the most popular and well-supported implementation. It was mostly just a matter of installing the Ubuntu packages and starting the service, but there was a bit of manual work:

- The default config file is set up to store data in SQLite, but using SQLite is advised against, so I needed to manually create a PostgreSQL database and username, and add those to the config file.
- The default config is missing `macaroon_secret_key` and `registration_shared_secret` settings, which are kinda important.
- Because I wanted the server to be hosted on a different VPS than my website, I needed to set up delegation and some of the documentation online on how to do that isn’t quite correct.

For XMPP, I used [Prosody](https://prosody.im/) and the install went very smoothly. Again, just install the package and start the service. The only manual work was:

- Needed to enter a host name in the example config file.
- Ubuntu doesn’t give access to LetsEncrypt certificates to the prosody user, so I needed to fix permissions.

Overall, I would highly recommend Prosody as an XMPP server. Synapse is a good Matrix server too, but the Debian/Ubuntu packagers could take a look at Prosody for an example of a smooth install.

**My Matrix account is <em>at me colon toby.ink</em>.**

**My XMPP account is <em>me at toby.ink</em>.**
Day 709 : Wait For It
Tags: hiphop, code, coding, lifelongdev
Published: 2023-03-08 22:10:46

_liner notes_:
- Professional : Really productive day. Had an early meeting and a few more through out the day. There wasn't really enough time between meetings to really get into coding, so I did a bunch of smaller tasks that I could knock out. After the last meeting, I started working on the proof of concept demo.

- Personal : Went through tracks for the radio show. Worked on my side project until I ran into a blocker and spent the rest of the night thinking on how to solve it. Went to bed earlier than normal since I had an early meeting.

![A trail through talk stone faces with green moss and a small creek with rocks in it in Ice Age Trail, WI, USA](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xakievogqm9ehsc7ml50.jpg)

Going to go through tracks. I think I'll continue working on the proof of concept project for work and have a think on the blocker I ran into with my side project. The technologies I'm using for the proof of concept is similar to my side project so it may help me work it out. I'm sure if I'm productive it will come to me instead of staring at a screen to wait for it.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube OFb7bM4HgTI %}
Deploy full stack React app on Heroku
Published: 2023-03-07 21:29:18

We're gonna deploy our full stack React app in the same Heroku app. The back end is a Node express app, while the front end is a react app. The outcome of the deployment is that our backend would live on `https://react-app-name.herokuapp.com/api` and our client can be accessed by public via `https://react-app-name.herokuapp.com`. I have my Postgresql database set up on a unbuntu server. Click [here](https://dev.to/tttn13/host-a-postgresql-database-on-ubuntu-server-using-ec2-3dfi) if you would like to learn more.

This is the structure of my app 

```
app
|_server
|__client
```
### 1. Create a Heroku account

Sign up for a Heroku account. You need to add a credit card in order to create an app but it's not gonna cost anything to deploy the app. There's used to be a free tier plan that we can use to add Postgresql db service which made everything so much simpler, however they scrapped that, hence I chose to host the db on a virtual machine. 

Click New -> Create New App and choose a name for it. 

### 2. Add the config vars 

In the Settings section of the app on heroku, add the env variables needed to run your app. 

In my case, since I have the db hosted on an aws ec2 instance, I have the following variables

```
REACT_APP_BASE_URL=/api
PG_USER=ubuntu
PG_PASSWORD=password
PG_HOST=dbhost
PG_PORT=5432
PG_DATABASE=dbname
PG_DIALECT=postgres
```


### 3. Configure the Node server app

Add a `Procfile` file at the root of our project which is where the `package.json` for the server app lives. The reason I have to make a distinction is because I have my server folder nested in a parent folder that doesn't have a `package.json`. `Procfile` will tell heroku how to run the app when it's deployed to heroku. `node server.js` is how the server app is launched. If the main point of entry of your program is called differently, change the script to `node point-of-entry.js`

In the Procfile, add the following 

```
web: node server.js
```

### 4. Deploy the app

I assumed that you already have git initialized on your project otherwise run `git init`

After committing all the code to your gh repo, run  `heroku git:remote -a heroku-app-name`. Replace `heroku-app-name` with the name of your heroku app. 

Like mentioned above, I have my backend directory in another directory, hence I have to adjust the command to deploy the code to the remote heroku. 

```
git subtree push --prefix server-folder heroku main
```

If your app doesn't have the same structure, you can just run the below and it should be good.  

```
git push heroku main
```

It's gonna take a while to deploy your app. Inspect the logs on heroku if you encounter any issue.

If everything is done correctly, you should have a live app.
HTML 4 LinkTree
Published: 2023-03-08 21:49:32

just trying to set links into my tree


Spotify: https://open.spotify.com/user/obsidiankng?si=cc9679a7035847ec

Botanical Studies: (Rough Draft) <iframe src="https://docs.google.com/document/d/e/2PACX-1vQ55A60PT9Um55Uojs43R0YA6jyUlsvDoLPqnWyzbJWSIwiPSg7F3anerjsHJVcn5_MIhK2ci0M8_jV/pub?embedded=true"></iframe>

Replacing this line: <a target="_blank" href="https://www.twitch.tv/kensseiisan"> Watch My Streams</a>

with facebook
Join us for our upcoming webinar!
Tags: webinar, tutorial, productivity, opensource
Published: 2023-03-08 19:30:48

Hi, devs!

First of all, Happy International Women's Day!

I am here to invite you to join me at the next webinar I'm hosting for CTO.ai, where I'll talk about **How to use CTO.ai’s open-source SDKs to create customizable Workflows for software delivery**.

At this talk, I'll approach some subjects like:

- Workflows for developers
- Open-source SDKs to build a customizable delivery' platform for developers to use.

Here's the agenda:

✅ What workflows stand for
✅ What are the open-source SDKs available to get started
✅ How to use them (examples of usage in a real-life environment)
✅ How can these SDKs integrate with third-party tools for product delivery?
✅ Using SDKs to calculate DORA metrics in your project
✅ Q&A

It's a webinar 30 min long, plus a Q&A at the end so we can chat and discuss doubts that might come up along with the presentation.

You can subscribe through the website: https://cto.ai/webinars or directly through [this link](https://cto-ai.zoom.us/webinar/register/WN_cvrr1hhsSW2eHX4BXtnQtg).

See you there! :)
The CodeNewbie Podcast, S23:E4: A/B Testing
Tags: codenewbie, career, beginners, podcast
Published: 2023-03-08 21:37:08

Hey hey hey! Happy Wednesday y'all! We are back at it again with another episode of the CodeNewbie Podcast for ya.

In Season 23 Episode 4 of the CodeNewbie Podcast, @saronyitbarek talks about the importance of A/B testing with [Leemay Nassery](https://twitter.com/LeemayNassery), Senior Engineering Manager at Spotify. 

{% embed https://www.codenewbie.org/podcast/practical-a-b-testing %}

Leemay Nassery is an engineering leader at Spotify who is passionate about tying engineering to business and user impact while keeping her team's career growth at the forefront.

- [Listen on Apple Podcasts](https://podcasts.apple.com/us/podcast/s23-e4-practical-a-b-testing-leemay-nassery/id919219256?i=1000603263896)

- [Listen on Spotify](https://open.spotify.com/show/2T2OwucPOy2uDG1CUsjIMB?si=d94ce3703c0a46f8)

Or, listen wherever you get your podcasts!

***

**Make sure to subscribe to the CodeNewbie podcast if you haven't yet!**

Happy coding! We hope you enjoy this season of the CodeNewbie Podcast 💜
Meet banditypes — the smallest TypeScript validation library
Tags: javascript, typescript, webdev
Published: 2023-03-08 21:04:35

I'm excited to announce  [banditypes](https://github.com/thoughtspile/banditypes) — a new validation library for TS and JS. You may have heard of [zod](https://zod.dev/) or [superstruct](https://github.com/ianstormtaylor/superstruct) — these great tools let you define a JS schema to validate objects, and automatically convert the schema to a TS type to avoid duplication. Well, banditypes does the same thing, but in 400 bytes!

![A code sample of banditypes validator](https://blog.thoughtspile.tech/images/banditypes-sample.png)

Curious to learn how it can be so small? It boils down to three design principles:

1. Strict scope cutting. More full-featured validation libraries tell you _what,_ exactly, failed validation. This feature had to go.
2. Export functions, not objects with methods, because functions tree-shake better. This is exactly why superstruct is already 3–5 times lighter than zod.
3. More extensibiltiy. If you cut features from the core, the users must be able to write the missing bits themselves.

And some more optimization on top:

1. Compile to modern JS. Gzip is good, but replacing `function ()` with `() =>` still saved 20 bytes!
2. Minimal API. Bye-bye `literal(42)`, we have `enums([42])`
3. Gzip-aware code style. Gzip removes repetition, so you need to make different parts of code as similar as possible. Write `Object` once, repeat for free. Surprise: copy-pasting functions with minor changes is often smaller under gzip than _proper_ code reuse.

I have published an [article](https://blog.thoughtspile.tech/2023/03/02/banditypes-smallest-validation/) with a more in-depth explanation. 

---

Banditypes is not a validation library for every use case, but it gains something from its minimal design, and was fun to build. Check it out [on GitHub,](https://github.com/thoughtspile/banditypes) and maybe even give it a spin in your next project!
Let's keep moving the goal posts
Tags: wecoded
Published: 2023-03-08 21:02:19

Since I joined the tech industry, I have been heartened to see an evolution which has left a lot of old type of thinking behind.

We are far from able to celebrate a victory lap, and often the backlash to progress can be as painful as the old place, but I am happy when old conventional wisdom is challenged, and is no longer seen as wisdom at all.

## The broken pipeline

Not too long ago, **it was easy to dismiss progress on diversity and inclusion as something we can achieve _in the future_**, because the only problem is a "pipeline problem" — that is to say, if we teach the _children_ differently, we might _eventually_ change some things. It didn't work, because it wasn't children being harassed in the workplace, passed over for promotion, or stereotyped into giving up on technical roles.

I think this notion received eye-rolls for a long time, but eventually it received _mainstream critical challenges_. It is still an idea thrown around, primarily by old heads clinging to old ideas, but it is no longer acceptable to think of these challenges as things we _can't achieve right now_.

## Moving the goalposts

The goal posts have moved, and have to keep moving. Our industry still has too many invisible barriers, but **industry leaders can no longer entirely hide behind bland euphemisms**. The next phase is not accept small wins, but demand big wins.

A tech financial slowdown seems to have led to a slowdown in investment in diversity and inclusion — and this can't be acceptable. We know this is today's problem, not tomorrow's _especially_ in tough tiimes.

The future must include everything, we must accept that a faster pace of social progress is necessary. We must be able to let go of yesterday's ideas (like the notion that it's still cool to do #shecoded in face of the reality that given enough scrutiny, it was an exclusionary idea).

Happy coding, everyone!