teleren/devto huggingface dataset:
Google Scripts Resizing images to consistent width in Sheets
Tags: googleappsscript, googlesheets, imageresizing
Published: 2023-08-21 23:05:47

Google Scripts Resizing Images to Consistent Width in Sheets
------------------------------------------------------------

As software developers, we often find ourselves working with large amounts of data in spreadsheets. Sometimes, this data includes images that need to be resized for consistency and better presentation. Luckily, Google Scripts provides a powerful solution to automate this process in Google Sheets.

Resizing images manually can be a tedious and time-consuming task. With Google Scripts, however, we can write a custom script that automates the resizing process, saving us valuable time and effort. Let's dive into how we can achieve this!

### Step 1: Creating the Google Script

First, open your Google Sheets document and navigate to "Extensions" > "Apps Script." This will open the Google Apps Script editor in a new tab. Here, we can write our custom script to resize the images.

To get started, we need to define a function that will be triggered when we run the script. Let's name it `resizeImages`. Within this function, we can access the active sheet and iterate through the images, resizing them to a consistent width.

 

    
      function resizeImages() {
        var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
        var images = sheet.getImages();
    
        for (var i = 0; i < images.length; i++) {
          var image = images[i];
          var width = 300; // Set the desired width for the images
    
          image.setWidth(width);
        }
      }
      

 

Feel free to adjust the `width` variable to your desired value. This will be the consistent width to which all images will be resized.

### Step 2: Running the Script

Once you've written the script, save it and return to your Google Sheets document. To run the script, go to "Extensions" > "Apps Script" again, and this time, click on the play button (▶️) in the toolbar. This will execute the `resizeImages` function and resize all the images in your sheet to the specified width.

Now, sit back, relax, and watch as your images magically transform to a consistent width, making your spreadsheet look more polished and professional. Who said software development can't be fun?

### Conclusion

Thanks to Google Scripts, automating the resizing of images in Google Sheets has never been easier. By following the simple steps outlined in this article, you can save time and effort by letting the script handle the tedious task of resizing images for you. So go ahead, give it a try, and enjoy the benefits of consistent image widths in your spreadsheets!

### References

*   Google Developers - [Google Apps Script for Sheets](https://developers.google.com/apps-script/guides/sheets)
*   Google Developers - [Sheet.getImages() Documentation](https://developers.google.com/apps-script/reference/spreadsheet/sheet#getImages())
dvibe - share Repo updates to slack / discord
Tags: githubhack23
Published: 2023-05-23 02:51:08

## What I built 

A github action, which takes the webhook link as parameter, and publish the current repositories data to slack channel, using webhook

### Category Submission: 
New github action.

### App Link

https://github.com/marketplace/actions/github-repo-reports

### Screenshots 

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



### Description 

Takes the webhook url as parameter, and use git api & chats.io api, and generate a image based report to slack. 

### Link to Source Code 

https://github.com/parama4u/dvibe

### Permissive License 

MIT

## Background (What made you decide to build this particular app? What inspired you?) 

I am in IT world for 15+ years, half in big orgs, and other half in startups, its always a issue,where to see a granular status report of a Repo. Github provoids off-the-shelf, other paid tools do similar.

- The issue is when Micro-service-architecture followed, and we have 20+ micro services, its hard to check one by one on repo.
- Its also hard to integrate the same to new micro-services, and manage accesses.

So simplifying issue and solution, making it gitaction, set that a cron based report, and its on code, new repos can simply copy paste the same action, with dev - review - merge route.  


### How I built it (How did you utilize GitHub Actions or GitHub Codespaces? Did you learn something new along the way? Pick up a new skill?) 

Used local environment, and github actions. I am publishing a github action on my own for the first time, was spending 70% time on github actions documentation page.

### Additional Resources/Info

Planning to add more graphs, will continue the project, after the hackathon too.
O que são annotations?
Tags: programming, braziliandevs, beginners, java
Published: 2023-08-21 22:20:46

Eae gente bonita, beleza?

Dessa vez eu vim aqui falar um pouco para vocês sobre as **_annotations_** ou **_decorators_** . Elas são muito comuns em linguagens como Java, C# e em frameworks como Angular e NestJS. Em algum momento da sua vida você vai ver uma e precisar usar também, então é sempre bom saber onde vivem? O que comem?

<img src="https://media.giphy.com/media/YS8c0Z7in21AM4A2AR/giphy.gif" alt="gif entendendo">


## O que são?

Annotations são funções que podem ser usadas em **classes**, **métodos** ou **atributos**.
As annotations tem a seguinte assinatura _**@**_ seguido do nome da anotação.


```js
@Table(name = "person")
class Person {
  @Id
  id: number;

  @IsNotNull
  name: string;
}
```

Você pode perceber que no exemplo acima temos duas annotations. A annotation _**@Table()**_ recebe um parâmetro chamado **name** enquanto as outras não recebem nada e nem ao menos tem parenteses. E é assim mesmo que a coisa funciona. Isso pode depender da linguagem que você estiver usando. Na dúvida leia a documentação da linguagem.

<img src="https://media.giphy.com/media/tIeCLkB8geYtW/giphy.gif" alt="gif" />

## Para que servem?

As annotations podem servir para diferentes casos, como no exemplo acima a annotation @Table() serve para dizer que essa classe se refere a tabela de nome pessoa. Enquanto a annotation @Id diz ao banco que aquele campo é uma chave primária e por fim a annotation @IsNotNull diz ao banco que aquela coluna é não nula. 

Geralmente as annotations são disponibilizadas por frameworks para facilitar a configuração. É bem comum os ORM's disponibilizarem esse tipo de artifício para fazer as configurações, assim evitando criar arquivos de configurações e agilizando o desenvolvimento.

É importante dizer que não só ORM's os usam as annotaions. Por exemplo, você pode usar o @Test para dizer que aquele método é um teste e para várias outras coisas no Java.


É importante mencionar também que você pode criar as suas próprias annotations para fazer o que você quiser, [nesse link](https://docs.nestjs.com/custom-decorators) você pode ver como fazer isso no NestJS.


------

Se chegou até aqui, me segue la nas [redes vizinhas.]  (https://bento.me/cmsdev)
<img src="https://media.giphy.com/media/D08aklo5n0hi5PJyZw/giphy.gif" />
Day 809 : Everything Fresh
Tags: hiphop, code, coding, lifelongdev
Published: 2023-08-21 22:14:03

_liner notes_:
- Saturday : Due to trying to finish up some work for the job and going to the doctor's I left a little later than normal to head to the station because I was finishing up some prep work for the radio show. Luckily, I normally get to the station SUPER early, so it wasn't too bad. Plus we had some guests come by the station. I got to see someone I haven't seen in a minute. It was a good show. I recorded regular and 360 videos of the interview! The recording of this week's show is at https://kNOwBETTERHIPHOP.com

![Radio show episode image of a flyer with information for an upcoming HIPHOP show with the words Aug 10th 2023 Feets of Furry Guests: Cydney Poitier, Rubox and Terse](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f7fpi6jsbb6vp426juey.jpg)

- Sunday : What a day! Fam! I spent ALL DAY encoding and trying to upload these 360 videos. They are GBs in size. I did all this while doing the https://untilit.works cyphers. That's why I started it. So, I finally got everything uploading to YouTube and storage pretty late and left it to run overnight. Of course, when I woke up and checked on it, looks like Windows decided to update and restart the computer. Awesome.

- Professional : So yeah, started the day setting up the 360 videos to be uploaded again. Got the blog post I wrote up reviewed by the team and made some changes and got that ready to be posted tomorrow. I had a meeting and basically spent the day trying to get the demo application that goes with the blog post to work the way I want. I'm super close, but there's something I'm missing or not understanding with the third party library I'm using. I thought I could just get all the results from the response, but I think they aren't regular Objects, but I think Dictionaries. It makes sense because you don't want to have duplicates, but I just need to figure out how to get the values I'm looking for. After that, I should be basically done.

- Personal : So, I finally booked my hotel for my trip to Singapore. I chose one that I've been seeing in different YouTube videos and what made the difference was that a coworker that lives in Singapore had in their list. The hotel checks off a lot of things for me. I also reordered some old shirts to make sure everything fresh for my trip. Everyday the trip is getting more and more real to me. haha Been looking into things to do. I saw they have a Universal Studios there. I'll probably go to see how it compares to the one in Orlando.

![A bunch of rocks on the shore of a river in Buzk's Gard Park, Ukraine with some trees on the banks at sunset](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/moimtgbw1d5ddiorv6b3.jpg)

So, I'm going to do some more research for work on this third party library and see how I can get my data to send to the front end. After that, if I have time, and not tired, I'll go through tracks for the radio show and maybe watch some anime.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube CSoIe0YDpYw %}
Understanding Slicing in Python: A Comprehensive Guide
Tags: javascript, python, learning, beginners
Published: 2023-08-21 22:01:44

Slicing is a powerful technique in Python that allows you to extract specific portions of sequences like strings, lists, or tuples. In this comprehensive guide, we'll delve into the intricacies of slicing, exploring its syntax, capabilities, and various scenarios where it can be applied. Brace yourself for an enlightening journey through code examples and insights.

## Slicing Syntax:

Slicing follows a simple syntax: `sequence[start:stop:step]`. Here's what each component means:

`- start`
 The index where the slice starts (inclusive).

`- stop`
 The index where the slice ends (exclusive).

`- step`
 The step size between elements (default is 1).

**Basic Slicing:**

![python](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4o8u2ip2kswcpezm0jnd.png)
**Negative Indices:**

![python](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vuzzm9ter3hsyxj9huic.png)
**Stepped Slicing:**

![python](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y8l7mq3laxenzf957u3g.png)
**Slicing Strings:**

![python](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bnlaj3o5c6ye92tagldw.png)
**Omitting Indices:**

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

**Best Practices:**

`Understand Indexing:` Remember that slicing includes the starting index but excludes the stopping index.

`Avoid Hardcoding Indices:` If you're unsure about the length of the sequence, consider using len(sequence) to determine your indices.

**Conclusion:**

Slicing in Python is a versatile technique that empowers you to extract specific sections of sequences with precision and elegance. By mastering slicing syntax and considering its applications, you'll elevate your ability to manipulate and manage sequences effectively.

`LinkedIn Account` : [LinkedIn](https://www.linkedin.com/in/matthew-odumosu/)
`Twitter Account `: [Twitter](https://twitter.com/iamcymentho)
**Credit**: Graphics sourced from [LinkedIn](https://www.linkedin.com/pulse/slicing-python-er-suraj-kumar-soni/)
benefits on the method .count
Tags: methods, count, all, length
Published: 2023-08-21 22:00:28

Hello all,

I have been working on 'ActiveRecord' as of lately, and I was wondering if one could explain the benefits of running: 

restaurant.all.length # slower at is runs all data from the table 

as compared to: 

restaurant.count   # finds the unique ID 

I understand that this will ultimately speed up the process, but when would it be better to allow for the run of all the data in every table as compared to the unique ID in the .count method? 

Is there a specific time one should run one over the other?
How to get a token to access the Azure cost API
Tags: azure, cost
Published: 2023-09-21 14:03:59

---
title: How to get a token to access the Azure cost API
published: true
date: 2023-08-21 22:00:00 UTC
tags: Azure, Cost
canonical_url: https://mindbyte.nl/2023/08/22/token-access-azure-cost-api.html
---

The [Azure Cost CLI](https://github.com/mivano/azure-cost-cli) is a command-line dotnet tool created to facilitate interaction with Azure’s cloud costs. While the development of the tool was a technical endeavor, it posed a significant challenge in one particular area: authentication.

## Authentication Complexity

Obtaining a token to access the Azure Cost API without burdening users with usernames, passwords, or the creation of service accounts was a challenging issue. The need for a straightforward application that could retrieve the account information directly from the environment necessitated a unique approach.

## Utilizing DefaultAzureCredentials

The answer was found in `DefaultAzureCredentials`. This functionality attempts [various credential providers](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/Credentials/DefaultAzureCredential.cs) to find a valid one, offering a seamless way to authenticate. The approach enabled the retrieval of a token without adding complex authentication steps.

## ChainedTokenCredential with AzureCliCredential

To refine the process, a new `ChainedTokenCredential` was created, placing the `AzureCliCredential` at the start and then falling back to the default options if necessary. Below is the code snippet that encapsulates this elegant solution:

```csharp
// Get the token by using the DefaultAzureCredential, but try the AzureCliCredential first
var tokenCredential = new ChainedTokenCredential(
    new AzureCliCredential(),
    new DefaultAzureCredential());

// Fetch the token and ask explicitly for the Azure Cost API scope
var token = await tokenCredential.GetTokenAsync(new TokenRequestContext(new[]
    { $"https://management.azure.com/.default" }));

// Set the resulting token as the bearer token for the HTTP client
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Token);

```

### Simplicity and Flexibility

This method’s success lies in its simplicity and flexibility, enhancing user experience and leveraging existing Azure CLI setups across different environments.

## Conclusion

The Azure Cost CLI tool is more than a utility; it represents a thoughtful response to a real-world problem. By innovatively combining `ChainedTokenCredential` with `AzureCliCredential`, a solution was crafted that is not only efficient and secure but also simple to use.

For developers and administrators seeking a user-friendly way to interact with the Azure Cost API, this approach provides a practical and elegant path forward.
SRE vs DevOps Tasks
Tags: devops, sre, sitereliabilityengineering, softwareengineering
Published: 2023-08-21 21:53:34

The roles of an SRE and DevOps Engineers look similar from a bird’s eye view. 

However, they both work with different goals in mind. A DevOps engineer focuses on speed and agility, while an SRE is always looking at the availability and reliability of the site.

To better understand its differences, consider an instance wherein the DevOps team is planning to develop and launch a web application.

**When it comes to the application lifecycle, a DevOps engineer handles:**

✅ Application design
✅ Development
✅Infrastructure configuration

They also ensure that the app is properly deployed to the production environment and performing as per the defined metrics. 

In this process, a DevOps Engineer creates cross-functional teams to facilitate shorter and faster release cycles, with every member sharing the responsibility throughout the product life cycle.

**An SRE takes over from here and ensures the infrastructure is properly functioning:**

✅ First, the SRE team creates Service Level Objectives (SLOs) to measure the system/site performance.

✅ They run the application under normal operating conditions, note down the performance levels, and then run it under heavy loads to identify the acceptable performance degradable level.

✅ After that, they prepare Service Level Agreements (SLAs) based on these values. When the team receives a warning that the performance level is getting closer to the SLA value, they immediately respond and revert it to a healthy condition.

✅ The SLOs are also used to prioritize reliability work. For instance, fixing performance issues of a service that is not meeting the SLO is prioritized over optimizing the performance of an app running at the SLO level. 

While a DevOps engineer designs and implements DevOps in an organization, an SRE always sustain it to deliver optimal performance. 

So, a collaboration between these two professionals is important to deliver improved results to clients.

The following image gives a more detailed explanation of these tasks.


![SRE vs DevOps ClickIT Comparison](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zg5w44e3snvbzi4o3nk8.png)



**DevOps vs SRE**, which one do you prefer? Feel free to share your thoughts!


---
Check out the full comparison blog at [ClickIT](https://www.clickittech.com/?utm_source=devto&utm_medium=referral&utm_content=footer): https://www.clickittech.com/devops/sre-vs-devops/?utm_source=devto&utm_medium=referral

And follow us for more DevOps debates and comparisons.
Relational Database
Tags: database, sql, programming, beginners
Published: 2023-08-21 21:48:45

In this article, we will cover the relational database. What it is, how it works, and what are the main relational database management systems.

**Brief History**

The relational database was created in the 1970s at IBM to address certain problems that existed before, such as difficulties in data access, inconsistency, redundancy and lack of security.

**What Is It?**

In a relational database, data is stored in tables that can establish relationships with each other. This format is chosen when the application we are developing requires both consistency, ensuring that everyone shares the same data, and integrity, avoiding data loss or corruption.

Tables within a relational database consist of columns and rows. Each column represents an attribute associated with an entity, such as "name," while each row contains a specific instance of that entity, for example, a person. In the figure below, we present an illustrative example of a table.


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


In tables within a relational database, there is always a primary key, which is unique. This key is unique because it is used to identify a row. In the image below, we have an example of a table where the ID is the primary key.


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


We also have the foreign key, which is a unique key that references the primary key. It is with these two keys that we establish relationships between tables. 

Here, we have two tables that relate to the ID key.


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

**Characteristics of Relational Databases**

- Highly structured
- Various entities
- Less redundancy
- Represented using a logical and physical schema
- Use of the standard query language SQL (Structured Query Language)

**SQL**

In SQL, we have Data Definition Language (DDL), which is the integrated language for creating tables, and Data Manipulation Language (DML), which is the language for manipulating data.

**Main Relational Database Management Systems**

To control storage, security, ensure integrity, and manipulate data, we use software called Database Management Systems (DBMS). The main DBMSs available in the market are:

- Microsoft Azure SQL Database
- Microsoft SQL Server
- MySQL
- Oracle Database
- PostgreSQL
- SQLite
- MariaDB
- Hive
Guess the Band
Tags: webdev, javascript, programming, github
Published: 2023-08-21 21:28:59

Using CSS, HTML , and JavaScript I created a game in a website only using front-end topics. I created this program to cement my understanding of using all three scripting languages to make a stylish, interactive, and well structured game in a website. Some pictures of my program below:


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


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


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

If you would like to see more about my project please follow the link below to my GitHub page.

[https://github.com/david-alej/Guess-the-Band](url)
Should you ALWAYS write unit tests?
Tags: discuss, unittest
Published: 2023-08-21 21:24:40

I was reading an article about [unit tests](https://www.testim.io/blog/unit-test-vs-integration-test/). Honestly, it seems like a lot of effort. Do you receive a lot of value from your unit tests? Personally, I'm still trying to understand domain-driven design. I feel like with supple design, we need to use several techniques to pin software on the wall. Constraints such as revealing interfaces, side-effects-free functions, and many assertions should make your software better.

What do you think? Is it always better to write unit tests?