teleren/devto huggingface dataset:
Go Series: Pointer
Tags: go, beginners
Published: 2023-04-25 21:50:10

![Golang Logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8tdkgcszo71tdh7eans9.png)

{% replit @achristoph/Pointer  %}

A pointer is simply a variable that holds the location in memory where a value is stored. 
Pointer indicates mutable parameter.
Go gives **the choice** to use pointers or values for both primitives and structs.

The common gotcha is when passing a struct - a struct is passed by value. [Example](https://replit.com/@achristoph/Pointer#person/person.go)

```go
func changePersonFailed(person Person){
  person.Name = "Jane"
}
person := Person{Name: "John", Age: 1}
changePersonFailed(person)
```
Original person object is not modified since the person is a copy of the original person struct

To pass by reference or in other words, passing the pointer instead, can be done by adding the * prefix on the person parameter in the method definition, and to pass the pointer of the object by adding & prefix to the person object
```go
func changePerson(person *Person){
  person.Name = "Jane"
  desc := "new value"
  person.Description = &desc
}
person := Person{Name: "John", Age: 1}
changePerson(&person)
```
The best practice, however, is to always strive to not modify the object passed as argument into the function and return it as a return value of the function instead, such as:
```go
func changePersonBestPractice(person Person) (p Person) {
	p = Person{Name: "Name", Age: person.Age}
	return p
}
person := Person{Name: "John", Age: 1}
updatedPerson := changePersonBestPractice(person)
```
Mutated object can be difficult to track of - where the object was mutated . Instead, returning a new object will guarantee the original object is modified while still getting back a new object with updated values. 
append methods is an example of this practice. Original slice is kept as is, and a new slice returned with the given element added

```go
names := []string{"a","b"}
names = append(names, "c")
fmt.Println(names)
```

Another reason is garbage collector has more work with pointers since value types are in stack and stack is sequential where as heap where the pointers located are not.
You Are Still the Product
Tags: capitalism
Published: 2023-05-06 15:58:31

---
title: You Are Still the Product
published: true
date: 2023-04-25 21:05:00 UTC
tags: Capitalism
canonical_url: https://kevincox.ca/2023/04/25/youre-still-the-product/
---

<main style="--width:min(36em,100%);display:grid;grid-template-columns:1fr var(--width) 1fr;overflow:auto;padding:0;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><blockquote style="box-sizing:border-box;font-size:1.2em;grid-column:2;margin:1em;padding:.6em;position:relative"><p style="box-sizing:border-box;font-style:italic;margin:0 1rem;padding-bottom:0;padding-top:0;text-align:center">If you’re not paying, you are the product.</p></blockquote>
<p style="box-sizing:border-box;grid-column:2;margin:0 1rem .8em">People often read this quote and assume the negation; that if you are paying you aren’t the product. Unfortunately for any public company that simply isn’t true. The true “customers” of a public company are the shareholders, and they demand maximum profit. The people paying (or not) are just a resource to be mined as effectively as possible.</p>
<p style="box-sizing:border-box;grid-column:2;margin:0 1rem .8em">If a company is selling a TV, and they will make more money by selling ads, then they will sell ads on that device. It has nothing to do with lowering the price of the device, price isn’t directly linked to cost. The math is simply that they will make <code style="background:#000;border:1px solid #555;border-radius:.3em;box-sizing:border-box;color:#fff;margin:0;padding:.1em;white-space:pre-wrap">price - manufacturing cost</code> in one situation, and <code style="background:#000;border:1px solid #555;border-radius:.3em;box-sizing:border-box;color:#fff;margin:0;padding:.1em;white-space:pre-wrap">price - manufacturing cost + ad revene - development cost</code> in the second. As long as the revenue from ads is expected to be greater than the cost of updating the software they will do it.</p>
<p style="box-sizing:border-box;grid-column:2;margin:0 1rem .8em">The exception of course is if it cuts into purchases. If ads are projected to bring in $10M, but cost $15M in sales then ads don’t get shipped. (Long term effects such as brand perception may also be considered.) In practice few consumers let presence of ads influence their purchase decision. Often times they aren’t even aware of the ads until after they have set up the product, and can’t be bothered to pack it back up and return it. (Funny enough “Contains Ads” is never in big letters on the packaging.)</p>
<p style="box-sizing:border-box;grid-column:2;margin:0 1rem .8em">So if you are paying you are still the product, but you have more value to the company, so the abuse will be limited by the threat of you shutting your wallet.</p></main>
Running Bash commands with Python
Tags: bash, python, linux, systems
Published: 2023-04-25 20:54:36

## When plain Bash is not enough

A while ago I read an excellent [introductory Bash tutorial](https://dev.to/godcrampy/the-missing-shell-scripting-crash-course-37mk) on Dev.to by [Sahil Bondre](https://dev.to/godcrampy).

It is a really great tutorial on shell scripting basics, but I remember when I was beginning my adventure with shell scripting, and when I was (over)fascinated with Bash. In time, when my neuroimaging scripts started becoming more and more complex, I slowly began loosing control over my code! 

Many times I felt like that:


![Linux bash why won't you work - crying peter parker | Meme Generator](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a5upkv2496dlqak5fpef.png)


## The Python era

That was about that time when I discovered, that at some point, when more complicated logical expressions were needed (more conditionals, loops, and functions), it’s worth switching from Bash to Python. Hopefully, with Python you can wrap (almost) any bash command. And it is as simple as that:

```python
import subprocess as sp

bash_command = "ls ~/"
print("\nBash command:\n%s\n" % bash_command)

process = sp.Popen(bash_command, stdout=sp.PIPE, shell=True)
output, error = process.communicate()

print("\nBash command output:\n%s\n" % output)
print("Bash command error:\n%s\n" % error)
```

(It works both for Linux and macOS.)

Note the additional prints, as it is easier to debug the command before it is run. Additionally, you can see the output of the command (just like for a normal bash shell).

The above example was inspired by [this StackOverflow answer](https://stackoverflow.com/a/4256153/8877692).

It turned out that Python syntax is more readable and easier to maintain, yay! 🙂


![How To Write Better Python Code? - DEV Python is just a better “pseudocode compiler” than Bash.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jiluie66zp0h8uqiai1y.png)



## Take `~/` message

Don't stick with a plain bash for too long — often all you really needed is Python! Nevertheless, for a very simple scripts, you can of course always make a use of a good ol’ Bash ;)

---

See also my original post from 2020 (now it is already 2023 :) , but the knowledge is still a very much up-to-date): https://www.mindyourdata.org/posts/when-plain-bash-is-not-enough/

---

Cover photo source: Photo by <a href="https://unsplash.com/@iam_abhi?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Abhishek rana</a> on <a href="https://unsplash.com/s/photos/snake-in-shell?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
Mozilla Open Source Project: 10 Things I Learnt.
Tags: webdev, opensource
Published: 2023-04-25 20:54:21

About a month ago, I signed up for [Outreachy Internship Program](https://www.outreachy.org) where I got the chance to contribute to one of the Mozilla projects called [Firefox Desktop Nightly](https://www.mozilla.org/en-US/firefox/114.0a1/releasenotes/) and I learned a lot of things but here are just 10 of them:

1. 
Introduce yourself in the `introduction room`. Let other members and mentors know you're new to contributing to the Mozilla project. Mentors will guide you on how to get the setup on your local machine and get to work.

1. 
As a beginner, look for `good-first-bug` to start working on. Most of these issues come with instructions on how to solve them. Also, pay attention to any previous comments/discussions to get an understanding of what others have done. If you are still stuck, post your question on the `introduction` platform.

1. 
Always post your questions to the platform. Do not DM questions to mentors unless agreed by the mentor. Posting questions on the platform may help others to learn from it and mentors do not have to repeat themselves when newcomers join.
 

1. 
If you have started a thread with one mentor, make sure you stick with that mentor. Do not go asking other mentors about the same issue unless they offer to help. Mentors may refer others to also help.
 

1. 
You can DM mentors but make sure to ask if they are comfortable. Mentors do not have much time on their hands considering the number of mentees.
 

1. 
If you need help, look for the appropriate platform and post your question. Remember, there are many of these projects that are been worked on so taking your issues about setup to where they are discussing the new features, you might not get much help. You will probably be redirected to the appropriate platform.
 

1. 
Do not be rude. You are not only learning to better at coding but also communication skills. If you feel intimated or hurt by someone else's comment/reply, step away from your computer and take some fresh air. Possibly another mentor/colleague will step in to guide you better.
 

1. 
If new members ask a question and you have an idea, you should offer to help them because doing so will help to recap what you have learned and build your confidence too.
 

1. 
It is very much OK if at a point you feel lost. Do not hold back from seeking help. I recommend that first, you do a little research and if it does not help, you can ask for assistance. But be polite when asking your questions.
 

1. 
Lastly, have an open mind. Do not go into any project thinking you know it all and want to show off. If you know something, help others who do not know. And be ready to learn new things and you will be fine.

Lastly and most importantly, always read the contribution guidelines.
#DEVDiscuss: Naming Things
Tags: devdiscuss, programming, javascript
Published: 2023-04-25 20:02:15

*image created by [Margaux Peltat](https://www.patreon.com/margauxpeltat) for the [Chilled Cow YouTube channel](https://www.youtube.com/watch?v=lTRiuFIWV54)*

Time for #DEVDiscuss — right here on DEV 😎

Inspired by @samuel-braun's [Top 7 post](https://dev.to/devteam/top-7-featured-dev-posts-from-the-past-week-1d0h), tonight’s topic is...**naming things** 😱

{% embed https://dev.to/samuel-braun/naming-every-developers-nightmare-3ge8 %}


---
Questions:
- **Do you have a favorite naming pattern for variables?**
- **What's the worst-named variable you've seen in the wild?** _Note: comments must abide by the [Code of Conduct](https://dev.to/coc)!_
- **How do you feel about naming? Love it, hate it, indifferent?**
- **Any triumphs, fails, or other stories you'd like to share on this topic?**
PostgreSQL Memory Architecture
Tags: apacheage, postgres
Published: 2023-04-25 19:37:58

PostgreSQL has two kinds of memory locations to store data: the shared memory area, and local memory area.


![PostgreSQL Memory Architecture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u5e73f9202r3pgbok85p.png)


## Shared Memory Area

The shared memory area is used by all processes of a postgreSQL server. It is allocated when the server is started. 

The shared memory area can be divided into sub-areas based on their function. The main sub-areas are described below:

1. Shared pool buffer: this is where postgres loads pages and operates on them.
2. WAL buffer: this is where WAL data is stored before being written to permanent storage.
3. Commit log: stores the states of all transactions.
4. Checkpointer
5. Autovacuum
6. Sub-areas for semaphores and locks for concurrency control.

## Local Memory Area

This is unique to each backend process. It is used for query processing. It has 3 major sub-areas:

1. work_mem: this area is used for sorting tuples by the ORDER BY and DISTINCT operations.
2. maintenance_work_mem: used for maintenance operations.
3. temp_buffers: used for storing temporary tables.

### References:
https://www.interdb.jp/pg/pgsql02.html
Glassmorphism Form UI CSS
Tags: css, glassform, ui, webdev
Published: 2023-04-25 16:03:47

## HTML

```
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Glassmorphism Form</title>
    <!--Google Font-->
    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;500;600&display=swap" rel="stylesheet">
    <!--Stylesheet-->
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="background">
        <div class="shape"></div>
        <div class="shape"></div>
    </div>
    <form>
        <h3>Welcome Back!
            <span>Login to your account.</span>
        </h3>

        <label for="username">Username</label>
        <input type="text" placeholder="For ex. CodingArtist" id="username">

        <label for="password">Password</label>
        <input type="password" placeholder="Minimum 6 characters" id="password">

        <button>Sign In</button>
    </form>
</body>
</html>
```

## CSS

```
*,
*:before,
*:after{
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}
body{
    background-color: #080710;
}
.background{
    width: 430px;
    height: 520px;
    position: absolute;
    transform: translate(-50%,-50%);
    left: 50%;
    top: 50%;
}
.background .shape{
    height: 200px;
    width: 200px;
    position: absolute;
    border-radius: 50%;
}
.shape:first-child{
    background: linear-gradient(
        #9b22ea,
        #bf23f6
    );
    left: -80px;
    top: -80px;
}
.shape:last-child{
    background: linear-gradient(
        to right,
        #ff512f,
        #f09819
    );
    right: -30px;
    bottom: -80px;
}
form{
    height: 520px;
    width: 430px;
    background-color: rgba(255,255,255,0.07);
    position: absolute;
    transform: translate(-50%,-50%);
    top: 50%;
    left: 50%;
    border-radius: 10px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.1);
    box-shadow: 0 0 40px rgba(8,7,16,0.6);
    padding: 50px 35px;
}
form *{
    font-family: 'Poppins',sans-serif;
    color: #ffffff;
    letter-spacing: 0.5px;
    outline: none;
    border: none;
}
form h3{
    font-size: 32px;
    font-weight: 500;
    line-height: 42px;
}
form h3 span{
    display: block;
    font-size: 16px;
    font-weight: 300;
    color: #e5e5e5;
}
label{
    display: block;
    margin-top: 30px;
    font-size: 16px;
    font-weight: 500;
}
input{
    display: block;
    height: 50px;
    width: 100%;
    background-color: rgba(255,255,255,0.07);
    border-radius: 3px;
    padding: 0 10px;
    margin-top: 8px;
    font-size: 14px;
    font-weight: 300;
}
::placeholder{
    color: #e5e5e5;
}
button{
    margin-top: 50px;
    width: 100%;
    background-color: #ffffff;
    color: #080710;
    padding: 15px 0;
    font-size: 18px;
    font-weight: 600;
    border-radius: 5px;
    cursor: pointer;
}
```
Follow:
https://www.instagram.com/devwebsstore/
http://ondevwebs.com/
https://store.ondevwebs.com/glassmorphism-form-ui-css/
CTO.ai will be at Open Source Summit in Vancouver!
Tags: opensource, devops
Published: 2023-04-25 19:13:01

Hi devs!

We’re excited to announce that we will be at Open Source Summit North America in Vancouver on May 10-12! Visit us at booth G10 to talk about ways to measure & automate your cloud native workflows!

![Flyer containing CTO.ai booth and event information for the Open Source Summit in Vancouver](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6j7gemq7lymq6h1fejso.jpeg)

See you there!
Spill the tea ☕️
Published: 2023-04-25 19:01:59

Hello Dev community! 👋
I’m Milena, an aspiring web developer. I’m enrolled to start my formal education this summer. I’m a former hairdresser and am super excited to make this career change. Any tips on what NOT to do? Or care to share any advice that you wish someone had told you when you were starting up?
How to DRY Up Your NestJS DTOs
Tags: nest, typescript, node, cleancode
Published: 2023-04-25 18:56:00

## Introduction:

In NestJS, Data Transfer Objects (DTOs) are used to define the shape of data for various operations, such as creating or updating entities. However, it's common to have similar properties between DTOs for creating and updating entities, which can lead to redundancy in your code. In this post, we'll explore a smart way to reduce redundancy in NestJS DTOs using class inheritance and the PartialType utility provided by the @nestjs/mapped-types package.

**Step 1:** Install the @nestjs/mapped-types package

First, you'll need to install the @nestjs/mapped-types package, which provides the PartialType utility:

```bash
npm install @nestjs/mapped-types
```

**Step 2:** Create a base DTO for creating a new entity

Let's create a base DTO for creating a new user. This will be our CreateUserDto:

```typescript
// create-user.dto.ts
export class CreateUserDto {
  firstName: string;
  lastName: string;
  email: string;
  password: string;
}
```

**Step 3:** Create an update DTO for updating an entity using class inheritance and PartialType

Now, we'll create an UpdateUserDto by extending the CreateUserDto and using the PartialType utility. This will make all properties from CreateUserDto optional in UpdateUserDto:

```typescript
// update-user.dto.ts
import { PartialType } from '@nestjs/mapped-types';
import { CreateUserDto } from './create-user.dto';

export class UpdateUserDto extends PartialType(CreateUserDto) {}
```

## Conclusion:

By using class inheritance and the PartialType utility, we've successfully reduced redundancy in our NestJS DTOs. The UpdateUserDto inherits all properties from CreateUserDto, but they are optional due to the PartialType utility. This keeps your code DRY (Don't Repeat Yourself) and makes it easier to maintain.

When you need to update your DTOs, you only need to modify the base DTO (CreateUserDto), and the changes will automatically be reflected in the UpdateUserDto. This approach helps you write cleaner and more maintainable code in your NestJS applications.
Understanding methods and functions in JavaScript
Tags: javascript, webdev, frontend, beginners
Published: 2023-04-25 18:43:15

Chances are if you are learning JavaScript or using it for development you definitely have make use of the popular `console.log()` method, which is use to output message on the console. in this place console is the object, while log is a function inside the console object

Lets dive into the differences between functions and methods

## What is a function:
A function is a set of instructions that you can use over and over again in JavaScript. It's like a recipe that tells your code how to do something. You can give the function a name, and then call it whenever you want to use those instructions.

```
function addValue(a, b) {
  return a + b;
}

console.log(addValue(3, 4)); // Output: 7

```
the function addValue accepts two parameters a and b, and returns their sum.

## What is a method:
A method is a special tool in JavaScript that can be used to make objects do something. It's like a button that you can press to make a toy do a specific action. Each object has its own set of methods that you can use to control it. In a lay mans term **They are function inside object**

```
const employee= {
  username: "mdjibril",
  developer: "fullstack developer",
  sayHello: function() {
    console.log("Hello, my username is " + this.username + " and I am a " + this.developer);
  }
};

employee.sayHello(); // Output: "Hello, my username is mdjibril and I am a fullstack developer."

```

In this example, sayHello is a method attached to the employee object. It logs a message to the console that includes the object's username and developer properties.

In summary, functions are standalone blocks of code that can be called from anywhere in your code, while methods are functions attached to objects that can be called on those objects.

## More Example

**Function to check if a number is even**

```
function isEven(number) {
  if (number % 2 === 0) {
    return true;
  } else {
    return false;
  }
}

console.log(isEven(4)); // Output: true
console.log(isEven(5)); // Output: false

```

**method to convert a string to uppercase**

```
const myString = "hello world";

const upperCaseString = myString.toUpperCase();

console.log(upperCaseString); // Output: "HELLO WORLD"

```

that's a wrap, hope this clear the understanding between methods and function for you.
Testing If works
Published: 2023-04-25 18:29:58

Defining product strategy
strategies and effectively communicate recommendations to executive management
Solid technical background with understanding and/or hands-on experience in software development and web technologies
Strong problem solving skills and willingness to roll up one’s sleeves to get the job
Skilled at working effectively with cross functional teams in a matrix organization
Excellent written and verbal communication skills
  
Translating business requirements into technical specifications and vice versa
Planning and designing product roadmap
Allocating resources
Prioritizing product features and communicating the reason behind this to the stakeholders
Communicating effectively with all stakeholders
Ensuring timely completion of the product without cost overrun
Gathering customer requirements
Ideating and planning a winning product
Budgeting, team creation and resource allocation
Drawing up the product roadmap
Communicating with all stakeholders
Planning for and allocating resources


Results 
The development of drought monitoring tool lead to ensuring customer satisfaction because the it aligned with business goals. The technical project lead could monitor and report the project progress to the stakeholders. 
Upon deployment of the project
Stockholm Precision Tools
Published: 2023-04-25 18:14:18

De acuerdo con la nueva visión y valores de la empresa, SPT se [encuentra](https://www.visionmexico.mx/) en la búsqueda de nuevos negocios para evolucionar y asentarse como proveedor de [confianza ](https://www.emprendernegocio.mx/)de herramientas de prospección de alta precisión y calidad ofreciendo soluciones fiables y novedosas. Uno de los objetivos de la compañía es llevar a cabo alianzas con países que [inviertan ](https://www.impulsoemprendedor.mx/)de forma activa en el desarrollo de economías sostenibles y [prioricen ](https://www.elpuntonoticias.mx/)esfuerzos en gobernanza medioambiental y social.