teleren/devto huggingface dataset:
6 differences you must know between Terraform & Cloudformation
Tags: devops, devjournal, terraform, cloudformation
Published: 2023-05-25 01:32:00

Terraform and Cloudformation, another showdown!  

They both have their own unique powers. Here are the 6 differences you must know to make the right choice:


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


## 1. Language: 
Terraform uses its own proprietary language, HashiCorp Configuration Language (HCL), while CloudFormation uses JSON or YAML.


## 2. Provider Support:
Terraform supports a wide range of providers, including AWS, Azure, and Google Cloud, while CloudFormation is specific to AWS.


## 3. State Management:
Terraform maintains a state file to keep track of the infrastructure it manages, while CloudFormation does not have a similar feature.


## 4. Rollback Capability:
Terraform has built-in rollback capabilities, allowing for easy recovery from failed changes. CloudFormation allows for rolling back changes, but it must be done manually.


## 5. Community Support:
Terraform has a larger and more active community, with a wide range of providers and modules available. CloudFormation has a smaller community and is specific to AWS.


## 6. Orchestration:
Terraform is focused on Infrastructure as Code and can be used for multi-cloud orchestration, while CloudFormation is focused on AWS and can be used for Infrastructure as Code, but with a limited scope.

Thanks for reading this.

If you have an idea and want to build your product around it, schedule a call with [me](https://calendly.com/pragyanatvade).

If you want to learn more about DevOps and Backend space, [follow me](https://dev.to/pragyanatvade).

If you want to connect, reach out to me on [Twitter](https://twitter.com/pragyanatvade) and [LinkedIn](https://www.linkedin.com/in/pragyanatvade/).
Selecting the best GUI toolkit - part 4: Windows Forms
Tags: winforms, comparison, guitoolkit
Published: 2023-05-25 00:01:42


![](https://codehouse.digfish.org/wp-content/uploads/2023/04/AppMenuSharper_sshot-158x300.png)

NOTE: this the fourth part of a series. The previous article was about AutoHotkey. You can find the [article here](https://codehouse.digfish.org/selecting-the-best-gui-programming-toolkit-part-3-autohotkey/ "article here").
Windows Forms is a GUI programming framework developed by Microsoft for building Windows desktop applications. It provides a set of pre-built controls that developers can use to create user interfaces for their applications. It was the first Toolkit developed with the release of the first .NET frameworks, coping with the experience microsoft acquired with MFC and Visual Basic Forms. Microsoft release Windows Forms as open-source in 2018, but its scope is still limited to Microsft inhouse technologies, and its ports using the MonoFramework are limited.
Compared to tkinter and AutoHotkey, Windows Forms offers a richer set of controls and a more modern look and feel. It also has strong support for data binding, which can simplify the development of data-driven applications. The WinForms repository is [available here](https://github.com/dotnet/winforms). 

Since Microsoft provides Visual Studio standard as free, I switched to using Visual Studio for this implementation. You can design the form and then complete the events handlers source later and return to the design mode again. VS keeps the source code for the widgets in sync when returning for design mode. It's the advantage you get when working with a toolkit from the same toolmaker. After reading some tutorials and reusing the source code provided, I could accomplish the end of the implementation in less time than comparing with the two prior implementations. The code for the event handlers is very intuitive. Drag'n'Drop is supported and I made it to work with not much complexities.
One drawback is that the .NET doesn't bring JSON support out of the box, I had to use the NuGet package manager to install it.

One grat debugging feature that I enjoyed and the other IDEs don't possess it's the hability to apply changes imediatelly to the already running application being debugged. It avoids the need to restart the whole execution of the application all over again.

One potential downside of Windows Forms is that it is limited to Windows operating systems, so your applications won't be cross-platform. Additionally, it may require more knowledge of the .NET Framework and Windows development in general, which could make it more challenging for beginners to get started with. I didn't try the code with Mono on MacOS and Linux since it was very propbable to do changes to the code.
Perhaps with the new versions of .NET Core for Linux and MacOS that need will disappear !
The source code for this project [is available at GitHub](https://github.com/digfish/AppMenuSharper "is available at GitHub").


*Article posted using [bloggu.io](https://bloggu.io). Try it for free.*
Monitoring a Hacker News Post
Published: 2024-03-28 08:38:52

---
title: Monitoring a Hacker News Post
published: true
date: 2023-05-25 00:00:00 UTC
tags: 
canonical_url: https://www.tercmd.com/monitoring-a-hacker-news-post
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aywt7pv9h3myhvfez0hs.png
---

I posted a link to my [repo regarding AI context lengths](https://l.tercmd.com/gh/ai-memory-overflow) to Hacker News under the Show HN category and wanted to see its position in the listing every now and then.

## API

Fortunately, Hacker News has an API which you can send a request to for it to respond back with a list of posts. This was a Show HN post, so I needed the `/v0/showstories.json` API. I implemented simple Python code to request that path and get the index of the post. After this, I calculate a page number by dividing the post index by 30.

## Message Design?

Slack offers something called Block Kit, which allows you to build detailed messages. I tried a few designs and settled on a regular message. Regardless, if I do need to redesign it, I can just add blocks.

I first went with a button View Post in List.

![Slack message from app HN Monitor with message Post #36056445 is #36 on show page 2! with a button on the side View Post in List](https://cdn.hashnode.com/res/hashnode/image/upload/v1705244386324/7376dc3a-4932-4460-bb18-7671f0ea66ff.png)

This led to some issues.

I eventually added a link that does the same thing, which doesnt show any errors and works well.

![Slack message from app HN Monitor with message Post #36056445 is #40 on show page 2! with a link View post on page](https://cdn.hashnode.com/res/hashnode/image/upload/v1705244387924/eac79c6d-7a19-4f45-96b0-d4939f1062eb.png)

## View Post in List Link

This is a link to the specific page on HN with an anchor tag of the post ID. This results in the page scrolling to the very post being tracked.

![Hacker News Post](https://cdn.hashnode.com/res/hashnode/image/upload/v1705244389541/c9ecdadf-2658-48c7-831e-b511b2fae598.png)
Expanding exports with transcript and caption files
Published: 2023-05-25 17:03:00

---
title: Expanding exports with transcript and caption files
published: true
date: 2023-05-25 00:00:00 UTC
tags: 
canonical_url: https://blog.brainstory.ai/transcript-and-captions/
---

We are thrilled to announce the launch of our latest export features that allow you to transform your video’s audio into text using Contenda’s AI & speech recognition technology, then download this text in two useful formats: Transcript file (.txt) or Caption file (.srt).

## What are the benefits of transcript and caption files for content creators?

1. **Enhanced Accessibility**   
 By providing .srt caption files and transcripts, Contenda’s new features can greatly improve the accessibility of your video content. Individuals with hearing impairments can now read the captions and gain a complete understanding of the video’s message, allowing them to fully engage with the content.

2. **Improved Comprehension and Retention**   
 Transcripts and .srt caption files serve as valuable aids in understanding and retaining information. Viewers can read along with the video, reinforcing their comprehension of the content. Complex terminology, accents, or rapid speech can be better grasped through reading, ensuring that the intended message is effectively conveyed and understood by all viewers.

3. **Upgraded SEO and Discoverability**   
 Including transcripts with video content allows search engines to index and crawl the text, significantly improving the discoverability of the video. As a result, Contenda’s features offer a powerful advantage for content creators by making their videos more accessible to search engines, increasing organic reach, and attracting a broader audience.

## How does it work?

1. Transform your content through Contenda
2. Click Export
3. Select Transcript or Caption

<video controls width="500" height="400">
  <source src="https://contenda.co/blogimages/transcriptexport.mp4" type="video/mp4">

BOOM! It’s that easy. Start using new export capabilities now!
PHPStorm Auto Format with Laravel Pint
Tags: laravel, webdev, php
Published: 2023-05-24 14:53:10

Code fixers such as PHPCSFixer play a vital role in maintaining high code quality and consistency. These tools detect and rectify coding style issues, ensuring that the codebase follows predefined standards. By enforcing uniform formatting, code fixers enhance readability, promote better collaboration among developers, and significantly reduce the time spent on manual code reviews and corrections.

In the context of Laravel, Pint can be utilized for this purpose. This article focuses on running Pint. To configure the automatic execution of Pint when saving a file in Laravel, follow these steps:

1. Open the settings page by pressing `CTRL + ALT + S`.
2. Type "File Watcher" in the search bar.
3. Click the + (plus) icon.
4. Select "Custom" from the options.

Fill out the form as follows:

- Name: Laravel Pint (you can change this)
- File Type: PHP
- Scope: Current File (to only format the current file)
- Program: $ProjectFileDir$\vendor\bin\pint
- Arguments: $FilePath$

Next, open the "Advanced Options" section below and check the box for "Trigger the watcher on external changes". Save the file watcher and enable the watcher. Now you can edit a PHP file to see if it works.
Pre-Push Time Saver
Tags: dx, git
Published: 2024-04-08 09:54:00

---
title: Pre-Push Time Saver
published: true
date: 2023-05-25 00:00:00 UTC
tags: dx,git
canonical_url: https://www.simonporter.co.uk/posts/pre-push-time-saver
---
 Git has [a range of hooks](https://git-scm.com/docs/githooks) that you can use to protect yourself against mistakes, or ensure code standards are kept across your team. I recently had a need to add a `pre-push` hook to save myself some time when pushing up new PR's.

Our test suite can take quite a while to run, so I'll typically push up, and then move onto other things to come back in a little bit after CI has finished in case tweaks are needed that I missed or didn't run into locally.

Occasionally, I'll be working on a part of the code that looks okay in VSCode, but then fails our typechecking or lint checks because a part of my change broke a file I didn't have open. This pre-push hook makes sure I don't forget to run typechecking before I push up any changes, and will block the push if it fails. Meaning I get a much quicker feedback loop locally rather than needing to wait for CI.

While this does slow down my initial pushes, it's saved me more times than it probably should have and let me fix things up before the CI gets a chance to run.

### How to install

To get this running in a project, we can create a file in `.git/hooks/pre-push` and make it executable with `chmod +x .git/hooks/pre-push`:

```sh
#!/bin/zsh

cmd="yarn run typecheck" # replace with your typechecking/linting command

echo "running typecheck before push..."
eval $cmd
result=$?
if ! eval "$cmd"; then
echo "Failed typecheck! Fix before pushing or force push: \`git push --no-verify\`" >&2
exit 1
fi

exit 0
```

### VSCode integration

To [get this working in VSCode](https://github.com/microsoft/vscode/issues/132778#issuecomment-1047763835), we also need to add the `push` command to the `git.commandsToLog` setting inside our VSCode preferences. This allows us to view the error log on failure from within VSCode too.

With these two things in place, we're off to the races!


> ℹ️ **note**
> In case you ever need to &quot;just get it pushed&quot;, you can force push
    your branch by using the [--no-verify](https://git-scm.com/docs/git-push#Documentation/git-push.txt---no-verify) flag: `git push --no-verify`

_This article was originally published on [simonporter.co.uk](https://www.simonporter.co.uk/posts/pre-push-time-saver)_
Next-Gen Builder
Tags: programming, tooling, opensource, productivity
Published: 2023-05-24 23:46:24

The only build tool that allows you to pass in a repo and build your project, while getting extensive metadata tied to your shippable product. There's no need to frantically track down build info if something goes wrong. Know who built it, in what directory, on what machine, at what time. Never not know again.

Builder is a decentralized build automation tool that removes the need for the traditional centralized build model.

In the video above watch Builder build #ethereum #argocd & #cockroachdb all with a single command!

The tradition centralized build model has major bottlenecks and has massive infrastructure requirements at scale. Builder's goal is to solve this problem.

[Project here!](https://github.com/AuditDeploy/Builder)

[YouTube video link here! 
](https://www.youtube.com/watch?v=b-OHscV2NIs&ab_channel=AuditDeploy)
Join us and contribute your ideas to the project. Builder was created by the engineering team at [AuditDeploy](https://www.auditdeploy.com/)
Building a Simple CRUD Application with Go: An Overview about the project
Tags: go, apacheage, postgres, swe
Published: 2023-05-24 23:21:18

**Introduction**
In the start of this month, I assigned the task of developing the Age Viewer Go (Desktop) application. The purpose of this application is to provide a user-friendly interface for viewing and managing age-related data. With the use of Go programming language, we aimed to create a lightweight and efficient application that meets our specific requirements.
**Functions**
- **Create (C)**:
The create operation involves adding new data to a system. It typically entails gathering user input, validating the data, and storing it in a database or another persistent storage medium. For instance, in a blog application, the create operation allows users to compose and publish new articles. Developers must ensure proper input validation, data integrity, and error handling to prevent erroneous or inconsistent data from being created.
```golang
func CreateUser(w http.ResponseWriter, r *http.Request) {
	// set the header to content type x-www-form-urlencoded
	// Allow all origin to handle cors issue
	w.Header().Set("Context-Type", "application/x-www-form-urlencoded")
	w.Header().Set("Access-Control-Allow-Origin", "*")
	w.Header().Set("Access-Control-Allow-Methods", "POST")
	w.Header().Set("Access-Control-Allow-Headers", "Content-Type")

	var user models.User

	err := json.NewDecoder(r.Body).Decode(&user)

	if err != nil {
		log.Fatalf("Unable to decode the request body.  %v", err)
	}

	insertID := insertUser(user)

	res := response{
		ID:      insertID,
		Message: "User created!!",
	}

	// send the response
	json.NewEncoder(w).Encode(res)
}
```
- **Read(R)**
This function is an HTTP request handler that retrieves a user based on the provided user ID. It sets the necessary headers for the HTTP response, including the content type and access control. The function extracts the user ID from the request parameters, converts it to an integer, and retrieves the corresponding user using the getUser function. If an error occurs during the conversion or user retrieval, it logs an error message. Finally, it encodes the retrieved user as JSON and writes it as the response.
```golang
func GetUser(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Context-Type", "application/x-www-form-urlencoded")
	w.Header().Set("Access-Control-Allow-Origin", "*")
	// get the userid from the request params, key is "id"
	params := mux.Vars(r)

	id, err := strconv.Atoi(params["id"])

	if err != nil {
		log.Fatalf("Unable to convert the string.  %v", err)
	}

	user, err := getUser(int64(id))

	if err != nil {
		log.Fatalf("Cannot find the user. %v", err)
	}

	json.NewEncoder(w).Encode(user)
}
```
This article will be divided into two or more parts for better comprehension. Thank you for reading this far.

**References:**
- [CRUD Project](https://github.com/M4rcxs/Golang-CRUD/blob/master/middleware/handlers.go)
- [AGE](https://github.com/apache/age)
systemd, crond and Docker Container
Published: 2023-05-24 23:30:50

---
title: systemd, crond and Docker Container
published: true
date: 2023-05-24 23:07:03 UTC
tags: 
canonical_url: https://blog.mandraketech.in/systemd-crond-and-docker-container
---

Recently, I was in a situation where I needed cron jobs to run inside my DevContainer, to mimic the behaviour of my production machine. Specifically, in the context of log rotation. And, given that the default container images do not contain the `systemd` process on AmazonLinux 2023, a CentOS 8 based distribution ( my environment of choice ), I had to find a way to make it work.

Thankfully, ChatGPT came to my rescue. It gave me a good starting point and allowed me to create a repository for this, in a more polished and "best practices friendly" structure.

First, the objectives. I wanted to have a `systemd` run environment, that would run `cron` jobs, and other services, inside my DevContainer.

This required me to create a Dockerfile that would install the `systemd` service, and `cronie` to run cron jobs.

```
FROM amazonlinux:2023

# Install required packages
RUN yum -y update && \
    yum -y install systemd cronie tar gzip git && \
    systemctl enable crond.service

```

After this, I can now initialize my image to have the cron configurations:

```
# Configure crond
COPY cron.d/* /etc/cron.d

```

And finally, start the `systemd` process as the CMD for the container. This is a blocking process and ensures the container is not killed immediately:

```
# Start cron and systemd
CMD /usr/sbin/init

```

There you go. We are now ready to run the container. Just one more thing.

To enable systemd to do its job, this container needs to run in privileged mode. So, my docker-compose.yml looks like this:

```
services:
  crond-service:
    build:
      context: docker-context
      dockerfile: Dockerfile
    privileged: true

```

A sample cron config file, to just print a log message when the system reboots, sits inside the `cron.d` directory in my docker build context directory.

```
@reboot root echo "in crond after reboot"

```

To run the container:

```
docker compose up -d

```

To check that the cron service is running:

```
docker compose exec crond-service systemctl status crond.service

```

And to connect into the container, while the service is running:

```
docker compose exec crond-service bash

```

Note that the name of the service in the docker-compose file is: `crond-service`

Code use in this blog, including the `.devcontainer.json` and more, is available at: [https://github.com/navneetkarnani/docker-crond](https://github.com/navneetkarnani/docker-crond)

This blog originally published at https://blog.mandraketech.in/systemd-and-docker-container on 25/May/2023 by Navneet Karnani ( https://linkedin.com/in/navneetkarnani )
Day 114 of #365DaysOfCode — Exploring Testing Frameworks
Tags: webdev, javascript, beginners, programming
Published: 2023-05-24 22:39:09

Hey everyone, it’s Day 114 of #365DaysOfCode & Day 14 of #100DaysOfPython! Just a quick update..Today was all about manually testing my project. I’m happy to report that so far, everything seems to be running smoothly.

Then, I thought it was time to add a little flair to the error messages for my OAuth popup window. Now, they’re not only easier on the eyes, but they’re also easier to understand. Another thing I worked on today was allowing users to update their profile info.

But, of course, no day would be complete without learning something new. I spent some time researching different types of testing: unit, integration, and end-to-end testing. It was pretty fascinating stuff.

I was also surprised to discover just how many testing frameworks are out there: Jestjs (developed by Meta), React Testing Library, Supertest, Cypress, Mocha, Chai.. and those are just a few.

So, in short:

Unit testing is the process of testing individual parts of your code. This could be individual functions or components. Jest is often used alongside a testing library like Enzyme or React Testing Library for React components.

Sort of one level above that is integration testing, which is when individual units are combined and tested as a group. This is to check if they function together correctly. Jest, Supertest and React Testing Library (for the frontend) can be used for that.

One level above that is end-to-end (e2e) testing. It simulates real user scenarios, essentially testing how all the parts work together. It’s used to test whether the flow of an application is performing as designed from start to finish. Cypress and Puppeteer are common e2e testing frameworks for web applications.

That said, I’m not planning to go overboard with this. I’ve been testing my code thoroughly as I’ve been building, so I don’t feel the need to use every testing tool under the sun.

Python:

I continued with my Python course today, focusing on building small, basic projects. While these may not be impressive yet, I’m thoroughly enjoying Python. However, coming from JavaScript, Python’s use of indentation is something I still need to get used to.

All in all, today was a day of testing, tweaking, and learning. I’m looking forward to seeing what tomorrow brings. Until then, happy coding!
Error: listen EADDRINUSE: address already in use (JSON)
Tags: help, webdev, json, beginners
Published: 2023-05-24 22:34:05

THE PROBLEM

I began the Ramen Rater assignment for Flatiron School (essentially a lab focused around using GET, POST, PATCH for Postman) by running json-server --watch db.json     and I got the following error:

Some error occurred Error: listen EADDRINUSE: address already in use 127.0.0.1:3000
    at Server.setupListenHandle [as _listen2] (node:net:1740:16)
    at listenInCluster (node:net:1788:12)
    at GetAddrInfoReqWrap.doListen [as callback] (node:net:1937:7)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:8) {
  code: 'EADDRINUSE',
  errno: -98,
  syscall: 'listen',
  address: '127.0.0.1',
  port: 3000

With this error, I am not able to continue working on the lab (Postman). I researched this issue on Google, Stack Overflow, Slack, and Piazza. 

HOW TO FIX THIS

I booked a help session and was able to get help fixing this issue in 2 ways. The core issue was that port 3000 was already in use due to a previous lab still running. One of the ways to fix this is to run npx kill-port in the terminal.



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

This frees up the port and makes it available for running json-server --watch db.json and getting the API set up in Postman. 

A second way to solve this problem would be to find the process ID (PID) through entering lsof -i tcp:3000 in the terminal, then running kill -9 [process id number]. This will free up the port and allow one to run db.json.


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