teleren/devto huggingface dataset:
Excuse me, would you let my Neural Network drive?
Tags: javascript, neuralnetwork, perceptron
Published: 2019-02-08 06:15:16

---
title: Excuse me, would you let my Neural Network drive?
published: true
description: A neural network experiment involving a JavaScript game
tags: javascript, neural network, perceptron
canonical_url: https://github.com/victorqribeiro/carGamePerceptron
cover_image: https://thepracticaldev.s3.amazonaws.com/i/keql8rl9r22wje8ef2kj.png
---


# Excuse me, would you let my Neural Network drive?

A Neural Network experiment involving a JavaScript game: can a perceptron drive a car?

[![Scrap](http://img.youtube.com/vi/g0WV3qWcVuA/0.jpg)](http://www.youtube.com/watch?v=g0WV3qWcVuA)

A live version of the code is hosted [here](https://victorribeiro.com/carGamePerceptron)

# About

Not so long ago I published the [simplest perceptron you'll ever see](https://github.com/victorqribeiro/perceptron), code I wrote after a machine learning class, a while back. Ever since that I've been meaning to do something cool with it. So, browsing some [more old codes](http://jsfiddle.net/user/victorqribeiro) I found a [little game](https://github.com/victorqribeiro/carGame) I made when I was studing fake 3D perspective, so I thought: can my perceptron play this game?

So I gave the game code a little brushing, wrote some more code to capture the data of me playing it (I played until I got a score of 33 points) and feed it to my neural net. After that I just played with the learning rate and iterations and let it play the game on it's own.

A [Neuroevolution](https://en.wikipedia.org/wiki/Neuroevolution) you say? Yes, I thought about that. I have a fully conected multilayer perceptron, that I'm about to realease, So I'm saving the ideia of evolving a neural net with genetic algorithm for that.

# Questions?

If you have any questions about the code or how I implemented it, or even how I got the data to feed the neural network (features), please feel free to contact me. (I left some comments on the code)


You can take a look at the code [here](https://github.com/victorqribeiro/carGamePerceptron)
Understanding Arrow functions in JavaScript
Published: 2019-02-08 05:49:46

---
title: Understanding Arrow functions in JavaScript
published: true
description: 
tags: 
---

![](https://thepracticaldev.s3.amazonaws.com/i/er6hpt4l34quc2ktxkkt.png)

Arrow functions were introduced in es6 or es2015, since then it's very popular among developers. And it's the coolest thing that I love the most.

Arrow functions changed the way we declare a function. It's made functions declaration easy, fast and stylish.

The arrow in it's name come from it's arrow like syntax. Let's take an example

```
const foo = () => console.log('Hey, Arrow!');
```

##How to use it##
Arrow functions works very similar to anonymous functions.

```
//Anonymous functions
const foo = function () {
    console.log("I'm old!");
}
 
//Arrow functions
const foo = () => {
    console.log("I'm new!");
}
```

But arrow functions provide more flexibility. 
Like if you have only one statement in function body then you can remove those curly braces.

```
const foo = () => console.log("Isn't it cool!");
```
Also if you returning some value you don't need to provide the return kayword.
```
const foo = () => "Wow!"
```
And if you need to return an object you would do.
```
const msg = () => ({
    type: 'msg',
    body: 'Hey'
})
```

Now, You can pass multiple parameters to it.
```
const add = (a, b) => a + b;
```
And last but not the least, if you have only one parameter you also can remove those Parenthesis.
```
const product = a => a * a;
```
Now look how easy it is to declare a function using arrow functions.

I hope you learn something from this article. Thanks for reading..
Decompile and dissasemble JVM bytecode compiled from Kotlin source code
Tags: kotlin, java, jvm, bytecode
Published: 2019-02-08 04:19:32

---
title: Decompile and dissasemble JVM bytecode compiled from Kotlin source code
published: true
description: how to disassemble and decompile for kotlin.
tags: kotlin,java,jvm,bytecode
---

This is an experiment to try using javap (disassembler) and jad (decompiler) for this Kotlin code.


```kotlin
fun main (args: Array <String>) {
    println ("Hello, World!")
}
```

Code source
https://kotlinlang.org/docs/tutorials/command-line.html

Like other JVM languages, Kotlin is compiled into a class file executable as Java.
We can verify it because javap can display the mnemonic of JVM and decompile as java source code with jad.


Compile this.

```
kotlinc hello.kt -include-runtime -d hello.jar
```

Extract jar and use javap, jad for hello.class

```
jar xf hello.jar
```




# Environment

macOS High Sierra 10

# javap (Disassembler)

## Preparation

It is unnecessary since it is in the JDK from the beginning

## Execution

```
javap - c HelloKt.class
```

Result

```
Compiled from "hello.kt"
public final class HelloKt {
  public static final void main (java.lang.String []);
    Code:
       0: aload_ 0
       1: ldc # 9 // String args
       3: invokestatic # 15 // Method kotlin / jvm / internal / Intrinsics.checkParameterIsNotNull: (Ljava / lang / Object; Ljava / lang / String;) V
       6: ldc # 17 // String Hello, World!
       8: astore_1
       9: getstatic # 23 // Field java / lang / System.out: Ljava / io / PrintStream;
      12: aload_1
      13: invokevirtual # 29 // Method java / io / PrintStream.println: (Ljava / lang / Object;) V
      16: return
}
```


# jad (decompiler)
## Preparation
How to introduce jad

```
brew tap caskroom / cask
brew install caskroom / cask / jad
```



## Execution
 You can display the mnemonic as a comment with the -a option.

Command

```
$ jad -a HelloKt.class
$ cat HelloKt.jad
```

```java
import java.io.PrintStream;
import kotlin.jvm.internal.Intrinsics;

public final class HelloKt
{

    public static final void main (String args [])
    {
        Intrinsics.checkParameterIsNotNull (args, "args");
    // 0 0: aload_ 0
    // 1 1: ldc 1 # 9 <String "args">
    // 2 3: invokestatic # 15 <Method void Intrinsics.checkParameterIsNotNull (Object, String)>
        String s = "Hello, World!";
    // 3 6: ldc 1 # 17 <String "Hello, World!">
    // 4 8: astore_ 1
        System.out.println (s);
    // 5 9: getstatic # 23 <Field PrintStream System.out>
    // 6 12: aload - 1
    // 7 13: invokevirtual # 29 <Method void PrintStream.println (Object)>
    // 8 16: return
    }
}
```

It was  easy to introduce and analyze.
I will check how Kotlin specific functions are represented and converted as Java in the future.
Tips for react-native upgrade to v0.58.4
Tags: reactnative
Published: 2019-02-08 03:19:01

---
title: Tips for react-native upgrade to v0.58.4
published: true
description: 
tags: react-native
---

## What is the article

I tried upgrade react-native v0.57.7. to v0.58.4.

This article is the saga of upgrading.

## Steps

At first, upgrade react-native to v0.58.4, , react to 16.6.1 and metro-react-native-babel-preset to 0.51.1 by yarn or npm.

You might meet errors when `yarn react-native ios or android`.

Additional steps here.

### For iOS

[Mentioned from changelog](https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md#058), you need to link `JavaScriptCore.framework` as librariy by manual.

It's all done when my use case.

### For Android

Upgrading for android is a bit complicated, follow the [changelog](https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md#058)

I met error of `More than one file was found with OS independent path 'lib/x86_64/libjsc.so'` same as [this issue comment](https://github.com/facebook/react-native/issues/2814#issuecomment-458866869)

So, I fixed errors by modifying build.gradle files.

The final result of files are following.

- `android/build.gradle`

```gradle
...
ext {
    ...
    buildToolsVersion = "28.0.2"
    compileSdkVersion = 28
    ...
}
```

- `android/app/build.gradle`

```gradle
android {
    ...
    packagingOptions {
        pickFirst 'lib/x86_64/libjsc.so'
        pickFirst 'lib/arm64-v8a/libjsc.so'
    }
    ...
}
```

## Conclusion

I hope these tips are helpful for you.
Have a habby react-native developing!
Best Way to Test Coding Skills During a Job Interview? 
Tags: discuss
Published: 2019-02-08 02:02:08

---
title: Best Way to Test Coding Skills During a Job Interview? 
published: true
description: 
tags: discuss
---

According to HackerRank's 2019 Developer Skills Report, hiring managers cite assessing skills as their number one problem when screening tech candidates. 

What is the best way to assess coding skills during job interview for a developer candidate?
Hi, I'm Alex! Nice to meet you
Tags: introduction, intro, helloworld
Published: 2019-02-07 22:33:15

---
title: Hi, I'm Alex! Nice to meet you
published: true
description: 
tags: #introduction, #intro, #helloworld
---
 ![At work](https://thepracticaldev.s3.amazonaws.com/i/ib3o3vrg8jamia56jokq.jpeg)


Hi, I'm Alexandru, a young(ish) PHP developer. I have more than 6 years experience in web technologies and a couple more in the now non-existing Flash. 

I've been reading articles on this community for quite some time and felt inspired to write a bit about myself.

More about the early days at http://codingrealm.com/ (WIP)

I am passionate about web development, especially designing systems architecture and backend code. I do dabble in Vue.js and well, Js in general ... but I don't care much about CSS(my brain just never wraps around it the right way :P ). I do however like anything about UX.

I've started PHP and web from scratch after years of Flash animations and mini-apps. It was tough, at least at first. I had to work my way up through:

 - old codebase debug
 - analytics engines that used Mysql clusters, in memory tables, tens of workers etc 
 - Wordpress development
 - random 'frameworks' bought by clients that afterwards wanted everything changed
 - new app development, from Laravel, v3 up to 5
 - leading teams that create and maintain sites, that now power entire businesses for our clients

My experiences, long nights, random errors (looking at you emoji and strlen), console.log that break IE and many, many more helped shaped me, and now in return, I am trying to shape the young devs at my workplace. 

I think I will try to write more, it's starting to grow on me.

Ps. I collect toys from KinderEggs, so that clear desk above is just an anomaly 

![At work](https://thepracticaldev.s3.amazonaws.com/i/exnn96tlaevun004o1fo.jpeg)
How to get started with Angular, for total beginners...
Tags: angular
Published: 2019-02-07 22:27:47

---
title: How to get started with Angular, for total beginners...
published: true
description: how to start developing with Angular
tags: angular
---
For a friend, I put together steps to start from scratch with Angular. By "from scratch" I mean, you know how to turn on your computer and work with HTML and CSS, but as far as working with Angular, you haven't a clue. I include setting up your dev environment. Let me know what you think.

https://www.benmulford.com/home/how-to-start-from-scratch-with-angular-a-beginners-guide
Ruby/Rails : Memoization with dynamically defined methods
Tags: beginners, rails, ruby, performance
Published: 2019-02-07 22:08:30

---
title: Ruby/Rails : Memoization with dynamically defined methods
published: true
description: Memoize results of dynamically defined methods in Ruby and/or Rails 
tags: beginners, rails, ruby, performance
---

Ruby(and Rails for that matter) is pretty magical and I am sure most people working on it or those who have written any sort of code in the language at all will agree with me on this. 

![Mind=Blown!](https://media.giphy.com/media/xULW8y5CDynhoSOwVy/giphy.gif)

One of the most common tricks that Ruby allows you to do, and is used almost everywhere in Rails as well, is the ability to dynamically define methods. You can do so by simply, you guessed it right, calling `define_method` inside a class.

```ruby
class User < ActiveRecord::Base

    scope :active, -> { where(active: true) }
    scope :visible, -> { where(visible: true) }
    scope :deleted, -> { where(deleted: true) }

    FILTERS = %w[active visible deleted]
    
    FILTERS.each { |filter|
        define_method filter do
            self.class.send(filter)
        end 
    }
end
```

Now that we have seen what `define_method` can do, let's move on to some jargon. [Memoization](https://en.wikipedia.org/wiki/Memoization) in general means to cache complex computation or network calls in-memory. Memoization is a fairly common practise in most real-world applications and a simple example of how it is used in rails in daily life:
```ruby
    def get_users
        @users = User.where(conditions...).all
    end

    def get_users_memoized
        @users ||= User.where(conditions...).all
    end
```
In an ideal production app, you would use pagination as well, but I would like to keep things simple for now. Say if you called the method `get_users` multiple times as part of rendering a page, it would make a query to the database and fetch the list of users every time you call the method, whereas upon calling `memoized_results` multiple times, only the first time the database would be hit and the results of the query would be cached in the instance variable `@users`.

Coming back to the dynamic_method definition earlier, you would need a hack to apply the same memoization technique here as you cannot use a single static variable for memoizing multiple different methods. Snippet below demonstrates on how we can use meta-programming(more ruby magic ;)) to overcome this limitation:

```ruby
# memoize db/network responses in instance variable dynamically
def memoize_results(key)
  return instance_variable_get(key) if instance_variable_defined?(key)
  instance_variable_set key, yield  
end

# usage
FILTERS.each { |filter|
    define_method filter do
        memoize_results("@#{filter}_users") do
            self.class.send(filter)
        end
    end 
}
```
Poll: Interested in a step-by-step guide to build your first website? blog? app?
Tags: codenewbie, 100daysofcode, poll
Published: 2019-02-07 21:56:57

---
title: Poll: Interested in a step-by-step guide to build your first website? blog? app?
published: true
description: Running a poll to determine what kind of guides to create and publish throughout 2019. Votes + Feedback will dictate what I work on.
tags: #CodeNewbie #100DaysOfCode #Poll
---

Doing some research. Please help me out. :)

Would you be interested in a step-by-step guide to building your first website, blog, or app? I want to help! I will create guides throughout 2019 based on your feedback.

(If yes, reply with preferred format, e.g. PDF, eBook, video, blog).

[Vote on this Twitter Poll here to let me know!](https://twitter.com/LashaKrikheli/status/1093399781337194497)
Overcome Fear
Tags: discuss, career, motivation, challenge
Published: 2019-02-07 20:50:09

---
title: Overcome Fear
cover_image: https://thepracticaldev.s3.amazonaws.com/i/zf23o789q6lbsvqwyba5.jpg
published: true
description: What are those things you fear so much that you cannot embrace and still yet to overcome?
tags: discuss, career, motivation, challenge
---

What are those things you fear so much that you cannot embrace and still yet to overcome?

For example, for me, it is putting myself out there and in front of everyone or everything. At that moment I am getting the most social anxiety. 

Yes, I am trying to identify my fear, and then go ahead and face them head on because our fears are our limits only. So, I am working on that to become better day after day. 

Usually, we have two options. Either we will forget everything and accept the fear, or we will face everything and rise! The choice is only on us.

However, by avoiding any challenges, we stunt our growth. When we challenge ourselves, our quality of life increases exponentially. Not only our quality of life will improve, but also we will learn more about ourselves in the process. Challenging ourselves will make us feel stronger, smarter, and happier.

Traditionally, it happens a lot when it comes to career, relationship or any specific fear - phobia - like acrophobia, claustrophobia, arachnophobia, etc.  The best solution, in this case, is to challenge ourselves and resolve the situation that is making us so unhappy. 

Bad job? Change a job. 
No personal growth? Leave your comfort zone.
Toxic relationship? Don't gift yourself with it.
Any phobia? Ask help from a doctor.

In the end, the negativity associated with these situations will limit our potential when it comes to all areas of our life. 

I believe once we resolve these situations, the result gives us a fantastic opportunity to learn and set our soul on fire 🔥

Do you know your fears? Challenge them!

**Do you have any fear you want to challenge tomorrow? Leave a comment below!**

---

_Photo by Aarón Blanco Tejedor on Unsplash_
How to run simple tests against custom Ansible modules
Tags: ansible, testing, vscode, python
Published: 2019-02-07 20:44:54

---
title: How to run simple tests against custom Ansible modules
published: true
description: Quick insight on how to test Ansible modules in CLI and in VSCode
tags: ansible, testing, vscode, python
---

Say you're writing a module to ensure a cat.jpg file exists but the out of the box `file` module isn't cutting it for you! Typically, you'd bring up the documentation and start plugging away at your new, special module! Everytime you hit a major milestone of functionality, you'd write a little playbook using the new module, move over to your CLI and run `ansible-playbook cat-module-test.yml`

```
$cat cat-module-test.yml

---
- hosts: localhost
  connection: local
  gather_facts: false
  tasks:
    - cat_module:
        state: present
        src: cat.jpg
        dest: /tmp
```

While this DOES work, there are a couple problems:
1. you are only testing if the module works; you can't see any debug outputs during execution
2. cannot watch variables during execution
3. cannot set break points
4. output is ansible-ized, less friendly to read while testing

Instead, I will show you a new way to easily test this code by passing arguments directly. First we need to make an args file:

```
$ cat args.json

{ "ANSIBLE_MODULE_ARGS": {
    "state": "present",
    "src": "cat.jpg",
    "dest": "/tmp"
  }
}
```

## Test via CLI

Using this `args.json` file you can easily test without invoking `ansible`!

`python ./cat_module.py args.json`

## Test via VSCode

Alternatively, you can use an IDE, here's an example of how to use in VSCode

1. after opening your folder, click the `debug` menu option on the left pane
2. create a new debug config and adjust the appropriate stanza in `launch.json`

```
{
    "name": "Python: Terminal (integrated)",
    "type": "python",
    "request": "launch",
    "program": "/home/rmullen/git/library/cat_module/cat_module.py",
    "console": "integratedTerminal",
    "args":["/home/rmullen/git/library/cat_module/args.json"]
},
```

**Press play!** (literally, the play button in the debug menu)

With this method, you can now set break points, see print() statements, and step through code the way you would hope when writing python!
What is Proof of Work?
Tags: blockchain, opensource
Published: 2019-02-07 19:47:44

---
title: What is Proof of Work?
published: true
description: Do you know the pros and cons of PoW? Bitcoin and Ethereum main consensus?
tags: blockchain,opensource
---

The next several blocks of my series will be dedicated to synchronization between blockchain nodes and how they come to an agreement (**consensus**).

Everything in software has its pros and cons... there is no silver bullet, sadly.

{% twitter 1093595939871383552 %}

For more blocks checkout my Twitter-chain: https://twitter.com/BlocksByLukas
What is your experience with Safari Books training?
Tags: selflearning, videotraining, pluralsight, safaribooks
Published: 2019-02-07 18:43:41

---
title: What is your experience with Safari Books training?
published: true
description: 
tags: self-learning, video-training, pluralsight, safaribooks
---

I had a Pluralsight subscription once. I was happy, but I didn't know safari books back then.

I was thinking of subscribing there, as I am reading very positive reviews on various sites.

Is live training worth it? Do they have lot of videos and up-to-date contents? Do you read their books from day one?

What is your experience, pros and cons etc though? Bonus, if you have used both fairly recently and can do a quick comparison.
Best Tutorials to Learn Spring MVC?
Tags: springmvc, java, web, tutorial
Published: 2019-02-07 18:22:16

---
title: Best Tutorials to Learn Spring MVC?
published: true
description: Asking for recommendations for tutorials.    
tags: Spring MVC, Java, Web, tutorial
---

I would appreciate any recommendations for how to best learn Spring MVC. It can be a book or online tutorial. I need to learn for a possible job!
Introducing DocsThursday: A Monthly Documentation "Party"
Tags: documentation
Published: 2019-02-07 17:49:17

---
title: 'Introducing DocsThursday: A Monthly Documentation "Party"'
tags: 
  - "docs"
  - "documentation"
cover_image: "https://thepracticaldev.s3.amazonaws.com/i/nl2j3xbcpydonw07nx60.png"
canonical_url: "https://www.feliciano.tech/blog/introducing-docsthursday/"
published: true
---

I love open source documentation and if you're reading this, maybe you do too.
I have a personal mantra of "Inspire, Educate, Motivate" and documentation fits right into that.
Documentation allows us to **educate** others to a near infinite scale.

You know, I partially owe my career to the free and accessible Linux server documentation that is available on the [Linode Docs](https://www.linode.com/docs/) website.
I'm a die-hard Ubuntu user but I can't tell you the countless times the [Arch Linux Wiki](https://wiki.archlinux.org/) has helped me out of tight spots.

Docs are invaluable.

I want to **motivate** more people to contribute and learn from one another on how we can make better contributions and better doc websites.
[DocsThursday](https://DocsThursday.com) is a party, campaign, workshop, or whatever you want to call it to create and contribute to open source documentation on the 3rd Thursday of every month.

<!--more-->

## Why DocsThursday?

There's nothing special about Thursdays.
I could have done a Docs Wednesday or Friday but it wasn't as catchy and we all know Tuesdays are for tacos.
So Thursday it is.

DocsThursday is inspired by DigitalOcean's [Hacktoberfest](https://hacktoberfest.digitalocean.com/), [24 Pull Requests](https://24pullrequests.com/), and most importantly, Write the Docs's [Writing Day](https://www.writethedocs.org/conf/portland/2019/writing-day/).
I'm trying to take the energy and productivity of Writing Day and replicate it more frequently at meetups local to you, with your co-workers within your company, and even online as a hackathon.

Let's take 30 minutes, an hour or even more, just once a month in order to give some love to open source documentation.

Interested? Check out the website, [DocsThursday.com](https://DocsThursday.com).


## Would you like to help out?

DocsThursday is brand new and I'm still figuring out what to do with it.
The [website is open source](https://github.com/felicianotech/docsthursday.com) and built with [Hugo](https://gohugo.io/).
Feel free to open PRs to improve the website or open Issues to ask questions or start discussions.
You can also start discussions/ask questions here in the comments or [message me on Twitter](https://twitter.com/FelicianoTech).

If you've had these feelings or similar ideas, speak up!
Let's do this together. :smile:

---

**P.S.** The first DocsThursday is February 21st.
I run the Write the Docs NYC meetup and we're hosting an event in New York for DocsThursday.
If you're around, [check it out](https://www.meetup.com/WriteTheDocsNYC/events/258747106/).
If you're not, start one in your area on the 21st and I'll list it on the DocsThursday website for people to find.