teleren/devto huggingface dataset:
Assistant professor
Published: 2024-04-28 22:11:33

[Assistant professor](https://www.coze.com/store/bot/7360718914042527750?from=bots_publish&panel=1&bid=6cbm5gb880g06)

Reinforcement teachers play an essential role in the educational and emotional development of students, offering individualized and personalized support. However, the importance of this support is even more pronounced for students living with family members with low educational attainment. These students face additional challenges in their educational journey due to the family environment with limitations in academic knowledge.

Students living with family members with low educational attainment often lack academic support at home, which can result in learning gaps and difficulties in areas such as mathematics, language, and science. In this context, reinforcement teachers play a crucial role by providing individualized support, adapting their teaching approaches to the specific needs of each student. They fill these learning gaps, helping students overcome specific difficulties and maximizing their learning potential.

Additionally, reinforcement teachers also provide personalized guidance and encouragement, promoting students' confidence and self-esteem. For students living with family members with low educational attainment, who may face additional challenges due to the family environment, this emotional support is critical for academic success. Reinforcement teachers play a crucial role in breaking the cycle of low family educational attainment, offering support and opportunities for these students to achieve their educational goals.

In summary, reinforcement teachers play a fundamental role in students' lives, especially those living with family members with low educational attainment. They offer individualized academic and emotional support, adapting their teaching approaches to the specific needs of each student. By filling learning gaps, promoting confidence and self-esteem, and offering emotional support, reinforcement teachers help these students overcome challenges and achieve academic success.

[This assistant professor answers students' questions.](https://www.coze.com/store/bot/7360718914042527750?from=bots_publish&panel=1&bid=6cbm5gb880g06)
Real end-to-end type-safety with Expressjs
Published: 2024-04-28 22:10:51

TLDR: Check out my new end-to-end type adapter for Express.js: [express-typed](https://github.com/Eliav2/express-typed)

---



![express-typed-gif](https://github.com/Eliav2/express-typed/assets/47307889/9c8d9406-73b8-4932-8312-282c9e56988d)

I’ve always appreciated the simplicity of Express, but it was created back in 2009, long before TypeScript emerged in 2014. Consequently, type safety wasn’t built into the framework from the start.

While alternatives like [trpc](https://trpc.io/) exist, they often come bundled with peculiar adapters specific to trpc, not always seamlessly fitting into other setups.

Another option [ts-rest](https://ts-rest.com/) and [zodios](https://www.zodios.org/), but they require upfront type definitions imported into both backend and frontend. This approach can be tedious, especially when dealing with dynamic backend types, such as those in Prisma ORM.

When confronted with these challenges in my recent project, I decided to build a custom type adapter for Express.js Router. This solution relies heavily on type declarations, wrapped in a tiny runtime wrapper around Express.Router, that enables type inference (as TypeScript inference primarily operates declaratively: during assignment and return, while Express.Router routes are declared imperatively)

This library was successfully deployed in production with my latest project, and the results were so impressive that I couldn’t resist extracting the type adapter into a separate library to share with you all.

Check out the GitHub repo for more details, and please share any suggestions or issues you encounter!
Breaking spaces in vim
Tags: vim
Published: 2024-05-01 07:34:13

---
title: Breaking spaces in vim
published: true
date: 2024-04-28 22:00:00 UTC
tags: Vim
canonical_url: https://peateasea.de/breaking-spaces-in-vim/
cover_image: https://peateasea.de/assets/images/nbsp-to-space-dev-to-2.png
---

*Originally published on [peateasea.de](https://peateasea.de/breaking-spaces-in-vim/).*

Some text editing software packages seem to insert non-breaking spaces into files willy-nilly. This can be a pain if you don’t want them. Also, they’re _very_ hard to find because–to the eye–they’re indistinguishable from a normal space. What to do?

If you’re like me and use [vim](https://www.vim.org/) as your day-to-day editor and want to break free from non-breaking spaces, you can replace them in the entire document (from [normal mode](https://vimdoc.sourceforge.net/htmldoc/intro.html#Normal)) like so:

```vim
:%s/<Ctrl-V>u00a0/ /g
```

[or more compactly](https://mastodon.social/@normalmode/112326418540079038) like so:

```vim
:%s/<Ctrl-V>xa0/ /g
```

* * *

For those who might be interested in the details, here’s what’s happening:

- when in normal mode, commands are prefixed with a colon `:`
- the `%` means that the following command will be carried out for all lines in the buffer or file.
- `s` denotes the start of a substitution.
- the `/` characters delimit both the string to search for and the string to replace it with.
- `<Ctrl-V>` means to enter the `^V` control character by pressing the `Ctrl` key and `v` together.
- `u00a0` is the [unicode hex sequence (in vim) for a non-breaking space](https://www.compart.com/en/unicode/U+00A0). The `^V` combined with the unicode hex sequence then produce a non-breaking space.
- the trailing `g` means to carry out the substitution “globally” i.e. for all occurrences on the current line (the `%` then handles the case for all lines).

Happy hacking!
Session in PHP with an example
Tags: php, session
Published: 2024-04-28 21:43:25

Sessions in PHP are a mechanism to store user-specific information across multiple web pages. This is useful when you need to track a user's state within your application, such as keeping items in a shopping cart or remembering their login status.

Here's how sessions work in PHP:

1. **Starting a Session:** You initiate a session using the `session_start()` function. This function either retrieves an existing session associated with the user (identified by a session ID) or creates a new session if one doesn't exist.

2. **Storing Session Data:** You can store data related to the user in the session using the associative array `$_SESSION`. This array acts like a container where you can assign key-value pairs. For example, `$_SESSION["username"] = "johnDoe";` stores the username "johnDoe" under the key "username".

3. **Accessing Session Data:** On subsequent pages within the same session, you can access the stored data using the `$_SESSION` array. The values can be used for various purposes, like personalizing content or remembering user preferences.

4. **Destroying Sessions:** Sessions can expire automatically when the user closes the browser or after a specific period of inactivity. You can also explicitly destroy a session using the `session_destroy()` function.

Here's an example to illustrate these concepts:

**login.php:**

```php
<?php
session_start();

if (isset($_POST['username']) && isset($_POST['password'])) {
  // Simulate successful login (replace with actual authentication logic)
  $_SESSION['username'] = $_POST['username'];
  header('Location: profile.php');
  exit;
}
?>

<!DOCTYPE html>
<html>
<body>
<form method="post">
  Username: <input type="text" name="username" required><br>
  Password: <input type="password" name="password" required><br>
  <button type="submit">Login</button>
</form>
</body>
</html>
```

**profile.php:**

```php
<?php
session_start();

if (!isset($_SESSION['username'])) {
  header('Location: login.php');
  exit;
}

$username = $_SESSION['username'];
?>

<!DOCTYPE html>
<html>
<body>
  Welcome, <?php echo $username; ?>! This is your profile page.
</body>
</html>
```

In this example:

- `login.php` checks for submitted login credentials. If valid (replace with actual authentication), it stores the username in the session (`$_SESSION['username']`) and redirects to `profile.php`.
- `profile.php` starts the session and checks if a username is present in the session. If not, it redirects back to the login page. If a username exists, it welcomes the user by name using the retrieved session data.

This is a basic example of using sessions in PHP. You can extend this concept to store various user-specific information and manage user state across your web application. Remember to always implement proper security measures when handling user data in sessions.
Landing page
Tags: devchallenge, frontendchallenge, css, javascript
Published: 2024-04-28 20:57:04

_This is a submission for [Frontend Challenge v24.04.17](https://dev.to/devteam/join-us-for-the-next-frontend-challenge-earth-day-edition-52e4), Glam Up My Markup: Earth Day Celebration Landing Page_

## What I Built

<!-- Tell us what you built and what you were looking to achieve. -->

## Demo
<!-- Show us your project! You can directly embed an editor into this post (see the FAQ section from the challenge page) or you can share an image of your project and share a public link to the code. -->

Links:
- [demo](https://juliashlykova.github.io/earth-day-landing-page/);
- [code](https://github.com/JuliaShlykova/earth-day-landing-page)

## Journey
<!-- Tell us about your process, what you learned, anything you are particularly proud of, what you hope to do next, etc. -->

<!-- Team Submissions: Please pick one member to publish the submission and credit teammates by listing their DEV usernames directly in the body of the post. -->

<!-- We encourage you to consider adding a license for your code. -->

<!-- Don't forget to add a cover image to your post (if you want). -->


<!-- Thanks for participating! -->
Counting Even Numbers in an Array using JavaScript
Tags: webdev, javascript, programming, productivity
Published: 2024-04-28 20:54:13

In JavaScript, it's often necessary to perform operations on arrays efficiently. **One common task is counting the number of even numbers within an array**. The isEven function provided below accomplishes this task by iterating through the array and incrementing a counter whenever it encounters an even number.

```Javascript
function isEven(arr) {
    var count = 0; // Initialize a counter to keep track of even numbers
    
    // Iterate through the array
    for (var i = 0; i < arr.length; i++) {
        // Check if the current element is even
        if (arr[i] % 2 === 0) {
            count++; // Increment the counter if the element is even
        }
    }
    
    return count; // Return the total count of even numbers
}
```

```Javascript
console.log(isEven([1, 2, 3, 4, 5])); // Should output 2

```

## Analysis

- **Efficiency:** The time complexity of this function is O(n), where n is the length of the input array. This is because it iterates through the array once, performing a constant-time operation (modulus) on each element.

- **Space Complexity:** The space complexity of this function is O(1) because it only uses a constant amount of additional memory regardless of the size of the input array. The only variable it declares is count, which stores the count of even numbers.
Frontend Developer? Here are 10 resources that can make your work easier.
Published: 2024-04-28 20:39:45

Including SVG Shapes, Loader, Waves, Gradient, Blob, Font Finder, CSS animation, and Illustrations


### 1. https://www.svgshapes.in
A website with 100+ beautiful SVGs. No Attribution required. You can customize their color with solid and gradient. Then use them for your project by downloading them as PNG or Copy as SVG.

### 2. https://loading.io
A website where you can get the Loaders for your website. Ajax Loader, Animated Icons, Live Background, in GIF / SVG / APNG / CSS / LOTTIE / MP4 & More!

### 3. https://getwaves.io
Make some waves! A website where you can make Waves for 100% FREE with color and shape customization.

### 4. https://cssgradient.io/gradient-backgrounds
A website dedicated to Gradient Backgrounds.

### 5. https://www.magicpattern.design/tools/blob-generator
A website to create Blob for your project.

### 6. https://www.myfonts.com/pages/whatthefont
Instant font identification powered by the world’s largest collection of fonts. A font finder website. You can find a font from screenshots or other images. It is really helpful when you are not able to identify what font anyone else using.

### 7. https://undraw.co/search
A website dedicated to Illustrations

### 8. https://www.cssportal.com/css-column-generator/
CSS Portal is home to many examples of CSS / HTML and how it can be used in website design. Here you'll find all CSS properties and many CSS generators to help with all your design needs.

### 9. https://svgwave.in/
SVG wave generator with animations

### 10. https://meshgradient.in/
Beautiful mesh gradient generator

### Bonus: https://gradient.style/
Advanced CSS gradient generator


Give them a try and watch your designs come to life! 💻

Happy Coding ✨

#FrontendDevelopment #WebDesign #DeveloperTools #codinglife #frontend #developer
Book Report Bot
Tags: cozechallenge, devchallenge, ai, machinelearning
Published: 2024-04-28 20:21:30

*This is a submission for the [Coze AI Bot Challenge](https://dev.to/devteam/join-us-for-the-coze-ai-bot-challenge-3000-in-prizes-4dp7): Bot Innovator.*

## What I Built
<!-- Tell us what your bot does, who it's for, and what problem it solves -->

This bot creates a book summary with bulletpoints from the inputted book title. 

This is a great bot for people who would read many books and would like to create notes on the book's content so that they can keep track of what they have read over weeks, months and years. 

The outputted content can be also used as the starting point for a book report style presentation in front of an audience.

## Demo

<!-- Share a link to your bot in the Coze Bot Store and include screenshots or recordings showcasing a user's chat interface with your bot. -->

https://www.coze.com/store/bot/7362660548351148037?bot_id=true

**Setup (3 Images)**

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


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


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


## Your Configuration

<!-- Screenshot or record your bot's configuration, including prompts and skills used.  -->

Used ChatGPT4 and Dalle-3 to create text and images.

**Example (2 Images)**

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


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



## Journey

<!-- Tell us about your process, what you learned, anything you are particularly proud of, what you hope to do next, etc. -->

I had been looking for AI tools to help me organize my education and reading materials. There are many AI tools out there, but Coze was very easy to use compared to the others that I have tried. Its UI/UX interface and the separation of tools/abilities were intuitive to work with.

I first worked with Coze at the Hacker Dojo event on April 27, 2027. Within an hour, I already had a working bot with multiple interconnected skills and the outline of an unrelated but complex workflow. The workflow expands on the idea of the Book Report App but links far more output content. 

**For the future**, I would like to expand the input options from a single book title to the option to upload the book in a pdf file. This expanded input option would allow me to organize more recently published books and content.

<!-- Team Submissions: Please pick one member to publish the submission and credit teammates by listing their DEV usernames directly in the body of the post. -->

<!-- Don't forget to add a cover image (if you want). -->


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

<!-- Thanks for participating! -->
Introduction to Frontend System Design
Published: 2024-04-28 20:17:50

## Radio Framework
Approach your front end system design interviews in structured fashion.
A good structure is half the battle won.

## What is Radio about?
1. Requirement Exploration: Understanding the problem throughly and determine the scope by asking a number of clarifying questions.
2. Architecture/High-level Design: Identify the key components of the products and how they are interlinked to each other.
3. Data Modal: Describe the various entities, the field they contain and which component(s) they belong to.
4. Interface Definition(API): Define the interface (API) between components in the product, functionality of each API, their parameters and responses.
5. Optimizations: Discuss about possible optimizations opportunities and specific areas of interest when building the product.

**Note** This is a short intro of radio approach for frontend system design. I will come back with in depth of the above approach in the next post.

Happy Learning 🙌🏼
Bot Innovator: Converting images with Image Wizard AI Assistant
Tags: cozechallenge, devchallenge, ai, machinelearning
Published: 2024-04-28 19:55:29

*This is a submission for the [Coze AI Bot Challenge](https://dev.to/devteam/join-us-for-the-coze-ai-bot-challenge-3000-in-prizes-4dp7): Bot Innovator.*

## What I Built
Sometimes, we need to convert an image from one format (X) to another (Y). Perhaps you require an optimized image format, such as JPEG, or the website where you intend to upload doesn't accept your current format.

To address this issue, the Image Wizard AI Assistant helps by converting images from both common and uncommon formats to another desired format. It also assists in selecting the best format for a specific case. There's no need to search online; simply upload the image and specify the desired format. The bot will handle the conversion and provide a URL for the new image.

## Demo

[Bot link on Coze Bot Store](https://www.coze.com/store/bot/7362968711982104582)

Video showcase
{% embed https://youtu.be/-F2FmUm8J8Y %}

## Your Configuration

Initially, I chose to concentrate this bot solely on image processing contexts, defining specific roles and behaviors.

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

On Skills, I exclusively utilize the [Image Wizard plugin](https://www.coze.com/store/plugin/7362967850568548358) to convert images into various images formats. Making possible accepts gif and converting to JPG, for example.

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

To improve the user experience, I used the Dialog to display helpful options for starting a chat. Additionally, I utilized Auto-Suggestions to generate some useful questions related to the context.

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

## Journey

As described in my [Coze Trailblazer submission](https://dev.to/gabrielsenadev/coze-trailblazer-adding-image-processing-capability-with-image-wizard-2hff), developing this bot helped me learn and experiment with many things to make it possible.

Working with the Coze ecosystem was a gratifying experience because everything worked well and helped me improve further in AI-based Assistant development.

In the future, my expectation is to develop more tools for image processing and provide them to users through this bot.
Convert hex to base64
Tags: 100daystooffload, cryptopals, challenge, crypto
Published: 2024-04-28 19:45:34

This is the first crypto challenge in set 1 from [cryptopals](cryptopals.com), which is the qualifying set. 

The difficulty level is relatively easy, to solve this problem I have used the programming language Go.

# Problem description

Convert a string with hex values to a base64 string. The rules are:

> Always operate on raw bytes, never on encoded strings. Only use hex and base64 for pretty-printing.

The input is:

`49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d`

which should give the following output

`SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t`

# Solution

The go language has great support for this kind of problems through their standard libraries in `encoding` package.

There are two of interest in this case.

```golang
import (
	"encoding/base64"
	"encoding/hex"
)
```

The names of these packages are pretty much self-explanatory, `base64` implements base64 encoding and `hex` implements hexadecimal encoding and decoding.

First step is to convert the hexadecimal string to a slice of bytes. The `hex` package has a perfect function for this, `DecodeString`, which takes a hexadecimal string.

```golang
	bytes, err := hex.DecodeString(theString)
	if err != nil {
		fmt.Println("Error decoding hexadecimal string:", err)
		return
	}
```

The last step of the problem is to encode this slice of bytes to base64. Naturally we will look after a good function for this job in the `base64` package. There are two candidates for this, `EncodeToString` and `Encode`. We will go with `EncodeToString`, since we want to print a string to see if we got the correct result. 

```golang
str := base64.StdEncoding.EncodeToString(bytes)
```

Now we have all the pieces to solve the problem, and the program could look like this.

```golang
package main

import (
	"encoding/base64"
	"encoding/hex"
	"fmt"
)

func convertToBase64(hexString string) (string, error) {
	bytes, err := hex.DecodeString(hexString)
	if err != nil {
		return "", err
	}

	return base64.StdEncoding.EncodeToString(bytes), nil
}

func main() {
	theString := "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d" // Replace with your hex string

	str, err := convertToBase64(theString)
	if err != nil {
		fmt.Println("Error decoding hexadecimal string:", err)
		return
	}

	fmt.Println("Base64:", str)
}
```

# Conclusion

The problem is easy to solve when having access to Go's standard packages and its great documentation.
 
# References

* [Set 1 - Challenge 1](https://cryptopals.com/sets/1/challenges/1)
* [The Base16, Base32, and Base64 Data Encodings](https://www.rfc-editor.org/rfc/rfc4648.html)
* [encoding/base64](https://pkg.go.dev/encoding/base64)
* [encoding/hex](https://pkg.go.dev/encoding/hex)
the cryptopals crypto challenges
Tags: 100daystooffload, challenge, cryptography, beginners
Published: 2024-04-28 19:37:23

This looks fun, [cryptopals](https://cryptopals.com/).

This is a site with a set of crypto challenges designed to educate and test skills in cryptography. These challenges do not require any advanced mathematical skills, 9th grader's level of math should be sufficient, and no prior cryptography knowledge is needed. You will only need to be able to code in any programming language.

The challenges are described as progressively getting harder and are based on real-world vulnerabilities. At the moment there are eight sets of problems.

Set 1: [Basics](https://cryptopals.com/sets/1)
Set 2: [Block crypto](https://cryptopals.com/sets/2)
Set 3: [Block & stream crypto](https://cryptopals.com/sets/3)
Set 4: [Stream crypto and randomness](https://cryptopals.com/sets/4)
Set 5: [Diffie-Hellman and friends](https://cryptopals.com/sets/5)
Set 6: [RSA and DSA](https://cryptopals.com/sets/6)
Set 7: [Hashes](https://cryptopals.com/sets/7)
Set 8: [Abstract Algebra](https://cryptopals.com/sets/8)

Let's give it a go and see how many challenges we can complete.