teleren/devto huggingface dataset:
Cómo instalar y usar distintas versiones de node en ubuntu y derivados.
Tags: ubuntu, node, nvm, spanish
Published: 2022-12-23 23:43:00

**Antes de empezar:** Mi máquina tenía instalado Node mediante NodeSource, desinstale fácilmente esa versión para proceder al método de este tutorial. Si tienes Node instalado por otro método, toma tus previsiones antes de continuar. 

En algunas ocasiones necesitaremos manejar una versión distinta de Node a la instalada actualmente en nuestra máquina. Ya sea que estés aprendiendo algo nuevo, trabajando en el proyecto de otra persona o cualquier otro motivo.

Esta situación la viví hace poco, por lo que averiguando di con **Node Version Manager (NVM)**. Una manera de tener distintas versiones de Node instaladas y la posibilidad de usar la que desees según tu necesidad. 

La instalación es sencilla, supongamos que quiero instalar la versión LTS más actual (a fecha de hoy la 18) y la anterior LTS (la 16).

```bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
```
o también:
```bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
```
Luego procedemos a ejecutar estas líneas que cargaran NVM:

```bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" 
```
Nos queda un solo paso, si no cambiaste la shell de tu terminal lo más seguro es que utilices bash, por lo que necesitas ejecutar este comando para recargar la configuración `source ~/.bashrc`, yo soy fiel usuario de zsh por lo que tendré que usar `source ~/.zshrc` y listo ya tendría que estar funcionando. 

Ahora que tengo todo listo, proceso a instalar la última LTS:
```bash
nvm install --lts
```

Para instalar la anterior versión pongo:
```bash
nvm install --lts=gallium
```
Gallium es el nombre de la versión 16 que era la anterior. 
**Recuerden que la primera versión que instalemos será la que se utilizara por defecto.** 

Ahora, cuando quiera usar la versión 16 simplemente pongo:
```bash
nvm use --lts=gallium
```
También funciona poner el número mayor de la version:
```bash
nvm use 16
```
Con esto ya estaría, recuerden que pueden instalar números específicos de versión, así como solo poner el número mayor de versión, tipo `nvm install 14`

Un último tip, si quieren la lista completa de nombres de versiones lts o numeros de versiones disponibles, pueden usar el comando `nvm ls-remote`

Para más comandos y ejemplos tienen el enlace de NVM:
[Documentación de NVM](https://github.com/nvm-sh/nvm)
SPVM 0.9672 is released
Tags: perl, spvm, beginners, programming
Published: 2022-12-23 22:46:14

<a href="https://metacpan.org/pod/SPVM">SPVM</a> 0.9672 is released.

## New Features and Enhancement

<a href="https://github.com/yuki-kimoto/SPVM/blob/master/Changes">Changes</a>

```
0.9672 2022-12-24
  [Performance Degration]
    * Degrates the performance of the method call, field access, class variable access, basic type access, class access in precompiled source
      because the ids are cached only at the beginning of the precompiled function, not static memory.
  [Changes]
    * Precompiled methods become reentrant because method IDs, field IDs, class variable IDs, basic type IDs, class IDs are not saved to static variables.
```

## For Programming Beginners

### What Is SPVM?

SPVM is a static typed programming language that can be installed from Perl/CPAN.

### How potential dose SPVM have?

Growth is expected in the fields of Bio Tech, AI/ML, Apple/iPhone/iPad Apps, Google/Android Apps, IoT Device, Connected Car, Smart Device, Smart Home, etc.

This is because SPVM can produce an executable file that supports cross platforms and make easy to calculate arrays and bind C/C++
Setting up server and database to perform CRUD operations using Apollo-GraphQL, PostgreSQL, Sequelize, and Express
Published: 2022-12-23 22:43:19

**How to perform CRUD (create, read, update, delete) operations with Apollo GraphQL, PostgreSQL, Sequelize, and Express, you will need to set up a GraphQL server using the apollo-server-express library and connect it to a PostgreSQL database using the Sequelize ORM (Object-Relational Mapping) library. Here's a general outline of the steps you'll need to follow:**

1. Set up your Express server and GraphQL endpoint:
Install the necessary dependencies, such as apollo-server-express, graphql-tools, express, and sequelize.
Define your GraphQL schema, which will describe the types of data you can query and manipulate, as well as the relationships between those types.
Implement your GraphQL resolvers, which are functions that execute the CRUD operations when a GraphQL query or mutation is received.
Use the apollo-server-express library to create an Apollo server instance and integrate it with your Express app.

2. Connect your GraphQL server to a PostgreSQL database using Sequelize:
Configure Sequelize by defining your database models and establishing a connection to the PostgreSQL database.
Write the code to perform the CRUD operations using the Sequelize API.
Here's an example of how you might define a Sequelize model for a Task model and implement a GraphQL resolver for a create operation:

```
const Task = sequelize.define('task', {
  title: {
    type: Sequelize.STRING,
    allowNull: false,
  },
  description: {
    type: Sequelize.STRING,
  },
});

const resolvers = {
  Mutation: {
    async createTask(parent, args, context, info) {
      const { title, description } = args;
      const task = await Task.create({ title, description });
      return task;
    },
  },
};

```
This resolver function receives a Mutation type in the GraphQL schema, along with the necessary arguments, and creates a new Task instance using the Sequelize create method. It then returns the created instance as the result of the mutation.

There are other ways the CRUD operation can be achieved, and it is explained below:

```
const sequelize = new Sequelize('database', 'username', 'password', {
  dialect: 'postgres',
});

const Task = sequelize.define('task', {
  // define model fields here
});

sequelize.sync();

```
When defining your GraphQL schema, you will need to specify the Mutation type and the fields that correspond to each CRUD operation. For example:

```
type Mutation {
  createTask(title: String!, description: String): Task!
  updateTask(id: ID!, title: String, description: String): Task
  deleteTask(id: ID!): Task
}

```
To ensure that your GraphQL resolvers have access to the Sequelize models, you can pass them as part of the context object when creating the Apollo server instance:

```
const server = new ApolloServer({
  typeDefs,
  resolvers,
  context: () => {
    return {
      Task,
    };
  },
});

```
I hope this additional information is helpful! Let me know if you have any further questions.
Need your advise, Building personal project
Published: 2022-12-23 21:57:56

Hello everyone,

I have an idea in my mind, Im already in the developing process, but im sure Im missing so many things of course,

My main question of course, once project is completed, how I can make it more visible on the internet, how I can reach my audience, 

I have purchased UI Kit from MUI store which really helped me in my react learning journey as well

I was building the project using CRA for landing and admin pages, but Im considering having the lading page built with nextJs for better SEO

What else should I keep in my mind,

Any advise?

Thank you in advance
How to save trained model in tensorflow ?
Tags: tensorflow, deeplearning, python, machinelearning
Published: 2022-12-23 21:22:38

To save a trained model in TensorFlow, follow these steps:

1. Create a tf.keras.Model object or subclass of it.
2. Train the model using the fit() method.
3. Create a tf.keras.ModelCheckpoint callback object and pass it to the fit() method as an argument.
4. Set the save_weights_only parameter to True in the ModelCheckpoint callback object. This will save only the weights of the model, not the entire model structure.
5. Set the filepath parameter in the ModelCheckpoint callback object to the desired file location where you want to save the model.
6. Run the fit() method to train the model and save it at the specified file location.

Example:


```
# Create a model
model = tf.keras.Sequential([
    tf.keras.layers.Dense(64, activation='relu', input_shape=(10,)),
    tf.keras.layers.Dense(64, activation='relu'),
    tf.keras.layers.Dense(10, activation='softmax')
])

# Train the model
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])

# Create a ModelCheckpoint callback to save the model weights
checkpoint = tf.keras.callbacks.ModelCheckpoint(filepath='/tmp/model.h5', save_weights_only=True)

# Train the model and save the weights
model.fit(x_train, y_train, epochs=10, callbacks=[checkpoint])

```

You can then load the saved model weights using the load_weights() method of the model object:


```
# Load the saved model weights
model.load_weights('/tmp/model.h5')

# Evaluate the model on the test data
loss, accuracy = model.evaluate(x_test, y_test)
print(f'Test loss: {loss}, Test accuracy: {accuracy}')

```

# Hope you like it! Till then happy coding....
Using the forem-api for cross-posting
Tags: webdev, nextjs, forem
Published: 2022-12-23 20:45:14

I've been redoing my portfolio/blog/website project using some newer technology. One "advanced" feature I finally got around to adding is the ability for my SSG site to get posts from [forem's API](https://developers.forem.com/api).

This in theory allows my site to use dev.to as a "blog post source". However there a number of gaps with this approach. Namely things are not "live", in that any post on dev isn't instantly posted to my own site. 

Furthermore, my site is still **very** bare bones, to the point there are probably issues with how these posts will render, along with overall ugliness. 

This will all be worked on over time as I continue with fleshing out features on my site and add more interesting features. 

Keep learning, keep growing 👍

Checkout my portfolio/blog/website here:
https://bradtaniguchi.dev

**Beware** its very dusty/half-built and basic!
ChatGPT got me a job - writing my resume
Tags: ai, career
Published: 2022-12-23 20:27:35

I didn’t have a dad to help me with my CV but now I’ve got AI, so with all this talk (unsubstantiated) of “dey took our Jrbs” I’d like to counter that with a, your using it wrong , dummy statement. 

### Observe exhibit A:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xrui70oveo3liz1tca71.jpeg)

Yes chatGPT is delighted to help me improve my CV / Resume and gives me tips! Now I can get great advice about getting a job, and then get it taken away by AI 🤣
Bye Bye, Annoying Twitter Login Banner!
Tags: webdev, browserextension, javascript, twitter
Published: 2022-12-23 20:09:04

### TL;DR
Extension that hides login banner on twitter website: [Chrome Web Store Link](https://chrome.google.com/webstore/detail/toggle-twitter-login-bann/knepanacipkghjjodojlhlapdcloaipj?hl=en&authuser=2)

### Why
You must have observed that when you visit [twitter](https://www.twitter.com), when not logged in, an annoying blue bottom banner appears in your face, asking you to log in.

If you are like me, you probably don't want to login just to see a public post. Also, the login banner is so annoying.

So, I built an extension just for this.

### What does this do?

It hides that bottom banner based on your preference. That's it.
If you want to login, you can easily unhide it and login. 

### Features

- Hide/Show the bottom login banner in https://www.twitter.com
- Persist this setting across browser restarts
- Hide/Show state is synchronized across different tabs and windows where twitter.com is open ON THE SAME DEVICE 

1. When the banner is NOT hidden
![Screenshot (19) - 1](https://user-images.githubusercontent.com/15051871/209400766-0bb43c59-4f41-40bf-84c5-08538c7b65c3.png)

2. When the banner is hidden
![Screenshot (18) - 1](https://user-images.githubusercontent.com/15051871/209400584-46164c26-2764-4130-9761-dd731c353a03.png)

Here is the source code: [GitHub](https://github.com/stagefright5/remove-twitter-login-banner)

#### Update:

Extension is published now! [Chrome Web Store Link](https://chrome.google.com/webstore/detail/toggle-twitter-login-bann/knepanacipkghjjodojlhlapdcloaipj?hl=en&authuser=2)

You can also install locally by cloning the repo. [Click here for the guide](https://github.com/stagefright5/remove-twitter-login-banner#how-to-install)

~~I have submitted the extension for reviewing to publish it to the Chrom web store.~~

~~I will update this post with the link when it gets reviewed and accepted. Did not expect the process of publishing to chrome web store to be so long and tedious!~~

Also, this is my first browser extension. So, it might have weird non standard code.
Problems rendering gists in posts
Tags: help
Published: 2022-12-23 19:42:19

---
title: Problems rendering gists in posts
published: true
tags: help
---

{Use the questions/pointers below to guide your post — don't forget to delete the placeholder text!}

Is anyone else experiencing problems when rendering gists containing code in posts on DEV community?

 I'm seeing a line for each character...

`{% gist https://gist.github.com/trikitrok/a9b2b77762045a77cfd9c6854046add7 %}`

{% gist https://gist.github.com/trikitrok/a9b2b77762045a77cfd9c6854046add7 %}

but if you go to check the gist it's totally fine

https://gist.github.com/trikitrok/a9b2b77762045a77cfd9c6854046add7


Any idea how to solve this?
How to get the length of object in JavaScript
Tags: javascript, beginners, programming
Published: 2022-12-23 19:32:00

In this article we will learn how to get length of an object.

It is very common to get length of an object in JavaScript.

***

## Problem

Now we have a problem, which is that we want to know the length of the object.

Let's imagine we have an object like this:

```javascript
const myObject = {
    name: "John",
    age: 30,
    isMarried: true,
    country: "USA"
};

console.log(myObject);
// { name: 'John', age: 30, isMarried: true, country: 'USA' }
```

And we want to get length of that object!

**How to solve this problem?**

Now let's ask a question, is there a built-in function as in the array that returns the length of the object? **The answer is no.**

**OK, but how do we know the length?**

We can take advantage of the function in the array, but now we have to convert the object into an array first.

So we will use `Object.keys()` because it returns an array with all keys.

**The solution will be as follows:**

- We will convert our object to an array
- We will use `Object.keys()` because it returns an array with all keys.
- Use the length property to get the number of elements in that array


***

## Solution: Get length of an object

```javascript
// Object
const myObject = {
    name: "John",
    age: 30,
    isMarried: true,
    country: "USA"
};

// Get all keys in array
const keys = Object.keys(myObject);

// Get length of an array
const result = keys.length;

// Result:
console.log(result);
```

**Output**

```
4
```

The Object.keys() method returns an array of a given object's own enumerable string-keyed property names. (Source: [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys))

***

## Thank you for reading

Thank you for reading my blog. 🚀 you can read more awesome articles from [my blog](https://mo-ibra.com/) 🚀🚀
how does meat consumption affect global warming
Published: 2022-12-23 19:16:08

Meat production, particularly the production of beef, is a significant contributor to greenhouse gas emissions. The production of meat, especially beef, requires large amounts of land, water, and energy, and generates significant amounts of methane, a potent greenhouse gas. In addition, the transportation and processing of meat also contribute to greenhouse gas emissions.

Reducing meat consumption can help to reduce greenhouse gas emissions and mitigate the impacts of global warming. Plant-based sources of protein, such as beans, lentils, and tofu, generally have a lower environmental impact than meat and can be a more sustainable choice.

It's important to note that individual choices alone cannot solve the problem of global warming. Collective action, including policy changes and investments in clean energy and sustainable agriculture, is also necessary to make a meaningful impact. However, reducing meat consumption can be a simple and effective way for individuals to reduce their own carbon footprint and make a positive impact on the environment.
How to solve global warming
Published: 2022-12-23 19:14:22

Global warming is a complex problem that requires the efforts of individuals, communities, and governments around the world to address. Here are a few steps that can be taken to help reduce greenhouse gas emissions and mitigate the effects of global warming:

**Reduce energy consumption:** One of the largest sources of greenhouse gas emissions is the burning of fossil fuels for energy. By using energy more efficiently and transitioning to clean energy sources, we can reduce our carbon footprint. This includes using energy-efficient appliances and lighting, insulating our homes to reduce heat loss, and driving fuel-efficient vehicles.

**Plant trees and vegetation:** Trees and other vegetation absorb carbon dioxide from the atmosphere and help to offset some of the greenhouse gases that contribute to global warming. Planting trees and other vegetation is a simple and effective way to help combat global warming.

**Support clean energy technologies:** Renewable energy sources, such as solar and wind power, produce little or no greenhouse gas emissions. Supporting the development and adoption of clean energy technologies can help to reduce our reliance on fossil fuels and combat global warming.

**Reduce deforestation:** Deforestation and land use changes contribute significantly to greenhouse gas emissions. Protecting forests and promoting sustainable land use practices can help to reduce these emissions.

**Support public policy:** Governments play a critical role in addressing global warming. Supporting politicians and public policies that prioritize action on climate change can help to drive the changes needed to address this global challenge.

**Make lifestyle changes:** As individuals, we can also make a difference by reducing our own carbon footprint through lifestyle changes. This can include reducing meat consumption, choosing to walk or bike instead of driving, and supporting businesses that prioritize sustainability.
How much will it cost to build an eCommerce website using Shopify and woocommerce
Tags: ecommerce, woocommerce, shopify, webdev
Published: 2022-12-23 19:05:01

The cost of building an eCommerce website using WooCommerce or Shopify will depend on a variety of factors, including the complexity of the website, the features, and functionality you want to include, and the design and branding elements you want to incorporate.
Here are some estimates of the potential costs you may incur when building an e-commerce website using WooCommerce or Shopify.

**WooCommerce:**

1. WooCommerce is a free plugin for WordPress, so you will need to have a WordPress website to use it. Depending on your hosting plan, WordPress hosting can cost anywhere from $3 to $30 per month.

2. You will also need to purchase a domain name, which typically costs around $10-30 per year.

3. If you want to use a premium WooCommerce theme, you can expect to pay anywhere from $50 to $200 or more.

4. If you want to add additional features or functionality to your website, you may need to purchase additional plugins, which can cost anywhere from $50 to $300 or more.

**Shopify:**

1. Shopify offers several pricing plans, ranging from $19 to $299 per month(Their basic plan is now at $1 for the first 3 months). The cost you pay will depend on the features and functionality you need for your website.

2. You will also need to purchase a domain name, which typically costs around $10-15 per year.

3. If you want to use a premium Shopify theme, you can expect to pay anywhere from $180 to $350.

4. If you want to add additional features or functionality to your website, you may need to purchase additional apps, which can cost anywhere from $5 to $500 or more.

It's important to keep in mind that these are just rough estimates, and the actual **[eCommerce website building cost](https://codersmutant.com/ecommerce-website-cost-comparison/)** using WooCommerce or Shopify will depend on your specific needs and goals. It's a good idea to plan out your budget and do some research on the various costs involved before getting started.
Pros and Cons for a HTMX beginner
Tags: webdev, tooling, codenewbie, performance
Published: 2022-12-23 18:54:24

HTMX is a JavaScript library for performing AJAX requests, triggering CSS transitions, and invoking WebSocket and server-side events directly from HTML elements.

HTMX allows you to create modern and powerful user interfaces with simple markup.

Nowadays the community has been talking a lot about this tool, and how it could benefit front-end applications. 

Nonetheless, with this post we want to give you something to think about, the pros and cons before jumping into this new trend.

https://lab.codes/pros-&-cons-htmx-dt
Here is a general roadmap for learning web development
Tags: webdev, javascript, beginners, programming
Published: 2022-12-23 18:53:33


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

**Learn HTML:** HTML (HyperText Markup Language) is the foundation of the web. It's used to structure content on the web and define the meaning of that content. You can start learning HTML by reading tutorials and guides online, or by taking an online course.

**Learn CSS:** CSS (Cascading Style Sheets) is used to style and layout web pages. It's used to control the appearance of elements on a web page, such as fonts, colors, and layout.

**Learn JavaScript:** JavaScript is a programming language that is used to build interactive elements on web pages. It's used to create things like forms, pop-up windows, and games.

**Learn a web framework:** A web framework is a set of tools and libraries that make it easier to build web applications. Some popular web frameworks include React, Angular, and Vue.js.

**Learn a back-end language: **A back-end language is used to build the server-side of a web application. Some popular back-end languages include Python, Java, and PHP.

**Learn a database:** A database is used to store data for a web application. Some popular databases include MySQL, PostgreSQL, and MongoDB.

**Practice, practice, practice:** The best way to become a good web developer is to practice building web applications. You can start by building simple projects and gradually work your way up to more complex projects. You can also contribute to open source projects to get experience working with a team.

It's also important to keep up with new developments and technologies in the web development field. This can help you stay current and competitive in the job market. You can do this by reading blogs and articles, attending meetups and conferences, and participating in online communities.