teleren/devto huggingface dataset:
How to Write Classes in Golang
Tags: go, python, oops
Published: 2023-02-16 15:01:00

## Introduction

I have seen many people coming from Python background struggling with Go. What I have obeserved it they write code that is limited to writing functions and calling them. They never leverage design constructs such as abstraction, encapsulation, inheritance, composition etc. I can understand their pain because I've been in the same boat.

In today's post I'll compare how we write classes in Python vs how we do the same thing in a Go way.

## What is a class composed of?

1. Attributes in form of variables
2. Behavior in form of methods

## Example in Python

Consider the following code in Python that defines a simple Person class with a name attribute and a greet method:

```py
class Person:
    def __init__(self, name):
        self.name = name
    
    def greet(self):
        print(f"Hello, my name is {self.name}")

p = Person("John")
p.greet()  # prints "Hello, my name is John"
```

If you're a Python programmer looking to learn Go, you'll be happy to know that Go has a similar concept to classes called "structs". Structs are similar to classes in that they allow you to define a custom data type with its own fields and methods.

## Struct to define the structure and attributes

To define a struct in Go, you use the type keyword followed by the name of the struct and a set of curly braces containing the fields. Here's an example of a simple struct called Person:

```go
type Person struct {
    name string
    age  int
}
```

This defines a struct called Person with two fields: name and age, both of which are of type string and int respectively.

## Method or behaviour using receiver function

You can also define methods on your structs by using the func keyword and attaching the method to the struct using the (p *Person) syntax, where p is the receiver of the method and Person is the type of the receiver. Here's an example of a method called SayHello that prints a greeting to the console:

```go
func (p *Person) SayHello() {
    fmt.Printf("Hello, my name is %s and I am %d years old\n", p.name, p.age)
}
```

To create an instance of a struct, you can use the new function or the shorthand syntax :=. Here's an example of both:

```go
// Using the new function
p1 := new(Person)
p1.name = "John"
p1.age = 30

// Using the shorthand syntax
p2 := Person{name: "Jane", age: 25}
```

You can also define a "constructor" function to create instances of your struct. This can be useful if you want to perform some initialization logic when creating a new instance. Here's an example of a constructor function for the Person struct:

```go
func NewPerson(name string, age int) *Person {
    p := new(Person)
    p.name = name
    p.age = age
    return p
}
```

You can then use this constructor function to create a new instance of the Person struct like this:

```go
p := NewPerson("Bob", 35)
```

I hope this tutorial has helped you understand how to define and use structs in Go as a Python programmer. Structs are a powerful and flexible way to define custom data types in Go, and I encourage you to explore them further.

Thank you for reading!
10 Exercises at Home
Published: 2023-02-16 15:00:46

Here are 10 [exercises](https://newwayhealthandfitness.com/simple-flat-abs-workouts/) that you can do at home with little or no equipment:

Bodyweight squats: Stand with your feet shoulder-width apart, then bend your knees and lower your hips until your thighs are parallel to the ground. Stand up to complete one repetition.

Push-ups: Start in a plank position with your hands shoulder-width apart. Lower your chest to the ground and then push yourself back up to the starting position.

Lunges: Stand with your feet shoulder-width apart, then take a big step forward with one foot and lower your back knee until it almost touches the ground. Push back up to the starting position and switch legs.

Planks: Start in a push-up position, then lower your elbows to the ground and hold your body in a straight line from your head to your heels.

Jumping jacks: Stand with your feet together and your arms at your sides, then jump and spread your legs while raising your arms above your head. Jump back to the starting position.

Burpees: Start in a standing position, then drop down to a push-up position, jump your feet forward to a squat position, and then jump up in the air with your arms above your head.

Bicycle crunches: Lie on your back with your hands behind your head, then lift your feet off the ground and alternate bringing your opposite elbow to your opposite knee.

Mountain climbers: Start in a plank position, then alternate bringing your knees up to your chest as fast as you can.

Jump squats: Start with your feet shoulder-width apart, then lower your hips into a squat and explode up in the air, landing back in the starting position.

Tricep dips: Sit on the edge of a chair or bench with your hands on the edge and your feet on the ground. Lower your body down until your arms are at a 90-degree angle, then push back up to the starting position.
A headless hook-based exam proctoring system with React
Tags: linodehackathon
Published: 2023-02-16 14:39:25

## What I built

I built a headless online exam proctoring system using React.

### Features

1. Force full-screen mode
2. Warns when user switches tabs
3. Prevents user from opening the context menu (menu opened by pressing right-click from the mouse)
4. Prevents user from copying website content
5. Works well with custom proctoring logic (which you might want to implement separately)
6. Webcam detection (Coming Soon)

## Category Submission

SaaS Superstars✨

## App Link
[Checkout the demo app here](http://172.104.207.164/)

## Screenshots

![Begin Exam](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/exxrz1wk0bh79n2m2zhc.png)

![Exam page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kattztrgfzhdgi1ktcco.png)

![Full screen warning](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d4xqrld0jd0q9nw20dv7.png)

![Tab focus warning](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jpfik0j7ldxsv15biqck.png)

## Description

This is a headless proctoring library which only gives you some flags. What you do with that information is totally upto you. The UI for handling various use cases is completely in your hands. For more details, [check out the project README](https://github.com/ansh-saini/react-proctoring#overview).

## Link to Source

{% embed https://github.com/ansh-saini/react-proctoring %}

## Background

I was looking for a ready-to-use proctoring system for an online exam. I found a few solutions but all of them were coupled very closely with the UI. I could not find a headless proctoring system. So, I decided to build my own. It is perfect for having full control over the UI while reaping all the benefits of a proctoring system.

## How I built it

- I utilized Linode's web server to deploy the demo application to the web. I had never configured a web server before. I learnt how to do that from Linode's awesome documention.
- I'm thinking of adding a face detection feature to this library. I'm planning to host machine learning models on Linode then use it as an API in this library.
- I learned about various browser APIs. Like page visibility detection, requesting camera permissions, requesting full screen permission from the browser etc.
- I learned about ways of getting around cross-browser issues when it comes to native APIs.

### Final thoughts
This was my first time using Linode. Things were very easy to setup. I followed [this guide](https://www.linode.com/docs/guides/how-to-deploy-a-react-app-on-debian-10/) to understand how to deploy my application. I think Linode is a great platform and I'm definitely going to figure out how to utilize my free $100 credit in a better way 😁
platform as a service with ISV Low code platform
Tags: rad, webdev, javascript, opensource
Published: 2023-02-16 14:34:02

One can find that the ISV economy is growing very rapidly. Low code platforms have grown extremely popular in the last ten years. They are used by IT departments and various companies all over the world. The main benefit of using these tools is that they are easy to use. The demand for intensive [software developments](https://www.wavemaker.com/java-low-code-platform/) is increasing day by day. As months and years advance, new functions and adaptations are required. Higher performance, more new The [platform as a service (PaaS)](https://www.wavemaker.com/application-platform-as-a-service-apaas/) is the best type of cloud based solution because it allows you to concentrate on creating your code. The PaaS is just like a consumer app. platform as a service (PaaS) business models has been the ideal investment for many industries like healthcare and technology. The PaaS business model is now evolving because of the increasing need for [RAD Low code platforms](https://www.wavemaker.com/rapid-app-development-studio/) are made for people that don't actively write code. These platforms allow people to create apps without writing any code themselves. This means that people of all skills can create an app easily. If you are planning to build a SaaS business, then you need to listen to how to make it successful. Below is a step by step guide to think about when launching your SaaS business IT operations are designed to work better for the developer and the W is probably one of the biggest improvements. The tools and requirements are getting better to become more appealing to the developer. One thing to consider is that the bw benefits business more for personalization.
Resolvendo problemas no HackerRank: Divisíveis por uma soma de arrays
Published: 2023-02-16 14:15:15

Olá, seja bem vindo a mais uma etapa do Resolvendo problemas no Hacker-Rank,nessa sessão iremos resolver casos de valores que juntos podem ser divisíveis por outro.


**Divisible Sum Pairs -**

Esse algoritmo pega dois números em array e pega o primeiro que vale index i e o segundo que vale index j.
Com as seguintes regras: 

- O index [i] tem que ser menor que o j.
- Eles eles tem que ser divisíveis por k.

int n: o comprimento do array `arr`
int ar[n]: um array de inteiros
int k: o inteiro divisor

Vejamos um exemplo:

```
ar = [1,2,3,4,5,6]
k = 5

// 3 pares estão dentro dos parâmetros:[1,4],[2,3],[6,4]
// Visto que os 3 casos acima são multiplos de k =5,pois a soma de [1,4] e [2,3] dão resultado 5 e [6,4] entra como múltiplo do valor k também.
```


Vejamos agora o raciocínio desse código:

```
function divisibleSumPairs(n, k, ar) {

return ar.reduce((acc, cur, index) => 
acc + ar.slice(index + 1).filter(j => (cur + j) % k === 0).length, 0);

}
```

Nesse código, usamos a função reduce para iterar sobre o array ar e acumular o número de pares que são divisíveis por k. Para cada elemento do array ar, usamos o método slice para criar um novo array que contém apenas os elementos que estão à frente dele e, em seguida, filtramos esse array para manter apenas os elementos que, somados ao elemento atual, são divisíveis por k.

Com isso, o resultado será:


```
6 3 // 6 =n e 3 = k
1 3 2 6 1 2

5// possibilidades.
```

Com isso,finalizamos mais uma edição. Até a próxima!!!
Big Data on AWS - Part 2
Published: 2023-02-14 19:41:40

In part one of this blog series, we explored two AWS services, Amazon S3 and Amazon EMR, that are used for big data processing and analysis. In this second part, we will explore other AWS services that are commonly used for big data processing and analysis.

Amazon Redshift
Amazon Redshift is a cloud-based data warehousing service offered by AWS. It is designed to store and analyze large amounts of structured data. Amazon Redshift allows users to query and analyze data using standard SQL queries.

Amazon Redshift provides several features that make it an ideal data warehousing solution, including:

High-performance: Amazon Redshift is designed to provide high performance for querying and analyzing large amounts of data.

Scalable: Amazon Redshift can scale up or down to store and analyze any amount of data.

Cost-effective: Amazon Redshift uses a pay-as-you-go pricing model, which means that users only pay for what they use.

Integration with other AWS services: Amazon Redshift can be integrated with other AWS services, such as Amazon S3 and Amazon EMR, to process and analyze big data.

Amazon Athena
Amazon Athena is a serverless, interactive query service offered by AWS. It enables users to query data stored in Amazon S3 using standard SQL queries. Amazon Athena is designed to be easy to use and does not require any infrastructure or administration.

Amazon Athena provides several features that make it an ideal query solution, including:

Easy to use: Amazon Athena provides a web-based console that makes it easy to query data stored in Amazon S3.

Serverless: Amazon Athena is serverless, which means that users do not need to manage any infrastructure.

Scalable: Amazon Athena can scale up or down to query any amount of data stored in Amazon S3.

Integration with other AWS services: Amazon Athena can be integrated with other AWS services, such as Amazon S3 and Amazon Glue, to process and analyze big data.

Amazon Kinesis
Amazon Kinesis is a platform for streaming data on AWS. It enables users to ingest, process, and analyze real-time streaming data. Amazon Kinesis is designed to be scalable and can process millions of data streams in real-time.

Amazon Kinesis provides several features that make it an ideal streaming data solution, including:

Scalable: Amazon Kinesis can scale up or down to process any amount of streaming data.

Low latency: Amazon Kinesis provides low latency data processing, which means that data can be processed in real-time.

Integration with other AWS services: Amazon Kinesis can be integrated with other AWS services, such as Amazon S3, Amazon Redshift, and Amazon EMR, to process and analyze streaming data.

In conclusion, AWS provides a wide range of services for big data processing and analysis. These services are designed to scale to process any amount of data and provide a cost-effective solution for businesses looking to leverage big data for their operations. By using these services, businesses can gain valuable insights from their data and make better decisions that can drive growth and success.
Academic Writing Skills
Published: 2023-02-16 14:14:28

**[Academic Writing Skills](https://academicwritingpro.co.uk/)** is the ideal solution for anyone experiencing academic pressure or writing difficulties. You can contact them directly and place your order. Their professionals are available 24 hours a day, 7 days a week to help you with your problems. Our experts, on the other hand, always make certain that you are satisfied with our services.
Turn Your Phone into a Mobile Rotating Proxy without Root
Tags: android, proxy, programming, webdev
Published: 2023-02-16 13:44:02

First, you need to install the Localtonet app on your phone by download it from the Google Play Store here: https://play.google.com/store/apps/details?id=com.localtonet.localtonetapp

Next, go to https://localtonet.com/ and sign up for an account. Once you're signed up, go to the clipboard page and copy the AuthToken.

On the Localtonet app on your phone, paste the AuthToken in. You should see an Android icon on the "My tokens" page.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jp9rzhghc88wj1zl14i8.png)
You can adjust the settings for how often the phone goes into airplane mode (as marked in blue in the screenshot), and you can also generate a reset link.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/micybjlqrvsaw314fapc.png)
If your phone is not rooted, when you generate a reset link, trigger it once and the default assistant settings page will open. From there, select Localtonet as the default assistant.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/czgyti66bfoa6t9i2af9.jpeg)
Next, go to https://localtonet.com/tunnel/proxyserver and choose either HTTP or SOCKS proxy, then create it. Click "Start" to start the proxy server.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c5dlhkuupwb8mkw4721k.png)
You can connect to the server using the IP address and port number provided. You can also set a username and password in the tunnel settings.

Note that the SOCKS5 proxy supports TCP/UDP
Supercharge Your Productivity with ChatGPT!
Tags: chatgpt, productivity, timemanagem, webdev
Published: 2023-02-16 13:18:55

We want to be more productive and efficient as professionals and are constantly seeking for new methods to do so. You may automate activities and optimize your workflows by using ChatGPT, a strong language model.



ChatGPT can help you operate more effectively and productively, whether you're a software developer, marketer, or business owner. You may increase your productivity by using ChatGPT in the following ways:



![ChatGPT Writing](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/is13z4x2dupziwm906rh.png)

**Writing:** ChatGPT enables you to produce high-quality content fast and simply, saving you time and easing the tension of writer's block. ChatGPT can assist you in writing any type of document, including reports, blogs, and emails.



![ChatGPT Product Managment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ye47ccablb0yl1z9f2sf.png)

**Product Management:** ChatGPT enables you to automate a variety of project management operations, including task list creation, meeting scheduling, and reminder emailing. This might assist you in maintaining organization and guiding your staff.


![ChatGPT Customer Care](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/27opm7m2m1pirkbb1lba.png)

**Customer Care:** ChatGPT may be used to automate customer care operations including answering frequently asked inquiries, fixing straightforward problems, and offering help to clients. This can help you give your clients better service while freeing up time for more difficult duties.

![ChatGPT Personal Assistance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kveh3n686f95wmeehhef.png)

**Personal assistance:** ChatGPT may be used as a personal assistant to help you keep track of your tasks, manage your schedule, and make reminders. ChatGPT is available to you whether you want assistance with your to-do list or only a kind reminder to take a break. 


By using ChatGPT to automate tasks and streamline your workflows, you can boost your productivity and get more done in less time. Give it a try and see the difference it can make in your workday! 

#ChatGPT #productivity #automation #workflow #softwaredeveloper #timemanagement
What is Concurrency in Golang — Key Terms and Examples
Tags: webdev, programming, go, beginners
Published: 2023-02-16 13:17:34

When we search term **concurrency in Golang**, we come around mainly to the `goroutines` and `channels`. Sometimes we also find `waitgroup` or `mutex`.

There are many terms that can explain concurrency in Golang. But we mess it up when we start implementing the same.

Today we will discuss concurrency in Golang with an example of **sentiment data processing** using goroutines, channels, waitgroups, and many more terms.

_**Sentiment data processing:** It is a data processing example, in which we can analyze sentiment data from social media posts, comments, or any expression-related data, whether the data is positive, neutral, or negative._

Concurrency in Go is one of the language’s key features and is designed to make it easy to write highly concurrent and scalable applications.

It is the ability to execute multiple tasks or processes simultaneously, that allows efficient use of system resources and improves application performance.

## Concurrency vs parallelism with an example:

Note that concurrency and parallelism are two different terms.

- **Concurrency** — It’s meant to do `multiple tasks` at the `same time`. It is a term used for writing programs.
- **Parallelism** —It’s meant to do `multiple tasks` with `multiple resources` at the `same time`. It is hardware related term, used when building CPUs and cores.

**Example** — Students have been assigned a task to write a paragraph from the board.

**Concurrency:** Students are reading from the board and writing at the same time. (one resource — student)

**Parallelism:** The teacher is reading loudly and students are writing at the same time. (multiple resources — student & teacher)

To understand all the terms with step by step guide and the `sentiment data processing` example, check out our [Canopas Blog](https://blog.canopas.com/a-practical-guide-to-concurrency-in-golang-key-terms-and-examples-aa54dddb9fec).
Providing a smooth website experience with Git
Tags: git, github, python, a11y
Published: 2023-02-16 13:14:00

**Want to launch a website which never starts showing bugs when you are working on an update, and never keeps on turning off and on because you are repeatedly making changes, all for free?**
*If you do, then keep on reading!*

---

I have [a website](https://discipulis.vulcanwm.repl.co) where I want my users to have the **best experience** and not be affected by me updating the website everyday.
I *don't want to spend money* on the website as I'm not sure if the website deserves the money.
This is my *workflow* for the best free user experience and how Git plays into it:

# PyCharm Project
I have a PyCharm project where I code the website *locally*
. Here I can do all the testing **without it affecting the actual website**.
![pycharm project](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pg1rth6pnnlvkb1lnscj.png)


# Git Repo
The PyCharm project is connected to a **Git repo** where I commit all the changes I have done to the website.
The Git Repo also has **all the issues related to project** and I use GitHub Projects to manage when I'm going to add each feature.
![git repo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lsjw3h819vf072ps7445.png)


# Replit Repl
The repl is where I host the code. The Repl is also **linked to the Git Repo**, and whenever I make a commit on the Git Repo, I just do *`git pull` in the Repl Shell* and rerun the repl.
![replit repo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s8jn3hwl2ihv4hphvk47.png)



# Smooth Website Experience
Replit provides **unlimited free domains**, and I use pingers so my website doesn't go offline.
This way my users aren't affected by me constantly editing the code and creating and fixing bugs!
![smooth website experience](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gh2jx3z4oqdhwd0sdd4b.png)



---

Thanks for reading this post!
Follow me for more posts like these and make sure to like the post if you enjoyed reading it.