teleren/devto huggingface dataset:
Who is a developer ???
Published: 2024-02-11 20:21:34


A developer, also known as a programmer, coder, or software engineer, is an IT professional who uses programming languages to create software. They design, build, and implement computer programs and applications. Developers write, test, debug, and maintain applications. They can specialize in different areas such as web development, mobile app development, game development, and more. Their roles can vary widely depending on the type of organization they work for. They are usually employed by technology companies that create software or by organizations that develop bespoke applications. Developers need strong technical aptitude and often have degrees in fields such as computer science, information technology, mathematics, or engineering.
Restrict Access to AWS Quicksight based on source ip
Tags: aws, quicksight, businessintelligence, amazonwebservice
Published: 2024-02-11 19:48:57

Amazon [QuickSight](https://aws.amazon.com/quicksight/) is a fast, cloud-native business intelligence service that makes it easy to create and share interactive dashboards. It offers machine learning insights to all users, connects to many data sources, and has a cost-effective pay-per-session pricing model. QuickSight simplifies data analysis, helping businesses make informed decisions quickly.

We noticed that the quicksight can be accessed from any device which was surprising to us in the beginning. Here are the steps we followed to restrict the access based on ip of the client.

To enable IP-based restrictions for the users who has access to QuickSight admin console takes the following steps:

On the QuickSight console, on the user name menu, choose Manage QuickSight.

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


In the navigation pane, choose Security & permissions.

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


Under IP restrictions, choose Manage.

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


For IP address, enter the IP address which is to be allowed access in CIDR format.

Choose Add.

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


To edit an existing rule, choose the pencil icon next to the rule.

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


To delete an existing rule, choose the trash icon next to the rule.

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


Make sure to add your own IP address to the list to prevent being locked out yourself.

After you add, edit or delete IP address rules, choose Save changes.

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



Turn on the rules to start your IP-based restriction.

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


When the IP restriction is turned on and the list of allowed IP addresses in CIDR format is in place, any authorised user trying to access QuickSight when not logged in to the organizations VPN (regardless of their role of admin, author, or reader) is presented with an error page.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdibb4699ec1k9d2w5iu.jpeg)
Understanding the Journey of a Web Request
Tags: webdev, beginners, learning, softwaredevelopment
Published: 2024-02-11 19:30:33

*"What happens when you type https://www.google.com in your browser and press Enter?"*

**Disclaimer:** This post is meant for those who have started to learn about web infrastructure components and help them make sense of it all.

##**Introduction**
When we enter the URL "https://www.google.com" into our browser and press Enter, there are a number of events that happen before you are greeted with Google's search bar on the homepage.

**1. DNS Request:**
It all starts with a DNS (Domain Name System) request. When we enter a URL into our browser, our browser needs to translate the URL, which is the human-readable version of an IP address, back to an IP address. The DNS server responses with the corresponding IP address for Google's servers.

**2. TCP/IP:**
Now that the browser knows the IP address of the server, it establishes a TCP (Transmission Control Protocol) connection. TCP ensures reliable and an ordered delivery of data packets between the client (our browser) and the server (Google's).

**3. Firewall:**
Before the connection is established, it may have to go through a firewall. Firewalls act as a barrier between our PCs and the internet, by filtering out potential harmful traffic and only allowing authorized connections.

**4. HTTPS/SSL:**
In the URL "https://www.google.com", "https://" (specifically the s) indicates that a secure connection using SSL (Secure Sockets Layer) or its successor, TLS (Transport Layer Security), is required. This protocol provides a layer of encryption that ensures that the data exchanged between the client and server is encrypted, protecting it from potential hackers.

**5. Load-Balancer:**
Load balancers distribute incoming requests across Google's multiple servers. They help optimize performance and ensure high availability by evenly distributing the traffic and redirecting requests to healthy servers.

**6. Web Server:**
When the request finally reaches Google's servers, it is first handled by a web server such as Apache or Nginx. The web server will process the request, retrieve the requested resources (like the Google Homepage), and then return an HTTP response.

**7. Application Server:**
For dynamic content, the request will be passed to an application server. The server executes the necessary back-end code in order to generate the requested content.

**8. Database:**
In some cases, the application server needs to communicate with a database to retrieve or store data. For example, when searching on Google, the application server will query a database to fetch the relevant results.

##**Conclusion**
From the initial DNS request to the final database interaction, the web request involves a number of different components working together to deliver the requested content to your browser.

I hope this blog has somehow managed to painted a picture in your mind as to how a web infrastructure functions to produce the many web pages we interact with on a daily.
I tried to json_decode a string in scientific notation
Tags: php, webdev, bug
Published: 2024-02-11 19:29:28

I spent 6 hours trying to work on a bug ticket assigned to me. It turns out the code has been trying to json_decode a floating-point number in scientific notation.

Okay, let me give some context, we have this method somewhere in a `Utils.php` file:

```php
function is_value_empty($value): bool {
	$value = json_decode($value ?: '');
	if (!is_array($value)) {
		return empty($value);
	}

	$has_non_empty_value = false;
	foreach ($value as $row) {
		if ($has_non_empty_value) {
			break;
		}

		$has_non_empty_value = !empty($row);
	}

	return !$has_non_empty_value;
}
```

The job of this method, in the context that it is been used, is to check if the `$value` passed is empty. But it also needs to check the following:
- if `[]` is passed, it needs to return true
- If `['', '']` is passed it still needs to return true.
- If a JSON encoded array with falsy values is passed it still needs to return true

Now the issue we were facing was that a certain user was trying to validate if `0E86023` was empty or not.

As you can see, the first thing this method does is to attempt a `json_decode( )`. It then checks if it successfully decodes the value. If the decoded value is not an array, it simply use the php `empty( )` method and that's it.

The issue with `0E86023` or any floating-point number is that, if this expresssion is executed:

```php
json_decode('0E86023')
```
We would get a floating point response from php as 0.0

```
Psy Shell v0.11.22 (PHP 7.4.33 — cli) by Justin Hileman
> json_decode('0E86023')
= 0.0

>
```

But this number might look like its exactly `0.0`. But its not, its a number very very close to zero but not exactly zero. Therefore checking `empty(json_decode('0E86023'))` would return false.

This is why this method has been failing for the user and they have not been able to update their information with a value like `0E86023`.

For a quick fix, I added a simple if statement on top of the method like so:

```php
function is_value_empty($value): bool {
	if (is_numeric($value)) {
		return false;
	}

	$value = json_decode($value ?: '');
	if (!is_array($value)) {
		return empty($value);
	}

	$has_non_empty_value = false;
	foreach ($value as $row) {
		if ($has_non_empty_value) {
			break;
		}

		$has_non_empty_value = !empty($row);
	}

	return !$has_non_empty_value;
}
```

It's interesting that this happened in a case where thousands of other records are been successfully updated but this particular user kept complaining that they could not use the feature.

So yea, not sure which is weird, `json_decode( )` or `empty( )`
LeetCode 2620. Counter (Easy)
Tags: javascript, leetcode, beginners, codenewbie
Published: 2024-02-11 19:23:39

Another day, another LeetCode problem 🤓. I hope, you could solve the last problem on your own and fully understand what was happening.

## Starting point

Given an integer `n`, return a `counter` function.

This `counter` function initially returns `n` and then returns 1 more than the previous value every subsequent time it is called (`n`, `n + 1`, `n + 2`, etc).

## My Submission

Let's take a look at my code. Yours maybe looks different, and that's okay. Everyone has their own approach.

```javascript
var createCounter = function(n) {

    return function() {
        let m = n;
        n++
        return m;
    };
};
```

What happens here?

```javascript
var createCounter = function(n) {

};
```

What was given by LeetCode was the outer declaration, the initialization of `var createCounter`, which was assigned a function that takes one argument, a number `n`.

👻 **Note:** I personally never use `var` when declaring a variable, I always opt for `let` or `const`, but since this was the default, I'll keep it that way (there's nothing really wrong with using `var`).

### Return a function

In the description it is said that we should return a function, which I did by writing

```javascript
    return function() {

    };
```

### Initial return and increment

The first return should be the number `n` itself. The next return should be one more then the number before and so on.

```javascript
let m = n;
n++;
return m;
```

By declaring `m` and giving it the value of `n`, the first time we call the function the value of `return m` is what is was declared in the beginning, the value of `n`.

`n++`, which stand for increment the number `n` by 1, only happens after `m` is return. So, the second time we call the function, `m` will then be `m + 1`.

---

In general, I am bad at explaining technical stuff. So any advice is welcome to improve my explanation skills 🙏🏽.
Feature release 1.36 of the Date::Holidays Perl distribution
Tags: perl, release, cpan, opensource
Published: 2024-02-11 19:22:34

---
title: Feature release 1.36 of the Date::Holidays Perl distribution
published: true
description: This is an adapter class for the Date::Holidays:: namespace and other things holiday
tags: perl, release, cpan, opensource
---
Triggered by yet another contribution from Wesley Schwengle (waterkip) I am happy to announce release 1.36 of the [Date::Holidays](https://metacpan.org/pod/Date::Holidays) Perl distribution.

The release introduces support for:

- [Date::Holidays::CW](https://metacpan.org/pod/Date::Holidays::CW), a distribution handling holidays for [Curaçao](https://en.wikipedia.org/wiki/Cura%C3%A7ao).

Here is a short demo of inquiring whether 2024-12-25 is a holiday in Curaçao.

```perl
#!/usr/bin/env perl

use strict;
use warnings;

use Data::Dumper;
use Date::Holidays;

my $holidays_hashref = Date::Holidays->is_holiday(
    year      => 2024,
    month     => 12,
    day       => 25,
    countries => ['cw'],
);

print STDERR Dumper($holidays_hashref);

exit 0;
```

And the output:

```perl
$VAR1 = {
          'CW' => 'Pasku di Nacemento'
        };
```

## Change log for Date::Holidays

### 1.36 2024-02-11 Feature release, updated not required

- Addition of support of [Date::Holidays::CW](https://metacpan.org/pod/Date::Holidays::CW) via [Date::Holidays::Adapter::CW](https://metacpan.org/pod/Date::Holidays::Adapter::CW) via PR [#125](https://github.com/jonasbn/perl-date-holidays/pull/125) by Wesley Schwengle (@waterkip) author of: [Date::Holidays::CW], the calendar implementation for Curaçao
Release 0.36.0 of Spellcheck (GitHub) Action: maintenance/feature release - sort of
Tags: release, opensource, githubaction
Published: 2024-02-11 19:14:28

---
title: Release 0.36.0 of Spellcheck (GitHub) Action: maintenance/feature release - sort of
published: true
description: Feature release of a GHA for checking spelling
tags: release, opensource, githubaction
---
I have released version [0.36.0](https://github.com/rojopolis/spellcheck-github-actions/releases/tag/0.36.0) of the GitHub Action for doing spelling checking of your documentation etc. for which I am the current maintainer.

This release was prompted by several updates.

- Docker base image bumped to Python 3.12.1
- and the `pyspelling` dependency was updated to 2.10

The core component of the action is the `pyspelling` package which is a Python package for checking spelling. It is a wrapper around the `hunspell` and `aspell` libraries and provides a Pythonic interface to them. The action is a simple wrapper around this package to make it easy to use in a GitHub Action workflow.

With 2.10 `pyspelling` introduces the ability to run in parallel, which should speed up processing time. I have not been able to document this at this time, but I will more into if this requires additonal work in regard to Docker images used for the action.

## Change Log

### 0.36.0, 2024-02-06, feature release, update not required

- With version 2.10 of **PySpelling** the action now supports the configuration of running jobs in parallel, see the [documentation for PySpelling](https://facelessuser.github.io/pyspelling/configuration/)

- Docker image updated to Python 3.12.1 slim via PR [#177](https://github.com/rojopolis/spellcheck-github-actions/pull/191) from Dependabot. [Release notes for Python 3.12.1](https://docs.python.org/release/3.12.1/whatsnew/changelog.html)
How to add the ko-fi Donate Button to your GitHub repository
Tags: github, webdev, coding
Published: 2024-02-11 19:09:51

"How can I add the Ko-fi donate button to my GitHub repository? Adding a donate button to your GitHub repository is a simple process. First, go to the 'Buttons, Widgets and Sharables' section on Ko-fi's website. Next, select the 'GitHub Donate Button' option and copy the code provided. Once you have the code, you can easily add it to your GitHub repository. That's all you need to do." 😅

Use this anywhere that accepts Markdown.

```
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/O4O1TUHOK)
```

"You can support me if you want." 🙃

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/O4O1TUHOK)
Top Git Commands Every Developer Should Know
Tags: github, git, githubactions
Published: 2024-02-11 19:02:38

 
**Initialize a Repository:**
   ```bash
   git init
   ```

**Clone a Repository:**
   ```bash
   git clone <repository_url>
   ```

**Check Repository Status:**   ```bash
   git status
   ```

**Stage Changes:**   ```bash
   git add <file_name>
   ```

**Commit Changes:**   ```bash
   git commit -m "Your commit message"
   ```

**View Commit History:**   ```bash
   git log
   ```

**Create a New Branch:**   ```bash
   git branch <branch_name>
   ```

**Switch to a Branch:**   ```bash
   git checkout <branch_name>
   ```

**Merge Branches:**   ```bash
   git merge <branch_name>
   ```

**Pull Changes from a Remote Repository:**    ```bash
    git pull origin <branch_name>
    ```

**Push Changes to a Remote Repository:**    ```bash
    git push origin <branch_name>
    ```

**Check Differences between Branches:**    ```bash
    git diff <branch1> <branch2>
    ```

**Discard Changes in Working Directory:**    ```bash
    git checkout -- <file_name>
    ```

**Undo the Last Commit (Keep Changes):**    ```bash
    git reset --soft HEAD^
    ```

**Undo the Last Commit (Discard Changes):**    ```bash
    git reset --hard HEAD^
    ```

**Stash Changes:**    ```bash
    git stash
    ```

**Apply Stashed Changes:**    ```bash
    git stash apply
    ```

**Create a Tag:**    ```bash
    git tag -a <tag_name> -m "Your tag message"
    ```

**Fetch Changes from a Remote Repository:**    ```bash
    git fetch origin
    ```

**Remove Untracked Files:**    ```bash
    git clean -fd
    ```
Say good bye to controllers: C# Minimal APIs
Tags: webdev, beginners, csharp, programming
Published: 2024-02-11 19:01:02


Imagine being able to define an entire API endpoint in a single line of code, without **controllers**. Yes, you read that correctly—just one line. This isn't just a pipe dream; it's the reality of what you can achieve with **Minimal APIs in C#**:

```
var builder = WebApplication.CreateBuilder(args);

// ConfigureServices

var app = builder.Build();

app.MapGet("hello", () => "Hello dev.to!");

app.Run();
```

From setting up the web application builder to defining a simple "hello" endpoint that greets with **"Hello dev.to!"**—this code is the epitome of succinctness. By trimming down the fat, we are left with the purest parts of the framework, enabling us to focus on what truly matters: creating.

The perks of Minimal APIs are manifold:

**Simplicity**: that welcomes newcomers and pleases seasoned architects.

**Performance**: gains from a reduced footprint.

**Flexibility**: to scale from a microservice to a full-fledged application.


Diving into Minimal APIs doesn't require an expedition into unknown territories. Armed with the **.NET 6 SDK or later**, and your favorite text editor or IDE, you're well-equipped to embark on this journey.

As you **embrace this paradigm**, you may find yourself curious for more—more insights, more nuances, more knowledge. For those hungry minds, I recommend watching a detailed exploration on YouTube that demystifies Minimal APIs even further. Check out [this video ](https://www.youtube.com/watch?v=pYl_jnqlXu8&t=)for an in-depth understanding and practical demonstrations that will elevate your mastery of Minimal APIs.

In closing, Minimal APIs are not just a feature; they are a philosophy. A philosophy that champions the virtues of **less is more**, proving that sometimes, the minimal approach can yield the maximum impact.
Gin Up Your Workflow: A Go REST API Crash Course
Tags: go, webdev, beginners, tutorial
Published: 2024-02-11 18:54:44

## Building a Simple REST API in Go with Gin

In this post, we'll explore building a basic REST API using Go and the Gin framework. We'll walk through the code, understand the concepts, and see how to store and retrieve key-value pairs.

**Prerequisites:**

* Basic understanding of Go programming
* Familiarity with HTTP concepts

**What you'll learn:**

* Creating a REST API with Gin
* Storing and retrieving data using key-value pairs
* JSON data formatting

**Code Snippet:**

```go
package main

import (
	"encoding/json"
	"fmt"
	"github.com/gin-gonic/gin"
)

var store map[string]string

func main() {
	store = make(map[string]string)
	router := gin.Default()

	router.POST("/key", func(c *gin.Context) {
		key := c.Param("key")
		value := c.PostForm("value")

		store[key] = value
		c.JSON(200, gin.H{"message": "Stored"})
	})

	router.GET("/key/:key", func(c *gin.Context) {
		key := c.Param("key")
		value, ok := store[key]

		if !ok {
			c.JSON(404, gin.H{"message": "Not found"})
			return
		}

		var unmarshaledValue map[string]interface{}
		err := json.Unmarshal([]byte(value), &unmarshaledValue)
		if err != nil {
			c.JSON(500, gin.H{"message": "Error unmarshaling value"})
			return
		}

		c.JSON(200, unmarshaledValue)
	})

	router.Run()
}
```

**Explanation:**

**Import Libraries:**

   - `encoding/json`: For JSON data encoding and decoding.
   - `fmt`: For output formatting.
   - `github.com/gin-gonic/gin`: The Gin framework for web applications.

**Define Map:**

   - `store`: A `map[string]string` to store key-value pairs.

**Create Gin Router:**

   - `router`: A Gin router instance to handle HTTP requests.

**Store Key-Value Pairs:**

   - `POST /key`: Handles POST requests to store data.
   - It retrieves the `key` from the URL path and `value` from the request body.
   - Stores the pair in the `store` map and returns a "Stored" message.

**Retrieve Key-Value Pairs:**

   - `GET /key/:key`: Handles GET requests to retrieve data.
   - The `:key` part captures the key from the URL path.
   - Retrieves the value for the specified key from the `store` map.
   - Returns a 404 Not Found if the key isn't found.
   - Otherwise, unmarshals the JSON-encoded value and returns it.

**Run the Server:**

   - `router.Run()`: Starts the Gin server and listens for requests.

**Summary:**

This code demonstrates building a simple REST API in Go with Gin. It allows storing and retrieving key-value pairs in JSON format.

I hope this helps! Feel free to ask any questions you may have.
Exploring Scopes
Tags: webdev, programming, tutorial, dotnet
Published: 2024-02-11 18:47:56

🛠️ I dove into creating a project that showcased the practical application of scopes. By walking through the project step by step, I was able to not only reinforce my own understanding but also provide a beginner-friendly explanation to help others grasp this concept.

**The Book Definitions:**

- **Scoped:** Objects are created once per request or scope and reused within that scope, ensuring consistency and efficiency within a defined boundary.
- **Transient:** Objects are created each time they are requested, ensuring freshness and avoiding unintended sharing of state across multiple clients.
- **Singleton:** Objects are created only once throughout the application's lifecycle, providing a single shared instance globally, suitable for resources that are expensive to create or manage.
And I won't waste much time but directly give you a small walk through the code...
So I started creating an MVC Project took the HomeController and modified it which looks like below each Repository generates a Guid.

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

And the Program.cs


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

and the results were as below 
The first time started the project.

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

Refreshing the page.

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

In Simple Terms,
Transient = New Service - every time requested.
Scoped = New Service - once per request.
Singleton = New Service - once per application lifetime.

Happy coding! 💻✨