teleren/devto huggingface dataset:
[C Language]printf and format specifier
Published: 2023-05-05 00:02:47

## printf()

In C language, printf() is a function used to output formatted text on the console or in a file. It is declared in the standard library header file stdio.h and its syntax is:

```c
int printf(const char *format, ...);
```
The first parameter format is a string literal that contains the text to be printed along with optional format specifiers. The format specifiers are placeholders for values that will be replaced during runtime, based on the type and value of additional arguments passed to the function.

For example, the %d specifier is used to print an integer, %f for a floating-point number, %c for a character, and %s for a string. There are also additional specifiers that control the width, precision, and alignment of the printed value.

Here's an example of how to use printf() to print a formatted string:

```c
#include <stdio.h>

int main() {
   int age = 25;
   float weight = 68.5;
   char gender = 'M';
   char name[] = "John";

   printf("Name: %s, Age: %d, Gender: %c, Weight: %.2f\n", name, age, gender, weight);
   return 0;
}
```

This program will output the following text:

```c
Name: John, Age: 25, Gender: M, Weight: 68.50
```

In this example, the %s specifier is used to print the name string, %d is used to print the age integer, %c is used to print the gender character, and %f is used to print the weight floating-point number with 2 decimal places.

Note that the return value of printf() is an integer that represents the number of characters printed.

## format specifier
Here are some examples of format specifiers for commonly used data types:

`%d: Used to format an integer value.
%f: Used to format a floating-point value.
%c: Used to format a single character.
%s: Used to format a string of characters.
%p: Used to format a pointer value.
%x: Used to format an unsigned hexadecimal value.
%o: Used to format an octal value.
%e or %E: Used to format a floating-point value in scientific notation.
%u: Used to format an unsigned decimal value.
%ld: Used to format a long integer value.
%lu: Used to format an unsigned long integer value.`
Content & Tooling Team Status Update
Tags: puppet, community, hackathon
Published: 2023-05-05 17:28:39

---
title: Content & Tooling Team Status Update
published: true
date: 2023-05-05 00:00:00 UTC
tags: puppet, community, hackathon
canonical_url: https://puppetlabs.github.io/content-and-tooling-team/blog/updates/2023-05-05-status-update/
---

## Bank Holidays Galore!

Happy Friday everyone! The weeks are feeling very short lately with all of the bank holidays we’re getting. Hopefully you’re making the most of the long weekends and doing something nice!

## Puppet 8 support

We’re finally closing out the last little bits of work in adding support for Puppet 8 in our tools and modules and have started addressing the tech debt that’s come from this work. This has been a huge effort from the team over the last month and it feels good to be at the finishing line! Also, a huge thanks for everyone who contributed to help remove deprecated functions in [stdlib](https://github.com/puppetlabs/puppetlabs-stdlib), we really appreciate it.

## May the source be with you Hackathon

Yesterday we held a hackathon for our developer tooling ecosystem! This is the first annual hackathon and we got some really great collaboration and contribution to our tools. This is the first of hopefully more fun events we’ll be hosting! So keep your eyes peeled.

![CAT-team-lightsaber-fight](https://media.giphy.com/media/Dea0leKapJzJC/giphy.gif)

## Community Contributions

We’d like to thank the following people in the Puppet Community for their contributions over this past week:

- [`provision#209`](https://github.com/puppetlabs/provision/pull/209): “Fixed: tasks/docker.rb”, thanks to [shaun-rutherford](https://github.com/shaun-rutherford)
- [`provision#208`](https://github.com/puppetlabs/provision/pull/208): “(MAINT) Support Puppet 8”, thanks to [coreymbe](https://github.com/coreymbe)
- [`puppetlabs-stdlib#1348`](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1348): “Add Stdlib::IP::Address::CIDR”, thanks to [Geod24](https://github.com/Geod24)
- [`facterdb#272`](https://github.com/voxpupuli/facterdb/pull/272): “new facts for 4.3 and 4.4 and a few stragglers for 4.1”, thanks to [hbrown-uiowa](https://github.com/hbrown-uiowa) and the following people who helped get it over the line ([bastelfreak](https://github.com/bastelfreak))

## New Module / Gem Releases

The following modules were released this week:

- [`puppetlabs-docker`](https://github.com/puppetlabs/puppetlabs-docker) (`7.0.0`)

- [`puppetlabs-postgresql`](https://github.com/puppetlabs/puppetlabs-postgresql) (`9.0.2`)
.NET Monthly Roundup - April 2023 - .NET 8 Preview 3, C#12, and more!
Tags: dotnet, aspnetcore, azure
Published: 2023-05-04 23:09:53

{% embed https://www.youtube.com/watch?v=vMAHIMz9Z8Y %}

Welcome to our April .NET Monthly Roundup with Jon Galloway! In just 3 minutes, Jon breaks down the latest news from the month of April 2023 that .NET developers need to know.

### Top links
📚[All the links](http://aka.ms/dnmr-2304)

### 🔥.NET 8 Preview 3
➡️[Announcing .NET 8 Preview 3](https://devblogs.microsoft.com/dotnet/announcing-dotnet-8-preview-3/)
➡️[ASP.NET Core updates in .NET 8 Preview 3](https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-8-preview-3/)
➡️[ASP.NET Core Route Tooling Enhancements in .NET 8](https://devblogs.microsoft.com/dotnet/aspnet-core-route-tooling-dotnet-8/)
➡️[Improvements to auth and identity in ASP.NET Core 8](https://devblogs.microsoft.com/dotnet/improvements-auth-identity-aspnetcore-8/)

### 📰Other cool news
➡️[Check out new C# 12 preview features!](https://devblogs.microsoft.com/dotnet/check-out-csharp-12-preview/)
➡️[Learn how to modernize your .NET apps from the pros!](https://devblogs.microsoft.com/dotnet/learn-how-to-modernize-your-dotnet-apps/)

### 📺Top videos
➡️[Let's Learn .NET Virtual Events - All Around the World](https://devblogs.microsoft.com/dotnet/lets-learn-dotnet-anywhere-in-the-world/)
➡️[.NET on Azure for Beginners - YouTube](https://www.youtube.com/playlist?list=PLdo4fOcmZ0oVSBX3Lde8owu6dSgZLIXfu)

### 🌐Community news and events
➡️[.NET Foundation news and updates from April](https://mailchi.mp/dotnetfoundation/april2023)
➡️[.NET Annotated Monthly | JetBrains | The .NET Tools Blog](https://blog.jetbrains.com/dotnet/2023/05/02/net-annotated-monthly-may-2023/)
➡️[Join the .NET Team at Microsoft Build 2023!](https://devblogs.microsoft.com/dotnet/microsoft-build-2023-and-dotnet/)

### What did you think?

With so much new information coming at you each month, we're looking at ways to bring you the highlights. Let us know if this helps, and how we can do it better next month!

Jon
Chatly-A simple chatting app with Next.js App Router(Server Components), Prisma, PlanetScaleDB and TailwindCSS.
Published: 2023-05-04 22:47:54

**A simple chatting app built with Next.js App Router(React Server Components), Prisma, PlanetscaleDB and TailwindCSS.**
Project live demo:http://next-chat-rosy.vercel.app/
How to Generate API Documentation with Insomnia
Tags: javascript, tutorial, node, api
Published: 2023-05-04 22:45:44

Insomnia is a powerful REST client that can help you test and debug your APIs. But did you know that you can also use it to generate API documentation? In this tutorial, we'll show you how to do just that.

## 1. Create your Insomnia Project

First, you'll need to create an Insomnia project. If you're not familiar with Insomnia, you can download it for free from the [official website](https://insomnia.rest/).

![Insomnia project creation screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6sbztrmbyftk9jigz0yk.png)

## 2. Export your project in JSON format

Once you've created your project, you'll need to export it in JSON format. To do this, go to `File` > `Export Data` > `Insomnia v4 (JSON)`.

![Exporting the Insomnia project screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vfds52248ng313f4aij7.png)

![Choosing the export destination screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vghmpsm1rn4bqbjyedx.png)

## 3. Generate the documentation

Before you can generate the documentation, you'll need to install Node.js on your system.

Once you have Node.js installed, open your command prompt or terminal and navigate to the folder where your JSON file is located.

![Navigating to the folder where the JSON file is located screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yxoo5hpkir5i00qz5b6c.png)

Execute the following command:

```
npx insomnia-documenter --config <name of the file>.json --output <name of the documentation>.json
```


![Generating the documentation screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/22gdnmoo0aap9utv0589.png)

## 4. See your documentation

### Local Documentation

If you want to see your documentation on your local machine, you'll need to run a server. To do this, navigate to the folder where your documentation was generated and execute the following command:

```
npx serve
```

![Running the server screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/meyjcy3aip4vc8tpf255.png)

![Viewing the local documentation screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ml4n1ei7w4pkeqsmjnxs.png)

### Online Documentation

If you want to share your documentation on the internet, you'll need to upload it to a deploy website. We recommend using [Netlify](https://www.netlify.com/) because it's easy and fast.

If this article was helpful, please give a ❤️ to make more content like this.
Flask app not updating fetched data from database without restart
Tags: flask, webdev, python, javascript
Published: 2023-05-04 22:35:57

Hi,
I'm having a problem with my Flask app where it doesn't update the data fetched from the database when I insert new data. The app only fetches the old data that was fetched when I started the app. No matter how much new data I insert, the fetched data doesn't update until I restart the Flask app by stopping it with ctrl+c and running it again with flask run.
I tried disabling the cache like this:

`cache = Cache(app, config={'CACHE_TYPE': 'null'})
`
However, it didn't work. I also checked the user class, the queries, and the functions, and everything seems to be working perfectly and showing results. Additionally, I'm using commit like this:

`cursor.execute(query, data)
self.conn.commit()
`
Here's my configuration:

`async_mode = None

app = Flask(__name__)

class MyApp:
    def __init__(self):
        self.app = app
        self.app.add_url_rule('/', 'home', self.home,
                              methods=["GET", "POST"])
        self.app.config['DEBUG'] = True
        # Secure session configuration
        self.app.config['SESSION_TYPE'] = 'filesystem'
        self.app.config['SESSION_FILE_DIR'] = '/tmp/flask_session'
        # Whether the session cookie should be secure (i.e., HTTPS only)
        self.app.config['SESSION_COOKIE_SECURE'] = True
        # Prevents JavaScript from accessing the session cookie
        self.app.config['SESSION_COOKIE_HTTPONLY'] = True
        self.app.config['SESSION_PERMANENT'] = False
        self.app.config['SESSION_COOKIE_SAMESITE'] = 'Strict'
        self.app.config['SECURITY_PASSWORD_SALT'] = 'password_salt'
        # 'development', 'production', or 'testing'
        self.app.config['ENV'] = 'development'
        # Disables testing
        self.app.config['TESTING'] = False
        self.app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0

    def run(self):
        self.app.run()`

Is there any way to see the update without restarting the Flask app? Any help would be appreciated. Thanks in advance!
How to Enhance Node.js Application Security
Tags: webdev, javascript, tutorial, productivity
Published: 2023-05-04 22:00:14

Node.js is a popular open-source JavaScript runtime environment that allows developers to create scalable and high-performance applications. However, with the increasing number of cyber-attacks and data breaches, it has become more important than ever to prioritize the security of Node.js applications.

In this article, we will discuss some best practices for enhancing Node.js application security.

- **Keep your dependencies up to date**

One of the most common ways that hackers exploit Node.js applications is by exploiting vulnerabilities in dependencies. Many developers use third-party packages, plugins, and libraries to speed up the development process. However, outdated dependencies can contain known security vulnerabilities that hackers can exploit.

To ensure the security of your Node.js application, it is important to keep all dependencies up to date. You can use tools such as npm-check-updates and Snyk to check for outdated dependencies and vulnerabilities.

- **Use secure coding practices**

Writing secure code is one of the most important steps in enhancing Node.js application security. You can follow secure coding practices such as input validation, output encoding, and proper error handling to prevent common security vulnerabilities such as cross-site scripting (XSS) and SQL injection.

You can also use tools such as ESLint and JSHint to detect security vulnerabilities in your code.

- **Implement authentication and authorization**

Authentication and authorization are essential for securing any application. Node.js provides several modules for implementing authentication and authorization such as Passport.js and JSON Web Tokens (JWT). These modules can help you implement secure authentication and authorization mechanisms such as two-factor authentication (2FA) and multi-factor authentication (MFA).

- **Use encryption for sensitive data**

Encrypting sensitive data such as passwords and credit card information is a crucial step in enhancing Node.js application security. You can use modules such as bcrypt and Crypto to encrypt data.

- **Implement logging and monitoring**

Logging and monitoring can help you detect and respond to security incidents quickly. You can use tools such as Winston and Log4js to implement logging and monitoring in your Node.js application.

## Conclusion

Securing Node.js applications is crucial to protect sensitive data from cyber-attacks and data breaches. By following these best practices, you can enhance the security of your Node.js application and protect it from potential security threats. Keep your dependencies up to date, use secure coding practices, implement authentication and authorization, use encryption for sensitive data, and implement logging and monitoring to detect and respond to security incidents quickly.

Thanks for reading...
**Happy Coding!**
Dynamically create an object from another one
Tags: javascript, programming, codenewbie
Published: 2023-05-04 21:58:49

Here we will be discussing how to format one object type into another without duplicating the property names from the original object. Here is an example of what we are starting with:

```js
const en = {
  catLabel: 'cat label',
  birdLabel: 'bird label',
  dogLabel: 'dog label',
  lizardLabel: 'lizard label',
  // more props we dont care about
}
```

we want to create a new object with it to be used in our app:

```js
const object = {
  cat: { label: en.catLabel },
  bird: { label: en.birdLabel },
  dog: { label: en.dogLabel },
  lizard: { label: en.lizardLabel },,
  // more props we dont care about
}
```

There is some repetition going on here that we can clean up so we dont repeat ourselves so much. Lets first make a change to our original object:

```js
const obj = {
  labels: {
    cat: 'cat label',
    bird: 'bird label',
    dog: 'dog label',
    lizard: 'lizard label'
  }
  // more props we dont care about
};
``` 

Now lets create our new object in a way so we dont expressly call out each label:

```js
const myLabels = Object.keys(obj.labels).reduce(
  (result, current) => ({
    // passing along object from past iterations 
    // and adding them to the next iteration in the loop
    ...result, 

    // current would refer to the 'cat' | 'bird' | 'dog' 
    // these values are obtained from Object.keys()
    [current]: {
      // we get the label value via bracket notation: [`${current}`]
      // same as obj.labels.cat or obj.labels.bird
      label: obj.labels[`${current}`]
    }
  }),
  // due to quirk in .reduce() it will skip first item in loop unless we pass in default object
  {}
);
```

when we `console.log(myLabels)` we get the following outout


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

If you have any questions how this went together, feel free to leave a comment.

Thanks for reading!
Compiles, won't execute
Published: 2023-05-04 21:42:42

I have a book of c algorithm projects where I entered the relevant files into a project. The program uses stdio. It compiles OK, but when I execute the program I get absolutely nothing, not even a momentary command line (MS DOS) window. Going into a MS DOS window and running the exe file from the command line, I also get nothing. I should see the output from the stdio library here! Putting a System("pause") line  in front of the main return I don't think will help either. Since I am a newbie to the DevC++ IDE I believe that there is something wrong with how I set up the project. So I need advice on getting the code to work.
syd/wt1v
Day 744 : Joy and Pain
Tags: hiphop, code, coding, lifelongdev
Published: 2023-05-04 21:41:25

_liner notes_:
- Professional : Had a couple of meetings. It was good to see everyone. Rest of the day, I went through and finished updating some docs. At the end, had a couple of questions and scheduled a message to go out to my manager to get their feedback. Also took a look at a feature that I'll be building a demo and write a blog post.

- Personal : Last night, went through some tracks for the radio show. Looked at some lot listings. Did a little coding. Watched some anime.

![Si'u Point Trail, Ta'u Island, National Park of American Samoa beach with white sands and turquoise water with a jungle and green mountains in the distance ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b3256qtvqqr8s0ncmeqm.jpg)

Going to go through some Bandcamp tracks and get ready to post them to Twitter tomorrow. I want to also finish putting together tracks for the radio show. Maybe do some coding. I'm in the joy and pain phase of this side project. I'm at the point were I proved to myself that I can do it, but just need to finish. haha I want to get caught up on my anime show also.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube E63llN0w7Bs %}
useState: la caja de juguetes
Tags: usestate, reactnative, javascript, react
Published: 2023-05-04 21:37:01

Imagina que tienes una caja de juguetes, en ella se pueden guardar todos los juguetes que quieras, y cuando quieras jugar con alguno de ellos, solo tienes que abrir la caja y sacarlo. En React, la caja de juguetes es el estado, y los juguetes son los datos que queremos guardar en el estado. Para manipular el estado, React nos provee de un hook llamado useState.

Por ahora no nos preocuparemos de que es un hook, pensemos en él como una función que nos devuelve dos cosas: el valor actual del estado y una función para actualizarlo. Y se ve algo así:

```
const [miCajaDeJuguetes, guardarJuguetes] = useState([]);
```

En esta línea de código miCajaDeJuguetes es el valor actual del estado, y guardarJuguetes es la función que nos permite actualizarlo. La caja en principio está vacía (por eso escribimos []), pero podemos llenarla con juguetes más tarde.

Imagina que tenemos un Yo-yo que queremos guardar en la caja de juguetes. Podemos hacerlo de la siguiente manera:

```
guardarJuguetes([...miCajaDeJuguetes, '🪀']);
```

Como vemos, llamamos a la función guardarJuguetes, que nos devuelve useState para actualizar el estado, o en este caso el contenido de nuestra caja de juguetes. Como primer parametro del array utilizamos el spreadOperator ...miCajaDeJuguetes, que significa que estamos guardando todo lo que ya estaba en la caja, y luego, como segundo parametro, agregamos el nuevo yo-yo.

Con la misma función podemos vaciar la caja de juguetes:

```
guardarJuguetes([]);
```

Para leer todo el articulo puedes ir a nuestro blog: https://www.huasi.dev/blog/use-state-la-caja-de-juguetes
Want to be able to drag files into a web app? Got ya covered.
Tags: javascript, opensource, ux, showdev
Published: 2023-05-04 21:36:58

It's 2023. We all know how annoying it is when a web app wants us to provide a file but makes it cumbersome by only letting you do that by clicking on Ye Olde `<input type=file>`. All modern browsers have supported a much better way to do that for a while now, and this library makes it a snap to use them in any environment, vanilla or framework.

https://github.com/krofdrakula/drop/

## The Setup

Install `@krofdrakula/drop` in your dependencies or use `https://esm.sh/@krofdrakula/drop` as your module import.

Create some HTML in your page:

```html
<div id="drop_target" style="padding:40px;border:1px solid blue;">
  Drop files here.
</div>
```

In your JS, grab that element and pass it to the `create` function:

```js
import { create } from '@krofdrakula/drop';

const dropTarget = document.body.getElementById("drop_target");

create(dropTarget, {
  onDrop: (files) => console.log(files)
});
```

Open the page in a browser, open dev tools and drag a file into the element you created.

## In React-like Components

The `create()` function returns a cleanup function that can be used in conjuction with `useRef` and `useEffect` to correctly set it up:

```tsx
import { useRef, useEffect } from 'react';
import { create } from '@krofdrakula/drop';

const MyComponent = ({ onDrop }) => {
  const dropTarget = useRef();

  useEffect(() => {
    // you must return the returned function for it to be
    // able to clean up event handlers
    return create(dropTarget.current, { onDrop });
  }, [dropTarget.current, onDrop]);

  return <div ref={dropTarget}>Drop files here.</div>
};
```

## Handy Features

`create` takes a number of options that let you configure the behaviour of the control:

- it exposes various event handlers that let you control the element when the pointer hovers over it when dragging files or without;
- it lets you specify parser functions that allow you to convert files dropped onto the element before passing them to the `onDrop` handler;
- it uses the native file picker when clicking on the element by default.

Check out the [demo site](https://krofdrakula.github.io/drop/) to see it in action, or read the [README](https://github.com/KrofDrakula/drop#readme) for the full Monty.

All of this in a package that [fits any application's download limits](https://bundlephobia.com/package/@krofdrakula/drop). 

## Development

This package currently does everything I needed it to for the cases I knew it should handle. If you decide to try this out and hit a problem, let me know!