teleren/devto huggingface dataset:
Little drops on C# Interview questions- Stack x Heap.
Tags: csharp, dotnet, beginners
Published: 2020-07-03 20:52:17

## Little drops on C# Interview Questions series

This is the first drop, the intentions behind this series are to answer with a little bit of context or examples some of most commons C# interview questions.


## So Stack and Heap

First of all, both are inside the computer's RAM.  The key difference is the stack is used for static memory allocation and Heap for dynamic memory.

And then you say "Ok Pedro, but this means nothing to me"

I'll answer "Calm down we're starting"

## Stack

Variables allocated at the stack are available when your program is compiled hence the static allocation, the access to this memory is very fast. This memory area allows us to have stored function or methods calls in LIFO order allowing us to preserve our local variables on standby until a return occurs.

### The web site that does most of the developer job Exception

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/jd1jssauk0a7il3brt5y.gif)

More known as StackOverflow exception, this occurs because we have a limited memory region that is going to be used for the stack if a certain quantity of methods exhausts the quantity of memory available this will cause a StackOverflow exception. (This means that you F** up).

## Heap

The heap is memory set aside for dynamic allocation which means everything stored here will be stored at runtime making the access a little bit slower, but the size limitations are equals to the size of the virtual memory. The elements here are independent of one another and can be accessed at any time. The allocation block can be also freed up anytime.

## When to use each

The heap will be used for everything that you need to be stored at runtime and you don't know exactly how much data you'll allocate on the memory, on the other hand, the stack can be used for data that you'll know exactly how much data it takes and it will be stored at compile time.

## Multi-thread situations

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bd6efe1uws0bnjs9tssm.gif)

The stack is thread-specific and Heap application-specific.

The funny thing about situations like this, you can find each thread having its complexity and independent stacks but at the same time, they'll share the Heap. 

## References

If you know portuguese an awesome article going a little deeper on the stack can be found at:

[https://www.eximiaco.tech/pt/2019/05/30/entendendo-a-stack-e-a-stackoverflowexception/](https://www.eximiaco.tech/pt/2019/05/30/entendendo-a-stack-e-a-stackoverflowexception/)
Print coloured text in python
Tags: python, beginners, codenewbie, tutorial
Published: 2020-07-03 20:45:04

Hello,Today we will print coloured text in python.
First, we will install <code>ansi-colours</code> moudle.
<pre>
pip install ansi-colours
</pre>
After installing we will import ansi-colours as colour
then print your sentence after choosing the color.
```python
from ansi_colours import AnsiColours as colour
print(colour.red('Follow') + colour.blue('ME!'))
```
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/efhuc44ldpo8f3u0930x.png)
<a href="https://www.buymeacoffee.com/Oxyoxide" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/lato-green.png" alt="Buy Me A Coffee" style="height: 51px !important;width: 217px !important;" ></a>
twitter:https://twitter.com/Oxy_oxide
buy me a coffee : https://www.buymeacoffee.com/Oxyoxide
Don't forget to follow me.
Thanks for reading.
Hacktoberfest Prizes
Tags: question
Published: 2020-07-03 20:18:37

---
title: Hacktoberfest Prizes
published: true
description: 
tags: question
//cover_image: https://direct_url_to_image.jpg
---

Did everyone receive their hacktoberfest prizes? Not sure if mine got lost. Or stuff is just delayed due to the pandemic.
Introducing The sustainable.dev
Tags: sustainable, development, environment, climatechange
Published: 2020-07-03 20:02:01

---
title: Introducing The sustainable.dev
published: true
description: The sustainable.dev is a new resource for learning more about sustainable web development
tags: sustainable, development, environment, climatechange
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/3ajan56vmwyve044ewhi.jpg
---

Hey everyone! I wanted to post up to tell you all about my new side project.

https://the-sustainable.dev/

##So, what is it?
The sustainable.dev will become a resource for businesses to find development agencies and freelance developers who are working to create a greener web.

It will also be a resource to help those developers to work more sustainably. This content will include tips, tricks, case studies and blog content to help push ourselves as developers in thinking more thoroughly about our work and the websites / webapps we are creating - making them as sustainable as possible.

##What is the goal?
The hope is that many more awesome creators can be making websites that use as little carbon as possible, whilst still being creative, engaging and of course, accessible.

##How to get involved
If you would like to know more and find out when it launches you can sign up for [emails](https://mailchi.mp/9c5235dc0c6b/the-sustainabledev) or follow on Twitter [@sustainabledevs](https://twitter.com/sustainabledevs)

##How are you being sustainable?
I'd love to know how other developers feel about sustainable and green web development, and what you as an individual or team are doing to help combat climate change in your work. Let me know in the comments!


**Let’s make a better, more sustainable web, together.**
My first laravel + vue App
Tags: webdesign, laravel, vue, tailwindcss
Published: 2020-07-03 19:41:24

If you are a beginner in development and you are yet to build your first project, what are you waiting for? give it a shot, even if it has to do with following up a tutorial project, add some spice to it along the way. This project was inspired by andre Madarang youtube channel (https://www.youtube.com/playlist?list=PLEhEHUEU3x5pYTjZze3fhYMB4Nl_WOHI4). The fact that it was a project made by following his youtube tutorial, doesn't mean it was easy. There was quite a boatload of hiccups and obstacles along the way, which almost made me give up on the project. But, I really wanted to complete this project of mine. I really wanted to assign such accomplishment to myself, all of which kept driving me to continue.it began with a mindset of wanting to learn laravel PHP framework, I downloaded several books, but they weren't giving me the push I needed, then I decided it's best I challenge myself big time. Then, my next step was to go to youtube, on searching for laravel, brad traversy media's laravel course came up (https://www.youtube.com/playlist?list=PLillGF-RfqbYhQsN5WMXy6VsDMKGadrJ-). I followed up his tutorial, and I can tell you, he was really good, but deep down inside I needed something much more advanced, something that pose to become a real challenge. On the quest for this, andre course showed up. At first, the course is based on building aa movie app, using TMDB's Api and laravel 7 HTTP client, this alone was enough to spike my interest. So, I was like well..... Let's get to it. We started out by first installing all the needed dependencies, compiling the needed assets via webpack and then building out the UI using Tailwind CSS. This is the first of hearing about tailwind CSS, I wasn't ready to learn a new CSS framework, so I decided to follow up using my knowledge of bootstrap, to cut the long story short, I just decided to give Tailwind a try and it turned out to be great. Along the way, some of the obstacles I faced was integrating laravel livewire (for the play trailer button) and alphine js(for the search component). Eventually, I decided to use my very own vue js to write out the search component, using a step by step guide from (Christain Nicholas - create a searchable dropdownlist-medium)article, which also increased my problems.
1. vue js doesn't use blade routing.
2. I had to learn Axios, in order to call the search API endpoints into laravel.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/kr832pyr04nyv5edrwmv.png)
To fix the issue of routing in vuejs, vue router wasn't an option for I wasn't building a SPA, so I had to parse the link manually.
All in all, it was a really good experience, tackling problems and debugging the app, really gave me a sense of purpose, of wanting to become a developer. Do check out the app at https://zonamv1.herokuapp.com/. I plan to release more features to it in the nearest future. Explore, but please don't break.
if you ever want to learn a new framework, try watching a project being built out of it, to begin with, then venture into whichever method works best for you.
#029 Kubernetes - kubeadm
Tags: kubernetes, devops, tutorial
Published: 2020-07-03 19:29:44

# Introduction

this is part 28 from the journey it's a long journey(360 day) so go please check previous parts , and if you need to walk in the journey with me please make sure to follow because I may post more than once in 1 Day but surely I will post daily at least one 😍.

And I will cover lot of tools as we move on.
***

# Kubeadm
![setup](https://dev-to-uploads.s3.amazonaws.com/i/ljsrn9fds56udwmxluo5.png)
Kubeadm is a working environment , used in a big project that is entering the production phase , and working and there is customers. 
Kubeadm is best for private servers , let's say with 5 servers so you need to make a cluster from those 5 servers.

1. In Kubeadm , in those 5 servers you need Linux installed on Them also docker , because Kubernetes and Docker are build for Linux in first place.
2. Install kubeadm tool to install on all the servers.
3. Initializing for the master , and it's preferred to use the server with best specs , apiserver is the tool that I can communicate through it with the server.
![network](https://dev-to-uploads.s3.amazonaws.com/i/2nhgkmre5ctlhd4k1p0n.png)
4. Choose the network plugin that all those nodes(servers) can communicate on this cluster. For now we don't have a cluster yet so for now they are normal servers.
![joined](https://dev-to-uploads.s3.amazonaws.com/i/6dzlows3ain90lsxflm4.png)
5. Join workers with this network (using kubeadm join command) now every server will join the network.
![kubctl](https://dev-to-uploads.s3.amazonaws.com/i/ba5z1elyxiup1ua8e1r0.png)
6. kubctl is a command installed on local machine it translate my commands and send them to the master , and master take this command and communicate with the rest nodes. Not every one able to access it , there is an Authentication mechanism using a config file.

# End

this is an old way to setup a cluster you need to create many virtual machines to do it on single PC as a lab.
Now we have a IAC (Infrastructure as code) to do it. In up coming episode I will talk what we are going to use.
Benchmark para iniciantes - Go
Published: 2020-07-03 19:27:01

---
title: Benchmark para iniciantes - Go
published: true
description: 
tags: 
//cover_image: https://www.dauphinherald.com/resources/story/1563305110_5d2e2496c8f17_story.png
---

Eu sempre ouvi sobre benchmark nos meetups, nas lives, nas discussões, mas eu achava que seria algo tão dificil que só poderia estudar quando eu estivesse bem mais avançada na linguagem. Sim, estudar testes tem sido um desafio grande, mas lendo alguns artigos, documentação da linguagem me surpreendeu sobre a implementação. 

O benchmark é uma ferramenta incrível que o pacote testing oferece aos gophers. O benchmark é uma ferramenta de analise do desempenho do seu código em GO. 

Para implementar uma função benchmark não tem mistério e pode orientar a você sobre como seu código vai performando ainda em execução. 

ok, ok, chega de teoria e vamos para a prática…

Para implementar o benchmark vou usar como base a função Repeat que está salva no arquivo repeat.go.

~~~golang
package interation
 
const repeatCount = 5
 
// Repeat returns character repeated 5 times.
func Repeat(character string) string {
  var repeated string
  for i := 0; i < repeatCount; i++ {
     repeated += character
  }
  return repeated
}
 ~~~


No arquivo repeat_test.go eu implemento o teste da função e o  benchmark usando o pacote  [“testing”](https://golang.org/pkg/testing/ ).

~~~golang 
package interation
 
import (
  "testing"
 
)
 
func TestRepeat(t *testing.T) {
  repeated := Repeat("a")
  expected := "aaaaa"
 
  if repeated != expected {
     t.Errorf("expected %q but got %q", expected, repeated)
  }
}
 
func BenchmarkRepeat(b *testing.B) {
  for i := 0; i < b.N; i++ {
     Repeat("a")
  }
}
 
~~~
`

Para “rodar” o test benchmark basta chamar em seu terminal ` go test -bench=` ou ‘go test -bench="." ’ , caso voce esteja usando o windowns powershell.

No meu computador o resultado foi :

~~~
goarch: amd64
pkg: github.com/bellasouza/GOWithTest/interations
BenchmarkRepeat
BenchmarkRepeat-4   	 4988276	       211 ns/op
PASS

Process finished with exit code 0
~~~ 

Esse resultado significa que a minha função leva em média 211 nanosegundos para rodar 4988276 vezes a função.


---


### Considerações: <h3>
 Esses são os materiais valiosíssimos que me ajudaram a entender melhor sobre benchmark. 
Super indico a leitura:

* https://golang.org/pkg/testing/
* https://quii.gitbook.io/learn-go-with-tests/go-fundamentals/iteration
* https://dave.cheney.net/2013/06/30/how-to-write-benchmarks-in-go
iOS 14: What is new for WKWebView
Tags: ios, swift, ios14
Published: 2020-07-03 19:13:45

In this post let's go over some of the interesting changes for `WKWebView` in iOS 14.

### Sandboxing for JavaScript

There is new `WKContentWorld` type to represent the separation of website's JavaScript and JavaScript that developers inject into the page. They can now run in completely separate environments.

That means mainly that you don't have to worry about accidentally interacting with some website JS code and vice versa. So no naming clashes and also protections from malicious websites that may try to influence the app via JS communication.

There are two content worlds defined and these are `page` for the website environment and `defaultClient` which should be the first choice when injecting JS into the page.

`WKContentWorld` is a new parameter in methods like `evaluateJavaScript` or `callAsyncJavaScript` which we look at later in this post. This also applies to the `WKUserContentController` which allows you to send data from JavaScript to your app. This can now be associated with content world. So for example you have multiple instances and each within its own content world to prevent interference. 

### Better JavaScript evaluation with `callAsyncJavaScript`

This new method will likely be the most used way for running JS code in `WKWebView`. Mainly for two reasons. You can pass `arguments` parameter which is a `[String: Any]` dictionary and will be mapped to JS types. So you don't have to include those in the JavaScript string and can reuse it with different arguments.

What does the "async" in the method name means? It is an indication that this method can handle JS promises which are one of the option how JS handles asynchronous code.  If your JS code returns promise then the `completionHandler` of this method will not be called immediately and somehow return this promise but it will wait and you will get the value. This means `callAsyncJavaScript` can be trivially used with `fetch` to download any kind of data and then access it in Swift code.

### `findString`

As the name implies this method will let us find text in a webpage. You can do a bit of configuration or just use defaults that should work pretty well. The result is then selected and `WKWebView` automatically scrolls so the result is visible.

### Create PDF from page

Since iOS 11 we can take a snapshot of currently visible part of the page with the `createPDF` page which also lets us to configure the result we want.

### `pageZoom`

We can now easily zoom pages with this new property so we don't have rely on JavaScript to change the CSS to control zoom.

This was just a sort of high-level overview. For more watch the [Discover WKWebView enhancements](https://developer.apple.com/videos/play/wwdc2020/10188/) session.

*Note: Not all the new stuff is available in Xcode 12 Beta 1.*
It's my birthday!
Tags: wecoded, personal, motivation, watercooler
Published: 2020-07-03 19:09:14

That's all! :)

Okay, maybe a lil more.

This time last year I was barely able to remember how to write a for loop, recalling from college courses I took long ago. Mid-July of 2019 I decided to make a switch into programming and started teaching myself JavaScript. And now I'm here! Programming! Building! Interviewing (fingers crossed ;P)! Writing about it all!

I'm gonna take today to be kind to myself and cherish how far I've come.

With <3, happy coding!
Why is IBM cloud not widely used?
Tags: discuss, watercooler, cloud, ibm
Published: 2020-07-03 18:55:23

I started using IBM mainly because I needed more computing power for my machine learning projects, and I actually found IBM less complicated, cheaper (for my projects not sure about other usecases) and the overall user experience was much nicer than other cloud providers....and yet I don't know anyone in my network that uses IBM for their work or side projects?
PHP Composer: Speed Up Your Docker Build
Tags: devops, docker, php
Published: 2020-07-03 18:44:23

Once I was disappointed at dockerizing Nodejs applications. Runing `npm install` was like leaving earth for mars. Thanks to Yarn for saving my ass. But nowadays PHP composer has taken that place. Running `composer install` in Docker used to take a huge time and slow down CI/CD speed. But I've managed to speed up the build process with some ninja techniques.

### Rule 1

Use prestissimo with composer. It's a plugin to download packages in parallel. But I'd like to label it as Yarn of PHP. However, don't forget to install prestissimo before running actual `composer install`.

```dockerfile
RUN composer global require hirak/prestissimo
```

Before using this plugin, one of my Dockerfile used to take **5m49s** to be built while taking only **2m4s** with the plugin. Whoa!

If you are wondering how I am counting time:

```bash
$ time docker build --no-cache .
```

### Rule 2

Don't use `composer install` alone. Use the following options to save your time:

| Options | Description |
| :--- | :--- |
| --no-scripts | Disables the execution of the scripts defined in the root package. |
| --no-interaction | Do not ask any interactive question. |
| --no-autoloader | Skips autoloader generation. |
| --no-dev | Excludes suggestions from require-dev packages. |
| --prefer-dist | Install packages from dist when available. |

Here's an example:

```dockerfile
RUN composer install --no-scripts --no-interaction --no-autoloader --no-dev --prefer-dist
```

### Rule 3

Add your `composer.json`, `composer.lock` files and run `composer install` before adding the main source code. The reason is pretty straightforward. These composer files won't change frequently comparing with your main source codes. You'll get the benefits from Docker cache.

```dockerfile
ADD composer.json composer.lock ./
RUN composer install --no-scripts --no-interaction --no-autoloader --no-dev --prefer-dist
ADD . ./
```

If I sum up the whole thing, your Dockerfile might have this part to speed up the Docker build:

```dockerfile
RUN composer global require hirak/prestissimo
ADD composer.json composer.lock ./
RUN composer install --no-scripts --no-interaction --no-autoloader --no-dev --prefer-dist
ADD . ./
```

### Rule Nth

Have you heard about [dive](https://github.com/wagoodman/dive)? It's a tool for exploring a docker image, layer contents, and discovering ways to shrink the size of Docker/OCI image. I used to use dive to find out improvement areas. To analyze a Docker image simply run dive with an image tag/id/digest:

```bash
$ dive <your-image-tag>
```

Or, if you want to build your image then jump straight into analyzing it:

```bash
$ dive build -t <some-tag> .
```

Very easy, isn't it? Don't forget to check on GitHub for more clear documentation.

> Originally published at https://blog.maateen.me on July 1, 2020.
Building a Blog - Let's Get Started!
Tags: java, learning, codenewbie
Published: 2020-07-03 18:35:16

For a while now, I have been trying to keep up with writing articles for [my blog](http://www.rosafiore.eu/). Even though there is so much I want to learn, I still feel like I have trouble keeping a regular schedule for writing my articles. Currently, I'm using WordPress for managing my content, but last week I thought: why not building a blog from scratch?

With this project, I want to try and host my blog with a custom back-end and front-end. WordPress is awesome, don't get me wrong, but it is also cool to write everything myself. That gives me the opportunity to try new technologies and expand my knowledge. It is a work in progress and also a way for me to get more experienced with software engineering which means that changes will happen halfway the project. I might even fully overhaul it at some point, but it is all for the sake of learning, experimenting and of course having fun.

## Simple Requirements for Building a Blog
In order to start building a blog, it is important to have a set of requirements ready. It gives a bit of an overview of the project and a guideline to keep in mind. That is why I have decided to write down my requirements, so I can keep track of what I want in my system. Since this project is bound to grow and change, I want to start with something simple and basic. Then I can continue working out the specifics and more fancy features. So, I have comprised the following requirements for my project:
- Database saves all the metadata and location of the blog post
- A blog post can be retrieved from the database
- A blog post can be posted to the database
- A blog post can be shown

The requirements are simple, but they cover the basics for building a blog. I have already decided to go for a Spring Boot back-end, because I'm most familiar with Java. However, the next decision to make is deciding which type of database I will use for this project. That will be a post for next time.

If you want to follow the project and peek along with the code, feel free to check out [my GitHub repository](https://github.com/Rosaa-xd/rosafiore). However, if you have any tips, or things I should look into, I would love to read your suggestions in the comments below!