teleren/devto huggingface dataset:
19- Delete a Column from a Vector Layer Attribute in PyQGIS
Tags: programming, python, pyqgis
Published: 2023-03-27 00:27:45

--- series: A beginner's guide to using Python with QGIS ---
Learn how to delete a column from a vector layer attribute in PyQGIS by following these simple steps. This tutorial will guide you through the process of opening a shapefile with an attribute table and using a code snippet to remove a specific column from the table. Whether you're a beginner or an experienced user, this guide will help you streamline your workflow and improve your data management skills in PyQGIS.

To begin, open a shapefile that has an attribute table. To delete the third column of the table, use the following code snippet:

```python
# Get the currently active layer:
layer = iface.activeLayer()

# Begin editing the layer:
layer.startEditing()

# Delete the attribute with the index of 2 from the layer:
layer.deleteAttribute(2)

# Commit the changes made to the layer
layer.commitChanges()
```

In conclusion, deleting a column from a vector layer attribute in PyQGIS is a simple process that can be accomplished by following the steps outlined in this tutorial. With the help of the code snippet provided, users can easily remove a specific column from their attribute table and streamline their workflow in PyQGIS.

> If you like the content, please [SUBSCRIBE](https://www.youtube.com/channel/UCpbWlHEqBSnJb6i4UemXQpA?sub_confirmation=1) to my channel for the future content
18- Creating a responsive dialogue box using PyQGIS
Tags: programming, python, pyqgis
Published: 2023-03-27 00:15:49

--- series: A beginner's guide to using Python with QGIS ---
Are you tired of manually asking users if they want to save changes in QGIS? Look no further than this step-by-step guide on how to build an interactive dialog box! With the help of PyQGIS, you can create a user-friendly experience that saves time and effort. Follow along and learn how to streamline your workflow with this handy tool.

Building a dialog box to ask if users want to save changes:

```python
# import the necessary modules
from PyQt5.QtWidgets import QMessageBox

# create a QMessageBox instance
qmb = QMessageBox()

# set the text displayed on the QMessageBox:
qmb.setText('Want to save your changes?')

# set the standard buttons for the QMessageBox (Save, Discard, and Cancel):
qmb.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)

# execute the QMessageBox and store the return value:
return_value = qmb.exec()

# check the return value and print a message based on the button pressed:
if return_value == QMessageBox.Save:
    print("You pressed Save")
elif return_value == QMessageBox.Discard:
    print("You pressed Discard")
else:
    print('You pressed Cancel')
```

In conclusion, building an interactive dialog box in PyQGIS can greatly improve the user experience and streamline workflows in QGIS. With this step-by-step guide, users can easily create a dialog box to prompt users to save changes, saving time and effort. By utilizing PyQGIS, users can create a more efficient and user-friendly experience in QGIS.

> If you like the content, please [SUBSCRIBE](https://www.youtube.com/channel/UCpbWlHEqBSnJb6i4UemXQpA?sub_confirmation=1) to my channel for the future content
Journal Entry 2 - The Process
Tags: project2
Published: 2023-03-27 00:12:52

We have commenced the work of project 2 and we're excited to share our progress so far.

To get started, we looked at Flight and Fawaz Nice Card as references for our project. Our first goal was to create a single web component that was identical to the badge component on the Penn State Badges website. We used concepts we learned from Project 1 such as the details button, card layout, and this.image to create the component.

While we have made progress, we have encountered some issues along the way. One of the main issues we are facing is that we have been unable to get the drop down button to move to the right side. We are currently working on finding a solution to this problem.


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

Our next priority is to fix the web component to be identical to the one on the website. We are unsure how to solve the problem of moving the drop down button to the right, but we are actively working on it.

If you take a look at our [Vercel link](https://badge-list-pearl.vercel.app/), you'll see the problem of how it's not the same. Despite the challenges, we are making steady progress towards our goal and are determined to deliver a high-quality microfrontend that meets all the requirements outlined in the project.

As we continue working on our microfrontend, we're excited to explore more web components and see how we can use them to deliver a great user experience. We'll be sharing our progress along the way, so stay tuned for more updates!
Adding a new widget to a WordPress theme - to add more ads
Tags: webdev, wordpress, php
Published: 2023-03-27 00:11:35


Adding a new widget to a WordPress theme like Jobify by Astoundify requires some coding skills and knowledge of the theme's structure. Here are the steps we can follow to add a new widget to Jobify that allows users to submit ads:

first we create a child theme: It's always recommended to create a child theme of Jobify instead of modifying the parent theme directly. This way, our changes won't be lost when the parent theme is updated.

**Create a new widget**: In our child theme's directory, we create a new PHP file for our widget.  We can use the WordPress Widget API to create the widget. 
Here's an example code snippet that we can use as a starting point:


`class Jobify_User_Ad_Widget extends WP_Widget {

  function __construct() {
    parent::__construct(
      'jobify_user_ad_widget', 
      __('User Ad Widget', 'jobify'), 
      array('description' => __('Allows users to submit ads', 'jobify'))
    );
  }

  public function widget($args, $instance) {
    // Widget output
  }

  public function form($instance) {
    // Widget form
  }

  public function update($new_instance, $old_instance) {
    // Update widget settings
  }

}`


3. Add the widget to Jobify's widget areas: Now that we have created the widget, we need to add it to the widget areas in Jobify. We can do this by editing our child theme's 
functions.php file and adding the following code:

`
function jobify_register_user_ad_widget() {
  register_widget('Jobify_User_Ad_Widget');
}
add_action('widgets_init', 'jobify_register_user_ad_widget');
`


4. here we add the ad submission functionality: To allow users to submit ads, we can use a plugin like WPForms or Gravity Forms to create a form. 
We can then add this form to our widget's widget() method. Here's an example code snippet:


`public function widget($args, $instance) {
  // Display the widget title
  echo $args['before_widget'];
  if (!empty($instance['title'])) {
    echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
  }

  // Display the ad submission form
  echo do_shortcode('[gravityform id="1" title="false" description="false"]');

  echo $args['after_widget'];
}`


In this example, the Gravity Forms shortcode [gravityform id="1" title="false" description="false"] is used to display the ad submission form. 

we can replace this with the shortcode for your own form.

**Style the widget**: Finally, we can style the widget to match Jobify's design by adding CSS to your child theme's style.css file.

With these steps, we should be able to add a new widget to Jobify that allows users to submit ads.
TS: Gain Control of Primitive String Types
Tags: javascript, typescript, webdev
Published: 2023-03-27 00:06:55

Let's say you know what kind of values you expect to receive for a certain property / parameter, you want to lock down that property so it will only accept certain values. There are a number of ways we can do that with Typescript. This can be achieved simply using pipe (|) as in 'cat' | 'dog'. 

```ts
const PET_TYPES = {
  cat: 'cat',
  dog: 'dog'
}

interface Pet {
  species: 'cat' | 'dog'
}

const myPet: PET = {
  // incompatible types, type string does not match type 'cat' | 'dog'
  species: PET_TYPES.cat, 
  // valid
  species: 'cat'  
}
```


We want to be able to use PET_TYPES though in our object and interface. Let us make use of 'as const' after PET_TYPES to make the properties 'readonly'.

```ts
const PET_TYPES = {
  cat: 'cat',
  dog: 'dog'
} as const

interface Pet {
  species: keyof typeof PET_TYPES;
}

const myPet: PET = {
  // valid
  species: PET_TYPES.cat 
}
```

There are some other ways we can also defining string values as well.

```ts
type PetType = 'cat' | 'dog';

interface Pet {
  species: PetType;
}

const myPet: PET = {
  // this is not valid as we are trying to use PetType like a value, but it is a type
  species: PetType.cat
  // valid
  species: 'cat'
}
```

By doing these approaches we are give more definition to our string values when we know that a property will be one of only a few different values. When making use of 'as const' on the of our constant objects then we make the properties within all readonly which allows the Typescript compiler to treat 'cat' and 'dog' as well read-only and thus not a type string.

The major benefit of moving the definition of 'cat' and 'dog' value to PET_TYPE is we are now able to make the values for re-use and making changing of the values into one place in our app which is DRY (Don't Repeat Yourself).

Thanks for reading!
What would you like to see in your browser's new tab?
Tags: productivity, frontend, design, startup
Published: 2023-03-27 00:05:48

**TLDR;** the title of this post

I'm looking for a desktop app/web app/new tab extension that could act as a "productivity dashboard". Ex.: notes, calendar, pomodoro, RSS news feed, etc. Nothing new, right? Well, in the sea of apps I've tried out over the years, something seems to always be missing: it either takes multiple tools/subscriptions to achieve, it's missing features or there's too many and it's overwhelming. I'm testing the waters and liking the idea of building my own, but maybe it could be more than just for personal use. TLDR; the title of this post

I'm looking for a desktop app/web app/new tab extension that could act as a "productivity dashboard". Ex.: notes, calendar, pomodoro, RSS news feed, etc. Nothing new, right? Well, in the sea of apps I've tried out over the years, something seems to always be missing: it either takes multiple tools/subscriptions to achieve, it's missing features or there's too many and it's overwhelming. I'm testing the waters and liking the idea of building my own, but maybe it could be more than just for personal use. **What's your take? What kind of feature would you find interesting or what are you currently using?**

I was writing an article for my personal blog (the usual, I'm not great at tech writing yet) and, of course, deviated towards the nth random side project idea I've had that week. I'm not gonna lie to myself: I'm not great at content and I'm currently more motivated towards the fun I have while building than thinking about marketing/monetization. Thanks to this community and other indie hackers like you, I've refocused my efforts and improved managing my objectives/priorities to make time to code actively outside of my working hours. I've had the chance to make it a habit in the past year, and got to contribute both in decisions and as a developer on other people's projects that haven't launched yet. But this is different: this is something that I started for myself, with the objective of practicing my coding skills, experimenting with tools, and for my own personal satisfaction. So I'm just throwing this out there, "what if" other people could make use of it? Have you encountered similar troubles while using note/todo/project management software?

Thanks for your time reading and any of your input :)
OBS en Windows...oro puro
Published: 2023-03-27 00:01:49

OBS es una interfaz gráfica opensource que permite hacer streaming a través de múltiples aplicaciones como YouTube, Twitch, Telegram y muchas más. Llevo varios meses haciendo streaming desde a través de OBS tanto en Windows como en GNULinux y vaya que hay diferencia.

[](https://www.youtube.com/watch?v=zNCvzX75aFE)

CONFIGURACIÓN DE OBSERVACIONES

Para usar OBS configuro en los dos VAAPI para tirar de la gráfica integrada y dejar a la CPU de la menor carga posible…esto origina que al momento de hacer el live, la CPU se gaste lo menos posible, dejando esa potencia para lo que vas a hacer streaming.
COMPARANDO CONSUMO

Bueno ahora vienen las odiosas comparaciones…. En GNULinux dependiendo de la distribución llega a usar la CPU en un 7 a 10% y en algunas otras más….. en Windows 11 llega a un ridículo menos del 1%. Esto solo refleja nada más que este último está mejor optimizado porque tiene más tiempo trabajando en este tema del streaming.
CUAL ES EL PROBABLE FUTURO

Si me preguntan, me da la impresión que GNULinux va a llegar en los próximos meses o años a dar el golpe en este tema, esto a mi manera de pensar por el salto que está dando en cuanto a STEAM.

Bueno, esto es básicamente lo que deseaba aportar al tema del uso de OBS en Windows y en GNULinux

Saludos y nos vemos por Twitter.
🤖 Installing Pip on macOS
Tags: unix
Published: 2023-04-22 19:28:15

---
title: 🤖 Installing Pip on macOS
published: true
date: 2023-03-27 00:00:00 UTC
tags: Unix
canonical_url: https://bstefanski.com/installing-pip-macos
---

In this blog post, I'll discuss a situation where I wanted to install a module using pip (the package installer for Python) but encountered an unexpected error: zsh: command not found: pip. This was quite surprising, as I assumed that Python, along with pip, was installed by default on macOS.

As it turns out, while Python is indeed installed by default on macOS, pip is not, and you'll need to download it separately. Additionally, the downloaded version is `pip3`, so you'll have to create an alias for `pip` since some tools or documentation still reference the older command.

To accomplish this, you can use the following one-liner:

```

python3 -m ensurepip && echo 'alias pip=pip3' >>~/.bash\_profile && source ~/.bash\_profile

```

This command does the following:

- Installs pip directly from the Python3 library
- Adds an alias `pip -> pip3` to your `~/.bash_profile`, ensuring that you don't have to recreate the alias every time you restart your computer
- Reloads the `~/.bash_profile` file

After running this command, you should be able to execute the pip command without any issues.
Debian NetInstall Non-free
Published: 2023-03-26 23:59:46

Instalando la versión debían netinstall non-free

Cuando llegas a GNU-Linux, es casi imposible no oír hablar de debían, la distribución universal, pero cuando quieres instalar esta de manera "normal", te vas a topar con un error en el proceso de instalación que no es producto de ti durante el mismo, sino que debían de por si es libre y cuando lo haces, siempre te dará problemas en caso tengas algún componente que no sea libre completo.

Bueno dicho esto, existe una opción para instalar debían de manera live non-free que es la versión que usa el instalador calamares, pero no les quiero hablar de esta, les quiero comentar el modo de instalación que le llamo yo debían netinstall non-free que es la que no te va a dar problemas.

[](https://cdimage.debian.org/cdimage/unofficial/non-free/cd-including-firmware/current/amd64/iso-cd/)

Solo eliges la versión "firmware-11.6.0-amd64-netinst.iso" y luego procedes con normalidad. Al final tendrás una instalación debían muy limpia, luego lo primero que tendrás que hacer es añadir tu usuario a sudoers para poder hacerte root y luego ir personalizando tu distro a tu gusto.

Saludos y nos vemos en internet.
Ofimática en GNULinux
Published: 2023-03-26 23:57:36

Uno de los temas mas medulares que existe en GNULinux es sin dudarlo el tema de la ofimática, hay muchas alternativas libres y no libres, opensource y no-opensource....pero no estoy inventando la pólvora cuando afirmo que Microsoft Office tiene el dominio total de la ofimática a nivel mundial, incluso hasta en el mundo de Apple a través de las Macbook, casi todos los que conozco, usan este paquete de ofimática y no el suyo que viene por defecto, esto creo yo no por un tema de pasiones, sino por un tema de tiempo, productividad, esto porque casi todo el mundo lo usa.

Bueno dicho esto libreoffice 7.5 acerca muchísimo a los usuarios que quisiéramos hacer todo en GNULinux y no tener que depender de MO, pero sigue teniendo algunos detalles que te roban algunos minutos al momento de tener que arreglar algunos detalles, onlyoffice también ofrece una interfaz muy similar a MO, pero tiene al igual que todas el mismo problema....la compatibilidad al 100%. Dentro de estas, últimamente vengo usando WPSOffice que viene con algunos detalles que tienes que meter mano para ponerlo en español, pero que hasta ahora a mi, me ofrece casi 100% de compatibilidad con la vereda de enfrente, es mas puedo hacer un documento en WPS y compartirlo a un usuario que usar MO y no habrá casi ningún problema de compatibilidad, ni en sellos magnéticos, ni margenes ni nada, así que dicho esto me quedare un tiempo con esta.

Les mando un abrazo linuxero.
What to do when you receive a message from GitHub saying WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
Tags: github, ssh
Published: 2023-03-26 23:56:01

If you pish to GitHub and receive a message like this:

```
% git push
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Please contact your system administrator.
Add correct host key in /Users/xxxx/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/xxxx/.ssh/known_hosts:2
Host key for github.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
```

By using the following command, you can remove all keys belonging to GitHub from the known_hosts file.

```
$ ssh-keygen -R github.com
```

After that, you will have a successful push.
Array.sort(): defining the sort order
Tags: javascript, beginners, algorithms, typescript
Published: 2023-03-26 23:41:10

## The sort() method in JavaScript

> "The sort() method sorts the elements of an array in place and returns the reference to the same array, now sorted. The default sort order is ascending, built upon converting the elements into strings, then comparing their sequences of UTF-16 code units values.", according to [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort).

## Defining the sort order

Let's say you want to sort some data, a list of users for example, based on the `status` of each user (if they're `online` or `offline`), and based on the alphabetical order of the user's first name and last name, in that order respectively.

```typescript
type User = {
  firstName: string,
  lastName: string,
  status: 'online' | 'offline'
}

const users: User[] = [
  { firstName: 'Rafael', lastName: 'Nadal', status: 'online'},
  { firstName: 'Fernando', lastName: 'Alonso', status: 'offline'},
  { firstName: 'Daniel', lastName: 'Ricciardo', status: 'online'},
  { firstName: 'Daniel', lastName: 'Brühl', status: 'online'},
];
```

To do that we can use an optional `sort()` parameter `compareFn` which takes a function as an argument to define the sort order. This function has two parameters (`a` and `b`) that take the two elements of comparison as arguments. The return value `r` depends on the comparison result between the elements, according to the following logic:

```typescript
// r > 0 if a > b
// returns a number greater than zero if a > b

// r = 0 // a === b
// returns zero if a === b

// r < 0 // a < b
// returns a number less than zero if a < b
```
So if we want to write a function to sort our list considering the two mentioned elements (status and alphabetical order), we could write something like this:

```typescript
const sortUsersByStatusAndName = users.sort((a, b) => {
  if (a.status === b.status) {
    if (a.firstName === b.firstName) {
      return a.lastName.localeCompare(b.lastName);
    }
    return a.firstName.localeCompare(b.firstName);
  }
  if (a.status === 'online') {
    return -1;
  }
  return 1;
});

console.log(sortUsersByStatusAndName);

/* expected output:
[{
  "firstName": "Daniel",
  "lastName": "Brühl",
  "status": "online"
}, {
  "firstName": "Daniel",
  "lastName": "Ricciardo",
  "status": "online"
}, {
  "firstName": "Rafael",
  "lastName": "Nadal",
  "status": "online"
}, {
  "firstName": "Fernando",
  "lastName": "Alonso",
  "status": "offline"
}] 
*/
```

Note that we want to sort by bringing **first** all the `online` users (in **alphabetical order**), and **finally** the `offline` users (in **alphabetical order** as well).
Project 2 Week 2 Update
Published: 2023-03-26 23:30:59

I started this project tackling the front-end of development first. Since we are supposed to create a web page that mimics [this](https://badgesapp.psu.edu/explore) web page, I figured that the easiest way to complete the front end would be to inspect element the page and copy/paste the necessary HTML elements and the accompanying CSS styles. The resulting web page looks almost identical, with a few necessary tweaks here and there. However, the code used to achieve this is extremely messy with a lot of overlap, so I will have to go through it and clean up any redundancies. I haven't attempted any JavaScript wiring or API usage, but those will be my next steps in the coming weeks. Before that, I have to figure out how to import the necessary icons on each badge, as that's the only thing that didn't translate properly to my code. 
##### Here is the progress thus far:
https://github.com/JeffTaylor108/badge-search

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