teleren/devto huggingface dataset:
Nuxt.js Projelerinde Global Hata Yönetimi
Tags: javascript, beginners, vue, axios
Published: 2023-03-01 22:17:38

Günümüzde frontend projeleri eskiye kıyasla daha karmaşık ve dinamik bir hale gelmiş durumdadırlar. Bu nedenle bir frontend projesi geliştirirken birçok parametreyi göz önünde bulundurmak zorundayız. Bu parametlerden biri de iyi bir hata yönetiminin yapılmasıdır.

İyi bir hata yönetimi ile birlikte istenmeyen durumlar karşısında projemiz çökmeyecek, hatanın sebebi kullanıcıya gösterilebilecek ve kullanıcı deneyimi artmış olacaktır.

Bir frontend projesinde uygulamanın gerçekleştirdiği veya bir sebepten dolayı gerçekleştiremediği işlemler ile ilgili bilgileri kullanıcıya göstermek önemlidir. Bu bilgiler [snackbar](https://material.io/components/snackbars) ile kullanıcıya gösterilebilir.

![Snackbar örneği](https://cdn-images-1.medium.com/max/2000/1*0Pmkz8L3QPT7G6g5ftP14A.png)

Eğer Nuxt.js ile frontend projesi geliştiriyorsanız ve HTTP isteklerini axios ile yapıyorsanız, HTTP isteklerinden kaynaklanan hataların global olarak yakalanıp işlenmesi [Axios Interceptors](https://axios.nuxtjs.org/helpers) ile oldukça kolaydır.

**Axios Interceptors Nedir?**

Axios interceptors, her HTTP isteği veya yanıtında çağrılan fonksiyonlardır. HTTP istekleri ve yanıtları uygulama içinde ele alınmadan (“then” veya “catch” tarafından işlenmeden) önce bu fonksiyonlar yardımıyla ele alınabilirler.

**Axios Interceptors İle Global Hata Yönetimi Yapmak**

Axios’un Nuxt’a özel sürümü olan [axios-module](https://github.com/nuxt-community/axios-module) ile birlikte, projenize ekleyeceğiniz basit bir plugin ile global hata yönetimi yapmak mümkündür. Bunun için sırasıyla;

 1. Plugins klasörü içine axios.js dosyasını oluşturup nuxt.config.js içerisine dahil edelim.
{% gist https://gist.github.com/muhammederdinc/cadb8de9b1a8ff692c7eb18dc4c7ac81.js %}
2. Artık $axios.onError ile birlikte HTTP hatalarını yakalayıp yönetebiliriz. Ayrıca ihtiyaca göre onError ile birlikte onRequest, onResponse, onRequestError ve onResponseError da kullanılabilir.
{% gist https://gist.github.com/muhammederdinc/52cb67bbc3fd99c8443d7d868817e1c3.js %}
Global hata yönetimi ile birlikte HTTP isteklerininin ve yanıtlarının merkezi olarak yönetilmesi, temiz ve sürdürülebilir bir mimari kurmamıza yardımcı olacaktır. Ayrıca olası hataların giderilmesi ve yeni özelliklerin eklenmesi çok daha kolay olacak, projenin bakım maliyeti düşecektir.

### Kaynaklar

* [https://axios.nuxtjs.org/helpers/](https://axios.nuxtjs.org/helpers/)

* [https://axios.nuxtjs.org/extend](https://axios.nuxtjs.org/extend)

* [https://material.io/components/snackbars#anatomy](https://material.io/components/snackbars#anatomy)
Benchmark Testing Kubernetes Controller Runtime With Envtest
Tags: k8s, kubernetes, controllerruntime, envtest
Published: 2023-03-01 22:11:45

---
title: Benchmark Testing Kubernetes Controller Runtime With Envtest
published: true
description: 
tags: k8s, kubernetes, controllerruntime, envtest
# cover_image: https://d33wubrfki0l68.cloudfront.net/69e55f968a6f44613384615c6a78b881bfe28bd6/42cd3/_common-resources/images/flower.svg
# Use a ratio of 100:42 for best results.
# published_at: 2023-03-01 14:05 +0000
---

The envtest docs push you into Ginko, but I'm a huge proponent of idiomatic (add another t to this word and I still fit) Go and Ginko doesn't fit me.

Thankfully you can use standard Go test benchmark functions without any extra testing packages and profile code to improve controllers.

Here is how I did it...

```go
package something
import (
	"context"
	"path/filepath"
	"testing"

	"k8s.io/apimachinery/pkg/types"
	"k8s.io/client-go/kubernetes/scheme"
	controllerruntime "sigs.k8s.io/controller-runtime"
	"sigs.k8s.io/controller-runtime/pkg/client"
	"sigs.k8s.io/controller-runtime/pkg/envtest"
	"sigs.k8s.io/controller-runtime/pkg/reconcile"

	"something/mypkg"
)
func BenchmarkMy_Reconcile(b *testing.B) {
	testEnv := &envtest.Environment{
		CRDDirectoryPaths: []string{"path/to/crds"},
	}
	cfg, err := testEnv.Start()
	if err != nil {
		b.Fatal(err)
	}
	defer func() {
		err := testEnv.Stop()
		if err != nil {
			b.Error(err)
		}
	}()
	err = mypkg.AddToScheme(scheme.Scheme)
	if err != nil {
		b.Fatal(err)
	}
	k8sClient, err := client.New(cfg, client.Options{Scheme: scheme.Scheme})
	if err != nil {
		b.Fatal(err)
	}
	r := &MyController{
		Client:      k8sClient,
		Log:         controllerruntime.Log.WithName("controllers").WithName("mypkg"),
		Scheme:      scheme.Scheme,
		InitMetrics: map[string]string{},
	}
	rreq := reconcile.Request{NamespacedName: types.NamespacedName{
		Namespace: "test", Name: "test"}}
	for i := 0; i < b.N; i++ {
		got, err := r.Reconcile(context.Background(), rreq)
		if err != nil {
			b.Fatalf("MyController.Reconcile() error = %v", err)
			return
		}
		b.Logf("%#v", got)
	}
}
```

On my mac, I use brew to install etcd and kubectl. I clone kubernetes and build kube-apiserver myself and copy it to `/usr/local/bin`

```sh
brew install kubectl etcd
git clone git@github.com:kubernetes/kubernetes.git && \
pushd kubernetes && \
git checkout v1.26.1 && \
go install ./cmd/kube-apiserver && \
cp ~/go/bin/kube-apiserver /usr/local/bin && popd
```

Then I run this test with `KUBEBUILDER_ASSETS=/usr/local/bin go test -benchmem -run=^$ -bench ^BenchmarkMy_Reconcile$ -memprofile mem.prof ./something`

The output is the standard Go test benchmark output and the mem.prof which I examine using `go tool pprof mem.prof`.

I haven't been programming much lately and so I didn't have `dot` installed on my Mac and I had to lookup where to get it. I had to `brew install graphviz`.

I use `top10` to see the highest memory users and I use `web` to generate an SVG of the memory creation call graph.

In my case, the code base was over using `fmt.Sprint(f)` and I was able to optimize these string allocations. I consider this a win.
Cool nav link hover animations with tailwindcss
Tags: tailwindcss, design, css, neobrutalism
Published: 2023-03-01 22:02:44

There is this new trend called "neo-brutalism" that's used in quite a lot of applications on the web these day (e.g. on [Figma](figma.com) or [Gumroad](gumroad.com).

I personally really like that style and it seems really fresh and clean to me. Often the hover animations on navigation links are using a kind of sliding borders from left to right.

#Implementation in CSS 

After a little research I have found that this can easily be implemented with CSS and the pseudo-element "after".

```css
a:after {
  display:block;
  content: '';
  border-bottom: solid 3px black;  
  transform: scaleX(0);  
  transition: transform 250ms ease-in-out;
}
a:hover:after { transform: scaleX(1); }
```


This will create the effect of a bottom border growing from the center when hovering the link as can be seen in this codepen.

{% codepen https://codepen.io/vincentdorian/pen/jOvBONv %}

Pretty nice already, right?  

#Implementation in Tailwindcss

As I am a hard-core tailwind user (and probably always will be), I have transformed this into tailwind utility classes, such that when applied on a link element it looks as follows:

**Expand from center**
```html
<a href="#" class="relative text-xl w-fit block after:block after:content-[''] after:absolute after:h-[3px] after:bg-black after:w-full after:scale-x-0 after:hover:scale-x-100 after:transition after:duration-300 after:origin-center">
Link
</a>
```


**Expand from left**
```html
<a href="#" class="relative text-xl w-fit block after:block after:content-[''] after:absolute after:h-[3px] after:bg-black after:w-full after:scale-x-0 after:hover:scale-x-100 after:transition after:duration-300 after:origin-left">
Link
</a>
```


**Expand from right**
```html
<a href="#" class="relative text-xl w-fit block after:block after:content-[''] after:absolute after:h-[3px] after:bg-black after:w-full after:scale-x-0 after:hover:scale-x-100 after:transition after:duration-300 after:origin-right">
Link
</a>
```


This is an easy and quick solution to create some modern link element styling but there are many other ways this can be used (for example with background-gradients).

Here are my sources for this post:
[https://stackoverflow.com/questions/28623446/hover-effect-expand-bottom-border](https://stackoverflow.com/questions/28623446/hover-effect-expand-bottom-border)
[https://css-tricks.com/css-link-hover-effects/](https://css-tricks.com/css-link-hover-effects/)


❤️ Thanks for reading ❤️
WHY I BELIEVE IN CROSS-PLATFORM TECHNOLOGIES
Tags: mobile, flutter, reactnative, crossplatform
Published: 2023-03-01 21:43:01

In 2023, we really have a choice to develop a mobile application (web is even worse, I don't know how they manage to decide 😄). Without getting into the eternal native vs. cross-platform debate, I will explain here why I believe that choosing a cross-platform technology like Flutter or React Native is truly relevant for starting a mobile application project in 2023:

- Get 2 applications for once: you get a REAL mobile application for both iOS and Android at the same time. And it comes with all the other bonuses! Maintaining a single codebase, recruiting/managing a single mobile development team instead of separately for iOS and Android.

- Meet functional and business needs: when you take a step back, you'll notice that the vast majority of mobile applications boil down to displaying UI, dynamic lists of content, search journeys, detail pages, features like user authentication, saving favorites, notifications, API calls and database for displaying or updating content, etc... Nothing that cross-platform technologies cannot do in 2023.

- Get good quality and performance: I know, it's a big topic, especially if developers are reading this. But in reality, cross-platform mobile applications are as performant and high-quality as native applications today; many expert studies show this. Take your phone, download Facebook, Tesla, Discord, BMW, Sncf Connect applications (all cross-platform) and tell me if as a user, you see a real shocking difference in terms of fluidity, UI and user experience.

- Manage cost: it's not news that the tech industry is struggling right now, with all the layoffs, especially in the USA. Huge blind investments are rare and the big growth of tech companies has slowed down. The industry is currently in a period of cost reduction, and it impacts everyone, including projects. In my opinion, cross-platform has its best card to play right now.

- Target several devices: few companies want just a mobile application. Often they also want a website or web application. People buy more phones or tablets than PCs. New devices are selling more and more (smart watches, VR headsets, embedded dashboards in cars...). So many platforms for which companies would want to offer an application to their users. Again, cross-platform technologies have already anticipated this evolution and are doing well.

The list is not exhaustive, there are other benefits. In 2023, I think we need to dare changing our approach and questioning some status quos. And above all, try to look ahead and anticipate the future by making appropriate choices.
CodeNewbie Podcast, S23:E4 — Saying Yes to Opportunities
Tags: beginners, codenewbie, career, podcast
Published: 2023-03-01 21:28:18

In Season 23 Episode 3 of the CodeNewbie Podcast, @saronyitbarek talks about navigating the job search and what saying yes looks like with [Frankie Nicoletti](https://twitter.com/frfrfrankie)

Listen to our podcast on the CodeNewbie site [here](https://www.codenewbie.org/podcast/saying-yes-to-opportunities).

In this episode we talk to Frankie Nicoletti, VP of Engineering at SoLo Funds. Frankie is also a former accountant, Go programmer, senior leader, public speaker, and competitive powerlifter.

- [Listen on Apple Podcasts](https://podcasts.apple.com/us/podcast/s23-e3-saying-yes-to-opportunities-frankie-nicoletti/id919219256?i=1000602264069)

- [Listen on Spotify](https://open.spotify.com/episode/3wTzp9QrsSpHyQ6T0QqbWI?si=f809d8eef1894d69)

Or, listen wherever you normally get your podcasts!

***

**Make sure to subscribe to the CodeNewbie podcast if you haven't yet!**

Happy coding! 💜
DevOps Challenge
Tags: aws, cloud, awscommunity, 100daysofcloud
Published: 2023-03-01 20:54:12

[60/100] #100DaysOfCloud Today, I tried to do a challenge where I need to configure AWS AMI on my local machine using Oracle VirtualBox and then install LAMP on it using the user-data option. I tried to create my own seed.iso file using user-data and meta-data, downloaded the Amazon Linux 2 AMI and booted it on VirtualBox but couldn't log in showing login incorrect error. Tried using the official seed.iso by Amazon and still ended up getting the same error. Asked a friend to test it out and apparently he was able to log in but got another error which was not having internet access and wasn't able to install LAMP. Will find out what the issue is and try to get it done another day.

[GitHub](https://github.com/aaditunni/100DaysOfCloud/blob/main/Journey/060/Readme.md)
The Everyday Life of an HNG Intern; Isaac Ojerumu’s Story
Tags: career, beginners, programming, writing
Published: 2023-03-01 20:53:48

**The Final Episode**
It has been an amazing journey and I appreciate your being with me this far. Moving from Stage 1 to the final stage, jumping over every hurdle that we came across, has proved that progress, alone, is winning. 
Isaac Ojerumu, a Nigerian undergraduate and who's story we've journeyed through, is indeed very passionate about Tech. Having interviewed him, I got to realize that he is determined and dogged. His determination was first tried when he came across the scholarship offer and realized that it was an unpaid program. There and then, he laid his priorities straight and knowledge topped the list. 
In the course of the scholarship program, there were several challenges that Isaac came across and he just had to overcome all for the sake of progress. Alongside these challenges were benefits. Programs of such offer participants the opportunity to get acquainted with impressive and productive personalities that could stick for a lifetime. 
At the initial part of the program, tasks that were awarded to Isaac and his co-participants were what he described as a walkover being that he already had a valid experience in Tech. Moving on, midway, the going went tough and the tough just had to get going.  Tasks got more demanding and teamwork was set in motion. 
At the end of it all, Isaac,  with other participants, came out victorious with every bit of knowledge that they gained in the course of the program. Determination and hard work paid off. 
This series is an encouragement to those that have decided to take their career seriously. Concluding,  in the words of Issac: “know what you want to do and follow through with it. ”
This is me saying a big thank you to everyone that has journeyed with me thus far. Thank you for your reads and encouragement, you have been one of the major reasons for the survival of my career as a Technical writer. Thank you. 
This is where we draw the curtain. Yes, by God's grace, it's a wrap. 
Please, let's get in touch on Medium; **Zini Zada**, and Twitter; **Zada_Zini**
Upgrade text-davinci-003 to gpt-3.5-turbo
Tags: openai, gpt3, node, javascript
Published: 2023-03-01 20:47:18

If you are using OpenAI's GPT-3 language model for your natural language processing tasks, you are likely familiar with the text-davinci-003 model. However, OpenAI recently released a new model called gpt-3.5-turbo, which is even more powerful and cheaper than its predecessor. In this blog post, we will guide you through the process of upgrading from text-davinci-003 to gpt-3.5-turbo in your node.js application.

![gpt-3.5-turbo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p5evm7za1tl5ucldo53v.png)

## Step 1: Update the OpenAI package to the latest version(3.2.0).

The first step is to Upgrade the OpenAI package in your node.js environment. You can do this by running the following command in your terminal:

```bash
yarn add openai@^3.2.0
```

## Step 2: Update your code

Once you have updated your API key, you need to update your code to use the gpt-3.5-turbo model instead of text-davinci-003. Here is an example of how to do this:

```javascript
const { Configuration, OpenAIApi } = require("openai");

const configuration = new Configuration({
  apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
```
Everything above remains the same as the openai API configuration.

```javascript
// text-davinci-003
const completion = await openai.createCompletion({
  model: "text-davinci-003",
  prompt: "Hello world",
});
console.log(completion.data.choices[0].text);

// gpt-3.5-turbo
// replace .createCompletion() with .createChatCompletion()
const completion = await openai.createChatCompletion({ 
  model: "gpt-3.5-turbo",
// replace prompt with messages and set prompt as content with a role.
  messages: [{role: "user", content: "Hello world"}], 
});
console.log(completion.data.choices[0].message.content);
```

In the code above, replace `text-davinci-003` with `gpt-3.5-turbo` to use the new model.

You can also read the official documents here:
{% embed https://platform.openai.com/docs/api-reference/chat/create %}

## Step 3: Start your application

Finally, start your node.js application to begin using the gpt-3.5-turbo model for your natural language processing tasks. **If you are running your application during the process, please make sure to restart your application or it will not take effects!**

## Conclusion

Upgrading from text-davinci-003 to gpt-3.5-turbo is a simple process that can greatly improve the accuracy and effectiveness of your natural language processing tasks. By following the steps outlined in this blog post, you can easily upgrade your node.js application to use the new model. Happy coding!
Blackjack Python Terminal Game
Tags: python, gamedev, beginners, github
Published: 2023-03-01 20:39:28

This is a simple and lightweight python program that plays a simplified version of blackjack that runs on the terminal. It contains all the functions of a regular blackjack game, except the option to split your current hand (coming soon ;D). 

Your given a budget of $500 dollars at the start and the option to play at various tables, with different bets and dealers. If you lose all your money the game automatically ends.

I used OOP to create a card, player, dealer and casino classes. Each card is an object holding a rank and suit attribute, as well as method to show the cards value. The dealer deals by selecting a random card object from the deck - an array of all 52 possible cards. These cards are added to the hand array of the player and dealer. 

Wins and loses are calculated by comparing the value of the players hand with the dealers hand and busts occur when the hand value of the player or dealer is greater than 21.

This is a [link](https://github.com/TawyeebOS/blackjack) to my github repo if you want to try it out for yourself.
How severe is the cyber security expert shortage? Which cyber security job shows the most potential for growth?
Tags: cybersecurity, shortage, ethicalhackers, cybersecurityjobs
Published: 2023-03-01 20:18:30

Answering to question, cybersecurity has become a critical concern for many businesses and organizations as they rely on technology to conduct their operations. However, there is a significant shortage of cybersecurity experts globally, and the demand for cybersecurity professionals is on the rise. Protecting sensitive data and intellectual property from cyber threats has become a top priority, and cybersecurity professionals are essential to achieving this goal.

![Scarcity of talented ethical hackers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w433erdfbb12d7fxmcrq.jpg)

Despite the shortage of skilled cybersecurity professionals, there are many job opportunities available in the field for somewhat more than script kiddies. The cybersecurity industry is broad, and there are various job roles that require different skills and specializations. Here are some of the most in-demand cybersecurity jobs:
* Security Analysts: Responsible for monitoring and analyzing security alerts to identify and respond to potential cyber threats.
* Cybersecurity Engineers: Design and implement security systems to protect networks and data from cyber-attacks.
* Security Consultants: Provide expert advice to organizations on how to improve their security posture.
* Penetration Testers: Test systems for vulnerabilities and identify potential weaknesses that could be exploited by hackers.
* Information Security Managers: Oversee the security operations of an organization and ensure compliance with industry regulations.
Due to the rapid advancement of technology, cyberattacks have considerably grown, and organizations are struggling to locate enough cybersecurity experts. Concern over the shortage of qualified cybersecurity experts is growing on a global scale, especially in emerging nations where the candidate pool is smaller.

![Ethical Hacker](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eydtncwljwigf8gbyooc.jpg)

Experts must stay current with new innovations in order to remain competitive in the rapidly evolving cybersecurity industry. Many companies offer training and certification programs to keep their workforce up to date with the most recent industry requirements. In order to network with colleagues and keep up with industry advancements, cybersecurity experts might also go to conferences and events.

To conclude, there are numerous opportunities for people interested in a career in cybersecurity, and it is never too late to begin learning. The cybersecurity industry is vast, and there are numerous job opportunities available, each needing a unique set of skills and specialties. To remain competitive, it is vital to stay current on technological breakthroughs and market trends. If you require additional cybersecurity guidance and resources, you can visit The Decents Hub (https://www.thedecentshub.tech/), which provides answers to similar questions.
ABAP Learning Journey...
Tags: beginners, programming, database, abap
Published: 2023-03-01 20:04:04

###Hi community,
I've started to learn and work with ABAP language for 5 months. I completed frontend bootcamp then I found a job in SAP. I don't have luxury reject this opportunity therefore I accepted. But was thinking a lot that how to overhelm this situation. A new soft lang and fresh start something. After a while, see that every soft lang has similar concepts, loops, conditions, keywords, data types etc. I determined that I can do it. Because I know devs that change title every two years. 

Syntax is confusing at the beginning, some little practices makes it understandable, a project (without copying from tutorial) makes it OK.

SAP is an enormous software company, various opportunities and more stable than web development. (not released a fresh framework  everyday =))

Anyway, for brevity, I strongly recommend to beginners, newbies, "you should correspond those fields that they're suitable for you, your technical skills and you do it better than others." Passion is important but everyone likes web apps, colors, designs, drawings and after learning some HTML and CSS, he/she says "I'm a passionate frontend developer".

Result is simple, work smart and scheduled in your special way that you own built it. I believe you'll get success.

Have a nice week folks! =D Bye.