teleren/devto huggingface dataset:
F# For Dummys - Day 9 Branching
Tags: fsharp
Published: 2024-05-20 12:52:47

Today we learn control flow, or branching</br>
sometimes we need to execute a block of code only when it meets some condition</br>

```
//Pseudocode
if conditionOne then doTaskOne
else if conditionTwo then doTaskTwo
else doSomethingElse
```
we introduce 2 ways of branching
#### if...then
```f#
let temperature = 15

if temperature < 0 then
    printfn "Wear down coat"
elif temperature < 10 then
    printfn "Wear sweater"
elif temperature < 20 then
    printfn "Wear long sleeves"
elif temperature < 30 then
    printfn "Wear T-shirt"
else
    printfn "Wear bikini"
```
temperature = 15, the first branch suits is *temperature < 20* , even though *temperature < 30* is also true, the rest logic will not execute
#### match...with
```f#
// Match expression. 
match test-expression with
| pattern1 [ when condition ] -> result-expression1
| pattern2 [ when condition ] -> result-expression2
| ...
```
equivalent example:
```f#
let temperature = 15

match temperature with
| temperature when temperature < 0 -> printfn "Wear down coat"
| temperature when temperature < 10 -> printfn "Wear sweater"
| temperature when temperature < 20 -> printfn "Wear long sleeves"
| temperature when temperature < 30 -> printfn "Wear T-shirt"
| _ -> printfn "Wear bikini"
```
AND Pattern: we can combine conditions with (`&&`) operator, it hits when both condition match
```f#
let age = 10

match age with
| age when age > 0 && age <= 1 -> printfn "Infant"
| age when age > 1 && age <= 12 -> printfn "Child"
| age when age > 12 && age <= 16 -> printfn "Teenager"
| age when age > 16 -> printfn "Adults"
| _ -> printfn "Not born"
```
OR Pattern: we can combine patterns using the (`||`) operator to match multiple patterns
```f#
let x = 10

match x with
| x when x > 0 || x = 0 -> printfn "Positive or Zero"
| _ -> printfn "Negative"
```
we can define a pattern matching function
```f#
let temperature = 15

let clothingAdvice temp =
    match temp with
    | t when t < 0 -> "Wear down coat"
    | t when t < 10 -> "Wear sweater"
    | t when t < 20 -> "Wear long sleeves"
    | t when t < 30 -> "Wear T-shirt"
    | _ -> "Wear bikini"

printfn "%s" (clothingAdvice temperature)
```
another example from windows documentation
```f#
type Shape =
    | Square of side: double
    | Rectangle of width: double * length: double

let getArea shape =
    match shape with
    | Square side -> side * side
    | Rectangle (width, length) -> width * length

let square = Square 2.0
printfn $"The area of the square is {getArea square}"
let rect = Rectangle (3.0, 2.0)
printfn $"The area of the rect is {getArea rect}"
```
getArea function calculate the area according to different shape 
for a Square, it use side * side = 2.0 * 2.0
for a Rectangle, it use width * length = 3.0 * 2.0
```
The area of the square is 4
The area of the rect is 6
```
we didn't learn type yet, it defines a Union type here, and there is more powerful usage of **match**, we will introduce type, Union and discover more usage of match in the coming days
Navigating the New Frontier AI Role in Shaping Government Policies and Services
Tags: ai
Published: 2024-05-20 12:35:20

As artificial intelligence (AI) technologies advance, governments worldwide are positioned at a pivotal moment. The integration of AI into public sectors promises not only to enhance operational efficiencies but also to redefine citizen engagement and policy development. Here's a deeper dive into the transformative role of AI in government:

1. **Smart Governance**:
   AI's integration into administrative functions is transforming mundane tasks into automated processes. By handling everything from tax processing to regulatory compliance through intelligent systems, AI is enabling a shift towards smart governance that prioritizes speed and accuracy.

2. **Data-Driven Policy Making**:
   AI excels in analyzing complex, large-scale data sets to extract actionable insights. Governments are using AI tools to forecast economic trends, understand demographic changes, and tailor policies that effectively address future needs. This shift towards data-driven policymaking is crucial in an era where traditional methods fall short of addressing dynamic global challenges.

3. **Enhanced Public Safety**:
   AI technologies are at the forefront of enhancing public safety measures. Through predictive analytics, AI assists in crime prevention by identifying patterns and hotspots. Similarly, during natural disasters, AI-driven simulations and real-time data analysis can optimize response strategies, saving lives and reducing chaos.

4. **Ethical Considerations and Transparency**:
   As AI becomes a staple in government operations, the need for ethical frameworks and transparent methodologies cannot be overstated. The development of AI policies must consider privacy concerns, data security, and the potential for bias, ensuring that AI serves as a tool for equitable governance.

5. **Future Challenges and Opportunities**:
   The road ahead is filled with both challenges and opportunities. As AI reshapes government operations, ongoing dialogue is essential to address concerns about job displacement, privacy, and the digital divide. Conversely, AI also offers unparalleled opportunities to enhance service delivery and foster innovation in public administration.

**Engagement Section**:
Let’s open the floor for a broader discussion: **What are your views on the ethical implications of AI in government?** How should governments balance innovation with accountability?

**Share your thoughts below or share this post to keep the conversation going!**
Starting with React
Tags: react, javascript, beginners, programming
Published: 2024-05-20 12:34:22

If you are just beginning with react. Below are a few things to keep in mind as you are about to embark on a long road.

## Need to know

Some fundamentals need to be very clear:
1. HTML
2. CSS
3. Javascript

For beginners ie who are new to programming, you might find React a little overwhelming as it comes with a lot of its concepts and flows. Those from web programming backgrounds too need good practice to understand them.

You should be clear with your goal as to why you want to study react. Only because it's hot in the market or you want to go on the web development path much ahead.   

As React is purely dependent on Javascript, it has some benefits over other technologies. React is not a language or framework. It is a library, unlike Angular which is a complete ecosystem altogether. 

## React vs Angular

1. Angular is a complete ecosystem, a framework. Whereas React is a library. 
2. React is thus easy to learn as it depends mainly on Javascript. Where as to start your career in Angular you need to understand many deep concepts required to implement Angular.

There are a few benefits to React. React native is used as a hybrid technology which can generate code for Web, Android and Apple from a single code base. I am eager to get a grasp on it.
Tribal Teachings: Preserving Indigenous Knowledge in the Digital Age
Published: 2024-05-20 12:29:42

In the age of rapidly advancing technology and globalization, the preservation of indigenous knowledge and traditions is more crucial than ever. [Tribal Teachings](https://tribalteachings.com/) is a platform dedicated to safeguarding and promoting the rich cultural heritage of indigenous communities around the world.

This problem invites participants to explore the intersection of technology and cultural preservation by developing innovative solutions to document and disseminate indigenous knowledge through digital platforms. Participants are encouraged to leverage the resources and tools provided by Tribal Teachings to create applications, websites, or other digital solutions that facilitate the sharing of traditional wisdom, practices, and stories while respecting the cultural sensitivities and privacy concerns of indigenous peoples.

By addressing this challenge, participants not only contribute to the preservation of indigenous knowledge but also empower indigenous communities to share their heritage with the world on their own terms. Join us in embracing the diversity of human culture and ensuring that no voice is left unheard in the digital age.
Performance Metrics Using Guzzle
Tags: php, webdev, performance, beginners
Published: 2024-05-20 12:10:43

In this article we're going to investigate how you can track performance metrics using Guzzle. Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services.

## Introduction

Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services. It provides a simple interface for building query strings, POST requests, streaming large uploads, streaming large downloads, using HTTP cookies, uploading JSON data, etc.

## Installation

To install Guzzle, you can use Composer. Run the following command to install Guzzle:

```bash
composer require guzzlehttp/guzzle
```

## Usage

To send a request using Guzzle, you need to create a new `Client` instance and then use the `request` method to send
the request. Here's an example:

```php
use GuzzleHttp\Client;

$client = new Client();
$response = $client->request('GET', 'https://example.com/posts/1');

echo $response->getBody();
```

In this example, we're sending a `GET` request to `https://example.com/posts/1` and then printing the response body.

## Performance Metrics

Guzzle provides a way to track performance metrics for each request. You can use the `on_stats` options to get detailed
information about the request. Here's an example:

```php
use GuzzleHttp\Client;

$client = new Client([
    'on_stats' => function (\GuzzleHttp\TransferStats $stats) {
        echo $stats->getEffectiveUri() . "\n";
        echo $stats->getTransferTime() . "\n";
        echo $stats->getHandlerStats()['total_time'] . "\n";
    },
]);

$response = $client->request('GET', 'https://example.com/posts/1');

echo $response->getBody();
```

In this example, we're using the `on_stats` option to get detailed information about the request. We're printing the
effective URI, transfer time, and total time for the request.

Inside the `on_stats` callback, you can access the following methods to get insight into the request timings.

- `getEffectiveUri()`: Returns the effective URI of the request.
- `getTransferTime()`: Returns the total time in seconds it took to complete the transfer.
- `getHandlerStats()`: Returns an array of statistics from the handler.

Inside the `getHandlerStats()` method, you can access the following

- `total_time`: The total time in seconds it took to complete the transfer.
- `namelookup_time`: The time in seconds it took from the start until the name resolving was completed.
- `connect_time`: The time in seconds it took from the start until the TCP connect to the remote host was completed.
- `appconnect_time`: The time in seconds it took from the start until the SSL handshake was completed.
- `starttransfer_time`: The time in seconds it took from the start until the first byte was just about to be
  transferred.

This is how the app [UpChecker](https://upchecker.app/docs/performance) tracks performance metrics for each request using Guzzle. You'll get a detailed insight into the request timings and can use this information to optimize your application.
How to validate environment variables in Node.js?
Tags: javascript, node
Published: 2024-05-20 12:02:49

Hey devs 👋🏻

In this article I will teach an alternative to validate the content of environment variables using the package env-var to Node.js.

**Requirements**

✓ NodeJS v20.6 or later
✓ Knowledge in **pnpm** package (or any manager package)
✓ Basic Knowledge in Javascript/TypeScript
✓ Knowledge in **tsnd** package (if use TS)

**env-var**

This is a package that is responsible for verifying, validating and sanitizing environment-variables used in projects in Node.js or web applications.

**Getting started**

Firstly, it is necessary to install the env-var using any package manager (in this case I will use **pnpm**):

```bash
pnpm install env-var
```

After installation, we will create a simple application to demonstrate the functionality of the package (you can use env-var in both JS and TS:

Let's create a env file:

```
MONGODB_URL=127.0.0.1
MONGODB_PORT=1400
```

Then, we will create an application:

```js
import env from 'env-var'

function testeWithEnvVar() {
  const mongodbURL = env.get('MONGODB_URL');
  const mongodbPORT = env.get('MONGODB_PORT');
  console.log(`${mongodbURL}:${mongodbPORT}`)
}

testeWithEnvVar()
```

Now, run the code below:

```npm
npx tsnd --env-file path/to/.env path/to/main.ts

Example:
npx tsnd --env-file .env ./src/main.ts
```

This will show the following message in the console:

```
127.0.0.1:1400
```

But, imagine that we need to validate the content of a URL, validate if it is a valid URL or is not empty, how we can do this?

```js
import env from 'env-var'

function testeWithEnvVar() {
  const mongodbURL = env.get('MONGODB_URL').required().asUrlString();
  const mongodbPORT = env.get('MONGODB_PORT');
  console.log(`${mongodbURL}:${mongodbPORT}`)
}

testeWithEnvVar()
```

See that we need to add only two chained functions (required and asUrlString). Now, if the environment variable **MONGODB_URL** is inconsistent, for example, without content or if it is an invalid url, the message on the console will be:

```
[INFO] 15:58:29 ts-node-dev ver. 2.0.0 (using ts-node ver. 10.9.2, typescript ver. 5.4.5)
EnvVarError: env-var: "MONGODB_URL" is a required variable, but its value was empty
    at raiseError
.
.
.
[ERROR] 15:58:29 EnvVarError: env-var: "MONGODB_URL" is a required variable, but its value was empty
```

The idea of the article is not deepened in the use of env-var lib, but yes, to show the possibilities that it offers.

That's all folks...

**References**

This article was created based on [Marcos Schead's post](https://dev.to/schead/ensuring-environment-variable-integrity-with-zod-in-typescript-3di5) and uses this [env-var](https://www.npmjs.com/package/env-var) documentation
Best 8 Free and Paid Database Design Tools
Tags: sql, sqlserver, devart, dbforge
Published: 2024-05-20 11:58:14

Relational database design can be complex, particularly for big databases with plenty of objects and relationships. This approach is made much simpler by visualization.

A data model map can be developed using a lot of database design tools, after which tables and links between them can be created. In this manner, before integrating the model into a real database, users can meticulously sketch out the whole database structure, identify any problems, and fix them.

In addition to other helpful features, we'll look at the most widely used database design tools that help users visualize, improve, and transform database schemas into usable databases: https://blog.devart.com/top-8-free-and-paid-database-design-tools.html
Must-Visit Brisbane Sights for First-Time Visitors
Tags: the, wheel, brisbane
Published: 2024-05-20 11:43:44

If you're visiting Brisbane for the first time, you're in for a treat. This vibrant city offers a mix of stunning natural landscapes, cultural landmarks, and modern attractions. Here are some must-visit sights that will give you a true taste of Brisbane:

1. South Bank Parklands: This urban oasis is a perfect starting point. Enjoy lush gardens, walk along the river, or relax at the man-made Streets Beach. Don't miss the weekend markets and various dining options that cater to all tastes.


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


2. The Wheel of Brisbane: Located in South Bank, this iconic Ferris wheel offers breathtaking panoramic views of the city. A ride on [The Wheel of Brisbane](https://thewheelofbrisbane.com.au/) is a fantastic way to get an overview of the cityscape, especially at sunset.

3. Brisbane Botanic Gardens: Situated at the base of Mount Coot-tha, these gardens showcase an impressive array of native and exotic plants. The nearby Mount Coot-tha Lookout provides spectacular views of Brisbane and beyond.

4. Queen Street Mall: For a dose of shopping and entertainment, head to this bustling pedestrian mall in the heart of the city. It's lined with major retailers, boutique stores, and a variety of dining options.

5. Lone Pine Koala Sanctuary: Get up close and personal with Australia's unique wildlife at the world's oldest and largest koala sanctuary. You can hold a koala, feed kangaroos, and learn about the country's native animals.

6. Kangaroo Point Cliffs: These cliffs offer some of the best views of the Brisbane skyline. It's a popular spot for picnics, rock climbing, and abseiling. The riverside walk along the cliffs is perfect for a leisurely stroll or bike ride.

7. Cultural Centre: Home to the Queensland Art Gallery, Gallery of Modern Art (GOMA), Queensland Museum, and State Library of Queensland, this precinct is a cultural hub that showcases art, history, and science.

These sights will give you a comprehensive experience of Brisbane's unique charm, blending natural beauty, cultural depth, and urban excitement.
Need Help for Hosting a Static Website on an Apache Server Using an EC2 Instance
Published: 2024-05-20 11:39:13

The goal of this project is to gain practical experience in deploying a basic web application on Amazon Web Services (AWS). Specifically, the project involves launching an Amazon EC2 instance and configuring it to run an Apache web server that hosts a static website. This project demonstrates the core skills required to manage cloud infrastructure and deploy web applications.
Best Practices for Writing Clean and Maintainable HTML
Tags: html, webdev, learning, beginners
Published: 2024-05-20 11:37:26


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

I wanted to kick off a discussion on something fundamental but often overlooked in our day-to-day coding: writing clean and maintainable HTML. We all know HTML is the backbone of any web project, so ensuring it's structured and readable is crucial for long-term project health and collaboration.

Here are a few best practices that I've found helpful:

1. **Use Semantic Elements**
Using semantic HTML5 elements like `<article>`, `<section>`, `<header>`, and `<footer>` helps to create a more meaningful and accessible document structure. This not only improves SEO but also makes your code easier to read and maintain.

2. **Keep Your Code Indented and Organized**
Consistent indentation is key for readability. Whether you prefer 2 spaces or 4, the important part is to stick with it throughout your project. Additionally, group related elements together and use comments to indicate the structure of your document.

3. **Use Descriptive Class and ID Names**
Naming conventions should be clear and descriptive. Avoid vague names like `div1` or `header2`. Instead, use names that reflect the purpose of the element, like `main-header`, `sidebar-nav`, or `product-list`.

4. **Minimize the Use of Inline Styles**
Separate your content (HTML) from your presentation (CSS). Inline styles can make your HTML cluttered and harder to maintain. Use external or internal stylesheets instead.

5. **Accessibility Matters**
Ensure your HTML is accessible by using proper ARIA roles, labels, and attributes. This includes using `<label>` tags with form inputs, adding `alt` attributes to images, and making sure interactive elements are keyboard accessible.

6. **Keep It DRY (Don’t Repeat Yourself)**
Avoid duplicating code. If you find yourself repeating HTML structures, consider using templating techniques or frameworks that support reusable components.

7. **Validate Your HTML**
Use tools like the W3C HTML Validator to check your code for errors and adherence to standards. This can help you catch mistakes early and ensure your HTML is up to par.

---

I’d love to hear your thoughts and any additional tips you might have! How do you ensure your HTML is clean and maintainable? Are there any tools or methodologies you swear by?

Looking forward to the discussion!

---

**Asheel Ahmed**

*Front-End Developer*

*GitHub: [github.com/AsheelAhmedSiddiqui](https://github.com/AsheelAhmedSiddiqui) | Twitter: [@asheelahmedsiddiqui](https://twitter.com/asheelahmedsiddiqui)*
DOTMIRROR
Published: 2024-05-20 11:26:52

Welcome to DotMirror [Professional SEO Services](https://dotmirror.com/) go-to destination for a comprehensive SEO boost. We specialize in providing premium press release links and niche-relevant guest posts to enhance your online presence. Our high authority guest posts ensure maximum link juice, driving traffic and improving your site's ranking. Enjoy the benefits of fast indexing and free link tracking with our niche-relevant services, tailored to meet your unique needs. Trust DotMirror for reliable and effective SEO solutions.
How do I prevent the node.js server from crashing on uncaught exception
Published: 2024-05-20 11:25:02

As a good developer on uncaught exception, we need two things

**1. Our Server should not crash**
**2. Need detailed root cause of the exception as a Log for improvement in code**

To achieve both points I would recommend you to Add Wooffer (https://wooffer.io/) in your Code. you will solve this crashing problem and get more than your expectation

Step to achieve feature

**Step 1: Install**

`npm i wooffer`

or 

`yarn add wooffer`


**Step 2: Setup ENV**

```
token = "<Your Token>";
serviceToken = "<Your Service Token>";
```


Note: get your token and Service Token from https://app.wooffer.io/

**Step 3: Add Wooffer to the Root directory like index.js or app.js**

```
const wooffer = require("wooffer");
const express = require("express");

wooffer(process.env.woofferToken, process.env.woofferServiceToken);

// Add this code to track endpoint usage(Optional)
const app = express();
app.use(wooffer.requestMonitoring);
```

Once This process is done now your node server no more crash on uncaught exceptions and provide real-time slack alert
Nano Theatre
Tags: hometheatre
Published: 2024-05-20 11:18:59

We are among the most trusted home theatre manufacturers and suppliers in Delhi, as we uphold the highest standards of quality and craftsmanship. Each component of our home theatre systems is meticulously selected and rigorously tested to deliver superior performance and reliability. With our unwavering commitment to excellence, rest assured that your investment in luxury entertainment is in capable hands.
[https://www.nanotheatre.com/](https://www.nanotheatre.com/)
[https://www.nanotheatre.com/audio.html](https://www.nanotheatre.com/audio.html)
[https://www.nanotheatre.com/video.html](https://www.nanotheatre.com/video.html)
[https://www.nanotheatre.com/theme.html](https://www.nanotheatre.com/theme.html)