teleren/devto huggingface dataset:
Portfólio - Aula 1
Tags: community, coding
Published: 2024-01-31 00:16:54

Este portfólio tem como objetivo apresentar o meu avanço na disciplina de Laboratório de Programação do curso de BSI. Iniciando pela _aula 1_ que foi sobre o assunto de **paradigmas de programação.**

Abaixo um programa que solicita do usuário que lhe passe dados para realizar uma equação, que funciona com o paradigma procedural. Realizando a instrução de realizar a soma e mostrar o resultado.

```
#include <stdio.h>

// Função para calcular a soma de dois números
int somar(int a, int b) {
    return a + b;
}

int main() {
    // Declaração de variáveis
    int numero1, numero2, resultado;

    // Solicitar ao usuário que insira dois números
    printf("Digite o primeiro número: ");
    scanf("%d", &numero1);

    printf("Digite o segundo número: ");
    scanf("%d", &numero2);

    // Chamada da função para calcular a soma
    resultado = somar(numero1, numero2);

    // Exibir o resultado
    printf("A soma de %d + %d é: %d\n", numero1, numero2, resultado);

    return 0;
}
```
Execute aqui: https://onlinegdb.com/iNpWaDjou

Outro exemplo que realizar **uma ação é um programa que ao inserir um ano mostre como resultado a idade do usuário no ano de 2024**:

```
#include <stdio.h>
#include <time.h>

int main() {
    // Declaração de variáveis
    int anoNascimento, idade;

    // Solicitar ao usuário que insira o ano de nascimento
    printf("Digite o ano de nascimento: ");
    scanf("%d", &anoNascimento);

    // Obter o ano atual
    time_t agora = time(NULL);
    struct tm *dataAtual = localtime(&agora);
    int anoAtual = dataAtual->tm_year + 1900;

    // Calcular a idade
    idade = anoAtual - anoNascimento;

    // Exibir a idade
    printf("Neste ano de 2024 sua idade é: %d anos.\n", idade);

    return 0;
}
```
Execute aqui: https://onlinegdb.com/Z7bPhrXLj
Recover Cryptocurrency From Fraudsters With- Leeultimatehacker@aol.com
Tags: cryptocurrency
Published: 2024-01-31 00:08:18

While browsing through Instagram, I came across a post from one of my friends talking about their successful bitcoin investment and the substantial profits they had earned. Intrigued by their claims,I decided to visit the website mentioned in the post. After creating an account, I reached out to the support chat and was provided with a WhatsApp contact for further assistance.I connected with a person on WhatsApp who instructed me to install the MetaMask app and informed me that they would be the recipient of my money transfers. I was asked to make four bank transfers, totaling £148,000. Throughout this process, I believed that my friend, whose post had initially caught my attention, was also aware of the investment opportunity. However, I later discovered that his account had been hacked, and the hacker was using his page to promote false information about the company, leading me to believe it was legitimate.After noticing the scam, I sought help from Leeultimatehacker@aol.com, as I was unable to withdraw my funds from the website. They exposed the entire operation and successfully shut down the fraudulent website while recovering my funds. I am writing this with immense joy and gratitude for the exceptional assistance provided by LEE ULTIMATE HACKER throughout the recovery process. If you find yourself in a similar situation, I urge you to take the necessary steps and reach out to them today.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hucgli0a8mljn8i60bt4.jpg)
Welcome Thread - v261
Tags: welcome
Published: 2024-01-31 00:00:00

---
published_at : 2024-01-31 00:00 +0000
---
![A potato with a smiley face on it waving](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ahgihznsxk7cp5423z43.gif)

---

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

3. Share your wins from this week in our weekly ["What was your win this week?](https://dev.to/t/weeklyretro) thread.
Golden, librería de snapshot testing en Go
Tags: articles, tblist, go, testing
Published: 2024-02-27 15:09:41

---
title: Golden, librería de snapshot testing en Go
published: true
date: 2024-01-31 00:00:00 UTC
tags: articles,tblist,golang,testing
canonical_url: https://franiglesias.github.io/Golden-librer%C3%ADa-de-snapshot-testing-en-Go/
---

 **Golden** es una librería de _snapshot testing_ que he creado para Go. Después de unas semanas de trabajo, ya está declarada estable y he publicado la versión v1.0.0.

En parte, como ejercicio de aprendizaje. En parte, porque no me acaban de encajar otras librerías disponibles.

_Snapshot testing_ es una técnica bastante usada en desarrollo frontend que consiste en guardar el output de nuestro código y usarlo como criterio para ejecutar futuros tests. De este modo, creamos un test de regresión que nos asegure que mantenemos el comportamiento actual de una unidad de software.

En backend, el _snapshot testing_ no es tan usado, pero hay muchos casos de uso para esta técnica: objetos complejos, generación de archivos de todo tipo (JSON, CSV, XML, etc.) para los que es costoso desarrollar un test basado en aserciones.

Además, esta técnica es muy potente usada con código legacy o, en general, con código que no tiene tests. Nos permite obtener una buena cobertura rápidamente, antes de intervenir en un código.

**Golden** , además de _snapshot testing_, nos permite trabajar con _approval testing_. En esta modalidad, lo que hacemos es mantener el test fallando a propósito hasta que el snapshot que se ha generado sea revisado por nosotras o por una experta del dominio que nos pueda decir si el output es correcto o no. Cuando nos satisface, “aprobamos” el snapshot y lo usamos como criterio en los tests futuros.

_Approval testing_ es una técnica adecuada cuando estamos escribiendo código nuevo que genera objetos complejos o documentos.

Finalmente, **Golden** ofrece la posibilidad de realizar los tests combinatorios de la técnica _Golden Master_. Esta técnica consiste en bombardear el código a base de llamadas con distintas combinaciones de sus parámetros, de tal modo que lo forcemos a recorrer todos sus posibles flujos de ejecución.

Para ello, no tenemos más que indicarle a **Golden** listas de valores para cada parámetro de entrada de la unidad bajo test y generará todas las combinaciones posibles. Esta técnica puede ayudarnos a obtener una cobertura completa de un código existente sin tener que preocuparnos de entenderlo en profundidad. Una vez que hemos generado el “golden master” y estamos protegidas por el test, podemos empezar a aplicar técnicas de refactor para mejorar su diseño.

[Golden: librería de snapshot testing en Go](https://github.com/franiglesias/golden)
truly branching narrative
Tags: gamedev, writing
Published: 2024-02-25 21:28:22

---
title: truly branching narrative
published: true
date: 2024-01-31 00:00:00 UTC
tags: [ 'gamedev', 'writing' ]
canonical_url: https://onwriting.games/daily/20240131-1124-truly-branching-narrative/
---

The more I try different games that claim to have branching narrative, the more I realize that **the term doesn't give much information to the player**.

In general, what this means is that there is a system in which the player can choose options and those options allow them to go down one branch or another.

The problem I see is that in most games that promise branching narrative, **the branches are practically cosmetic**.

At most, they result in one ending or another, but **the story beats remain the same**.

I believe there are 2 types of branching narrative that are not cosmetic:

1. Where the choices significantly modify the story, changing not only details but also which story beats are part of the story.
2. A linear story without variations, but where each branch provides information that is not available in the other branches.

Can you think of any other type of branching that works well and doesn't leave the feeling of "lack of agency"?
Automated tests mean you can make changes quicker
Published: 2024-02-03 08:05:13

---
title: Automated tests mean you can make changes quicker
published: true
date: 2024-01-31 00:00:00 UTC
tags: 
canonical_url: https://www.oliverdavies.uk/archive/2024/01/31/automated-tests-mean-you-can-make-changes-quicker
---

Before fixing [yesterday's bug](https://www.oliverdavies.uk/archive/2024/01/30/tdd-doesnt-mean-you-know-everything-upfront), because I'd written automated tests, I ran them to ensure they were all passing.

Then, I was able to focus solely on adding the new use case - starting with a failing test to replicate the issue and then getting it to pass.

Because it was already tested, I didn't need to worry about breaking any other functionality and introducing regressions.

When the new test was passing, I could run the whole test suite and ensure they still passed and things continued to work.

Without the tests, I'd either need to check everything else manually (which takes time) or worry that something could potentially be broken.

Having tests meant I could be confident that the new and existing functionality worked.

 P.S. If you're creating a new Drupal module, try my [free Drupal module template](https://github.com/opdavies/drupal-module-template).
Introducing ShuttleLabs - Cutting Edge Rust talks!
Tags: rust, webdev, programming, techtalks
Published: 2024-01-30 23:53:07

### Discussing cutting-edge advancements in the Rust ecosystem

If you’re looking to stay ahead of the curve on all things Rust, connect with fellow Rustaceans and expand your skills, we’d love to have you join us at **ShuttleLabs**. Each month we will be hosting a thought leader from the space, diving into the hottest topics and creating an opportunity for discussion that can’t be found anywhere else. 

### Why we decided to start ShuttleLabs

Rust is growing faster than its resources and it’s difficult to stay up-to-date on all the advancements in the space. We hope that ShuttleLabs will solve this problem and create an environment for both seasoned and new Rust devs to continually learn, share their perspective, and hear from great contributors in the ecosystem.  

In our first session we will be exploring **Async In Rust, with Stefan Baumgartner!** Async in Rust is a big topic as Rust deals with async at a low level: using futures and executors, as well as being able to programatically create your own async runtime!

The details of the talk are below:

Topic: **Async in Rust**

Speaker: **Stefan Baumgartner** (@ddprrt on X)

Date: **February 6th, 15:00 (UTC)**

Location: [https://discord.gg/shuttle](https://discord.gg/shuttle)

### [Sign up now](https://shuttlerust.typeform.com/shuttlelabs)

If you want to be kept in the loop,  [sign up here](https://shuttlerust.typeform.com/shuttlelabs) to secure your spot and receive an email ahead of our next session. 

See you there!
Searchable
Published: 2024-01-30 23:46:45

```
struct SuccessView: View {
  @ObservedObject var viewModel: UserViewModel
  @State private var searchText = ""

  var results: [User] {
    searchText.isEmpty ? viewModel.users : viewModel.users.filter {$0.name.contains(searchText)}
  }

  var body: some View {
    List {
      ForEach(results) { user in
        NavigationLink {
          UserDetailView(user: user)
        } label: {
          UserRowView(user: user)
        } //: NavigationLink
      } //: ForEach
    } //: List
    .searchable(text: $searchText)
  }
}

```
Day 905 : Figure It Out
Tags: hiphop, code, coding, lifelongdev
Published: 2024-01-30 23:26:41

_liner notes_:
- Professional : Pretty good day. Had a meeting with my manager to talk about things to do this week. Got to demo a new Web Component I made as a Proof of Concept. I'll continue working on creating more. Made some changes to some tutorials to make them a little easier to follow along. Followed up on some community questions. Ran into one that totally stumped me. Could not figure it out. I asked some folks on the team so I'll see what they say.

- Personal : Went through a bunch of tracks for the radio show. Added nanostores after some research to my side project. Spent a bunch of time looking up some properties to purchase. It took forever to find one realtor's email. I could find their phone number easily, but trying to get an email. Whew!

![﻿A mountain ibex stands on a rocky slope in the Gran Paradiso Park, Italy. The ibex is in the foreground, with snow-capped mountains in the background. The sky is blue with a few clouds.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/adj3ovfjffscf0mq9on7.jpg)

Going to work on the radio show. Hopefully I got a reply from the realtor. See if I can implement the nanostores in my project and maybe add some authentication. Looking to end the night watching an episode of "Rurouni Kenshin".

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube QGsy6vlH6ZU %}
Learning Flexbox
Published: 2024-01-22 22:05:44

Flexbox layout 
- simplifies positioning elements
- Flex containers and flex items 
- designate an element as a flex container by setting its (display) property to flex or inline-flex.
- several properties that specify how it behaves
- justify-content, align-items, flex-grow, flex-shrink, flex-basis, flex, flex-wrap, align-content, flex-direction, flex-flow.

.container{ display:flex; }
-justify-content: position items from left to right
-
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d8x3ienz7csi1hxpmg0l.png)

align-items: makes it possible to space flex items vertically

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

flex-grow: allows you to specify if items should grow to fill a container and which should item grows proportionally more/less than others

flex-shrink: which elements will shrink and in what proportions.

flex-basis: allows you to specify width before it shrinks or stretches. ( lock width ) 
 
flex: lets you declare flex-grow, flex-shrink, and flex-basis in one line

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


flex-wrap: Allow content to move to the next link when necessary. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ex38x0fh38gz9ivvekph.png)

align-content: allows you to move multiple rows of content 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y3pjqfulfji7kv4yw1dh.png)


Flex-direction:
allows you to switch between main axes and cross axis. So they can be ordered vertically or horizontally.
-The flex-direction property can accept four values:
- row — elements will be positioned from left to right across the parent element starting from the top left corner (default).
- row-reverse — elements will be positioned from right to left across the parent element starting from the top right corner.
- column — elements will be positioned from top to bottom of the parent element starting from the top left corner.
- column-reverse — elements will be positioned from the bottom to the top of the parent element starting from the bottom left corner.


flex-flow: used to declare both the flex-wrap and flex-direction properties in one line.
GroupBox
Published: 2024-01-30 23:22:02

```
var body: some View {
    GroupBox(label:
        Label("End-User Agreement", systemImage: "building.columns")
    ) {
        ScrollView(.vertical, showsIndicators: true) {
            Text(agreementText)
                .font(.footnote)
        }
        .frame(height: 100)
        Toggle(isOn: $userAgreed) {
            Text("I agree to the above terms")
        }
    }
}

```

Link: https://developer.apple.com/documentation/swiftui/groupbox
GitLab runner on MacBook with docker-compose
Published: 2024-01-30 23:08:03

It turned out that running a self-hosted Gitlab runner on a MacBook with docker desktop and docker-compose was not so common approach.

Below are code snippets that enable that solution

- docker-compose.yaml

```
version: '3'
services:

 gitlab-runner:
  image: gitlab/gitlab-runner:alpine
  restart: always
  container_name: gitlab-runner
  hostname: gitlab-runner
  volumes:
   - /Users/gitlab-runner:/etc/gitlab-runner
   - /var/run/docker.sock:/var/run/docker.sock
  environment:
    - DOCKER_HOST=unix:///var/run/docker.sock
  networks:
      - gitlab-network

networks:
  gitlab-network:
    name: gitlab-network
```

- runner configuration config.yaml
```
concurrent = 2
check_interval = 0
shutdown_timeout = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "docker-stable"
  url = "https://gitlab.com"
  id = 112233
  token = "112233"
  token_obtained_at = 1111-01-24T21:09:11Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  [runners.cache]
    MaxUploadedArchiveSize = 0
  [runners.docker]
    tls_verify = false
    image = "docker:stable"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    network_mode = "host"
    shm_size = 0
    network_mtu = 0

```
Early Adopter's guide to Umbraco v14 - Contexts & Resources
Tags: umbraco
Published: 2024-01-30 23:07:17

Just a quick insert into this series of blog posts to say there is another series of blog posts, that go through getting server communication up and running between your new Umbraco v14 backend front-end (the Lit typescript thing) and your backend backend (your c# code).

[EarlyAdopter's Guide Umbraco v14 - Communication Series' Articles](https://dev.to/kevinjump/series/26248)

Normal programming will resume...
Early Adopter's Guide to Umbraco v14 Packages : Communicating with the server! - Part 4 - FrontEnd!
Tags: umbraco
Published: 2024-01-30 23:03:19

_The code for this series of posts can be viewed here : https://github.com/KevinJump/TimeDashboard_

Finally our journey from the server is about to reach the user! We have automatically built our OpenApi client, made a data store, a repository, and a context. Now we can plumb that into an element and show it to the user. 

## 5. A Dashboard
For brevity (now he's going to be brief!), we are not going to discuss setting up the dashboadElement, lets just say this is our `render` method:

```ts
render() {
   return html`
      <uui-box headline="${this.title}">
         <div>
            <uui-button @click=${this.getTime} look="primary" color="positive" label="get time"></uui-button>
            <h2>${this.time}</h2>
         </div>

         <div>
            <uui-button @click=${this.getDate} look="primary" color="default" label="get date"></uui-button>
            <h2>${this.date}</h2>
         </div>
      </uui-box>
  `
}
```

it shows two buttons, and two values, so the user can get the time, and the date. 

it looks like this : 

![Umbraco Time dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/re4yirq5od10z20m0jy5.png)

There are two parts to updating the interface:

## making requests

You can see from our markup we have a `getTime` and `getDate` method. These methods call our context, to do just that. 

```ts
async getTime() {
   await this.#timeContext?.getTime();
}

async getDate() {
    await this.#timeContext?.getDate();
}
```

Now these methods could be made to return the values, but here we are using the `observable` properties; because well we wanted to show how they worked, and also it means if these values where updated in other places in the app, they would show as updated because we updated these values in the context. 

### Observing changes

So to see the changes, we observe the values from the context: 

```ts
constructor() {
    super();

    this.consumeContext(TIME_MANAGEMENT_CONTEXT_TOKEN, (_instance) => {
        this.#timeContext = _instance;
       
        this.observe(_instance.time, (_time) => {
            this.time = _time;
        });

        this.observe(_instance.date, (_date) => {
            this.date = _date;
        });

    })
}
```

This means when these values change no matter where from we will get the update to our element. 

## Summary. 

There you go simples. Well not really simples, but thats all the bits you can use to get your content from server to client and back. The likelyhood is you might not need all the layers but I am very pleased to have finally worked it out (especially the auth bit!). and now package building can commence. 

I also promise to revist some of the things i skipped over to get here. the Umbraco docs are going for v14, and will probibly cover all of this way better - so do check them out.

https://docs.umbraco.com/umbraco-backoffice/extending/customize-the-editing-experience
Early Adopter's Guide to Umbraco v14 Packages : Communicating with the server! - Part 2 (Stores)
Tags: umbraco
Published: 2024-01-30 23:02:10

_The code for this series of posts can be viewed here : https://github.com/KevinJump/TimeDashboard_

## 2. Stores

The store sits between the repository and the resource (which fetches the data). and to be honest, i think its probibly a bit over kill for most people to have a store here, but following on from the Umbraco pattern the store is the thing that will call your resources (auto generated clients).

our complete store is : 

```ts
import { UmbControllerHost } from "@umbraco-cms/backoffice/controller-api";
import { UmbDataSourceResponse  } from "@umbraco-cms/backoffice/repository";
import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
import { TimeResource } from "../../api";


export interface TimeDataSource {

    getTime() : Promise<UmbDataSourceResponse<string>>;
    getDate() : Promise<UmbDataSourceResponse<string>>;

}

export class TimeManagementDataSource implements TimeDataSource {

    #host: UmbControllerHost;

    constructor(host: UmbControllerHost) {
        this.#host = host;
    }

    async getTime(): Promise<UmbDataSourceResponse<string>> {
        return await tryExecuteAndNotify(this.#host, TimeResource.getUmbracoTimeApiV1TimeTime())
    }

    async getDate(): Promise<UmbDataSourceResponse<string>> {
        return await tryExecuteAndNotify(this.#host, TimeResource.getUmbracoTimeApiV1TimeDate())
    }
    
}
```

the important Umbraco'y bit here is using tryExecuteAndNotify which wraps a lot of the logic around the request, so you get notification boxes when things go wrong, and the calls have all the right bits set on them to work. 

As you can see we are returning a `Promise` now and with the async calls we are waiting for requests to come back without blocking any  other code that might want to run.

## 3. Repositories. 
Respositores are the interface between the objects you manage in your application (entities) and the things coming from the server, you might manipulate/conolidate/check items here, but in our case its going to look a lot like our store.:

```ts
import { UmbControllerbase } from "@umbraco-cms/backoffice/class-api";
import { UmbControllerHost } from "@umbraco-cms/backoffice/controller-api";
import { TimeManagementDataSource } from "./sources/time.datasource";

export class TimeManagementRespository extends UmbControllerBase {
    #timeDataSource: TimeManagementDataSource;

    constructor(host: UmbControllerHost) {
        super(host);
        this.#timeDataSource = new TimeManagementDataSource(this);

        console.log('repository constructor');
    }

    async getTime() {
        return this.#timeDataSource.getTime();
    }

    async getDate() {
        return this.#timeDataSource.getDate();
    }
}
```

In our repositoty we are newing up the store, and then calling the methods to get the values back from the API.

Next .. The context !!

---
> _**Updated**: 2/3/2024: preview008. DataSouceReponse -> UmbDataSourceResponse_
> _**Updated**: 2/3/2024: preview008. UmbBaseController-> UmbControllerBase_
Have you tried the Arc browser?
Tags: browser, discuss, watercooler
Published: 2024-01-30 23:01:32

I have no affiliation with [Arc](https://arc.net/), but I've been experimenting with it, and I'm quite pleased. I've known about it for a while but did not feel like trying it _too early on_ before it worked out some kinks.

Have you tried Arc? Thoughts?