teleren/devto huggingface dataset:
Declaration va type patternlar haqida...
Published: 2022-05-30 02:02:45

Biz ifodaning ish vaqti turi berilgan turga mos kelishini tekshirish uchun declaration va type patternlardan foydalanamiz.Deklaratsiya namunasi ifodaga mos kelganda, quyidagi misolda ko'rsatilganidek, bu o'zgaruvchiga aylantirilgan ifoda natijasi tayinlanadi:

```
object greeting = "Hello, World!";
if (greeting is string message)
{
    Console.WriteLine(message.ToLower());  // output: hello, world!
}
```

```
int? xNullable = 7;
int y = 23;
object yBoxed = y;
if (xNullable is int a && yBoxed is int b)
{
    Console.WriteLine(a + b);  // output: 30
}
```
Agar biz faqat ifodani turini tekshirmoqchi bo'lsak, u holda o'zgaruvchi nomi o'rniga discard`_` dan foydalanishimiz mumkin:

```
public abstract class Vehicle {}
public class Car : Vehicle {}
public class Truck : Vehicle {}

public static class TollCalculator
{
    public static decimal CalculateToll(this Vehicle vehicle) => vehicle switch
    {
        Car _ => 2.00m,
        Truck _ => 7.50m,
        null => throw new ArgumentNullException(nameof(vehicle)),
        _ => throw new ArgumentException("Unknown type of a vehicle", nameof(vehicle)),
    };
}
```
C# 9.0 dan boshlab, bu maqsadda siz quyidagi misolda ko'rsatilganidek, Type patterndan foydalanishingiz mumkin:

```
public static decimal CalculateToll(this Vehicle vehicle) => vehicle switch
{
    Car => 2.00m,
    Truck => 7.50m,
    null => throw new ArgumentNullException(nameof(vehicle)),
    _ => throw new ArgumentException("Unknown type of a vehicle", nameof(vehicle)),
};
```
Deklaratsiya namunasi kabi, type patternda ifoda natijasi null bo'lmaganda va uning ish vaqti turi yuqorida sanab o'tilgan shartlarning istalganiga javob berganda ifodaga mos keladi. Shuningdek, siz ushbu naqshni aniq, qisqacha null tekshiruvi uchun ishlatishingiz mumkin:

```
if (input is not null)
{
    Console.WriteLine(input);
} else
{
    throw new ArgumentNullException(paramName: nameof(input), message: "Input should not be null");
}

```
Qo'shimcha ma'lumot olish uchun  [declaration pattern](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-8.0/patterns#declaration-pattern) va [type pattern](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/patterns3#type-patterns) bo'limlariga qarang.
JAVASCRIPT DISPLAY POSSIBILITIES.
Tags: javascript, beginners, tutorial, webdev
Published: 2022-05-30 01:18:25

**

## WHAT IS JAVASCRIPT DISPLAY POSSIBILITIES ?
**
       JavaScript display output or display possibilities is the feasible ways of displaying the output of a given code. Just like in CSS the “display” property when the value is set to “flex” it changes the default display of the container be it inline or block element property.  
       
  **<u>  JavaScript Display Possibilities</u>**
The output can be display by using four different ways which are listed below:

1. **innerHTML:**
 This method sets or returns the HTML content of an element. You can also say that it is used to access an element.  
`    <p id="cool">hey</p>
    <script>
        document.getElementById('cool').innerHTML = "Hello world!";
    </script>.`

2. **document.write():**   
 This method is mostly used for testing purpose. it is used to write some content or JavaScript code in a Document. also used to delete all the content from the HTML document and inserts the new content.
    `    <script>
         document.write('How are you?');
        </script>`

3. **window.alert():**
 You can use alert box to display data. The alert box is mostly used when you want an information to come through to the user. It is displayed with a message and an OK button.
`   <script>
      window.alert("Hello world!")
      alert(" HEY!" )
  </script>`
**NOTE:** These are both the same syntax.
            
4. **console.log():**
 The console.log() method outputs a message to the web console. The message may be a single string or it may be any one or more JavaScript objects.
  `     <script>
            console.log(6+3)
       </script>`
Spring AOP - Reusable Pointcut Expressions
Tags: spring, aop, java
Published: 2022-05-30 01:16:03

## Pointcut
A pointcut is a collection of one or more joinpoints where an advice should be invoked. You can declare pointcuts utilizing expressions or patterns like you'll see in the examples below.

## Syntax
_@Pointcut(" execution(modifiers? return-type declaring-type? method-name(param) throws?) ")_

- the pattern is optional if it has a **?** symbol
- patterns can use wildcards * (matches everything)
- the **@Pointcut** annotation contains a set of one or more JoinPoints where an advice should be executed
- **modifiers?** (optional) is the method's access modifier like public, protected, private
- **return-type** is the method's return type
- **declaring-type?** (optional) is the package or class name
- **method-name(param)** is the method's name with its parameters
- **param** could take zero or more arguments. _() matches a method that takes no parameters, whereas (..) matches any number of parameters (zero or more). The pattern (*) matches a method taking one parameter of any type_
- **throws?** (optional) is the exception type

## Combining Pointcut Expressions
**You can combine pointcut declarations using:**
&&, ||, ! operators


##Examples
**Declare pointcut methods (must not have a body)**
```
@Pointcut("execution(public * dev.company.*.service.*.get*(..))")
public void pointCutTemplateServiceForGet() {}

@Pointcut("execution(public * dev.company.*.service.*.post*(..))")
public void pointCutTemplateServiceForPost() {}

@Pointcut("execution(public * dev.company.*.service.*.delete*(..))")
public void pointCutTemplateServiceForDelete() {}
```


**Reuse a pointcut**
_In this example, we use the pointcut template pointCutTemplateServiceForGet() twice for two different advice_
```
@Before("pointCutTemplateServiceForGet()")
// implementation goes here
```

```
@After("pointCutTemplateServiceForGet()")
// implementation goes here
```


**Combine multiple pointcuts using &&**
```
@After(pointCutTemplateServiceForGet() && pointCutTemplateServiceForPost())
// implementation goes here
```


**Exclude a pointCut using !**
```
@Before(pointCutTemplateServiceForGet() && !(pointCutTemplateServiceForDelete()))
// implementation goes here
```


**Exclude multiple pointcuts**
```
@Before(pointCutTemplateServiceForDelete() && !(pointCutTemplateServiceForGet() || pointCutTemplateServiceForPost()))
// implementation goes here
```

There are many more possibilities when mixing and matching pointcut expressions, but I'll leave it up to your imagination.

_See [this article](https://dev.to/tommyc/spring-aop-quick-start-3o39) to learn more about Spring AOP._
🔑 Habilidad Técnica: 6. Conocimiento de tecnologías complementarias 🧠
Tags: spanish, career, latam, beginners
Published: 2022-05-30 00:54:09

Te volverás senior y querrás resolver todos los problemas con lo que has aprendido, pero no porque te vuelvas muy bueno utilizando un martillo deberás de verle cara de clavo a todo. 

Será posible que a veces tengas que recomendar o implementar tecnologías que complementen lo que sabes y que ayuden a resolver los problemas a los que te puedes enfrentar. 

El reto como siempre, al querer conocer nuevas o diferentes tecnologías es el distinguir las señales entre tanto ruido que hay en la industria.

En los últimos años hemos escuchado muchísimas tecnologías: 
* Big data
* Inteligencia Artificial
* Machine Learning
* Blockchain
* web3
* Serverless
* Headless
* Progressive Web Applications
* NoCode / LoCode
* etc.

Es un mundo de términos… de hecho es común que en nuestra industria suframos de FOMO (Fear of Missing Out), miedo a perdernos las oportunidades, porque de eso se tratan las historias de éxito a las que aspiramos, de un momento en el que alguien no tuvo miedo, se aventó y se hizo millonario, en tecnología estamos demasiado expuestos a eso.

Tenemos dos opciones, la primera es, aprenderlo todo, la segunda es, no aprender nada, si tomas alguna de esas dos estas perdido en tu proceso de desarrollo profesional. 

Si creo que debes de estar familiarizado con muchos de esos términos, porque muchas veces participarás en discusiones en donde se hable de estos conceptos, no tienes que ser capaz de defenderte siempre contra ellos o poder argumentar en su favor, pero no conocerlos puede hacer que te vean como alguien inexperto, recuerda que mi objetivo es que pases de ser Junior a Senior, conocer otras tecnologías es algo que debes de tener en cuenta y hacer de forma constante, tampoco significa que debas conocerlo todo.

---

Sigo trabajando en mis productos con el fin de ayudar de forma más estructurada a la comunidad de TI, si te interesan [pásale a mi perfil de Gumroad](https://marianorenteria.gumroad.com/)
- 📕 Líder Técnico
- 📘 De Junior a Senior
- 🗓 Mentorías
- 📑 Revisión de C.V.

Te invito a que **[me sigas en Twitter](https://twitter.com/marianorenteria/)** para que te enteres de todo el contenido que hago normalmente 🙃.

También soy creador del [podcast Chile, Mole & Tech](#)(https://dev.to/chilemoleytech), el cual esta [en todas las plataformas](#)(https://linktr.ee/chilemoleytech).

** Si te gusto este post, no dudes en compartirlo, me ayuda mucho. **
100+ Project Idea Resources for Web Developers
Tags: javascript, webdev, productivity, react
Published: 2022-05-30 00:32:17

## Out of app ideas?
Have you ever felt like you want to build something, something that's interesting but you're out of app ideas! It doesn't matter if you're a beginner or an expert, everyone feels this for sure at some point of time. Don't worry, I've got you covered! I'll be sharing project idea resources for all 3 categories of developers - beginners, intermediates and experts.

## Resources
- [App Ideas by Florin Pop](https://github.com/florinpop17/app-ideas#tier-1-beginner-projects) It has a list of almost 80 web app ideas ranging from beginner level to expert level, the project is no longer maintained but you also check out the open issues/pull requests for more app ideas!
- [App Ideas by Flavio](https://flaviocopes.com/sample-app-ideas/) It has a list of simple app ideas ranging from beginner to intermediate, check it out.
- [Frontend Mentor Challenges](https://www.frontendmentor.io/challenges) Frontend Mentor has a lot of free challenges available for beginners to experts which you can build as projects. 
- [CodeDamn Projects](https://codedamn.com/projects) A library of different projects to make ranging from easy to hard
- [App Ideas by JSBeginners](https://jsbeginners.com/javascript-projects-for-beginners/) It has a list of 100+ simple JavaScript ideas for beginners only and it's well structured.
- [r/AppIdea](https://www.reddit.com/r/AppIdeas/) This is a subreddit dedicated to posting different app ideas ranging from beginner to expert, scroll through the posts, you might just find your next app idea there!
- [GitHub](https://github.com/) GitHub has millions of projects made by different users saved as repositories, you just need to find them.

## Conclusion
You may save this blog to look at whenever you feel out of app ideas, and don't forget to bookmark the sites provided above!
Thanks for reading, Happy Developing ❤
How does JavaScript work in browsers? A quick explanation?
Tags: javascript, browser, programming, webdev
Published: 2022-05-30 00:27:51

We know that JavaScript code runs on the browser. The browser has a browser engine to execute the program. Google chrome has v8 engine, fire-fox has Spider monkey engine, Internet Explorer has Chakra engine.

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

Let’s take an example v8 engine of chrome browser. When v8 engine takes the JavaScript code from the js program source files then v8 engine starts parsing the code using “parser”. Then parsing is converted into “Abstract Syntax Tree(AST). After that interpreter converts this Abstract Syntax Tree to “Byte-code” or by using “Just in Time Compiler “optimized machine code”. Just in Time Compiler Increases the performance and code runs faster. In this way JavaScript code works in v8 engine to execute the program.
Docker MySQL setup on Mac OS X
Published: 2022-05-30 00:24:26

# Kill all running docker containers

```
docker ps -aq | xargs -r docker stop; docker ps -aq | xargs -r docker rm
```
# Start a MySQL server
*Very Important* is the flag `MYSQL_ROOT_HOST` is set to `%`.

```
docker run -d --name=local-mysql -p 54321:3306 -e MYSQL_ROOT_HOST=% -e MYSQL_ROOT_PASSWORD=password mysql/mysql-server
```

# Connect to MySQL using mac's mysql

```
export PATH="$PATH:/usr/local/mysql/bin"
# restart shell if required
mysql -h 127.0.0.1 -P 54321 -u root -ppassword
```

# Docker Compose Setup

```
version: '3'

services:
  db:
    image: mysql:5.7
    container_name: db
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_ROOT_HOST: '%'
    ports:
      - "54321:3306"
    volumes:
      - dbdata:/var/lib/mysql
volumes:
  dbdata:

```

Save the above file as `docker-compose.yaml`. Then run the following commands to start/stop the container. The container will persist data across restarts. If you want to clean up the volume use `docker-compose down -v` command.

```
docker-compose up
docker-compose up -d # runs in the background
docker-compose down
docker-compose down -v
```
When you realize half your car is stuck in a frozen lake.
Tags: python, mentorship, beginners
Published: 2022-05-30 00:10:32

One time I was driving on an icy road in my GTI. Then I heard a crunch and it tilted sideways.

It was actually partially the bank of a river that had such thick ice it seemed like a flat road. I immediately did everything I could to prepare for the recovery truck, but without them I was stuck.

I've wound up in this situation with my Python project. I Came up with an exciting project idea, judged it within my ability to execute, made quite good progress until... crunch. Tilt. Splash. I'm stuck.

This is something people gloss over when saying anyone can learn to code on their own. The ability to wave over a teacher or ask a student next to you if they can help can save hours of research, trial, and error. Furthermore with an instructor overlooking your attempts to get unstuck, you're less likely to come up with a fragile or unsafe solution. 

All this is to say my wonderful project is stuck, and boy I wish I had a Python tow truck to help me out. 

- Jas
Code Europe: Protect your code with GitHub's security features
Published: 2022-06-17 21:26:59

---
title: Code Europe: Protect your code with GitHub's security features
published: true
date: 2022-05-30 00:00:00 UTC
tags: 
canonical_url: https://devopsjournal.io/blog/2022/05/30/Code-Europe
---

I have the pleasure of speaking at [Code Europe](https://www.codeeurope.pl/en/speakers/rob-bos) and these are the slides for it:

Creating modern software has a lot of moving parts. We all build on top of the shoulders of giants by leveraging closed/open source packages or containers that other people have shared. That makes securing our software a lot more complex as well!

In this session you’ll learn what possible attack vectors you need to look for, how to protect yourself against them and how to leverage GitHub’s features to make your life easier!

Topics:

- Signed Commits
- Dependabot updates
- Dependency scanning for known vulnerabilities
- Secret scanning (and revoking) out of the box
- Using CodeQL

You can download the slides [here](https://devopsjournal.io/slides/20220530%20Code%20Europe%20Protect%20your%20code%20with%20GitHub%20security%20features.pdf).

[![Opening slide of the presentation](https://devopsjournal.io/images/20220530/20220530_Opening.png)](https://devopsjournal.io/slides/20220530%20Code%20Europe%20Protect%20your%20code%20with%20GitHub%20security%20features.pdf)
Problem's faced in Dijkstra's Java Code || Leetcode
Tags: java, dijkstra, graph
Published: 2022-05-29 22:51:41

When I am solving questions on Dijkstra's, I had basically two-way (or Java template) to write code for Dijkstra's, but for some questions, problem solved by both ways (or Dijkstra's Java templates) (https://leetcode.com/problems/network-delay-time/) are accepted and for some (e.g., https://leetcode.com/problems/path-with-minimum-effort/), anyone is able to solve the question.

For a graph (represented in Adjacency List):
```
ArrayList<int[]>[] graph = new ArrayList[n]; // n represents number of nodes.
```

**1. Dijkstra's - One way**
```
boolean[] vis = new boolean[n];
int[] dist = new int[n];
Arrays.fill( dist, Integer.MAX_VALUE );

PriorityQueue<Integer> q = new PriorityQueue<>( (a,b) -> dist[a] - dist[b] );
q.add( 0 ); // Starting node
dist[start] = 0;

 while( !q.isEmpty() )
 {
     int node = q.poll();

     if( vis[node] )
         continue;
     vis[node] = true;

     // traversing neighboours
     for( int[] nb : graph[node] )
     {
         int node2 = nb[0];
         int weight = nb[1];
         if( !vis[node2] && dist[node2] > dist[node] + weight )
         {
             dist[node2] = dist[node] + weight;
             q.add( node2 );
         }
     }
 }
```
**2. Dijkstra's - Second way**

```
 boolean[] vis = new boolean[n];
 int[] dist = new int[n];
 Arrays.fill( dist, Integer.MAX_VALUE );

 PriorityQueue<int[]> q = new PriorityQueue<>( (a,b) -> a[1] - b[1] );
 q.add( new int[2] ); // Starting node
 dist[start] = 0;

 while( !q.isEmpty() )
 {
     int node = q.peek()[0];
     int dis = q.peek()[1];

     if( vis[node] )
         continue;
     vis[node] = true;

     // traversing neighboours
     for( int[] nb : graph[node] )
     {
         int node2 = nb[0];
         int weight = nb[1];
         if( !vis[node2] && dist[node2] > dis + weight )
         {
             dist[node2] = dis + weight;
             q.add( new int[] { node2, dist[node2] } );
         }
     }
 }
```
Can anyone, help me to know which is the right way (1st or 2nd).
Elixir, Kubernetes, and minikube
Tags: elixir, kubernetes, minikube
Published: 2022-05-29 23:03:41

---
title: Elixir, Kubernetes, and minikube
published: true
description: Deploy Elixir to a minikube cluster
tags: elixir, kubernetes, minikube
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d6qfipkffvpd1a44aiaj.png
canonical_url: https://blog.miguelcoba.com/elixir-kubernetes-and-minikube
---

A couple of weeks ago I presented my talk:

**Elixir, Kubernetes, and minikube**

in the Elixir Meetup #5 organized by the fine people on curiosum.com.

This talk is based on chapter 4 of my book ["Deploying Elixir: Advanced Topics"](https://store.miguelcoba.com/l/advancedtopics). 

If you haven't gotten the book, this is an excellent way to see what the book is about.

Watch the recorded talk here:

{% embed https://www.youtube.com/watch?v=AvUPX6cAjzk&t=995s %}


## About

I'm [Miguel Cobá](https://miguelcoba.com). I write about Elixir, Elm, Software Development, and eBook writing.

- Follow me on [Twitter](https://twitter.com/MiguelCoba_)
- Subscribe to my [newsletter](https://newsletter.miguelcoba.com)
- Read all my articles on my [blog](https://blog.miguelcoba.com)
- Get my books:
    - [100 Elixir Tips](https://store.miguelcoba.com/l/100elixirtips) [FREE]
    - [Deploying Elixir](https://store.miguelcoba.com/l/deployingelixir) [FREE]
    - [Deploying Elixir: Advanced Topics](https://store.miguelcoba.com/l/advancedtopics)
    - [eBook Writing Workflow for Developers](https://store.miguelcoba.com/l/ebookwriting)
Just signed up!
Tags: javascript, webdev, html, css
Published: 2022-05-29 23:00:48

Hi, I'm new here! Decided to try and meet like mind developers and shared some of the bits I work on in my spare time.

[One of my projects can be found here: Calendar.js](https://github.com/williamtroup/Calendar.js)

There of course other ones on there, but little things I've thrown together over the years!
Quote to image Next.js App Devlog | Part 1
Tags: nextjs, javascript, react
Published: 2022-05-29 22:59:44

_Note: contributions to the code [here](https://github.com/ArcaEge/quote-overflow) are more than welcome_

I am the sort of person who gets random ideas at random times. This project started with one of those ideas.

## The Idea
I'm going to build a web app using Next.js that overlays user-defined text on top of an user-defined image. The images are each going to be a 'design', and each design will be able to be published. So basically, Canva but it's simpler, more focused and of course, completely free and open source. Because paid stuff mostly sucks.

## The frameworks and libraries
Storing all the designs in local storage wouldn't be enough, and I wanted an easy-to-implement, free OAuth login (sign in with Google, Github etc). Then, after a bit of googling I found [NextAuth.js](https://next-auth.js.org/).

I decided to use Prisma to simplify the database models, and connected that to NextAuth. I used Mantine for the frontend components because:

- Bootstrap doesn't look good without modifying half the CSS - the website doesn't have that 'pop'.

- Tailwind requires too much work and isn't a component library anyway.

- There are many other component libraries but Mantine is the most professional-looking one that I managed to find yet. It's also quite easy to work with.

That being said, I'll be explaining the rest of it in the next episode (if I manage to make one).