teleren/devto huggingface dataset:
Learn SwiftUI (Day 3/100)
Tags: swift
Published: 2024-04-30 20:54:43

## Swift

* Array
* Dictionary
* Set
* Enum

```swift
import Cocoa

// ## Arrays
var beatles = ["John", "Paul", "George"]
print(beatles)
beatles.append("Ringo")
print(beatles)
let numbers = [4, 8, 15, 16, 23, 42]
// numbers.append(43) // -> this is not allowed since numbers is constant
print(numbers)
// var temperatures = [25.3, 28.2, 26.4, "hello"]
// can't save both decimals and strings, an array can only have one type of data

// define an empty array
var names1 = Array<String>()
var names2 = [String]()
names2.append("John")
print(names2)
var names3: [String] = [] // use type hint
names3.append("Doe")
print(names3)


// array method
var numbers2 = [13,102,4,1,24]
print(numbers2.count)
let num = numbers2.remove(at: 0) // 13 will be removed, num is 13
print(num) // 13
print(numbers2)
print(numbers2.sorted()) // [1, 4, 24, 102], this will not change numbers2
print(numbers2.reversed()) // ReversedCollection, lazy operation
print(Array(numbers2.reversed())) // [24, 1, 4, 102]

// ## Dictionary
let employee2 = [
    "name": "Taylor Swift",
    "job": "Singer",
    "location": "Nashville"
]
print(employee2["name"]) // Optional("Taylor Swift"), the key may not exist
print(employee2["name"]!) // this will unwrap the optional to the actual value
print(employee2["height", default: "Unknown"]) // set the default value

// define an empty dictionary
var heights = [String: Int]()
heights["John"] = 6
print(heights)
var heights2: [String: Int] = [:]
heights2["John"] = 6
print(heights2)

// get count
print(heights2.count) // 1

// ## Set
var numbers4 = Set([1,2,3])
print(numbers4.count) // 3
numbers4.insert(3) // inserted: false
print(numbers4.count) // 3
print(numbers4.contains(2)) // true

// define an empty set
var numbers5 = Set<Int>()
numbers5.insert(1)
numbers5.insert(1)
numbers5.insert(5)
numbers5.insert(3)
print(numbers5.count) // 3
print(numbers5) // [5,3,1]
let numbers6 = numbers5.sorted()
print(numbers6) // numbers6 type is Array, not a Set, b/c set doesn't have order

// Enums
enum Weekday {
    case monday
    case tuesday
    case wednesday
    case thursday
    case friday
}

var day = Weekday.monday
day = .tuesday
day = .friday
print(day) // friday
/*
 Swift knows that .tuesday must refer to Weekday.tuesday 
 because day must always be some kind of Weekday.
 */
 
```
Learn SwiftUI (Day 2/100)
Tags: swift
Published: 2024-04-30 20:19:27

## Swift

* Boolean
* String interpolation
* Project: convert C to F

```swift
import Cocoa

// boolean
var gameOver = false
print(gameOver)
gameOver.toggle()
print(gameOver)

// join string
var name = "john" + " " + "doe"
// use string interpolation
let firstName = "john"
let lastName = "doe"
let age = 25
let fullName = "full name is \(firstName) \(lastName), and he is \(age) years old"

// check point
/*
Creates a constant holding any temperature in Celsius.
Converts it to Fahrenheit by multiplying by 9, dividing by 5, then adding 32.
Prints the result for the user, showing both the Celsius and Fahrenheit values.
*/

let tempC = 21
let tempF = tempC * 9 / 5 + 32
print("\(tempC) Celsius is \(tempF) in Fahrenheit")
```
SASSA Appeal Process
Published: 2024-04-30 19:44:44

The South African Social Security Agency (SASSA) offers an appeal process to ensure fairness and accountability in its decision-making regarding social security benefits. Beneficiaries who disagree with a decision made by SASSA have the right to appeal, providing them with a mechanism to seek a review of the decision. The appeal process involves several steps:

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

Notification of Decision: When SASSA makes a decision regarding a beneficiary's application or benefits, it notifies the individual in writing. This notification includes details about the decision, the reasons for it, and information about the appeal process. 
Request for Review: If a beneficiary disagrees with the decision, they can request a review by submitting an appeal within a specified timeframe, usually within 90 days of receiving the notification. The request for review should be made in writing and clearly outline the reasons for the appeal.
Submission of Supporting Documents: Along with the appeal request, beneficiaries may submit any relevant supporting documents or evidence to strengthen their case. These documents could include medical reports, financial statements, or any other evidence pertinent to the decision being appealed.
Internal Review: SASSA conducts an internal review of the decision, taking into consideration the appeal request and any supporting documents provided. This review is typically carried out by a different official or team than the one that made the initial decision to ensure impartiality.
Appeal Outcome: After completing the internal review, SASSA communicates the outcome of the appeal to the beneficiary in writing. If the appeal is successful, the decision may be overturned, and appropriate actions, such as reinstating benefits or making corrections, are taken. If the appeal is unsuccessful, SASSA provides reasons for the decision and informs the beneficiary of any further options, such as seeking legal advice or escalating the appeal to a higher authority.
Escalation: In some cases, beneficiaries may have the option to escalate their appeal to an independent tribunal or ombudsman if they remain dissatisfied with the outcome of the internal review.
Throughout the appeal process, SASSA is committed to ensuring transparency, fairness, and timely communication with beneficiaries, empowering them to seek redress in cases where they believe a decision has been made unfairly or erroneously. get more information [click here](https://sassacheck.net.za/about-us/).
Blocker: How to load environment variables on broswer environment using webpack.config.js
Published: 2024-04-30 19:44:36

payment.resource.ts

`import useSWR from 'swr';
import { openmrsFetch, useConfig } from '@openmrs/esm-framework';
import { BillingConfig } from '../../config-schema';
import { Buffer } from 'buffer';
import axios from 'axios';

type PaymentMethod = {
  uuid: string;
  description: string;
  name: string;
  retired: boolean;
};

const swrOption = {
  errorRetryCount: 2,
};

export const usePaymentModes = () => {
  const { excludedPaymentMode } = useConfig<BillingConfig>();
  const url = `/ws/rest/v1/cashier/paymentMode`;
  const { data, isLoading, error, mutate } = useSWR<{ data: { results: Array<PaymentMethod> } }>(
    url,
    openmrsFetch,
    swrOption,
  );
  const allowedPaymentModes =
    excludedPaymentMode?.length > 0
      ? data?.data?.results.filter((mode) => !excludedPaymentMode.some((excluded) => excluded.uuid === mode.uuid)) ?? []
      : data?.data?.results ?? [];
  return {
    paymentModes: allowedPaymentModes,
    isLoading,
    mutate,
    error,
  };
};

export const generateStkAccessToken = async () => {
  try {
    const consumerKey = '';
    const consumerSecret = '';
    const authorizationUrl = 'https://sandbox.safaricom.co.ke/oauth/v1/generate?grant_type=client_credentials';
    const auth = Buffer.from(`${consumerKey}:${consumerSecret}`).toString('base64');
    const headers = {
      'Content-Type': 'application/json',
      Authorization: `Basic ${auth}`,
    };
    const response = await axios(authorizationUrl, { method: 'GET', headers });
    const { access_token } = await response.data;
    return access_token;
  } catch (error) {
    console.error(error);
  }
};

export const initiateStkPush = async (payload) => {
  try {
    const access_token = await generateStkAccessToken();
    const initiateUrl = 'https://sandbox.safaricom.co.ke/mpesa/stkpush/v1/processrequest';
    const response = await axios.post(initiateUrl, payload, {
      headers: {
        'Content-Type': 'application/json',
        Authorization: `Bearer ${access_token}`,
      },
    });
    return response.data;
  } catch (error) {
    console.error(error);
    throw error;
  }
};`

webpack.config.js
`module.exports = require('openmrs/default-webpack-config');
`
I want to using dotenv on the payment.resource.ts
What is Illegal Shadowing
Tags: javascript, react, webdev, programming
Published: 2024-04-30 19:36:06

It is a Situation where a **variable in a inner Scope **(such as Block,Function) **unintentionally Hide a variable for the same name in an outerScope**  

Example 1 :->
`var x = 10;

function m1(){
    console.log(x)
    var x = 100;
    console.log(x);
}

m1();`
How to get the Developer Role on the Mode Discord Server
Published: 2024-04-30 19:26:47

If you are a developer building on Mode, you have the opportunity to get access to an exclusive role in the Mode Discord server, granting access to a private chat to get support, connect, and build your network.

This guide offers step-by-step instructions to get access to the `Developer` role.

It only takes 2 minutes!

### Claiming the Developer Role

Open Discord and navigate to the [Mode Discord Server](https://dub.sh/mode-discord).

![](https://lh7-us.googleusercontent.com/n-7Jr9gc1lJ7uckhfb7ovmgORfjef0Eyi06Pniz65n--ERi8W3-vz6NZZ447xKUL1mEKE7om3-Ev7PMgerhw1DBMMASHvU0nbAtdINlf6gu2bc29XZ7I7cg8Ja6RZ32V9dAWp3KFv_0PypfS34VpE_w align="left")

Click on the Mode Network Server options available on the Upper Left Corner of the Screen to reveal a dropdown list.

![](https://lh7-us.googleusercontent.com/YjfXepkz-adcV4kqLByc5FJdolSM5X8Tu8NYYOSJHsnyUM75Fkaul7pdC4E8qbOmPAxb7Vnul8dGp0bMS3fyLtlHHiBITZi6HFVhXtCX6M1KKmSO4TYZP3IlKvIHgNRYCZuhHOYxjua-49uQRiqQ96k align="left")

Select `Linked Roles` in the options menu.

![](https://lh7-us.googleusercontent.com/cGUuXgkIPMxEb_UmSSRYar5moba3rsX3TLLpmh7bnjmyXVHdm_FFGGhWQ00gYwIZeGwpY5Gg92unF0L93FA8fbqeZgJ0j4m5_eBI4wrAhHyTf53TZUltw7K7oVMaPMNi86n8pY_epepl4YvSVzAA68M align="left")

A Modal with the linked roles will appear. Select `Developer` from the options. You will be prompted to connect to your GitHub account.

![](https://lh7-us.googleusercontent.com/JVQEWbVHtwu-EsNZaXmfj7TfC-FmVNiZ1h7iYkf3ZNjxkmVN0egjYKY8qW7BFfLDdEJoiP_rG2uNTA2jmvrj6OMtyK07n2JVSar170V6aWUgFmIm3U2K5tgT_iyudqOpcqWcGplQwAknTcCMLEuR39w align="left")

Once you’ve successfully connected your GitHub account, you will be granted the Developer role.

![](https://lh7-us.googleusercontent.com/QeSXRFd07KXYTu_QvzABfYZu6_-IeyryCnKLdO3F7y63WTsXMpJifGiaJIS5Bo6DFqMwQeNFF7jrn51SNvT2DuzFr48Ql5B05pq73zvqvh6IUQfyJNtWr0YR0q5AmtyXOMIiwg5t1oKrdEWucN3Tc_M align="left")

Congratulation! You now have access to the developer-exclusive channel. Feel free to ask questions, share what you are building, and connect with other builders.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1707329696167/99a685ce-849d-4d10-824b-7eb9451f9fb0.png align="center")

### What's Next

* [How to Bridge Assets over to Mode from other networks](https://www.youtube.com/watch?v=NuI1cwpCX40&t=194s)
    
* [How to Register a Smart Contract on Mode using Hardhat](https://www.youtube.com/watch?v=bXw2oI_GNrI&feature=youtu.be)
    
* [Add Mode to Metamask in One Click](https://www.youtube.com/watch?v=rs0czuDlvjc&t=10s)
    
* [Mode Documentation](https://docs.mode.network)
RDS while connection error: no pg_hba.conf entry for host
Published: 2024-04-30 19:24:43

## Create a New Parameter Group:
1. Open the Amazon RDS console at https://console.aws.amazon.com/rds/.
2. In the navigation pane, choose "Parameter groups".
3. Click "Create parameter group" at the top right of the page.
4. In the "Parameter group family" dropdown, select "postgres15".
5. In the "Group name" field, enter a name for the new parameter group.
6. In the "Description" field, enter a description for the new parameter group.
7. Click "Create" at the bottom right of the page.

## Modify the rds.force_ssl Parameter of your new Parameter Group:
1. In the list of parameter groups, click on the name of the new parameter group you just created.
2. In the "Filter parameters" box, type rds.force_ssl and press Enter.
3. You should see the rds.force_ssl parameter. Click "Edit parameters".
4. Change the value of rds.force_ssl from 1 to 0, then click "Save changes".


## Associate Your RDS Instance with the New Parameter Group:
1. In the navigation pane, choose "Databases".
2. Click on the name of your RDS instance.
3. Click "Modify" at the top right of the page.
4. In the "Database options" section, find the "DB parameter group" setting and select the new parameter group you created from the dropdown menu.
5. Scroll down and click "Continue".
6. Review the summary of modifications and click "Modify DB Instance".

## Reboote Your RDS Instance:
1. In the navigation pane, choose "Databases".
2. Click on the name of your RDS instance.
3. Click "Actions" at the top right of the page, then "Reboot".
4. Confirm that you want to reboot the instance.

By following these steps, you should be able to successfully modify the rds.force_ssl parameter in your Amazon RDS instance. And hopefully the connection issue would be resolved.
Exploring China's Pragmatic AI Approach – The AI Cold War Might Just Have Begun
Tags: ai, news, discuss, learning
Published: 2024-04-30 19:02:02

Is China surpassing the US in the AI race? Their latest LLM innovation, SenseNova 5.0, is causing the industry to perk up and raising curiosity.

My latest article delves into China's aggressive AI push, including:

– SenseNova 5.0's capabilities and potential impact;
– China's pragmatic, application-driven approach to AI;
– How China's AI strategy challenges the West;



👉 [**Intrigued? Read the full analysis here!**](https://iwooky.substack.com/p/china-pragmatic-ai-sensenova)


[![Exploring China's Pragmatic AI Approach](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9opz8h2oa0sm77y3pjx.jpg)](https://iwooky.substack.com/p/china-pragmatic-ai-sensenova)
What is Variable Shadowing in Javascript
Tags: javascript, webdev, programming, react
Published: 2024-04-30 18:24:33

when variable Shadowing occur in which condition

Variable Shadowing occurs when a variable Declare with a local Scope (such as in function or block level Scope)
has the same name as a variable in the outerScope. 
as the result inner variable **shadow** the **outer variable** 
it will work for all (var,let,const)

`var x = 10;;

function m1(){
    var x = 100; // inner variable will shadow the outer variable 
    console.log(x);
}


m1();  // it will print 100;
console.log(x);  // it will print 10`
React
Tags: react, javascript, beginners, reactjsdevelopment
Published: 2024-04-30 18:13:15

**=>** React is a JavaScript library created by Facebook.

**=>** React is a tool for building UI components

---

_**Babel**_
Babel is a JavaScript compiler that can translate markup or programming languages into JavaScript.

---


_**JSX**_
JSX stands for JavaScript XML.
JSX is an XML/HTML like extension to JavaScript.

---

_**React Elements
**_
React applications are usually built around a single HTML element.

---
_**React Components**_

React components are JavaScript functions.
This example creates a React component named "sanu":

`function Welcome() {
    return <h1>Hello React!</h1>;
}
ReactDOM.render(<Welcome />, document.getElementById('root'));`

---


**How to Create React Application**

Make sure you have Node.js. 
Otherwise you must install npx:

```
npx create-react-app demo
```
```npm i npx```

```C:\Users\sanus3175>npx create-react-app demo```
Excited for a new space in my life
Published: 2024-04-30 18:12:16

I'm really excited to finally have a space in my life where I can share all the things that I geek out on with others. Facebook definitely isn't the space for that. Nor is LinkedIn. Twitter used to be that space for me before it turned into a giant dumpster fire. 

I'm going to work on trying to do short posts with a weekly recap of the different technologies I'm working with and the problems I'm experiencing as a way to get in the habit of posting here on dev.to
Congrats to the winners of the Frontend Challenge: Earth Day Edition!
Tags: frontendchallenge, devchallenge, javascript, css
Published: 2024-04-30 18:11:22

---
title: Congrats to the winners of the Frontend Challenge: Earth Day Edition!
published: true
description: We received so many creative, skillful, and inspiring submissions that showcased the communities’ talent.
tags: frontendchallenge, devchallenge, js, css
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v1j6wz3srlywj4z0u7vd.png
# Use a ratio of 100:42 for best results.
# published_at: 2024-04-25 15:53 +0000
---
Earlier this month, we celebrated our planet’s largest civic event, Earth Day, by kicking off our second Frontend Challenge. We invited the community to participate in two prompts, with the opportunity to win in an additional prize category:

**Prompts**
- CSS Art: Earth Day
- Glam Up My Markup: Earth Day Celebration Landing Page

**Additional Prize Category**
- Earth Day: Awarded to a top submission that brings awareness to climate change.

The response was incredible! We received so many creative, skillful, and inspiring submissions that showcased the communities’ talent. But as it goes with every challenge, there can only be a few winners. 

## Congratulations To…

@schmoris for educating us all and showing what we can do with fewer resources. And by fewer resources, we mean CSS-only!

This game is incredibly polished and interactive, and an incredible demonstration of the challenge.

{% link https://dev.to/schmoris/earth-rescue-a-css-only-game-o0e %}

---

@devdongsu for designing an interactive and thoughtful Earth Day Landing Page with the HTML we provided.

This is a simple, accessible page that is usable across desktop and mobile devices. Despite simplicity, it includes eye-catching animations and personality. There were so many great submissions here, and this one really nailed it in the end.

{% link https://dev.to/devdongsu/earth-day-frontend-challenge-landing-page-hugging-earth-30j0 %}

---

@jorgedelcampo, our additional prize category winner, for bringing awareness to climate change.

Talk about story-telling with CSS! This is another submission which does more with less, and in this case we get a full story about our earth and our impact. 

{% link https://dev.to/jorgedelcampo/happy-earth-day-3mgn %}

## What’s next?

We’ll be hosting another Frontend Challenge very soon! Be sure to follow our challenge tags so you don’t miss the announcement. 

{% tag frontendchallenge %}

{% tag devchallenge %}

Thank you to everyone who participated. ❤️

We hope you had fun, felt challenged, and maybe added a thing or two to your professional profile. 

See you next time!
Setup FTP server on Mac OS X
Tags: ftp, macbook, python
Published: 2024-06-24 13:50:37

---
title: Setup FTP server on Mac OS X
published: true
date: 2024-04-30 18:04:14 UTC
tags: ftp,macbook,python
canonical_url: https://avilpage.com/2024/04/how-to-setup-ftp-server-on-mac-os.html
---

<iframe src="https://www.youtube.com/embed/WmmB-6MXRYc" allowfullscreen>
</iframe>

On Linux & Mac OS X, Python comes pre-installed. On Windows, we can install it from Windows store or from [https://python.org](https://python.org) website.

We can verify the Python version using the below command.

```
$ python --version
Python 3.11.6

```

We can use the `pyftpdlib` library to create an FTP server. We can install the library using the below command.

```
$ python -m pip install pyftpdlib
[I 11:28:21] concurrency model: async
[I 11:28:21] masquerade (NAT) address: None
[I 11:28:21] passive ports: None
[I 11:28:21] >>> starting FTP server on :::2121, pid=99951 <<<

```

Now, we can start the FTP server using the below command.

```
$ python -m pyftpdlib

```

It will start the FTP server on port 2121. We can connect to the FTP server using the below command.

```
$ ftp localhost 2121

```
Meet RayQL - A Schema and Query Language for Your SQLite Side Projects
Tags: sqlite, rust, dsl, parser
Published: 2024-04-30 18:02:58

Let's be real, as developers, we've all spent way too much time setting up backends, writing validation schemas, and reinventing the wheel for common tasks when working on side projects. It's a massive time sink that takes away from the actual fun of building something new.

That's why I created [RayQL](https://github.com/harshdoesdev/rayql), a schema definition and query language for SQLite, built with Rust. The core goal is to provide a compact and familiar syntax that eliminates the need to reinvent the wheel for data validation, allowing you to quickly prototype and build backends without juggling multiple components. With RayQL, everything you need lives in a single executable, which makes it super-easy to get started on your side projects.

RayQL gives superpowers to SQLite by providing built-in validation functions (more on that in future releases) and everything you need for building SQLite-based backends. It's designed specifically for side projects, where you want to focus on your core idea rather than getting bogged down by redundant tasks.

One of the main pain points when working with databases is defining models and setting up relationships. RayQL makes this process a walk in the park:

```rayql
# Enum for user types
enum user_type {
  admin
  developer
  normal
}

# Model for 'user'
model user {
  id: int primary_key auto_increment,
  username: str unique,
  email: str unique,
  phone_number: str?,
  user_type: user_type default(user_type.normal)
}
```

No more dealing with string literals for enums or forgetting to set default values. It just works.

Let's say you want to create a `post` model with a foreign key relationship to the `user` model. With RayQL, it's as simple as:

```rayql
model post {
  id: int primary_key auto_increment,
  title: str default('New Post'),
  content: str,
  author_id: int foreign_key(user.id),
  created_at: timestamp default(now()),
}
```

Yup, that's it. No more jumping through hoops to set up foreign keys or default values.

You can try out RayQL right now using the online editor – [RayQL Studio](https://harshdoesdev.github.io/rayql-studio), or install it locally using this simple command:

```bash
curl -s https://raw.githubusercontent.com/harshdoesdev/rayql/main/install.sh | sh
```

RayQL is an open-source project, so feel free to contribute, report issues, or propose new features on the [GitHub repository](https://github.com/harshdoesdev/rayql).

The team has some exciting plans for the future, including automatic TypeScript type generation (coming in the `0.2` release) and support for writing database queries using the RayQL syntax.

So, if you're tired of spending more time on the backend than the actual project, give RayQL a try. It might just be the superpower you need to focus on what really matters – bringing your ideas to life.