teleren/devto huggingface dataset:
Enum.map_reduce/3
Tags: elixir
Published: 2019-10-22 11:52:53

Today I found a function in Elixir's standard lib that I have often needed.

Introducing: `Enum.map_reduce/3`

`Enum.map_reduce/3` can replace `Enum.reduce/3` when the `reduce` maps each element to another element and we also want to maintain some state or build a result along the way.

This might be a bit cryptic, so let's start with an example.

## Have a cache while mapping

Let's pretend I don't know about `Enum.map_reduce/3` and I need to map a list of numbers to the maximum of the number and the previous number.

I would do something like this:

```elixir
input = [5, 2, 8, 9, 1, 2, 7, 2]

{_last, numbers} =
  Enum.reduce(input, {0, []}, fn num, {last, acc} ->
    {num, [max(num, last) | acc]}
  end)

Enum.reverse(numbers)
```

(Ok, this simple example could also be solved nicely with `Enum.chunk_every/2` and `Enum.map/2`, but for the sake of example let's play with this)

This will give the expected result `[5, 5, 8, 9, 9, 2, 7, 7]`.

Notice that I need to reverse the number list at the end, since I append numbers to the start of the list.

If only there is a way to do this in a smarter way...

Well, with `Enum.map_reduce/3` we can do this:

```elixir
input = [5, 2, 8, 9, 1, 2, 7, 2]

{numbers, _last} =
  Enum.map_reduce(input, 0, fn num, last -> {max(num, last), num} end)
```

So here we use `map_reduce`'s accumulator to remember what the last number was.

## Build a result while mapping

We can also use it to accumulate something we need as a result while we're mapping a list.

Perhaps we want to know the largest number while doing the max-thing above:

```elixir
{numbers, {max, _last}} =
  Enum.map_reduce(input, {0, 0}, fn num, {max, last} ->
    {max(num, last), {max(num, max), num}}
  end)
```

Which will give the same `numbers` as before, but now we also get `9` as the max item.

## Enum.flat_map_reduce

In the cases where each iteration might yield zero or many items to the resulting list, we can use `Enum.flat_map_reduce/3`. This works like `Enum.map_reduce/3` with two differences:

* Each iteration must yield a list of elements instead of a single element. Notice that we can use an empty list if an iteration should not add something to the resulting list.
* It is possible to break early using `:halt`, almost like with `Enum.reduce_while/3`

Example: We want to map a list to another list where:

* All odd numbers are removed
* All even numbers are doubled
* We want to sum the original numbers
* If we hit 7, we stop

```elixir
input = [5, 2, 8, 9, 1, 2, 7, 2]

Enum.flat_map_reduce(input, 0, fn num, sum ->
  case num do
    7 -> {:halt, sum}
    n when rem(n, 2) == 0 -> {[n, n], sum + n}
    n -> {[], sum + n}
  end
end)
```

Which will give `{[2, 2, 8, 8, 2, 2], 27}`
Bash: Rename specific files in a folder
Tags: beginners, bash, linux, tutorial
Published: 2019-10-22 11:50:11

---
title: Bash: Rename specific files in a folder
published: true
description: Bash: Rename specific files in a folder
tags: beginners, bash, linux, tutorial
cover_image: https://thepracticaldev.s3.amazonaws.com/i/gbm5mc3y3l0ctezaad9u.png
series: Shorties
---

Recently I've built a script to download all my articles from dev.to into markdown files.

I used the timestamp and the name of the article.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/5uxqzlql02izpfsfxbzk.png)

This is working, but there is one annoying thing: every post has a date  in its file name and its frontmatter.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/bk47tw7fl40ui5k39anm.png)

That leads to:
- Increased complexity: Would have to change the date in both places if I would want to change the date.
- What would be the source of truth in case of two different dates?

### Problem

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/23idl0hut7m9fdsdpbjg.png)

### Desired Outcome

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/xa0tcaac83bp896ssgmt.png)

### Let's tackle this problem

```sh
# loop over every file with `md` extension, assign it to `file`
for file in *.md 
do
  # rename (by variable expansion starting from position 11)
  mv "$file" "${file:11}" 
done
```

### Further Reading
- [for man page](http://linuxcommand.org/lc3_man_pages/forh.html)
- [mv man page](https://linux.die.net/man/1/mv)
- [Variable Expansion](http://www.tldp.org/LDP/abs/html/parameter-substitution.html#EXPREPL1)

### Questions
- Do you write bash scripts?
- What's your favorite one?

---
What I learned from my GitHub profile
Tags: career, productivity
Published: 2019-10-22 11:07:32

_This post was originally published on [silvestar.codes](https://www.silvestar.codes/articles/what-i-learned-from-my-github-profile/)._

GitHub profile is often recognised as a developer’s portfolio. It reveals how often do you contribute, and what kind of projects do you like. But what else could we discover from a GitHub profile? Here is what I learned.

<!-- more -->

_This analysis doesn't include repositories from my clients._

## GitHub profile

![Contribution activity graph on my GitHub profile.](https://thepracticaldev.s3.amazonaws.com/i/su3fpouxz2kdcb2gutef.gif)

Here are some facts from [my Contribution activity graph]:

- I commit a lot.
- I commit often.
- I produced more than 7 commits per day in the last year.
- I produced almost 10 commits per day in 2018.
- I started with remote work in June 2017.
- I had two notable working gaps while struggling to find a gig: first one in autumn of 2017, the second one in spring of 2018.
- I had only one week without a single contribution this year.

## Sourcerer

Sourcerer is an open-source project that gives a visual overview of your GitHub profile.

> Sourcerer is a visual profile for SWEs that analyzes and derives your abilities, preferences, and habits from your commits and source code.

Here are some facts from [my Sourcerer profile]:

- I produced more than 3k commits.
- I wrote more than 1,8 million lines of code.
- I wrote more than 1,5 million lines of CSS.
- I wrote more than 90k lines of JS.
- I wrote only 1,7 lines of jQuery.
- I wrote more than 64k lines of HTML.
- I wrote more than 8k lines of PHP.
- I practised Gulp as a tool the most.
- I practised pug as a template engine the most.
- I was most productive during the day.
- I wrote the code during the weekend.
- I favour spaces for indentation.
- I favour the camelcase for variables.

## Conclusions

I came to a few conclusions based on facts from my GitHub profile:

1. **I work too much**. I work on weekends. According to Sourcerer, I am most active on Sundays. 😱
2. **More than 90% of my code is CSS**. I must be a *real* CSS developer. 💯
3. **Coding is my hobby**. Although this analysis doesn't include my paid engagements, it says how much I like to spend my free time. I spend my free time writing code. 🤔

Although this information is intimidating, I do not think I work too much. I mean, I work much, but I enjoy doing it.

Happy coding, everyone!

[my Contribution activity graph]: https://github.com/maliMirkec
[my Sourcerer profile]: https://sourcerer.io/malimirkec
Weekly Cloud-Native Digest #17
Tags: weeklydigest, cloud, news
Published: 2019-10-22 10:59:06

---
title: Weekly Cloud-Native Digest #17
published: true
date: 2019-10-22 10:47:59 UTC
tags: Weekly Digest,cloud,news
canonical_url: https://educosta.dev/blog/weekly-cloud-native-digest-17/
cover_image: https://thepracticaldev.s3.amazonaws.com/i/0ov6xhnzgga51ad9pkz7.jpg
---

Save  time and stay up-to-date with what’s going on in the Cloud-Native  ecosystem. Every week a collection of useful links with videos, articles  and more. 

- [Versioning  in an Event Sourced System - The goal of this text is not to discuss  Event Sourcing but to discuss how to version Event Sourced systems.](https://leanpub.com/esversioning/read)
- [Introducing  Azure Spring Cloud - To help make it simpler to deploy and operate  Spring Cloud applications, together with @pivotal Microsoft have created  @Azure  Spring Cloud. By @Johnmont](https://azure.microsoft.com/en-us/blog/introducing-azure-spring-cloud-fully-managed-service-for-spring-boot-microservices/)
- [How  Slack Built Shared Channels - See the technical decision behind the  implementation of Shared Channels on @SlackHQ , the implications of the  decisions, and how they' working on scaling for the future.](https://slack.engineering/how-slack-built-shared-channels-8d42c895b19f)
- [17  Ways to Undo Mistakes with Git - Git offers countless tools to undo and  recover from small and big mishaps. Here are 17 short  handy videos  that help you learn how to save your neck!](https://www.git-tower.com/blog/surviving-with-git-videos/)
- [5  facts that will make you rethink the use of Microservice. Although  Microservice is a tool to build scalable and resilient applications, it  has some requirements to be applied with success. This article explores  some of these requirements.](https://educosta.dev/blog/5-facts-that-will-make-you-rethink-the-use-of-microservice/) 	
- [Eventually  Consistent - Building reliable distributed systems at a worldwide scale  demands trade-offs between consistency and availability. By @Werner](https://www.allthingsdistributed.com/2008/12/eventually_consistent.html)
- [Building a Custom Serverless Chatbot](https://chatbotslife.com/building-a-custom-serverless-chatbot-pieces-parts-14ec8121b597) 									
- [Complex Event Flows in Distributed Systems](https://www.infoq.com/presentations/event-flow-systems/) 				



The post [Weekly Cloud-Native Digest #17](https://educosta.dev/blog/weekly-cloud-native-digest-17/) appeared first on [Be Cloud Native](https://educosta.dev).
Procject : Dictionary for novice programmers
Tags: discuss
Published: 2019-10-22 10:28:42

---
title: Procject : Dictionary for novice programmers
published: true
description: Hi, in this post I ask if it's good things to have a certification in Python and if anyone has done the Python Institute and has more information about it. 
tags: discuss
---

Hi coders,
I’d like to learn more about the main topics a programmer should know
I would like to do it for my personal project,that is, to create a sort of dictionary for novice programmers like me.
Would you like to help me?
-No need for explanation just the concept (For example : recursion )
-Any concept that can range from functional programming to object-oriented programming
Regards,
CamiCode
Top Application Performance Monitoring Tools
Tags: devops, testing, ios
Published: 2019-10-22 10:21:15

These numbers can be measured by the mobile app analytics tools and here we are sharing the list of the best application performance monitoring tools available to measure the app performance:

**Best application performance monitoring (APM) tools**

**App Annie**

![App Annie](https://thepracticaldev.s3.amazonaws.com/i/pyt54o94squyzg18am93.png)

Easy to use and implement this *Application performance monitoring tool* not only track user activity but also tracks app sales. App Annie is used by more than 700,000 applications. Now, it is integrated with Google analytic and after that, it supports the other app stores including Apple, Amazon, and Windows.

**Price:** In free versions, you can view store stats.

**Platform Compatibility:** Android, iOS, Windows

**MixPanel**
![MixPanel](https://thepracticaldev.s3.amazonaws.com/i/3ohxsm58dq1eseslyc5p.png)

MixPanel provides the [best solution for the mobile app](https://www.mindtechconsultancy.com/) owners to track the performance of their mobile app. It offers the analytic solution for the web as well as a mobile app.

You can understand the retention statistics of your website because this tool allows linking between mobile users and web users.

**Platform Compatibility:** iOS and Android

**Price:** The pricing strategy of Mixpanel is based on data points.

**Countly**

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/2mki2zvnf2qwri35csr7.png)
This tool is compatible with iOS, Android, Windows and Blackberry apps. Countly is an open-source mobile app as well game app analytic tool that can be hosted on the server for monitor application performance.

**Platform Compatibility:** Android, iOS, Windows Phone, Blackberry

**Price:** Free

Read More About: [Application  Performance Monitoring Tools](https://www.mindtechconsultancy.com/application-performance-monitoring-tool/)
The 5 SOLID principles with examples [in PHP]
Tags: liskovsubstitution, singleresponsibility, openclosedprinciple, solid
Published: 2019-10-22 10:08:47

---
title: The 5 SOLID principles with examples [in PHP]
published: true
description: Do you want to learn all about Object Oriented Programming? This post you will see examples of the 5 solid principles developed by uncle bob
tags: Liskov Substitution,Single Responsibility,Open Closed Principle,Solid
cover_image: http://anastasionico.uk/img/blog/solid-principles-in-objected-oriented-programming-with-examples-php.jpg
---
Last week one of the account managers in the company I work for asked me to edit a little feature we have on one of the websites we manage,

Turn out I spent almost a week on that task.

If that happened to you, this is the time to change!

This website is very old and it is not actively managed, it was developed a long time ago then passed from developer to developer.

I must say, I work on it only once or twice a year.

The task itself was really easy and should have been a quick fix…


The reality?

It took 2 days only to understand what I was looking at.


**Why do we like messes?**

I realized that this is a common problem while deciding to refactor some code.

I really did not enjoy spending my time there, taking note of which interface was doing what, where a class was invoked and why there were methods 200 lines long.

As web developers, we are creators we want to see stuff on a web page that was blank only a few minutes before.

We must do in conscientiously though!

**The way to write good code**

Software engineers have been there for years and some of them have developed theories and principles that have been proved right times and times again.

One of the most famous and engineer that has done it is Robert Martin,
he has created a set of 5 principles that, if followed, will make every program scalable and most important incredibly easy to read.

*That is called S.O.L.I.D.*


**What can you do?**
It’s time to stop wasting days try to understand code written ages ago.
You can do it, and it only requires to follow 5 principles.


[Read the full article here](http://anastasionico.uk/blog/solid-principles-in-objected-oriented-programming-with-examples-php)
I created a Chrome extension to practice LeetCode with Spaced Repetition
Tags: leetcode, productivity, chrome, career
Published: 2019-10-22 09:58:50

I was recently practicing LeetCode problems while preparing for interviews and I got frustrated with using Excel sheets to track my learning progress, so I decided to make a Chrome extension to automate my reviews 😊: **SpacedLeet**.

I used a simple spaced repetition algorithm to optimally set my next reviews and I used Webpack and Lit-HTML to make the extension 😁.

The process is straightforward: after working on a problem, you launch the extension and rate your performance.

![LeetCode problem rating](https://thepracticaldev.s3.amazonaws.com/i/mgr5ghs9ayb1iqolafnh.png)

Depending on your rating and how you performed in the past, the problem will be shown for review after a couple of days (or months) when you visit any page other than the problem page.

![LeetCode problems list](https://thepracticaldev.s3.amazonaws.com/i/u4g22zva0zene1ocpuhn.png)

You can get the extension on [Paddle](https://buy.paddle.com/product/572780). It's available for two dollars 😊.

You can also read more about it and how to install it on [the extension's website](https://spacedleet.imedadel.me).

I'm also looking for any feedback about the landing page and the extension 🙏.
React Website preloading
Published: 2019-10-22 09:35:45

Hi m8! i have an hard question! I'am new in react and i need to make a website preloader. I have an assets folder, i need to read all assets, preload with a progress bar and at the end, show my website. 

My first approach is to use preloadjs and hardcoding url assets, but is very mess  if i have a lot of assets, do you have any ideas to do it clever and smart?

Thanks all!!
Introduction to Nuxt Socket.IO
Tags: vuex, nuxt, socketio, vue
Published: 2019-11-22 06:28:49

---
title: Introduction to Nuxt Socket.IO
published: true
date: 2019-10-22 09:22:57 UTC
tags: vuex,nuxt,socketio,vuejs
series: nuxt-socket.io
canonical_url: 
---

[![](https://cdn-images-1.medium.com/max/600/1*9KeUbvUM-5iF1MrvhHgCvg.jpeg)](https://medium.com/@richard.e.schloss/introduction-to-nuxt-socket-io-b78c5322d389?source=rss-40d325a4ce73------2)

TL;DR — nuxt-socket-io is a module for the Nuxt framework that allows you to configure IO easily: that is, configure your socket.IO…

[Continue reading on Medium »](https://medium.com/@richard.e.schloss/introduction-to-nuxt-socket-io-b78c5322d389?source=rss-40d325a4ce73------2)
Using Vue Router in a Laravel subroute
Tags: vue, laravel
Published: 2019-10-22 09:21:23

I recently had to embed a Vue.js SPA into a Laravel application. As you may already know, your Apache/NGINX require some configuration in order to let the Vue Router handle the request rather than the default Laravel app.

For this particular case I could not make any change in the server side, so ended up with a quite elegant solution right into the Laravel router:


```php
Route::get('/admin/{opt?}', function () {
 return view('your.index');
})->where('opt', '.*');

// or

Route::view('admin/{opt?}', 'your.index')->where('opt', '.*');
```

In this case I am using a `/admin` path but it should work too if you use `/`.

I hope it helps someone!
HOPL - History of Programming Languages
Tags: languagelearning, hopl, programminglanguages
Published: 2019-10-22 09:19:59

As many are aware, there is an online museum of programming languages called [HOPL](https://hopl.info), which (sadly) is currently down while we change servers and seek funding. The [Wayback Machine](https://web.archive.org/web/20190506004623/http://hopl.info/) has some scrapes of the site for those interested. Wikipedia has many links back to HOPL. Unfortunately, these are all going to 404 until we can get things going again.

(The Wayback Machine has all kinds of cools stuff in its archive. Have you ever been trying to find a magazine article that used to be somewhere but isn't anymore? Wayback Machine!)

We have a shop window of sorts over on Facebook at [HistoryOfProgrammingLanguages](https://www.facebook.com/HistoryOfProgrammingLanguages) where we've been posting information, albeit sporadically, about languages, especially ones that currently are not in the main database. According to the main site, I'm the librarian in charge of 1990 to present. I'm am so far behind, it's not funny. 

A couple of years ago, in a burst of energy, I posted [Notes](https://www.facebook.com/pg/HistoryOfProgrammingLanguages/notes) about some of the backlog. I hope very soon to have another burst of energy, but there have been so-o-o-o-o-o-o-o many languages developed since 1990. When I get back to it again, I'll also post here. Watch for "[HOPL]" in the subject line.
JVM tmpdir option
Published: 2019-10-22 09:13:38

By default, JVM creates tmp dir under /tmp/
This setting can be changed by adding JVM option 
<b>"-Djava.io.tmpdir=mytmpdir"</b>

1 tricky thing is mytmpdir should be exist before starting Java process. 

So steps should be
1/ add JVM option -Djava.io.tmpdir
2/ mkdir mytmpdir
3/ restart java process
We're live on Product Hunt - Code News 2.0
Tags: news, coding, codingnews, producthunt
Published: 2019-10-22 08:55:44

PH link: https://www.producthunt.com/posts/code-news-2-0

👨‍👨‍👦 Me and my friends have been working hard on Code News to make it super easy for our colleagues coders to stay up-to-date with their favorites coding languages ✨

📱 iOS App version 1.0

✅ Integrated a lot more news sources

🔔 Get notified when news related to your interests are fetched

⚡️ Bolt your favorite news to reach the top list for others to read

🌟 Rebrand

🚀 We are growing organically day by day without no money invested:

![Code News growth](https://codenews.app/assets/images/codenews-growth.png "Code News growth")
#Help MediaPlayer doesn't run and still give an error
Tags: android
Published: 2019-10-22 08:43:45

MediaPlayer issue,
when I run MediaPlayer in andorid there is an error:

E/ExtMediaPlayer-JNI: env->IsInstanceOf fails
E/MediaPlayer-JNI: JNIMediaPlayerFactory: bIsQCMediaPlayerPresent 0

the code:
player = MediaPlayer.create(this, R.raw.jalazone);
player.setLooping(false);
player.start();

any help, please
Why not to use JQuery in a JavaScript Framework.
Published: 2019-10-22 08:26:34

Simple.... You just shouldn't... Its not wrong, but its overkill and at the same time you are under-powering all the features that your Framework has. Okay... Lets, go back in history and try to understand why JQuery was even invented. Back in the old days like the OLD days around 2006 - 2012... JavaScript was not yet a standard and it doesn't support cross browser DOM manipulation. Therefor someone had an Idea to make a JS library to band aid that wound in the world of web development. However, years later that wound would be healed. 

JavaScript has become a norm for web browsers and is now standardized across all platforms making JQuery no longer relevant. But hey! I'm not saying developers should stop using JQuery... But I'll warn you. Once you rely on JQuery you will have a harder time adjusting to new frameworks as it doesn't use the common syntax, and it has a rather distinct DOM implementations, after all JQuery is just another JavaScript library...

Back to the topic at hand on Why You shouldn't use JQuery in a framework? 

1. Because it'll just make your app heavy.

2. Everything JQuery can do, VanillaJS/JS/TypeScript can do better and faster.

3. It results to a terribly large amount of JavaScript code written.

4. Frameworks already has its OWN LIBRARY. JUST READ THE DOCS!!!

5. And finally... JQuery is  no longer relevant as mentioned above. It was a band aid solution on a wound that's already healed. It served its purpose...DONE

Alright! Little disclaimer... I'm not telling developers or aspiring developers to not use JQuery at all... But at the same time decide for yourselves whether its still relevant.


#jqueryvsjs #react #vue #angular
Code, code, code, coffee, repeat. And win €2500! Join our out-of-the-box fintech hackathon! 🌈
Tags: hackathon, challenge, ios, android
Published: 2019-10-22 08:07:59

No boring business problems to solve, just a fest of sheer fun and creativity in the city of Amsterdam! 

Our goal is to make banking personal, independent, useful and enjoyable by integrating it into our every-day life: our routine, activities that we enjoy or we wish we enjoyed😜, and the tools & gadgets we use.

## The challenge is as simple as this: 
Use [the most powerful banking API in the world](https://doc.bunq.com/?utm_medium=external_post&utm_source=devto&utm_campaign=bunq_hackathon_3.0) to create apps that motivate to live better -- healthier and more effective -- and automate the routine behind it. 

Our community have built some amazing apps that can inspire you:
* [View your bank accounts on your Apple Watch](https://medium.com/bunq-developers-corner/tutorial-view-your-bunq-accounts-on-the-apple-watch-using-the-bunq-api-complication-included-3c3459180c58)
* The more you cycle, the more you save: [Strava and Amazon Credit Card payments automated](https://github.com/igoramadas/jarbunq)
* You can [make your money play by your rules via IFTTT](https://github.com/woudt/bunq2ifttt/)

## Sign up by yourself or with a group

You can sign up with a group of up to 4 people. Simply [follow the link](https://bunqsurvey.typeform.com/to/FRbejd).

Want to sign up by yourself? No problem. In the week leading up to the Hackathon we'll match you with a team. That way you can focus on a great idea, while we take care of the rest.

Learn more about our hackathon: https://developer.bunq.com/hackathon