teleren/devto huggingface dataset:
Infrastructure vs Code : imperative vs Declarative approach
Published: 2023-02-21 19:05:12

**Infrastructure vs Code : imperative vs Declarative approach **

**"Infrastructure as Code" (IaC)** in Kubernetes denotes incorporating declarative configuration files to express the intended state of the system rather than creating imperative scripts that specify how to attain that state.

Declarative configuration files, such as YAML files, provide a high-level description of the desired state of the system, including the number of replicas of a particular application, the container images to use, and the networking and storage resources required. Kubernetes then uses this information to automatically configure the system to match the desired state.


So, here you tell Kubernetes what you want to happen, and then Kubernetes figures out how to make that happen. For example, you might tell Kubernetes that you want five replicas of a web application running, and then Kubernetes will make sure that there are always five replicas running, even if one or two fail.
Imperative configuration, on the other hand, involves using commands or scripts to directly manipulate the system to achieve a desired state. While imperative configuration can be useful for one-off tasks or debugging, it can be more error-prone and difficult to maintain over time. Means, you write a script that directly tells Kubernetes what to do, such as creating a new pod or updating an existing one.

Overall, the declarative approach is generally preferred in Kubernetes, as it enables better management of complex distributed systems and ensures a consistent and reliable state of the infrastructure. Because it is more reliable and easier to maintain. By defining the desired state of your application and infrastructure in a declarative way, you can ensure that your application always runs in the way that you intended, regardless of any changes or failures that might occur.
Avoid These 10 Blunders In Your Next Coding Interview
Tags: webdev, tutorial, career, programming
Published: 2023-02-21 18:26:07

![How to fail a coding interview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ugndwatl2c3olnx5yr07.png)

In my software engineering career I have taken 200+ coding interviews. 

In this article, sharing top 10 most common blunders interviewees make in the interviews and tips on fixing them.

## TL;DR
- [Not understanding the problem](#--not-understanding-the-problem)
- [Not asking questions](#--not-asking-questions)
- [Not planning before coding](#--not-planning-before-coding)
- [Not thinking out loud](#---not-thinking-out-loud)
- [Not using hints](#---not-using-hints)
- [Not giving brute-force solution](#--not-giving-brute-force-solution)
- [Not optimizing the solution](#--not-optimizing-the-solution)
- [Not speaking while coding](#--not-speaking-while-coding)
- [Not knowing Big O notation](#---not-knowing-big-o-notation)
- [Not testing the solution](#---not-testing-the-solution)

## ❌ Not understanding the problem
 
Fix:
 
✅ Re-read the question until you understand constraints and edge cases.
 
✅ Re-phrase question in your own words and verify understanding with the interviewer.

## ❌ Not asking questions

Fix:

✅ Clarify any detail about the problem you find ambiguous. 
 
✅ Ask for problem constraints. Range of values, size of input, etc.
 
✅ Ask the interviewer if they prefer time or space optimized solution.

## ❌ Not planning before coding

Fix:
 
✅ Determine starting and ending points for solving the problem. 
 
✅ Develop a high level algorithm before refining details.

## ❌  Not thinking out loud

Fix:
 
✅ Discuss solution approach with the interviewer.
 
✅ Walk them through your implementation by dry running code.

## ❌  Not using hints

Fix:

✅ Acknowledge the hint and how does it help.
 
✅ Expand on hint and see where else can it improve the solution.

## ❌ Not giving brute-force solution

Fix:
 
✅ Start by sharing simplest brute force solution.
 
✅ Explain why the approach is sub-optimal.

## ❌ Not optimizing the solution

Fix:
 
✅ Go through the solution step by step and identify the inefficiencies.
 
✅ Resolve inefficiencies by using right data structure or algorithm for the task.

## ❌ Not speaking while coding

Fix:
 
✅ Keep explaining to the interviewer what you are coding.
 
✅ Don’t speak code verbatim, also explain why you made a decision.

## ❌  Not knowing Big O notation

Fix:
 
✅ Know time and space complexity of classic algorithms.
 
✅ Practice calculating complexity of your code.

## ❌  Not testing the solution

Fix:

✅ Dry run the code with sample inputs and edge cases.
 
✅ If code doesn’t work, show that you understand why is that so.

## Wrapping up 📝

Hope you will avoid these blunders in your next coding interview.

If you liked this post, follow me for more of these. 🙂

Also, share ONE interview mistake that you never want to repeat in comments. 👇
Challenge #6: 👛 Multisig Wallet Challenge
Tags: web3, blockchain, solidity, javascript
Published: 2023-02-21 18:18:39

## Tasks to be done

This is a smart contract that acts as an off-chain signature-based shared wallet amongst different signers that showcases use of meta-transaction knowledge and ECDSA `recover()`.

At a high-level, the contract core functions are carried out as follows:

**Off-chain: ⛓🙅🏻‍♂️** - Generation of a packed hash (bytes32) for a function call with specific parameters through a public view function . - It is signed by one of the signers associated to the multisig, and added to an array of signatures (`bytes[] memory signatures`)

**On-Chain: ⛓🙆🏻‍♂️**

- `bytes[] memory signatures` is then passed into `executeTransaction` as well as the necessary info to use `recover()` to obtain the public address that ought to line up with one of the signers of the wallet.
  - This method, plus some conditional logic to avoid any duplicate entries from a single signer, is how votes for a specific transaction (hashed tx) are assessed.
- If it's a success, the tx is passed to the `call(){}` function of the deployed MetaMultiSigWallet contract (this contract), thereby passing the `onlySelf` modifier for any possible calls to internal txs such as (`addSigner()`,`removeSigner()`,`transferFunds()`,`updateSignaturesRequried()`).

## My Review

This challenge didn't really have any or much code to write, it was more about reading and understanding the code as well as self exploring the topics 🤓 At the core of this challenge is understanding `meta transactions`. Understanding meta transactions was very interesting and cool since they can be used in so many different ways, opening doors for many applications to be possible, one example being multisig wallet. The fact that you can pass a function inside a call data and then the contract can then call that function is so cool 🤌

## Important links

- [Speed Run Ethereum](https://github.com/scaffold-eth/scaffold-eth-challenges/tree/challenge-5-multisig)
- [Deployed webapp](https://kevinj-sre-c6.surge.sh/)
- [Deployed contract](https://goerli.etherscan.io/address/0xc45FEd4ebc8492b0E8997fB03Bc8D3183bF7B6f4)
- [Project source code](https://github.com/kevinjoshi46b/speedrunethereum/tree/master/challenge-6-multisig)
TailwindCSS Containers Breaking on High Resolutions?
Tags: tailwindcss, webdev, tutorial, typescript
Published: 2023-02-21 18:14:57

[TLDR; Take me to the Snippet](#code-snippet)

If you've ever worked with TailwindCSS, you know that it's a powerful utility-first CSS framework that provides a lot of helpful classes to make your styling work easier. However, one of its more powerful tools is customization, so we're not hand-tied to the decisions someone else made for us.

I've come across some issues with certain designs on really high-resolution screens, and the solution is provided by [Adam Wathan](https://github.com/adamwathan),, the creator of Tailwind in this [GitHub issue](https://github.com/tailwindlabs/tailwindcss/issues/1102#issuecomment-525386822).

Said solution deactivates the default container class and creates a custom container component.

```ts
//within the tailwind.config.ts file
corePlugins: {
  container: false,
}
```

> don't worry if your tailwindcss file is empty, there's a full code example at the end of the post.

After deactivating the default container and its widths, we're going to add a new component:

```ts
plugins: [
  // just remove the `: PluginAPI` part if you're not using TypeScript.
  function ({ addComponents }: PluginAPI) {
    addComponents({
      ".container": {
        maxWidth: "100%",
        "@screen sm": {
          maxWidth: "640px", //this stays the same as the default but needs to be redefined
        },
        "@screen md": {
          maxWidth: "768px",
        },
        "@screen lg": {
          maxWidth: "1024px",
        },
        //here's the main difference, the last width I want to support is 1024px,
        //so I'm avoiding the "@screen xl" and "@screen 2xl" breakpoints.
      },
    });
  },
];
```

My goal here was to create a container that would max the width at 1024px, because the design would look too weird on a 4k display, and I don't want to overload the users with information, thus encouraging scrolling down instead of being bombarded by every single pixel on the screen.

If you want some of the functionality from the default container class like center: true, you can still implement it yourself by adding: margin: "0 auto" in the .container object.

A final result would look like this:

### Code Snippet

```ts
import type { Config } from "tailwindcss";
import { PluginAPI } from "tailwindcss/types/config"; //ignore this import if you're not using TypeScript

export default <Partial<Config>>{
  theme: {
    extend: {
      colors: {},
    },
  },
  corePlugins: {
    container: false,
  },
  plugins: [
    function ({ addComponents }: PluginAPI) {
      addComponents({
        ".container": {
          maxWidth: "100%",
          margin: "0 auto", //centering the container
          "@screen sm": {
            maxWidth: "640px",
          },
          "@screen md": {
            maxWidth: "768px",
          },
          "@screen lg": {
            maxWidth: "1024px",
          },
        },
      });
    },
  ],
};
```
Code Smell 197 - Gratuitous Context
Tags: webdev, beginners, programming, tutorial
Published: 2023-02-21 17:59:58

*This is a nice way to mark 'your' classes and objects*

> TL;DR: Don prefix or suffix your names with irrelevant information

# Problems

- Lack of Polymorphism

- Bad Naming

- [Bijection](https://dev.to/mcsee/the-one-and-only-software-design-principle-3086) violation with names

# Solutions

1. Remove this context from your names

# Context

In software development, gratuitous context refers to the unnecessary inclusion of additional information or data in code or user interfaces that do not contribute to the functionality or usability of the software.

It can make the software more difficult to use, understand and maintain.

It also increases the risk of errors or defects. 

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/0e69debe5bcce802a00b09be29a1a668)
```rust
struct WEBBExoplanet {
    name: String,
    mass: f64, 
    radius: f64, 
    distance: f64, 
    orbital_period: f64, 
}

struct WEBBGalaxy {
    name: String,
    classification: String,
    distance: f64, 
    age: f64,
}
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/111aa1f4c0d67b3230f6166aadecd9d6)
```rust
struct Exoplanet {
    name: String,
    mass: f64, 
    radius: f64, 
    distance: f64, 
    orbital_period: f64, 
}

struct Galaxy {
    name: String,
    classification: String,
    distance: f64, 
    age: f64,
}
```

# Detection

[X] Semi-Automatic 

We can find command patterns and rename all objects.

# Tags

- Naming

# Conclusion

Class Preffixing was a widespread practice decades ago to claim ownership. 

Carefully consider the context and content of the software, and avoid including unnecessary or extraneous information wherever possible.

Now we know clean names are more important.

# Relations

{% post https://dev.to/mcsee/code-smell-141-iengine-avehicle-implcar-58ch %}

{% post https://dev.to/mcsee/code-smell-130-addressimpl-b46 %}

{% post https://dev.to/mcsee/code-smell-174-class-name-in-attributes-55c %}

# More Info

{% post https://dev.to/mcsee/what-exactly-is-a-name-part-ii-rehab-20gd %}

# Disclaimer

Code Smells are my [opinion](https://dev.to/mcsee/i-wrote-more-than-90-articles-on-2021-here-is-what-i-learned-1n3a).

# Credits

Photo by [Mitchell Griest](https://unsplash.com/es/@griestprojects) on [Unsplash](https://unsplash.com/photos/psDzkLlifxQ)
    
* * *

> The most dangerous kind of waste is the waste we do not recognize.

_Shigeo Shingo_
 
{% post https://dev.to/mcsee/software-engineering-great-quotes-26ci %}

* * *

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}
Are you new to coding? 💻 Here's a list of 5 essential skills you should learn before getting your first job.
Tags: webdev, beginners, programming, codenewbie
Published: 2023-02-21 17:59:53

![Learning to code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aops2p9zvjx6cxf3oa2j.png)

**Knowing how to find the info you need (aka Googling)**

Could you ensure you know how to find help online when you get stuck? Usually, adding "example" or "StackOverflow" to your search query brings you better results. Try to use the entire error message you get in your console. If you see some codes or numbers in the error message, use it too. For example, "TypeError: Assignment to constant variable StackOverflow".

**Parsing JSON data**

JSON is nothing else than a data representation format. Your programs are only helpful with data. The rule of thumb for API Content-Type is JSON. Please ensure you can get to the first element of the array in the nested object. 🔗[Web Dev Simplified has a great video on JSON](https://www.youtube.com/watch?v=iiADhChRriM)

**Working with version control (git and GitHub)**

When you develop a small application alone, you know exactly what is changing, and you can be sure no one else will break your code. When you get your first job, you will start working on a larger codebase with others. Code changes 1000% more often, and there will be some chaos. The remedy for this chaos is version control; most companies use git and GitHub. The good news is that you only need to learn 5–8 short commands. 🔗[Programming with Mosh has made a free course on youtube.](https://youtu.be/8JJ101D3knE)

**Familiarising yourself with your code editor and its tools**

According to the StackOverflow survey, most people use VSCode nowadays, and it's a great choice. You can use whatever editor you want, but if you're a beginner joining a project with some linter and formatting configs, you must ensure you can configure them in your editor too. ESlint and Prettier are the most popular formatter and linter for JavaScript devs. You can research your language tooling and start using linting and formatting as soon as possible in your project. 🔗[TraversyMedia video on VScode, Prettier and ESlint setup.](https://youtu.be/SydnKbGc7W8)

**Creating at least one tiny project from scratch**

This will give you a lot. You'll get a big picture of what is relevant in application development. You'll need to solve all the problems you'll encounter on your own , which will give you the best learning effects! Suppose you can use all the tips from above and create a little app or website that uses weather API and displays the current weather for a given location, put it on GitHub and deploy it online. In that case, you can start applying for junior positions. 🔗[Tutorial to make a similar app in JavaScript by Web Dev Simplified](https://www.youtube.com/watch?v=w0VEOghdMpQ)
Docker Logs, continue....
Tags: docker, devops
Published: 2023-02-21 17:55:37

---
title: Docker Logs, continue....
published: true
description: 
tags: #docker #devops
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-02-03 15:44 +0000
---
In my previous [post](https://dev.to/spartakos87/docker-logs-set-limits-fe0) I have explained how to set limits in docker logs. But after that we can see that, for some reason, docker after reach the max-size create a second file with extension **log.1**. 

<img width="100%" style="width:100%" src="https://media.giphy.com/media/s239QJIh56sRW/giphy.gif">

I don't know, yet, why this happening but, after the lattest file reach again the max-size, docker start write, from begin the first file..

# Set limits to the number of logs files!!!
So you need to add one more argument to your *docker-compose.yml*, for example,
```bash
logging:
       driver: "json-file"
       options:
           max-size: "100k"
           max-file: "3"
```
Now docker will create three logs files with these extensions:
**.log**, **.log.1**, **.log.2**
When first one hit the max-size will create the next one and etc.
When docker reach the limit in last file **.log.2** will recreate the first one **.log** .
My new NeoVim setup for JavaScript(TypeScript), react, vue development
Tags: vim, javascript, tutorial, webdev
Published: 2023-02-21 17:52:59

### TL;DR

Repo: https://github.com/2nthony/dotfiles includes a quick preview video.

---

![preview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0yeg5se7l6wfvnyfsfbl.jpg)

I've published a [post](https://dev.to/2nthony/my-neovim-setup-for-javascriptfront-end-development-160g) about my neovim setup before, but recently, I updated the setup again!

The most changes is: I use [LunarVim](https://lunarvim.org/) now, with bulk of personal customize plugins. I also made a vim color scheme [vitesse.nvim](https://github.com/2nthony/vitesse.nvim) just for myself to make the terminal(neovim) looks better 🤨.

In the end, I'm still looking for plugins to make it better and more useful, if you happened to know something good, please comment then let me know!🙏
AWS Glue Configurable Test Data Generator
Tags: glue, pyspark, aws, cdk
Published: 2023-02-21 17:37:43

Have you ever found yourself in a situation where you need to test a new cloud solution or a new feature, but you lack sufficient data, or you cannot use production data for privacy or security reasons? In such cases, test data generation comes in handy. This concept allows you to create controlled testing environments and generate test data that covers a wide range of scenarios. 

I have created an open source for a configurable Test Data Generator based on Pyspark and I am deploying it on AWS as an AWS glue service using  AWS Cloud Development Kit (CDK)

Feel free to check the code on the following Github repository and definitely you are more than welcome to contribute to it.

[Github repository: AWS Glue Configurable Test Data Generator](https://github.com/aws-samples/aws-glue-test-data-generator)

For a complete documentation, please check the following Wiki:
[AWS Glue Configurable Test Data Generator documentation](https://github.com/aws-samples/aws-glue-test-data-generator/wiki
)
Distributed Tracing
Tags: spring, sleuth, zipkin
Published: 2023-02-21 17:35:12

> Spring Cloud Sleuth provides Spring Boot auto-configuration for distributed tracing.
https://spring.io/projects/spring-cloud-sleuth#overview

> Zipkin is a distributed tracing system.
https://zipkin.io

# Dependencies

```xml
<dependency>
  <artifactId>spring-cloud-starter-sleuth</artifactId>
  <groupId>org.springframework.cloud</groupId>
</dependency>

<dependency>
  <artifactId>spring-cloud-sleuth-zipkin</artifactId>
  <groupId>org.springframework.cloud</groupId>
</dependency>

<dependency>
  <artifactId>spring-rabbit</artifactId>
  <groupId>org.springframework.amqp</groupId>
</dependency>
```

# Properties

```properties
spring.sleuth.sampler.probability=1.0
```

Now, if you have zipkin and rabbitmq running, you can call your service and see the traces in zipkin. 

For more information see https://www.appsdeveloperblog.com/spring-cloud-sleuth-and-zipkin/
Practical KISS
Tags: computerscience, designpatterns, todayilearned, community
Published: 2023-02-21 17:33:59

KISS is a software design principle, which stands for Keep it Simple, Stupid. But it might sound offensive to some people, so I will prefer **Keep it Stupid Simple**. KISS is based on the principle of minimalism and simplicity. The acronym - KISS is a design principle noted by the U.S. Navy in 1960. The acronym was reportedly coined by late [Kelly Johnson](https://en.wikipedia.org/wiki/Kelly_Johnson_(engineer)), lead engineer at the [Lockheed Skunk Works](https://en.wikipedia.org/wiki/Skunk_Works). 

This principle emphasizes that systems perform better when they are made simple. This concept does not only apply to software design, or software development, but can be applied to any industry. Now, simplicity does not means undermining the capability of a system. It just means that every system or program should be made as simple to understand as possible, while maintaining its features and capacity to perform tasks. 

![Keep It Simple Cookies](https://res.cloudinary.com/jishnupsamal/image/upload/v1676997149/jishnupsamal/uploads/2023/keep-it-simple-cookies_ajbg1t.jpg)

> **Everything should be made as simple as possible, but not simpler.**
> ~ Albert Einstein

## KISS in Practice

Keeping simplicity in mind, KISS can have several applications.

- Break down a problem into several small problems.
- Don't think that simplicity is associated with stupidity. Sometimes, the simplest solutions are the most correct solutions.
- Break tasks into several small sub-tasks.

![Photo by Anthony](https://res.cloudinary.com/jishnupsamal/image/upload/v1676997585/jishnupsamal/uploads/2023/balance_jxgb9e.jpg)
[*Photo by Anthony*](https://www.pexels.com/photo/close-up-photography-of-gray-cairn-stone-133372/)

- Don't create complicated solutions; you might yourself end up getting confused with what you have created.
- Simple systems are easier to scale and manage.

## Final Thoughts
Engineers tend to overcomplicate systems and they end up adding features and capabilities which are not required by the end user of the product. Systems work better when kept sample, rather than made complicated. Efforts should be made to achieve efficient results with minimum complexity and maximum simplicity. This is the whole crux of the KISS principle.

![Simplicity in Engineering](https://res.cloudinary.com/jishnupsamal/image/upload/v1676998373/jishnupsamal/uploads/2023/pexels-kei-scampa-4564088_eetpz7.jpg)
*Photo by [Kei Scampa](https://www.pexels.com/photo/futuristic-geometric-building-against-overcast-sky-4564088/)*

*Originally published on [Jishnu's Blog](https://jishnupsamal.me/blog/practical-kiss)*