teleren/devto huggingface dataset:
How I demonstrated a Growth Mindset recently
Tags: andela
Published: 2019-09-02 14:22:34

Hello! I am Kevin KIMENYI. I am from Rwanda and I am currently studying at the University of Rwanda/Nyarugenge campus. My personal interests are mostly digital designing. I also like to paint on canvas when I am free. However, I spend most of my free time designing using software like Photoshop, Microsoft Design(Publisher), etc. Furthermore, like many students, I like listening to music and watch movies.

To begin with, growing enthusiasm for hard work and determination aiming for success was not a short process for me as I am going to discuss. Before applying for Andela’s Program, my work as a student on holidays was only designing and going out with friends as well as other fun activities. Luckily, these holidays are not going to be the same. When I first heard of Andela, I made a detailed research about the company and decided to put design and so much fun aside for a while and start a serious coding career. For that very reason, I decided to apply without delay.

I am studying Software Engineering but my coding experience is pretty narrow. I have never done serious projects. As soon as I got an E-mail to attend Andela’s Bootcamp, I started working hard as if I was learning starting from scratch. I got to work on a project called Free Mentor Project, and the first challenge is to make User Interface (UI) with **HTML**, **CSS** and **JavaScript**. My experience to make UI is not very impressive but I am pretty sure I am good enough to make good UI as I am familiar with designing. 

The above project is not entirely programming related because the instructions says to make good UI that will be able to work in all devices, and also use GIT WorkFlow along with Github. Honestly, it was my first time to hear about responsiveness. For the first time, I made a homepage for UI. When I felt like I was done, one of my colleagues challenged me with reducing browser, then I realised that all my contents were not in a clear arrangement. This issue was so hard for me to fix. I started taking tutorials like I did not have any knowledge of **CSS**. I also started to work hard, wake up a little bit earlier and sleep later. With this strategy, I was able to fulfil my task.  Imagine how I was able to learn **CSS**, **HTML**, **JavaScript** and also make the assigned project in three weeks.

Finally, I started making some functionality platforms for the first time in my life. The second challenge was to make APIs for challenge one. I started building a project in JavaScript by using **Nodejs** Technically. I like to learn a new thing by doing it in action. That is why I took a step to build instead of taking a long-time learning JavaScript and Nodejs. I thought it would take me like a year to be able to work on a project. But when I started to learn and put in action, it was possible to think logically on how a task can be implemented and also make research on how to do it technically.   

To some up, Using Git and Github was for my first time. I tried my best to work with it while continuing learning. The two challenges I got for these last two weeks made me
LeetCode "Remove Nth Node From End of List"
Tags: leetcode, python
Published: 2019-09-02 14:18:38

---
title: LeetCode "Remove Nth Node From End of List"
published: true
description: 
tags: [leetcode, python]
---

I solved, but this could be shorter☹️

[Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list/)


```python
# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None

class Solution:
    def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:
        if n == 0:
            return None
        if n == 1 and head.next is None:
            return None

        i = 1
        before = None
        target = head
        node = head
        while node:
            if n < i:
                before = target
                target = target.next
            i += 1
            node = node.next
            
        if before is None:
            return head.next
        
        before.next = target.next    
        return head
```
Why you should stop declaring variables inside a for loop (especially in JavaScript)
Tags: javascript, optimization
Published: 2019-09-02 14:03:04

In my career, I've worked a lot with different programming languages, especially with C# and javascript.

During my years of development, I've faced a lot of performance issues, on Mobile and Desktop applications.

Often, the main reasons for performances lack are **scripts**.
Scripts are the main part of our website/applications, they weight a lot and they use a lot of resources, like CPU and RAM.

In Javascript, there isn't a manual garbage collector system (like c# or c++ __malloc__ or __free__ method), so you need to optimize the resources management part of your application to prevent memory leaks, zombie data or other performance issues.

But what can we do, as developers, to decrease the RAM usage for example?

# we need to write good code, reuse resources and handle data smartly.

For example, **don't declare variables inside a for loop** until it is really necessary!

## Why

A **for** loop is a looped method invocation, so a variable declared inside a **for loop** will exists inside the loop scope only, and it will be initialized
in every loop iteration! This means than a space in memory for the variable will be allocated in each loop cycle!

_What the heck!_

This fact, combined with the typeless Js language could create big memory leaks, performance issues, and other bad behaviors.

A simple, but effective method to recycle RAM is to declare variables once and reuse them when needed. The for loop is the simplest case but you can replicate this solution everywhere.

## Example

### BAD

Declare cursor inside the for loop and a string inside too.

```javascript
for (let i = 0; i < 1000; i++) {
  let logString = 'Current is: ' + i;
  console.log(logString);
}
console.log('%o', window.performance.memory);
```

```json
{totalJSHeapSize: 68876822, usedJSHeapSize: 46264582, jsHeapSizeLimit: 2197815296}
```

## GOOD

Declare **cursor** and **logString** outside the for loop:

```javascript
let logString = '';
let i = 0;
for (i = 0; i < 1000; i++) {
  logString = 'Current is: ' + i;
  console.log(logString);
}
console.log('%o', window.performance.memory);
```

```json
{totalJSHeapSize: 57747133, usedJSHeapSize: 45757109, jsHeapSizeLimit: 2197815296}
```

As you can see the **totalJSHeapSize** in the second implementation is less than the first one **(< 11129689‬byte ~ 11mb)**, the **usedJSHeapSize** too **(< 507473byte‬ ~ 0.5mb)**.

I know, this isn't a great saving, but with large projects, this could save your web application performances!

# Conclusion
There are a lot of optimization we can use to boost our applications, and this solution is not only JS-related, you could use it with any language you use.
But I think JS is the best case to use, because it's not resource-optimized.

I hope you found this article useful or just interesting!
Ara, an open source personal assistant
Tags: showdev, contributorswanted, android, java
Published: 2019-09-02 13:51:09

## Ara an OPEN SOURCE voice assistant 🎙📱

 

## What is Ara
Well, Ara came about as an idea in January of this year, I wanted a side project that I would enjoy, so with the help of some Friends (Chris and Eric) I started working on an Android app that would become Ara.
I wanted a great open source voice assistant app that could compete with the likes of Google and Amazon. after thinking about this we established 3 main goals:
* make a voice recognition system that can be run locally
* complete data privacy
* provide useful information on opening the app


To accomplish these goals I have used 100% open source software so I can guarantee no tracking, have extensive documentation for the SDKs I am using, and let the world use my code in there own projects.
I also did this as a proof of concept for an idea that is described here:
{% link https://dev.to/fultonbrowne/suggestions-for-an-ai-concept-1f6h %}

## What needs to be done?
 Ara is not done it needs 4 main things before a beta can be released
* Expanded voice capability
* Voice output
* Skills SDK (ara used to be able to detect several commands via the keyboard, but that was dropped for the development of this feature)
* IOT support

We also have some long term features we are working on:
* A public (hosted on are server) and privatec (hosted on, lets say a company servers) account system for easy data synchronization 

## contributing
please feel free to contribute, I normally do basic frontend stuff so all this AI and server stuff is hard for me I NEED the help.
{% github FultonBrowne/Ara-android %}
{% github FultonBrowne/Ara-Server %}
Daily Challenge #55 - Building a Pile of Cubes
Tags: challenge
Published: 2019-09-02 13:40:17

---
title: Daily Challenge #55 - Building a Pile of Cubes
published: true
series: Daily Challenge
description: Can you find the number of cubes from the volume of the structure?
tags: challenge
---

**Challenge**
Your challenge is to construct a building which will be made of a pile of _n_ cubes. The cube at the bottom will have a volume of _n^3_, the cube above will have volume of (n-1)^3 and so on until the top with a volume of 1^3.

You are given the total volume m of the building. Being given *m* can you find the number *n* of cubes you will have to build?

The parameter of the function _f_ will be an integer *m* and you have to return the integer *n* (such as n^3 + (n-1)^3 + ... + 1^3 = m) or 0 if there is no such n.

**Examples**
`f(1071225)` --> `45`
`f(91716553919377)` --> `0`

Happy Coding! 
***
_This [challenge](https://www.codewars.com/kata/build-a-pile-of-cubes) comes from g964 on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
Curving text around, (circle, spiral and semi circle)
Tags: codepen, javascript, webdev
Published: 2019-09-02 13:21:26

I could do better, if anyone cracks the kerning or responsiveness, give me a shout, I don't know if this is useful, it's certainly not accessible. Also it's probably possible to do a pure scss version.


{% codepen https://codepen.io/acronamy/pen/gOYGaej %}
Utilizar la propiedad revision con maven para mantener coherencia de versiones
Tags: maven
Published: 2019-09-02 13:19:25

Como pequeña ampliación a mi anterior artículo [la forma correcta de versionar y establecer dependencias](https://dev.to/earroyoron/la-forma-correcta-de-versionar-y-establecer-dependencias-4499) voy a indicar una ayuda que tenemos en maven, a partir de la versión 3.5.0

En esta herramienta de construcción podemos indicar una propiedad `revision` y usarla en el _parent_ y heredarla en todos los módulos _hijo_ de forma que podemos aplicar facilmente el principio de _coherencia en el versionado del despliegue_.

Esto es en el parent pondríamos:

```
  <groupId>io.earroyoron</groupId>
  <artifactId>project-parent</artifactId>
  <packaging>pom</packaging>
  <version>${revision}</version>
  <properties>
    <revision>1.3.0</revision>
  </properties>
```

y en los módulos por debajo indicaremos  esa propiedad:

```
  <parent>
    <groupId>io.earroyoron</groupId>
    <artifactId>project-parent</artifactId>
    <version>${revision}</version>
  </parent>

  <groupId>io.earroyoron</groupId>
  <artifactId>child-module-a</artifactId>
  <version>${revision}</version>
```

La ventaja principal es, como indico, mantener la **coherencia de versiones** que sería 1.3.0 en todos los componentes por debajo de ese parent (como debe ser).

Para quien tenga dudas de si esta es la forma correcta, que se mire el código fuente de, por ejemplo, Spring Boot, que utiliza este esquema.

## ¿Y los BOM?

Mi antiguo compañer y amigo [Marcos Martínez @cedillomarcos](https://twitter.com/cedillomarcos) me recordó que el uso de un BOM también es imprescindible en la gestión de versiones con _Maven_ pero voy a dejar este tema abierto para un próximo artículo.
Testing external API integration with VCR gem
Tags: rails
Published: 2019-09-02 13:19:24

Suppose your application connects to an external service via API and you have a wrapper for this API that handles and parses response. The [VCR gem](https://github.com/vcr/vcr) gives you ability to store parsed response in a special format (`cassetes`). VCR makes a real request to the API for the first test run and writes it's response to the cassete for next test runnings.

First you need to set VCR configuration:
```ruby
VCR.configure do |config|
  config.cassette_library_dir = "spec/vcr_cassettes"
  config.hook_into :webmock
end
```
And then write specs like the following:
```ruby
RSpec.describe ExternalService do
  describe '#new_order' do
    let(:params) { { foo: 'bar' } }

    it 'creates new order' do
      VCR.use_cassette("external_service") do
        result = subject.new_order(params) # makes HTTP POST to an external service

        expect(result.successful?).to be_truthy
        expect(result.data).to have_key('order_id')
      end
    end
  end
end
```
See more details on the [official page of the gem](https://github.com/vcr/vcr).
Who Else Does NOT Like Dark Mode?
Tags: webdev, discuss, javascript
Published: 2019-09-02 12:56:54

---
title: Who Else Does NOT Like Dark Mode?
published: true
description: 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/kkf9qergoxvpw5i1qgnd.png
tags: webdev, discuss, javascript
---

In case you didn't realize, **dark mode is the new trend in UI/UX.**

EVERY popular app / website you use is adding the "Dark Mode" feature.

What wow-ed me recently is the ambient light sensor in browsers:

![native](https://miro.medium.com/max/800/1*cjxgmtRKAnL3kWLFAoGahw.gif)
*src: https://blog.arnellebalane.com/using-the-ambient-light-sensor-api-to-add-brightness-sensitive-dark-mode-to-my-website-82223e754630*

More on this here:

{% link https://dev.to/ananyaneogi/enabling-dark-mode-on-websites-based-on-surrounding-light--3jel %}


But, I really find the dark theme annoying in so many ways.

Is it just me?
What are the top 3 tools that help you get your work done?
Tags: discuss, productivity
Published: 2019-09-02 11:34:24

---
title: What are the top 3 tools that help you get your work done?
published: true
description: 
tags: discuss, productivity
---

As devs, we all have tools that help us get our day to day to work done. If you had to name your top 3 productivity tools, not counting code editors or terminals, what would you choose?

Mine would be: 

1. [**Notion**](https://www.notion.so) - I'd love to write a post in the future showing my Notion setup. I'm such a fan! I love the customizability of this note taking app. It makes it easy for me to organize my notes in a way that makes sense to me and it's aesthetically pleasing. I use it both for work life and personal life.

2. [**Brain.fm**](https://brain.fm) - I've started using this service recently and it has made such a difference. In an open office, it can sometimes be hard to sit down and focus in on the code with everything else going on around me. If I sit down with my noise cancelling headphones and Brain.fm, I'm usually able to get focused in 10-15 min.

3. [**GoodReads**](https://www.goodreads.com) - GoodReads helps keep me accountable and stay on track with my reading, both personal and professional. I can track and prioritize books I want to read, split them into different lists, and see what my friends and co-workers are reading. Reading is fundamental to learning and growing so I'm glad to have a tool that helps keep it top of mind for me.

I can't wait to hear what yours are!
Strong password generation and hacking
Tags: passwordgenerator, cybersecurity, hacking
Published: 2019-09-02 12:53:55

I found a bit more difficult [read on password managers](https://medium.com/hackernoon/strong-password-dilemma-tips-on-securing-your-data-online-f853784f2bdf). It's quite understandable for a non tech folk and an easy read for tech lovers. The article explains what is password hacking and what are the potential dangers. 
You can find pretty interesting statistics about which big companies are experiencing password leaks and how common is this issue in general. I found it fascinating, how password hacking methods are improving and basically nobody is safe anymore.
nodejs event loop
Tags: node, javascript, eventloop, libuv
Published: 2019-09-02 12:47:43

---
title: nodejs event loop
published: true
description: nodejs event loop
tags: nodejs, js, event loop, libuv
---

最近遇到个问题，在for loop里面调用http.get请求，测试发现，会慢个几ms然后请求才会发出去,代码如下：
```js

async function run() {
    for (let i = 0; i < 100; i++) {
        for (let j = 0; j < 40; j++) {
            let local_ts = Date.now();
            let cid = 'cid_' + i * 1000 + j;
            let url = `http://127.0.0.1:8890/ts?id=${cid}&ts=${local_ts}`;
            http.get(url).then(ret => {
                let server_ts = ret.split(' ')[1];
                let finish_ts = Date.now();
                console.log(cid, ret, 'elapsed', finish_ts - local_ts, 'server_diff', server_ts - local_ts, 'finish_diff', finish_ts - server_ts);
            });
            console.log(cid, 'fired', local_ts, Date.now());
        }
        await Sleep(3000);
    }
}

run();
```
调用的是个http服务，传本地的timestamp给他，他返回server的timestamp，方便我们计算网络的latency。

这时候就非常疑惑了，为什么server收到我们发送的请求都要6-10ms，这中间网络肯定没这么慢。

怀疑是event loop的锅，首先看了下http的实现，在最后会调用一个process.nextTick

![libuv event loop](http://docs.libuv.org/en/v1.x/_images/loop_iteration.png)


event loop里面分了很多个loop，代码可以参考
```c
r = uv__loop_alive(loop);
  if (!r)
    uv__update_time(loop);

while (r != 0 && loop->stop_flag == 0) {
    uv__update_time(loop);
    uv__run_timers(loop);
    ran_pending = uv__run_pending(loop);
    uv__run_idle(loop);
    uv__run_prepare(loop);

    timeout = 0;
    if ((mode == UV_RUN_ONCE && !ran_pending) || mode == UV_RUN_DEFAULT)
      timeout = uv_backend_timeout(loop);

    uv__io_poll(loop, timeout);
    uv__run_check(loop);
    uv__run_closing_handles(loop);

    if (mode == UV_RUN_ONCE) {
      uv__update_time(loop);
      uv__run_timers(loop);
    }

    r = uv__loop_alive(loop);
    if (mode == UV_RUN_ONCE || mode == UV_RUN_NOWAIT)
      break;
}
```
而process.nextTick是在这里面任意一个loop结束后就执行的，所以我们的请求其实都堆积到了sleep那儿，因为http get都在for loop里面，所以这里我们如果要立马执行http get，需要切出我们的loop回到event loop. 在循环立马加入一个await Sleep(0)


```js

async function run() {
    for (let i = 0; i < 100; i++) {
        for (let j = 0; j < 40; j++) {
            let local_ts = Date.now();
            let cid = 'cid_' + i * 1000 + j;
            let url = `http://127.0.0.1:8890/ts?id=${cid}&ts=${local_ts}`;
            http.get(url).then(ret => {
                let server_ts = ret.split(' ')[1];
                let finish_ts = Date.now();
                console.log(cid, ret, 'elapsed', finish_ts - local_ts, 'server_diff', server_ts - local_ts, 'finish_diff', finish_ts - server_ts);
            });
            console.log(cid, 'fired', local_ts, Date.now());
            await Sleep(0);
        }
        await Sleep(3000);
    }
}

run();
```

这时候堆积之后再请求的问题就解决了，不过问题还是有，一毫秒左右才一个请求，感觉太慢。

PS. Sleep代码

```js
const Promise = require('bluebird');
module.exports = function(duration) {
    return new Promise(resolve => {
        setTimeout(() => {
            resolve(null);
        }, duration);
    });
}
```
Building Your Own Uber: 9 Apps Like Uber to Get You Inspired
Tags: mobileappdevelopment
Published: 2019-09-02 12:38:41

Almost 10 years ago Uber disrupted the market of taxi services by creating a simpler and cheaper alternative to traditional cabs. Since then the company has spread to 250 cities and 80 countries around the globe and has more than 75 million active users. Their 2018 report states that the company’s full-year revenue for 2018 was $11.3 billion, with 43% increase from the previous year. Uber’s success has become a phenomenon, as well as an inspiration for others in the B2C field. Apps like Uber have become a global trend across various industries: from housecleaning, medical services to food delivery, and even dog walking.

#Apps like Uber from various industries

##Swifto

![Apps like Uber: On-demand dog walking services](http://perfectial.com/wp-content/uploads/2019/08/swifto.png)

**What is it?**

Swifto is New York-based on-demand dog walking service. It incorporates mobile technologies, GPS tracking, photos and live notifications to offer the highest level of reliability and trust to pet owners. The service offers professional dog walkers who can help out either on the regular basis or if an occasional walk is needed.

**How it works?**

First, the app matches a user with a dog walker who is equipped with an app and whose background and experience are checked. From then on devoted dog owners can enjoy notifications about their pet’s walks, when they start and end, as well as can monitor the walk via GPS, browse pictures from the walks. At the end of every walk, owners will receive a message from the walker letting them know how the walk went. They can also watch their dog’s walk online.

Launched back in 2013, the app is still a success among dotting dog owners.

##BlackJet

![Apps like Uber: On-demand jets](http://perfectial.com/wp-content/uploads/2019/08/blackjet.jpg)

**What is it?**

Launched in 2012, BlackJet announced it’s like Uber but for jets. It allowed its customers to book seats on private jets immediately and with guaranteed seat availability. The service was originally backed by Uber co-founder and chairman Garrett Camp and an early Uber investor Shervin Pishevar who developed the idea. The startup attracted an array of celebrity investors from Ashton Kutcher, Will Smith and Ja Z’s Roc Nation to Marc Benioff and Tim Ferriss.

**How it works?**

Their idea was to become Uber but for the jet-set, where clients pay an annual fee and in exchange get access to a network of private jets on which they can book flights.

But it has been a bumpy ride for BlackJet. The company experienced massive layoff and service suspension in 2013 until they finally went out of business in 2016.

View blog and read more about [apps like uber](https://perfectial.com/blog/9-apps-like-uber/). The post appeared first on [Software Development Outsourcing  Company Perfectial](https://perfectial.com).