teleren/devto huggingface dataset:
Write to a file in c++
Tags: c, file
Published: 2022-03-12 14:58:39

The C programming language is the foundation of many languages, so knowing it will make it easier for you to get to grips with many similar environments. But, in addition to knowing what this language involves, it is essential to delve into its history, even if it happened almost 50 years ago.

Well, localizing yourself over time will not only give you a better understanding of this very important language in the programming world, but it will also help your training. In addition, we will also assess how and why it was born, and what this language actually means C.

It all started in 1970, in the laboratory of the Bell company, when Dennis Ritchie and Brian Kernighan started creating C. Ritchie was a collaborator of Ken Thompson, a computer scientist who now worked on UNIX (operating system) and who had also created the B language.

By the end you will know how to write lines to a plain text file. We will see two modes, the output mode for writing replacing the content, and the append mode for writing adding the content. All this programming in C ++.

Opening the file
We must declare a type variable ofstream, which will point to the file. Then we invoke the method open, passing it the name of the file and the opening mode . I'll show you two:

output : it is simply written over the file, replacing the content that exists in it. It is in fstream::out.
append : adds the content to the end of the file, so it does not replace the existing one. It is in fstream::app.
For the example I will use fstream::out.

string filename = "videogames.txt";
ofstream file;
// We open the file
file.open (filename.c_str (), fstream :: out);
Writing content
We are going to write content in the file simply redirecting to it using <<as well as when we print in the console redirecting to cout; well, that's how it's done in C ++

By the way, at the end of writing, we close the file with close

// And we write redirecting
file << "cuph";
file << "ead";
// Let's not forget line breaks
file << endl;
// We can write more
file << "doom eternal" << endl;
file << "doom 2016" << endl;
file << "resident evil 2" << endl;
// Finally we close it
file.close ();
cout << "Written correctly";
Putting it all together
The complete code to save content to a plain text file using C ++ is as follows:

#include 
include 
using namespace std;
/ *
sitename
/

int main () {
string filename = "videogames.txt";
ofstream file;
// We open the file
file.open (filename.c_str (), fstream :: out);
// And we write redirecting
file << "cuph";
file << "ead";
// Let's not forget line breaks
file << endl;
// We can write more
file << "doom eternal" << endl;
file << "doom 2016" << endl;
file << "resident evil 2" << endl;
// Finally we close it
file.close ();
cout << "Written correctly";
}
Hope it helps.
Simple Header Color line In CSS
Tags: css, html, webdev, codenewbie
Published: 2022-03-12 14:22:22

Header color is mostly used when you have large data on-page and it will show on the top of the page. So here we made a Simple Header Color line In CSS with HTML.

Also, we used gradient colors on this header in different colors. You can use this with the JavaScript function when your web page is loaded.

Make it yours now by using it, downloading it, and please share it. we will design more elements for you.

[Source Code](https://w3hubs.com/simple-header-color-line-in-css/)
Perfect Constant Vigilance
Tags: bestpactices
Published: 2022-03-18 22:31:24

---
title: Perfect Constant Vigilance
published: true
date: 2022-03-12 14:21:00 UTC
tags: BestPactices
canonical_url: https://kevincox.ca/2022/03/12/perfect-constant-vigilance/
---

<main><p>I commonly see problems “solved” by adding human review.</p>
<ol>
<li>Every non-public API endpoint must have the appropriate auth check.</li>
<li>Before promotion the promoter will review the list of commits and ensure that all new features are “ready for release”.</li>
<li>Every string interpolation must be <a href="https://kevincox.ca/2022/02/08/escape-everything/">properly encoded</a>.</li>
</ol>
<p>This is attractive because it is easy to publish a list of standards and expect human review to enforce them. The problem is that it doesn’t work. I call this fallacy <strong>Perfect Constant Vigilance</strong>.</p>
<p>The truth is that humans are awful at repetitive tasks, especially when they are tedious. Therefore <strong>human review is insufficient to reliably catch errors</strong>. This is the primary reason why we still have car accidents even though we have safe traffic rules and people learn them in driving school. Driving is a tedious task and humans will lose focus once they have done it enough. (This is also the reason I think that <a href="https://en.wikipedia.org/wiki/Self-driving_car#Levels_of_driving_automation">level 1-3 self-driving</a> is incredibly irresponsible, it makes driving even more tedious and routine.)</p>
<h2 id="what-to-do-instead"><a href="https://kevincox.ca/2022/03/12/perfect-constant-vigilance/#what-to-do-instead">What to do instead?</a></h2>
<p>There are different ways to relieve dependence on Perfect Constant Vigilance. Some ideas, listed from most preferable to least preferable.</p>
<ol>
<li>Remove the problem entirely. (Ex: Stop working with user-controlled data)</li>
<li>Make the problem impossible to occur by accident. (Ex: Make it impossible to call endpoints that don’t have an auth wrapper, public endpoints need to be explicitly marked as public)</li>
<li>Automate the review (Ex: Ban use of <code>innerHTML</code>)</li>
<li>Make the review less tedious. (Ex: Reduce review size)</li>
</ol>
<p>Unfortunately the solution is usually domain specific, but recognizing the pattern is the important first step. <em>“That solution relies on Perfect Constant Vigilance and is bound to fail eventually. Let’s explore other options.”</em></p></main>
Reverse Linked List Groups
Tags: cpp, algorithms, programming, 100daysofcode
Published: 2022-03-12 14:17:59

# Description

Given a singly linked list `node`, and an integer `k`, reverse every `k` contiguous group of nodes.

**Constraints:**

- `n ≤ 100,000` where `n` is the number of nodes in `node`

## Example 1

### Input

```
node = [0, 1, 2, 3]
k = 2
```

### Output

```
[1, 0, 3, 2]
```

---

## Example 2

### Input

```
node = [0, 1, 2, 3]
k = 3
```

### Output

```
[2, 1, 0, 3]
```

---

# Intuition

track: after you reverse a group of list, you need to link those groups together.

`node->next = solve(curr, k)`this node is the head before reverse, but after reverse it is the tail of current group of nodes

# Implementation

```cpp
/**
 * class LLNode {
 *     public:
 *         int val;
 *         LLNode *next;
 * };
 */
LLNode* solve(LLNode* node, int k) {
    LLNode *prev = NULL, *curr = node, *next = NULL;
    int times = k;
    while (times && curr) {
        next = curr->next;
        curr->next = prev;
        prev = curr;
        curr = next;
        times--;
    }

    if (curr) {
        node->next = solve(curr, k);
    }
    return prev;
}
```

## Time Complexity

- Time: O(n)
- Space: O(1)
@debug DativeJS
Tags: dativejs, javascript, tutorial, webdev
Published: 2022-03-12 14:13:07

The `@debug` expression in Dativejs is used to log out an object to the devtool and it also adds the `debugger` keyword



### Usage

```html
<div>
 {{@debug lists}}
</div>
```

```js
data: ()=>({
    lists: {
      name: "@dativejs/helpers",
      type: "Tools"
   }  
}) 
```


> **NOTE**  This Will Add Backdrop to your Browser its not from dativejs but your browser. So Use in a Valid Case



### Thanks For Reading

[My Twitter](https://twitter.com/tobithealpha_)
[My Github](https://github.com/tobithedev)
TypeError: (0 , next_sanity__WEBPACK_IMPORTED_MODULE_0__.createImageUrlBuilder) is not a function
Published: 2022-03-12 14:11:57

Hey, Guys! 

This is Kenn here, from CodeWithKenn.
From today, you'll be seeing many React/Next/Gatsby related bugs solved, just decided to add a kind of bugs Documentation style.

Because, I ended up searching for the same bugs after months (I don't remember what the solutions were). So, I decided to start documenting it here on Dev.to

This helps me to save some time and be more productive.

So, Feel free to follow if you're interested! Peace ;)


# Bug Info
`
TypeError: (0 , next_sanity__WEBPACK_IMPORTED_MODULE_0__.createImageUrlBuilder) is not a function`


Bug Solution

**createImageUrlBuilder ** is no longer wrapped by next-sanity and you'll need to install the dependency yourself [Next-Sanity](https://github.com/sanity-io/next-sanity#createimageurlbuilder-is-removed)

`$ npm install @sanity/image-url
// or
$ yarn add @sanity/image-url`


Notice also that createImageUrlBuilder is now a default import.

`-import { createImageUrlBuilder } from 'next-sanity'
+import createImageUrlBuilder from '@sanity/image-url'`

- [More Details here](https://stackoverflow.com/questions/71277628/typeerror-0-next-sanity-webpack-imported-module-0-createimageurlbuilder)


# Let's Connect

- [Twitter](https://twitter.com/KennKibadi) 
- [Github](https://github.com/KennStack01) 
- [LinkedIn](https://www.linkedin.com/in/kennkibadi/) 
- [Instagram](https://www.instagram.com/codewithkenn_/) 
- [Facebook](https://www.facebook.com/Code-With-Kenn-104376625415201)
- [See My Bio Link](https://www.bio.link/IamKenn)



Want to start blogging?  🔥[Join NOW!](https://hashnode.com/@CodeWithKenn/joinme)
New React.js Hook - useLayoutEffect
Tags: javascript, programming, react, beginners
Published: 2022-03-12 13:55:10

Hello | السلام عليكم Hi folks, in this blog we will cover useLayoutEffect React Hook. Hope you like it.

### the complete blog in hashnode
the link: https://alguerocode.hashnode.dev/new-reactjs-hook-uselayouteffect
React, Vue and Svelte: Comparing Imported Components
Tags: javascript, react, vue, svelte
Published: 2022-03-12 13:54:07


## Import component in...
Importing a child component is not so different in React, Vue or Svelte. Except when you are using exported component in React with the {}.

Check it out 🚀

### React
```jsx
// top of the file
import { ChildComponent } from 'ChildComponent'
```

With `export default`:
```jsx
// top of the file
import ChildComponent from 'ChildComponent'
```

### Vue
```jsx
<script setup lang="ts">
import ChildComponent from 'ChildComponent.vue'
</script>
```

### Svelte
```jsx
<script lang="ts">
import ChildComponent from 'ChildComponent.svelte'
</script>
```

## Passing `props` in...
React and Svelte has the same approach. Vue, on other hand, has the v-bind directive or its shorthand.

Check it out 🚀

### React
[Link](https://stackblitz.com/edit/vitejs-vite-5aebvw?file=src/app/App.tsx)
```jsx
<ChildComponent msg={msg} />
```

### Vue
[Link](https://stackblitz.com/edit/vitejs-vite-tty3de?file=src/App.vue)

```jsx
<ChildComponent v-bind:msg={msg} />
// or shorthand
<ChildComponent :msg={msg} />
```

### Svelte
[Link](https://stackblitz.com/edit/vitejs-vite-uzmte2?file=src/App.svelte)

```jsx
<ChildComponent msg={msg} />
```
Join me to learn to code in Rust
Tags: rust
Published: 2022-03-12 12:20:30

I am Romaric, CEO and co-founder of [Qovery](https://www.qovery.com). I am 12 years of experience in backend development. I am experienced in Rust, Python, Kotlin, Java, Groovy, Go, Scala. **In my free time I am working on [RepliByte](https://github.com/qovery/replibyte)** - an open-source application **written in Rust** to synchronize cloud databases. I've always enjoyed sharing my knowledge and that's why I am launching my Twitch channel to build in public RepliByte.

![Here is a picture of me while coding](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tfbu5ko8gzq61r4uj124.png)

Join me if you want:

1. To learn to code in Rust.
2. Contribute to building an ambitious and useful project.
2. Spend a good time.

My schedules:

- During the weekend.
- Some day during the week.

Here is my [Twitch](https://www.twitch.tv/codewithromaric).

I can't wait to see you there. Let me know in the comment what you would like to learn about Rust.
DevRel job roles - Content Creator or Content Developer?
Tags: discuss, devrel, career, watercooler
Published: 2022-03-12 13:37:22

---
title: "DevRel job roles - Content Creator or Content Developer?"
description: "What titles work best for someone who takes care of content creation - right from research & planning, to execution"
tags: "discuss, devrel, careers, watercooler"
---

**Developer Relations** is a niche field in software engineering. It is an umbrella term for a lot of activities that are geared towards building relationships with developers.

I've been in this field for almost 2 years, and one of the most significant activities as part of my work is to **create content**, mostly in the form of [technical deep dives](https://dev.to/egeninc). But to say that I'm a *content writer* or *technical writer* seems like an understatement, and I feel like I might be under-selling myself.

There are several more activities that I (or anyone else in this field) could be involved in. Here are some examples (in no particular order):

* Before even beginning to create content, one would need to do a lot of **research**, and planning what they create and how they'll execute it in the first place.
* Sometimes the content might be talking about tech, but isn't necessarily a coding tutorial. For example - if my organization is into Retail, I would need to write articles like *"What challenges do online retailers face when trying to scale up?"* That again involves research and acquiring **industry knowledge**.
* For the actual content, it's not always text-based. Often someone who's doing the writing also might be involved in creating **infographics**, and even explore **other formats** like videos.
* Working with Director of Talent for coming up with creative **job ads** for hiring developers.
* Working with the Head of Marketing to decide on factors like **SEO**, and the right platforms to publish the content on.

So if a person working in DevRel does the above activities and need to describe themselves in short, what should they call themselves? Would **Content Creator** make more sense, or **Content Developer**? Or are there are other titles that would work better?

---

What do you think? Let's discuss in the comments below - I'd love to know your thoughts! 😄
Como lembrar mais facilmente dos comandos Linux
Tags: linux, cli, command, terminal
Published: 2022-03-12 13:33:39

Minha dica para quem está começando no mundo Linux, e está tendo dificuldade em lembrar dos comandos de CLI (comand line interface):

Pense no comando como se ele fosse a ação que ela representa. Por exemplo, o comando `ls -la` é utilizando para listar todos os arquivos em um diretório, utilizando a forma longa. Lista é List em inglês, e o comando `ls` usa as letras l e s de List.

![terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s8xskhuzeaqxcdaw3a8f.png)

Isso também se aplica às flags dos comando, como `-l`, `-a` ou `-la` como muitos utilizam. Essas são flags do comando `ls`, em que o `-a` significa _all_, ou todos em português. E `-l` é para usar o formato de lista longa (_long_).

Traduzindo o comando `ls -la` ou `ls -l -a`:
Eu estou pedindo para o computador me _listar_ _todos_ os arquivos em um diretório, utilizando o formato de lista longa.

Essa técnica também pode ser utilizada para comandos dentro do Vim, que sei que é o maior terror da galera. Por exemplo, se eu quiser sair (_quit_) de um arquivo, eu uso o comando `:q`_uit_, e se eu quiser escrever (_write_) minhas alterações no arquivo, eu uso o comando `:w`_rite_. Para facilitar, ainda posso escrever as alterações no arquivo e sair dele ao mesmo tempo, juntando os comandos em `:wq`.
VS Code Keyboard Shortcuts | Or How To Become Even More Productive
Tags: javascript, vscode, productivity, tutorial
Published: 2022-03-12 13:22:59

Hi Everyone!

This article presents my favorite and most used keybindings, 
and how you can customize your own!

So open your vs-code and follow along :) 

First thing is to use the shortcut: <kbd>⌘ Cmd</kbd>+<kbd>K</kbd>+<kbd>S</kbd> (keep the command key pressed)

Here we can look at all the actions vscode has made for us,
and we can change existing key bindings or search for new ones.

![Change existing key bindings or search for new ones](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s3pqdvoewj5lqz5blca3.gif)
 

After that, press this button at the top right corner: 

![press on this button to open the JSON file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3c3bzj2mi5tp0gpm3yf2.png)

Or you can open this editor by going to the menu under **Code** > **Preferences** > **Keyboard Shortcuts**. (**File** > **Preferences** > **Keyboard** Shortcuts on Windows)

Here we can see the JSON file where our custom keybinding will be declared.
 
Every keybinding has to have a `key` and `command` keys.
**key**: the keys we combine
**command**: the action 
(we can also add a `when` key that will specify when we want to execute the action.)

Below you'll see my keybindings that I use all the time 

```js
[
  // Refresh the vscode window
  {
    "key": "cmd+r",
    "command": "workbench.action.reloadWindow",
    "when": "editorTextFocus"
  },
  // Transform the current selection to uppercase
  {
    "key": "ctrl+u",
    "command": "editor.action.transformToUppercase"
  },
  // Calculate the current selection
  {
    "key": "ctrl+m",
    "command": "editor.emmet.action.evaluateMathExpression",
    "when": "editorHasSelection"
  },
  // Create a new folder
  {
    "key": "ctrl+n",
    "command": "explorer.newFolder"
  },
  // Create a new file
  {
    "key": "ctrl+f",
    "command": "explorer.newFile"
  },
  // Extension shortcut: Add a log of the current selection
  {
    "key": "shift+cmd+l",
    "command": "turboConsoleLog.displayLogMessage"
  },
  // Add an empty log statement
  {
    "key": "shift+cmd+l",
    "command": "editor.action.insertSnippet",
    "when": "editorTextFocus && !editorHasSelection",
    "args": {
      "snippet": "console.log($1);"
    }
  }
]
```

You can notice that I'm using the `turboConsoleLog` extension for logging my variables, but I also wanted that the same shortcut will also output an empty `console.log()`.


There you have it 🙏🏼 Hope you enjoyed 🙂

For more detailed information on shortcuts in general visit: [visual studio keybindings](https://code.visualstudio.com/docs/getstarted/keybindings)

![customize all the things](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2lkhqenw43y2bw3n7jjo.png)
 

I'll soon post about [how to add custom snippets](https://dev.to/danielbellmas/my-custom-snippets-in-vscode-1mcp), so be sure to like and follow 😉

Stay Tooned!

![Brace yourselves, more personalization is coming!](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/24hk3hj6gj8dtjy0psi9.png)
HTTP Hello World server for testing purposes (part 1)
Tags: go, http, server, testing
Published: 2022-03-12 13:08:21

# HTTP Hello World server for testing purposes

Post created at 2022-03-12 09:53

I needed a http server, small, minimalistic, just for proxy testing.

There are many options to do this, but I wanted to create my own solution.

A basic golang project, with only native components, generating a docker image with 10MB. Just K.I.S.S. !

The repository for this project is in [github.com/guionardo/http_helloworld](https://github.com/guionardo/http_helloworld)

All what we need to do to use this tool is run a docker command: 

```bash
docker run --rm -p 8080:8080 guionardo/http_helloworld:latest
```
Git user config
Tags: git, beginners
Published: 2022-03-12 12:52:51

As a person who jumps from work to a personal git-based project I sometimes need to take eye on git user configuration.

## Configuration scopes
Git have configuration in following scopes:
* **system** - default configuration which applied for all users/projects (e.g.: `/etc/gitconfig`).
* **global** - configuration which applied for all projects, saved at user home (e.g.: `~/.gitconfig`).
* **project** - available for project only, saved in the project directory `.git/config`.

## User config commands
Here few handy git commands related to user config.

| command line | explanation |
| ------------ | ----------- |
| `git config user.name` | displays current user name |
| `git config user.email` | display current user email |
| `git config user.name <user full name>` | set given user name|
| `git config user.email <email>` | set given user email|
Jena Custom Functions
Tags: programming, ontology, jena
Published: 2022-03-12 12:50:53

https://github.com/oeg-upm/loom-ld

# 1. Write Functions

```java
public abstract class AbstractSimilarityFunction extends FunctionBase2 implements Similarity {

  private SimilarityAlgorithm algorithm;

  public AbstractSimilarityFunction(SimilarityAlgorithm algorithm) {
    this.algorithm = algorithm;
  }

  @Override
  public NodeValue exec(NodeValue v1, NodeValue v2) {
    String element1 = v1.asString();
    String element2 = v2.asString();
    Double score = similarity(element1, element2);
    return NodeValue.makeDouble(score);
  }

  public SimilarityAlgorithm getAlgorithm() {
    return algorithm;
  }

  public void setAlgorithm(SimilarityAlgorithm algorithm) {
    this.algorithm = algorithm;
  }
}

```

# 2. Registration Functions
```java
FunctionRegistry.get().put(uri, funcClass);
```

# 3. Use Custom Functions in SPARQL
```sparql
PREFIX loom:     <http://oeg.upm.es/loom-ld/functions/link#>
```