teleren/devto huggingface dataset:
How To Iterate Over C String
Tags: c, beginners, tutorial, programming
Published: 2022-11-07 10:03:21

Iterating over a string sounds like a simple task, but every time I have to do it, I come across a different way. This will be a collection of different ways and how they work. 

## Brackets
### For-Loop
We determine the length of the string with `strlen(str)` and access each character of the string with the bracket `str[i]`.

```c
char *str = "This is an example.";
size_t length = strlen(str); 

for (size_t i = 0; i < length; i++)
{
  printf("%c", str[i]);
}
```

Remember to place `strlen()` outside the for loop condition, otherwise it will be called on each iteration.

### While-Loop
We can also avoid determining the length of the string in advance, and simply iterate over the string until we reach the end indicated by a null terminator `\0`.

```c
char *str = "This is an example.";
size_t i = 0; 

while (str[i] != '\0')
{
  printf("%c", str[i]);
  i++;
}
```

Furthermore, the condition of the while loop can be reduced to `str[i]`, since any value that is not zero is evaluated as true.

```c
while (str[i])
{
  printf("%c", str[i]);
  i++;
}
```

## Pointer
### For-Loop
Accessing the first character of the string with brackets `str[0]` corresponds to `*str` and accessing the second character via `str[1]` corresponds to `*(str+1)` or `*++str`. To avoid modifying the original pointer `*str`, we copy it to a temporary pointer `*p` and increment this pointer at each iteration with `*++p`. This is the combination of `++p` and `*p`. 

```c
char *str = "This is an example.";
char *p = str;

for (char c = *p; c != '\0'; c = *++p)
{
  printf("%c", c);
}
``` 

### While-Loop
This is basically the same as the for loop, but accessing the character with `*c` and incrementing the pointer are separated. 

```c
char *str = "This is an example.";
char *c = str;

while (*c != '\0')
{
  printf("%c", *c);
  c++;
}
```

Since we only print the character with `printf()`, we can combine the access and increment into an expression `*++c` and pass it to `printf()`.

```c
while (*c != '\0')
{
  printf("%c", *++c);
}
```

Similar to the brackets notation, the condition for the while loop can be reduced to `*c`.

```c
while (*c)
{
  printf("%c", *++c);
}
```

## Discussion

There are probably many more ways to iterate over a C string, and many good reasons for when to choose which implementation. If anyone has another option or comment, I'd be happy to learn it and add it to this post.
Working with Containers? Check AWS Cloud Map
Tags: aws, containerapps, microservices, devops
Published: 2022-11-07 09:58:04

If you're working with containers, most of the time you need a service discovery service, to help you find your services. AWS Cloud Map does help you with that.

AWS Cloud Map is a cloud resource discovery service. With Cloud Map, you can define custom names for your application resources, and it maintains the updated location of these dynamically changing resources. This increases your application's availability because your web service always discovers the most up-to-date locations of its resources.

In many architectures you may have several instances or machines running in the background, and sometimes you might turn instances down and deploy new ones (using different deployment strategies), hence it will generate a new IP address for your instances which will be hard to track.

With Cloud Map you can even register many other AWS services (such as Amazon EC2 instances, Amazon DynamoDB tables, Amazon S3 buckets, Amazon Simple Queue Service (Amazon SQS) queues, or APIs deployed on top of Amazon API Gateway)

## Features:
- Discover resources via API calls or DNS queries
- Simplified service naming
- Assign custom attributes
- Access control
- Automatic health check
- Deep integration with AWS container services
- Rapid change propagation
- Fully managed

## Benefits
- Register application resources with custom names
- Constantly check the health of resources, ensure location is up to-date
- Provides a single registry for all your application services
- Reliably obtain up-to-date health statuses of your application resources
- Enables microservices to easily locate one another

The main aim of this article is to light up services from AWS, I wanted to keep it simple without any code or deep technical discussion, hence making it easy to be read.

Hope it was a good one and I highly encourage to start using the service specially if your working on enterprise level applications
A.I. Risk
Tags: ai, riskmanagement
Published: 2022-11-07 09:55:16

## Read Time : 2 Mins
## Intro
One of the objectives for digital transformation for an organization is to be effective. Artificial Intelligence (**AI**) is a key driver for effectiveness / productivity.
Navigating complex real time business scenarios and having **AI** as a silver bullet has its own risks. With a lot of buzz around **AI** technology, the observation is that businesses still struggle with adoption due to ambiguity with the risk of implementation.


## Proceed with Caution 
Businesses provide products and services to consumers and Safe use of the offerings are key for adoption. The key is to understand the boundary within which **AI** technology is safe to use and benefits the customer, outweighing the cost of implementation / usage of the service. 
Hence, it is critical to identify, communicate and address the risk associated with **AI**. The common proxy for risk management is ticking all the compliance / regulatory mandates. Need to factor other dimensions as well. 

Below are few themes that need to be considered as part of Risk management while implementing **AI** technologies:


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

The broad categorization is about how the technology is implemented and then how businesses have used the technology to drive effectiveness. The above figure categorizes the risk into 5 themes and suggests few examples for each theme. 



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

## Conclusion
Risk is a combination of potential impact (adverse impact) and the likelihood of occurrence for those impacts. Though the benefits of **AI** technology are highlighted so often , it is equally important to look into the risks with implementing the technology. 


**Further reading**

https://sloanreview.mit.edu/article/putting-responsible-ai-into-practice/
Day #3: How to build multiple profitable micro-startups as a Solopreneur?
Tags: entrepreneurship, startup, webdev, react
Published: 2022-11-07 09:49:18

At the beginning of my journey as an entrepreneur, I decided to build multiple micro-products and released them in the market as soon as possible.

https://medium.com/@journeypreneur/day-3-how-to-build-multiple-profitable-micro-startups-as-a-solopreneur-43a0801c586d
React Comfort - conditional rendering in react become easier and cleaner.
Tags: react, conditionalrendering, ifelse, reactif
Published: 2022-11-07 09:43:24

> You can find the full documentation on the [website](https://react-comfort.js.org/docs/components/if-else)

`If`, `Else`, and `ElseIf` is a react helper components with the help of which **conditional rendering** in react become **easier** and **cleaner**.

## Installation

```bash
npm install react-comfort
```

## Examples

Simple example using `If` and `Else` combination.

```jsx
import {If, Else} from 'react-comfort'

const Bar = (props) => {
    return (
        <If condition={props.age >= 18}>
            <h2>🍺🍺🍺</h2>
            <p>Buy alcohol!</p>

            <Else>
                <h2>🚫🚫🚫</h2>
                <p>Sorry, children cannot purchase alcohol!</p>
            </Else>
        </If>
    )
}
```

More complex example using `If`, `Else`, and `ElseIf` combination.

```jsx
import {If, Else, ElseIf} from 'react-comfort'

const App = (props) => {
    return (
        <If condition={props.condition_1}>
            <p>Show, if cond_1 is true</p>

            <Else>
                <p>Show, if condition_1 is false</p>
            </Else>

            <ElseIf condition={props.condition_2}>
                <p>Show, if condition_1 is false and condition_2 is true</p>
            </ElseIf>

            <ElseIf condition={props.condition_3}>
                <p>Show, if condition_1 is false and condition_3 is true</p>
            </ElseIf>
        </If>
    )
}
```

Example for **nested** `If`-`Else` combination.

```jsx
<If condition={condition_1}>
    <Else condition={condition_2}>
        <If condition={condition_3}>
            <Else condition={condition_4}>
                Hello!
            </Else>
        </If>
    </Else>
</If>
```

## Function Children

Regardless of the condition, both the children of `If` and `Else` will be executed by JavaScript․ This can lead to unwanted side effects and performance issues. In such cases, we can pass a **function instead of children**.

Let's consider the following example:

```jsx
<If condition={hasResult}>

    <p>Result: { getResult() }</p>

    <Else>
        <p>No Result</p>
    </Else>
</If>
```

In the example above, the `getResult()` function will always be called regardless of whether `hasResult` is **true** or **false**.

Let's solve that problem․


```jsx
<If condition={hasResult}>
    {() => <p>Result: { getResult() }</p>}
    
    <Else>
        <p>No Result</p>
    </Else>
</If>
```

## Links
- [Documentation](https://react-comfort.js.org/docs/components/if-else)
- [GitHub](https://github.com/Ruben-Arushanyan/react-comfort)
- [NPM](https://www.npmjs.com/package/react-comfort)
- [Twitter](https://twitter.com/rubenarushanyan)
Avatar Maker, a portal to the Virtual World
Tags: avatarmaker, zegocloud, sdk
Published: 2022-11-07 08:52:36

Today we can experience digital versions of ourselves, traversing the vast horizons of the Web, with a simple tool: Avatar maker.

This immersive technology recreates our existence through appropriate software and decent devices. Given its extensive use, especially in social media and gaming, we all know what an [Avatar](https://www.zegocloud.com/blog/create-an-avatar) is.

Let us now learn more about how to create it.

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

How to use an Avatar Maker
The Avatar maker allows users to unleash their imagination and create a novel version that represents them. This tool will enable users to customize avatars to interact with others on social media, online games, forums, messaging apps, and more.

As we know, many social media and video games have an Avatar maker feature already built in. To integrate the Avatar maker feature into existing applications or platforms, developers can use tools such as [ZEGO Avatar SDK](https://docs.zegocloud.com/scene-plan/30.), available for iOS and Android.

ZEGOCLOUD offers a state-of-the-art avatar creation solution that best fits the opportunities in the metaverse.

Alternatively, there are Avatar makers in-app or website format.

The SDK, based on powerful artificial intelligence algorithms, allows users to create and customize their digital selves with various options. You can then download your Avatar in voice chat applications, social media, live-streaming, games, virtual events, and many other scenarios.

[ZEGOCLOUD’s avatar solution](https://www.zegocloud.com/product/avatar) offers countless styles, including Cute, Anime, Comics, Games, Realistic and more, with related outfits, virtual makeup, and more. Ideal for adapting to any context according to your needs.

For the innovative ZEGO Avatar maker, check out the detailed tutorial to create your Avatar in a few easy steps!
Phim One Piece - Đảo hải tặc
Tags: phimlevn, phimonepiece
Published: 2022-11-07 07:31:21

Sau cuộc đấu những bộ tộc tan rã. Tộc Thiên Long lên nắm chính quyền và ra đời 20 vị vua trước hết trên địa cầu, cùng lúc ấy họ lập nên liên minh của 170 quốc gia, đứng đầu là Ngũ Lão Tinh lúc bấy giờ. Sau ấy thành phố vàng bị cái hải lưu đẩy lên Skypea - Đảo trên trời. Chính quyền thế giới đã tậu và diệt những kẻ biết về lịch sử trống 100 năm. Họ bưng bít phần nhiều và Nico Robin (8 tuổi) được treo giá 79 triệu Beri vì cô là người duy nhất đọc được chữ Cổ đại khắc trên phiến đá Poneglyph.
Sau này hải tặc Gol D.Roger đã trinh phục Đại Hành Trình và ông đã khám phá ra kho báu [One Piece](https://vi.wikipedia.org/wiki/One_Piece) - ông mắc bệnh hiểm nghèo và gia nộp mình cho hải quân, trước khi bị hành quyết ông đã nói tới kho báu One Piece của ông.
ko một người nào biết kho báu đấy là gì, nhưng từ đấy thời đại của Hải Tặc khởi đầu. nhiều hải tặc đã giăng buồm ra khơi. Shank Tóc Đỏ, Râu Trắng, Big Mom, Kaido lên khiến Tứ Hoàng giành quyền bảo hộ trên biển. Chính quyền thế giới xây dựng thương hiệu những Đô Đốc và thất vũ hải. Quân cách mệnh do Mokey D.Dragon lãnh đạo được thành lập họ sắm cách thức chống lại chính quyền toàn cầu và giúp giải phóng người dân ra khỏi ách thống trị tàn bạo của bọn Thiên Long Hội, dưới trướng là bọn hải quân luôn treo cao lá cờ "Chính nghĩa" nhưng thật ra ẩn sau đó là cả một âm mưu thống trị. Lịch sử [Vua hai tac](https://phimlevn.net/phim/one-piece-dao-hai-tac-cy13881) đựng rộng rãi bí ẩn mà Oda gửi đến đọc nhái vẫn cần được khám phá. Lịch sử trống 100 là gì? Kho báu One Piece là gì? trận đấu rút cuộc sẽ ra sao?
Để hiểu rõ hơn và với thêm tài liệu về One Piece chúng ta cùng nhau Con số lại lịch sử OnePiece đã đi đến hồi kết chưa nhé...!
Create a plain dotnet, routed API controller in Umbraco
Tags: umbraco, dotnet
Published: 2022-11-07 08:38:14

This is a very quick blog post, blink and you'll miss it! 😉

While building something the other day I suddenly had the need for a route that would output some JSON data. I didn't need anything from Umbraco, just some plain old (modern!) dotnet - yes this is for Umbraco 9+. 

I thought I'd have to register routes in `Startup.cs` and that I'd have to add a route to `ReservedPaths` in `appSettings.json`, but.. to my surprise: none of that is needed, nice and easy and contained in 1 single `.cs` file. 

So without further ado, here's the example:

```csharp
using Microsoft.AspNetCore.Mvc;

namespace Cultiv.Controllers;

[ApiController]
[Route("api/[controller]")]
[Produces("application/json")]
public class GreetMeController : ControllerBase
{
    [HttpGet]
    public ActionResult Get([FromQuery]string name)
    {
        var value = new MyModel
        {
            Introduction = "Hello",
            Name = string.IsNullOrWhiteSpace(name) ? "World" : name
        };
        
        return new JsonResult(value);
    } 
}

public class MyModel
{
    public string Introduction { get; set; }
    public string Name { get; set; }
}
```

The interesting part here is the `Route` attribute, where `[controller]` will be replaced with the controller name, `GreetMe`, so the route becomes `api/GreetMe` and the `Get` method is what will respond to any `Get` request coming in. 

This results in a nice JSON string response with the proper `application/json` response header:

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

This is called attribute routing and you can do a LOT more with it, [check out the Microsoft documentation](https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/routing?view=aspnetcore-6.0#attribute-routing-for-rest-apis) for more information.

That's it, that's the post! Just wanted to save it here to my external brain so I can find it in the future, hopefully it will help someone else as well.
Just one more check before I push my changes
Tags: testing, bugs, programming
Published: 2022-11-07 08:37:26

Do you know that feeling of...

* I will do just one more test before we go live.

* I just have I scenario that I want to check. 
* I have a feeling that I need to check this before we go live


Well this is what happends after I have that feeling

https://www.youtube.com/shorts/2aJOADKQt_8
Mu88
Published: 2022-11-07 08:26:34

Mu88 là nhà cái có tên tuổi trên thị trường cá cược tại Châu Á với kho game đa dạng và phong phú giúp thỏa mãn nhu cầu giải trí của người chơi. Link tham gia: [](https://mu88app.blog/)
#mu88 #mu88casino #mu88app #mu88link #nhacaimu88
Thông tin liên hệ Mu88:
Website: [](https://mu88app.blog/)
Blog: [](https://mu88appblog.blogspot.com/)
Mail: [mu88appblog@gmail.com](url)
Hotline: 0983.754.732
Địa chỉ: 23 Đào Tấn, Cống Vị, Ba Đình, Hà Nội
[](https://www.facebook.com/mu88appblog)
[](https://twitter.com/Mu8894944547
)[](https://mu88appblog.blogspot.com/)
Custom error pages in rails applications
Tags: ruby, rails, tutorial, beginners
Published: 2022-11-07 08:06:12

Ruby on rails is shipped with html-based error pages, but with some easy steps you can create your own erb-based pages. So, let’s do it.

Firstly you need to create controller, views and routes for your pages.

```ruby
$ rails g controller errors not_found unprocessable unacceptable internal_server_error
```

This generator will create at least following files - `app/controllers/errors_controller.rb`, `app/views/errors` directory and add routes to your `config/routes.rb`

**errors\_controller.rb** :

```ruby
class ErrorsController < ApplicationController
  layout false

  def not_found
    render status: :not_found
  end

  def unprocessable
    render status: :unprocessable_entity
  end

  def unacceptable
    render status: :not_acceptable
  end

  def internal_server_error
    render status: :internal_server_error
  end
end

```

**config/routes.rb** :

```ruby
  ### Errors
  match "/404", to: "errors#not_found", via: :all
  match "/406", to: "errors#unacceptable", via: :all
  match "/422", to: "errors#unprocessable", via: :all
  match "/500", to: "errors#internal_server_error", via: :all
```

Now, you need to disable default rails error handler. To do that, you need to add the following line to your `config/application.rb`

```ruby
  class Application < Rails::Application

    # use custom error pages
    config.exceptions_app = routes

  end
```

If you want to test error pages locally, you need to set the following option in your `config/environments/development.rb`

```ruby
  # Show full error reports.
  config.consider_all_requests_local = false
```

Almost perfect, but I’d like to propose you some improvements. Let’s look back to `config/environments/development.rb` and to some changes

```ruby
  # Show full error reports.
  config.consider_all_requests_local = !Rails.root.join("tmp/errors-dev.txt").exist?
```

When you start your application, it will check for file `tmp/errors-dev.txt` and enable or disable custom error pages. Then, let’s create file `lib/tasks/dev.rake` with following code

```ruby
namespace :dev do
  desc "Use custom error pages"
  task :errors do
    if File.exist?("tmp/errors-dev.txt")
      puts "Now you'll use default (development) error pages" if FileUtils.rm("tmp/errors-dev.txt")
    elsif FileUtils.touch("tmp/errors-dev.txt")
      puts "Now you'll use custom error pages"
    end
  end
end
```

Every time you need to enable custom error pages locally, just run in console

```
$ rake dev:errors
```

then restart your server, and you’ll switch error pages from default to custom and back.

Looking for more? Check my blog [https://alec-c4.com](https://alec-c4.com)
A Fun Programming Joke To Start Your Day
Tags: jokes, dailydeveloperjokes, watercooler
Published: 2022-11-07 08:00:10

---
title: "A Fun Programming Joke To Start Your Day"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes, #watercooler
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1259b6d7a73.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q:___ Did you hear about the programmer that was scared of IDEs?

___A:___ They retreated back into their shell
 -->
Fancy CLI text
Tags: cli, text
Published: 2022-11-07 07:55:15

---
title: Fancy CLI text
published: true
description: 
tags: cli, text
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2022-11-07 07:52 +0000
---



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

You can write fancy text like that from this site. 
> The font that you see top of the page is `ANSI Shadow` 



https://patorjk.com/software/taag/#p=display&f=ANSI%20Shadow&t=commithub
Install XAMPP on your linux system
Tags: linux, database, mysql, xampp
Published: 2022-11-07 07:28:26

Goto https://www.apachefriends.org/download.html

![XAMPP official download page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tiz5j70jbsiujpo2qnxl.png)
Download your desired version of linux `xampp-linux-x64-x.x.x-x-installer.run`

Once download is complete open terminal and navigate to your download location

Now Make the installer executable by running this command `chmod +x xampp-linux-x64-x.x.x-x-installer.run`﻿

![Make XAMPP executable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/snisjw75ogzo1dr9pzzh.png)

Enter the installation command `sudo ./xampp-linux-x64-7.4.30-1-installer.run`

![XAMPP installation command for linux](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26l4mkoph7wttc58wllu.png)

A GUI will pop up. Follow the instruction accordingly to install properly.

#How to open XAMPP on your linux machine ?

After complete installation you won't find any shortcut to open XAMPP. Don't worry. Follow this steps to run XAMPP.

Open terminal and type 
```
cd /opt/lampp
sudo ./manager-linux-x64.run
```
You'll see a pop up of XAMPP Window after that 

![Running XAMPP from Linux](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bf12i4wxx66pyn0k44vc.png)

Goto `Manage Servers` tab and start server according to your need