teleren/devto huggingface dataset:
Three months with M1 Macbook Air as a mobile developer
Tags: flutter, dart, macbook, m1macbook
Published: 2021-02-04 21:04:41

Being a flutter developer almost for three years, I always had to use virtual machines on my windows laptop to test and run flutter applications on ios device. It was always a terrible experience. It took so much time that sometimes I had to leave it for compiling for more than 15 minutes for a simple app.
But then in November, 2020 Apple released their new MacBooks with an M1 chip. 
Initially, I was very skeptical about the real-life performance of the M1 chip, so I waited for around 2 weeks to check some reviews on YouTube and from the Flutter community. 
After waiting for two weeks I pushed the trigger and bought the M1 MacBook Air 512GB, and I will call this the best investment in my mobile app development journey. 
The battery timing is awesome 8 hrs+ easily, and the performance is through the roof. The 2019 or early 2020 MacBooks are almost useless for development purposes but M1 MacBooks are the gamechanger.
Till now I have developed more than 10 apps using this mac and my experience is awesome. If someone will ask me about the recommendation before getting a new laptop without any doubt I will recommend MacBook Air - M1 without any hesitations.

You can find me on GitHub @ AasharWahla
and on LinkedIn @ AasharWahla
JavaScript Loops - Codecademy PRO version
Tags: tutorial, javascript, webdev, beginners
Published: 2021-02-04 20:55:17

**TL;DR:** I completed the **Loops** course in **JavaScript: Arrays, Loops, and Objects** module on Codecademy. This is a part of the 🔗 [**Codecademy Web Development Career Path**](https://youtube.com/playlist?list=PL7K3igiHYVk1_ulFuHesiv7BP_ALn82o8) series.



You can find the video on YouTube below ⬇️
{% youtube HZcQBxTCzGg %}



*If you like the video, don't forget to smash that like icon* 👍 *and subscribe* ❤️*. It will help a lot! Thanks!* 🙏



⏱️ Chapters:
🔗 [0:00](https://www.youtube.com/watch?v=HZcQBxTCzGg) Intro
🔗 [0:34](https://www.youtube.com/watch?v=HZcQBxTCzGg&t=34s) Loops
🔗 [2:08](https://www.youtube.com/watch?v=HZcQBxTCzGg&t=128s) Repeating Tasks Manually
🔗 [4:38](https://www.youtube.com/watch?v=HZcQBxTCzGg&t=278s) The For Loop
🔗 [9:02](https://www.youtube.com/watch?v=HZcQBxTCzGg&t=542s) Looping in Reverse
🔗 [10:22](https://www.youtube.com/watch?v=HZcQBxTCzGg&t=682s) Looping through Arrays
🔗 [14:02](https://www.youtube.com/watch?v=HZcQBxTCzGg&t=842s) Nested Loops
🔗 [20:05](https://www.youtube.com/watch?v=HZcQBxTCzGg&t=1205s) The While Loop
🔗 [24:50](https://www.youtube.com/watch?v=HZcQBxTCzGg&t=1490s) Do...While Statements
🔗 [28:42](https://www.youtube.com/watch?v=HZcQBxTCzGg&t=1722s) The break Keyword
🔗 [33:34](https://www.youtube.com/watch?v=HZcQBxTCzGg&t=2014s) Review Loops
🔗 [34:35](https://www.youtube.com/watch?v=HZcQBxTCzGg&t=2075s) Whale Talk
🔗 [46:50](https://www.youtube.com/watch?v=HZcQBxTCzGg&t=2810s) Loops Quiz



📚 Materials/References:
🔗 [Javascript Loops cheatsheet](https://www.codecademy.com/learn/paths/web-development/tracks/web-dev-js-arrays-loops-objects/modules/learn-javascript-loops/cheatsheet)

Thanks for reading! I hope you find it useful.
Using Vue JS with HTML and CSS
Tags: vue, javascript, html, css
Published: 2021-02-04 20:45:14

#What is Vue JS???
Vue JS is an open source view model for JavaScript.  After creating a resume using HTML and CSS, I wanted to dive deeper into the language and incorporate some JavaScript also.  Although all I created was the simple header for my resume, it was still very interesting to see how JavaScript works with HTML.  To first get started, one must copy a script tag into their HTML source code.  This is so the HTML and CSS knows that they are working with Vue JS.

##Now What?
For the header I created, I used the component to change my H1 tag, H2 tag, occupation tag, and photo tag.  I added the new Vue to have these data values.    Once created, all I had to do was add new div id and div classes to my HTML code.  Once in the HTML source, for example, I used the h1 class "name" and used my JavaScript code to change the header to name.first and name.last.  This would print out whatever value first and last are in the JavaScript.  That way, there was more than one place for a name, than instead of typing your name out every time, you can just use the JS tags.  

I next did the exact same thing for the H2 class.  Now every time there needs to be a job printed out, you can change the code in the JS source and use the occupation.job.  This way, it will print out anything in the job source.

Finally, for HTML to print out my photo, I needed to include the source where it was coming from.  Once I had the link, I created a photo class in the JS code.  Back in the HTML code, I had to add the img v-bind: src = "" so that the HTML can properly read the photo tag from the JavaScript.

##What About the HTML and CSS?
When writing the new JS code, all of the CSS stayed the same.  Other than some formatting, there was no extra code added.  Now in the HTML code, it had to be modified so it could accept the JavaScript.  After it was modified, everything worked as a team to print out a basic header from my resume.


Here is the Codepen source so you can play around with it:
[Codepen Example](https://codepen.io/savagenova/pen/eYBJYOW)

Here is a video explaining what I did in more detail:
[YouTube Explanation](https://www.youtube.com/watch?v=rBm1fz5kp9Q&t=2s)
Solution: Longest Harmonious Subsequence
Tags: algorithms, javascript, leetcode
Published: 2021-02-04 20:43:04

*This is part of a series of Leetcode solution explanations ([index](https://dev.to/seanpgallivan/leetcode-solutions-index-57fl)). If you liked this solution or found it useful,* ***please like*** *this post and/or* ***upvote*** *[my solution post on Leetcode's forums](https://leetcode.com/problems/longest-harmonious-subsequence/discuss/1049913/Javascript-or-Frequency-Map-Solution-w-Explanation-or-beats-100).*

---

####[Leetcode Problem #594 (*Easy*): Longest Harmonious Subsequence](https://leetcode.com/problems/longest-harmonious-subsequence/)

---

***Description:***

*We define a harmonious array as an array where the difference between its maximum value and its minimum value is __exactly__ `1`.*

*Given an integer array `nums`, return the length of its longest harmonious subsequence among all its possible subsequences.*

*A __subsequence__ of array is a sequence that can be derived from the array by deleting some or no elements without changing the order of the remaining elements.*

---

***Examples:***

Example 1:||
|---|---|
*Input:*|nums = [1,3,2,2,5,2,3,7]
*Output:*|5
*Explanation:*|The longest harmonious<br>subsequence is [3,2,2,2,3].

Example 2:||
|---|---|
*Input:*|nums = [1,2,3,4]
*Output:*|2

Example 3:||
|---|---|
*Input:*|nums = [1,1,1,1]
*Output:*|0

---

***Constraints:***
 - 1 <= nums.length <= 2 * 10^4
 - -10^9 <= nums[i] <= 10^9

---

***Idea:***

Since our target harmonious array is dealing with the absolute value of its elements and since it's a subsequence of our numbers array (**N**), we don't need to worry about the order of numbers or their index in **N**.

If all we care about is *what* numbers appear in **N** and not their order or index, then it means that we should start by building a **frequency map** from **N**.

Then we can just iterate through the entries in our frequency map (**fmap**) and keep track of the largest value found by adding each number's (**key**) frequency (**val**) with the frequency of **key+1**.

We should then **return** the best result (**ans**).

---

***Implementation:***

Since javascript's **Map()** stores its keys as strings, you need to use some method of converting the key back into a number before adding **1**. The normal way to do this is with **parseInt()**, but applying a double **bitwise NOT** (**~**) does the same thing far more efficiently, as long as the number is greater than **-2^31** and less than **2^31**.

---

**Javascript Code:**
```javascript
var findLHS = function(N) {
    let fmap = new Map(), ans = 0
    for (let num of N)
        fmap.set(num, (fmap.get(num) || 0) + 1)
    for (let [key,val] of fmap) 
        if (fmap.has(~~key+1))
            ans = Math.max(ans, val + fmap.get(~~key+1))
    return ans
};
```
Python If Statements

Published: 2021-02-04 20:41:54

x = 10
if x != 0:
if x % 2 == 0:
print('even number')
else:
print('odd number')
elif x == 0:
print('equal to zero')
elif x > 0:
for i in range(2,x):
if i % 2 == 0:
print('not a prime number')
else:
print('prime number')
else:
print('less than zero')
Message-driven microservices made simple
Tags: microservices, technology, messaging, eventdrivenarchitecture
Published: 2021-02-04 22:41:05

---
title: Message-driven microservices made simple
published: true
date: 2021-02-04 20:15:36 UTC
tags: microservices,technology,messaging,eventdrivenarchitecture
canonical_url: 
---

![](https://cdn-images-1.medium.com/max/1024/1*yi5--_rOF9vcU15ffFFdgQ.jpeg)

I’ve started a new side project. The goal is to drastically simplify the development of message-driven microservices.

Event sourcing is used as the standard persistence mechanism. In the future, I also plan to implement service integration using Kafka.

The project is called Being. It’s based on the [Lagom framework](https://www.lagomframework.com/).

Here’s the [link to the Being project](https://github.com/bertilmuth/being).

Please leave a comment what you think, or chat with me on Gitter.

I appreciate feedback.
AzureFunBytes Episode 29 - Intro to @daprdev with @mfussell
Tags: azure, microservices, cloudnative, beginners
Published: 2021-02-04 20:12:20

Each week on [AzureFunBytes](https://twitter.com/azurefunbytes), we drive into the tools and products that make up the foundations of using [Azure](https://azure.microsoft.com/free/?WT.mc_id=devops-14110-jagord).  This week we dive into microservices and how our distributed applications can thrive on [Azure](https://azure.microsoft.com/free/?WT.mc_id=devops-14110-jagord).  One tool that really helps drive productivity and helps developers build reliable and resilient applications is [Dapr](https://docs.dapr.io/concepts/overview/?WT.mc_id=devops-14110-jagord).

[Dapr](https://docs.dapr.io/concepts/overview/?WT.mc_id=devops-14110-jagord) is an open-source, portable, event-driven runtime that reduces the overhead in creating distributed microservices in the cloud. Dapr helps provide you with options to create microservices using any language, with any framework, on any platform. Dapr will help codify best practices for your distributed services infrastructure without requiring you to be an expert on cloud-native architecture.

{% youtube LQJzJGvABV4 %}

To help me through this, I will be working with [Mark Fussell](https://twitter.com/mfussell), one of the product leaders on the Dapr project. 

[Mark](https://twitter.com/mfussell) provides me some details on the latest release of [Dapr v1.0.0-rc.3](https://blog.dapr.io/posts/2021/02/03/dapr-v1.0.0-rc.3-is-now-available/), and the new features that come along with it. 

Along with hearing about Dapr's new features, we get into the weeds on how exactly Dapr can be installed, used locally, then finally in the cloud. 

You can try out the [Dapr quickstarts right here](https://docs.dapr.io/getting-started/quickstarts/) to begin your own personal journey into Microservices on Azure.

Learn about Azure fundamentals with me!

Live stream is available on Twitch at 2 pm EST Thursday. You can also find the recordings here as well:

https://twitch.tv/azurefunbytes
https://twitter.com/azurefunbytes
https://aka.ms/jaygordononyoutube

Join me, ask questions, and learn about Azure!

Useful Docs:

[Microsoft Learn: Azure Fundamentals](https://cda.ms/1jV) 
[Microsoft Azure: $200 Free Credit](https://cda.ms/1tj) 
[Dapr Overview](https://twitter.com/mfussell)
[Getting started with Dapr](https://docs.dapr.io/getting-started/?WT.mc_id=devops-14110-jagord)
[Try out Dapr quickstarts to learn core concepts](https://docs.dapr.io/getting-started/quickstarts/?WT.mc_id=devops-14110-jagord) 
[Dapr Reference Docs](https://docs.dapr.io/reference/?WT.mc_id=devops-14110-jagord) 
[Microservices in Azure](https://azure.microsoft.com/solutions/microservice-applications/?WT.mc_id=devops-14110-jagord) 
[Building microservices on Azure](https://docs.microsoft.com/azure/architecture/microservices/?WT.mc_id=devops-14110-jagord)
Problem Definition (1/6).
Tags: ai, machinelearning, python
Published: 2021-02-04 20:01:37

Problem Definition is the first step to take when building a Machine Learning (ML) model. It is a concise description of the problem to be solved. It is important to define and know the problem you are trying to solve as this reduces the amount of time used to tackle the problem. It also gives a hint on how to solve the problem and the tools to use. There are 4 **major** types of Machine Learning depending on the type of problem. These are:

#### 1. Supervised Learning.

Supervised Learning is a type of Machine Learning that has labels in the data. This type of learning is always organized and easier to read and view. The main types of Supervised Learning are:

- **Classification:**
This is a method of Supervised Learning that defines the class to which data elements belong and is best used when finite and discrete values are available for the output. It also forecasts a class for an input variable. An example is the prediction of cancer in a patient.

- **Regression:**
This is a type of Supervised Learning that predicts a continuous outcome variable (y) based on the value of one or multiple predictor variables (x). For example, the prediction of house prices in a state.

#### 2. Unsupervised Learning.
This is the opposite of Supervised Learning. This kind of learning is neither organized nor labeled i.e. it makes use of unstructured data. Examples of the kind of data used are images, audio files, and videos. A  popular type of Unsupervised Learning is Clustering.

Clustering is simply a list of data based on their similarity and dissimilarity. From the name, it means grouping data in clusters to get the best fit. One example of this is clustering users for movie recommendations.

#### 3. Transfer Learning.
Transfer learning is the transfer of knowledge from one ML model to another. It is a type of learning that focuses on the preservation of information acquired while solving one issue and applying it to a separate but related issue. An example is using the same knowledge used to recognize cars to recognize trucks. 

#### 4. Reinforcement Learning.
Reinforcement Learning is the preparation of machine learning models to make a series of decisions. The ultimate goal is to maximize the total reward of the system. This type of learning uses trial and error to come up with solutions. The system offers punishments for the action it performs in order to get what is needed from it.


Depending on what is to be achieved, the various learning are usually used for different purposes. It is best to understand the problem before selecting what model to employ.
Sorting algorithms: JavaScript - Selection Sort🚀
Tags: javascript, programming, codequality, webdev
Published: 2021-02-04 19:46:13

Table Of Contents
        * 🤓[INTRODUCTION](#intro)
        * 👉🏻[ABOUT SELECTION SORT ALGORITHM](#selection)
        * 👀[VISUALIZATION](#visualization)
        * 🛠[IMPLEMENTATION](#implement)
        * 👩🏻‍💻[CODE](#code)
        * 🙏[THANK YOU](#thank-you)

##🤓 INTRODUCTION <a name="intro"></a>

Hello, my dear coders! I hope you are all having a wonderful time coding and enjoying your life. In this blog article, we will discuss the selection sort algorithm using javascript. Connect with me via [Twitter](https://twitter.com/lazar_dev) or [LinkedIn](https://www.linkedin.com/in/lazar-stankovic-44a199177/)


Let's dive in! 🚀
![hack](https://media.giphy.com/media/MM0Jrc8BHKx3y/giphy.gif)


##👉🏻 ABOUT SELECTION SORT ALGORITHM <a name="selection"></a>

The Selection sort algorithm is based on the idea of finding the minimum or maximum element in an unsorted array and then putting it in its correct position in a sorted array. In other words, we are finding an index of an element with the smallest value in an entire vector data, and it changes its place with the first element. After that, we are searching for an element with the smallest value in the remaining part of the vector data and it's being placed in the second place.

Assume that the array `array = [9, 5, 6, 12] needs to be sorted in ascending order.

The minimum element in this array is 5, we find an element with the value of 5, and then swap places with the element that is currently located at the first position. Now, the minimum element is an element with a value of 6, which we put in a second position, and so on...It's pretty easy for us humans, well, for computers is different, we need to teach them everything! 😂


##👀 VISUALIZATION <a name="visualization"></a>

Let's visualize sorting of our previously mentioned array; array = [9, 5, 6, 12];

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


##🛠 IMPLEMENTATION <a name="implement"></a>
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/a6bv7no3vzr3zmokfvq0.png)


##👩🏻‍💻 CODE <a name="code"></a>
Play with code! 🚀

{% jsfiddle https://jsfiddle.net/codespresso/y6eo1cv7/9/ js,result%}


# 🙏 THANK YOU FOR READING!<a name="thank-you"></a>
References:
School notes...
School books...

Please leave a comment, tell me about you, about your work, comment your thoughts, connect with me! 

☕ SUPPORT ME AND KEEP ME FOCUSED!
<a href='https://ko-fi.com/Z8Z33D1HJ' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi4.png?v=2' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>

Have a nice time hacking! 😊
Everyone can be a "Hero"
Published: 2021-02-04 19:42:20

*Before we begin, I don't like the "Hero" term for this context, but you will quickly understand what it means. And we will talk about DevOps, but I think it doesn't really matter.*

---

A year ago, I never worked with Cloud or DevOps tools (personally or professionally) but I was curious about all this world even I didn't know anything about it. 

Today, I'm a DevOps working with Kubernetes Clusters in the cloud created by Terraform scripts... and with multiples certifications about DevOps technologies.

But what happened between? 

---

The answer is simple, my boss gave me a chance. 

She saw that I was motivated and believed in myself. So she also believed in me. More motivated by this, I gave all that I can do to be at the level. 

Of course, I followed a lot of courses during my spare time, worked a lot on onside projects to tests my skills... But the key was that I was *(and still am)* motivated to prove she's right to do it.

The message of this post is not to say "hey, look at me", it's for every dev to **keep their motivation** and I hope for you it will work. 

Also, it's for every leader/manager. **Be open to give a chance to motivated people.** It can really be a win-win.

---

I recently talked to someone who saw my profile on LinkedIn and wanted to hire me. Happy with my current job, I refused, but we talked a little bit. I explain my path which brought me here and I suggested him to do the same. To give a chance. He answers me that it could be a great idea because he doesn't find DevOps to hire.
I know it's something that we can't do in any situation, but it can be grateful for both parts.

Another example is when we were looking for interns. We had 3 profiles, 2 of them completely matches what we wanted, but they weren't motivated to work, by our projects... So we took the third one. She knows how to dev, but she didn't know our stack. However, she was motivated. And she gave us right when she arrived, because she learned our stack to be ready to work.

---

I hope the mindset will evolve, and finally 
> "Never take no for an answer" - *Johnny Gargano*


Thanks for reading this post, I will be happy to discuss about it.
Asset Compilation in Rails
Tags: rails
Published: 2021-02-04 19:38:02

In the previous post, we talked about what a frontend is, and briefly looked at how it works in Rails. Now, we'll look specifically at **pre-compilation**:
![Ruby on Rails Frontend Pipeline](https://dev-to-uploads.s3.amazonaws.com/i/w0a296sjfoaeyh8v474m.jpg)

# Why compilation?
Any moderately complex interactive web-app of today contains a *lot* of CSS and Javascript, so we smart developers devised extensions and frameworks to make them easier to manage, for example: 
- [webpack](https://webpack.js.org/) does a lot of things, one of them being the bundling of our numerous CSS and JS files (which we break up for ease of development) into fewer files that are faster to load
- [autoprefixer](https://www.npmjs.com/package/autoprefixer) lets us write CSS without having to worry about vendor-prefixes (some browsers named CSS properties differently as they were experimental at the time etc. For example, `transition` is `-webkit-transition` in Safari).

These make it more convenient (once you get past the learning curve) to work on our frontend, but this means our assets usually can't be used in their raw form - Rails has to convert them into the actual HTML, JS and CSS files before sending it to your browser.

In local development, the `rails server` will mostly do this conversion on the fly for you. But in production, you'll want to pre-compile production-ready assets, so the server can focus on generating and sending pure HTML.


# What is “production-ready”? 
This includes things like:
- Combining separate JS and CSS files into less files so a browser needs to make less requests
- Minifying (compressing) the files so they’re smaller and load faster
- Fingerprinting so the browser knows when to ignore its cached files and request for the latest ones

# What are my options for pre-compilation?
Rails 6 actually has two mechanisms for compiling static assets:
- The **Asset Pipeline** is the traditional way, using a gem called `sprockets`.
- **Webpack** is pretty much the a modern standard in the JS ecosystem, and Rails includes the `webpacker` gem to enable this.

You can actually just pick one or the other, but it seems the Rails-recommended way is to use Webpacker for JS files, and the Asset Pipeline for everything else e.g. CSS.

A brand new Rails 6 project loads with that in mind, so:
- `/app/assets/stylesheets` should be where your CSS files go
- `/app/javascript/` should be where your JS files go

For the curious, here's some [backstory](https://rossta.net/blog/why-does-rails-install-both-webpacker-and-sprockets.html) on why there are two ways to compile assets, by Ross Kaffenberger.

# How do I set up pre-compilation for production?
If you’re deploying with Heroku it will do all the pre-compilation for you, unless you've customised your build process. For other services, you'll have to run `rake assets:precompile` in your deployment scripts. See the [Rails guide](https://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets) for more details.

Next, we'll take a look at the different options for styling our web-sites/apps (i.e. CSS).