teleren/devto huggingface dataset:
Mistake #1 - Code First Approach
Tags: mistakes, developer, learning, beginners
Published: 2019-09-30 13:53:52

>“Mistakes are a fact of life. It is the response to error that counts.” - Nikki Giovanni

{% youtube auQqBWs9iKo %}

Everyone make mistakes and learn from it. However, it is also important to learn from others.

>“Learn from the mistakes of others. You can’t live long enough to make them all yourself.” - Eleanor Roosevelt

My journey of becoming professional software developer started in 2007, and I have to admit that I have made mistakes throughout my career progression. A good thing is that I learnt from those errors. This series of posts is to highlight these mistakes as well as some of my observations when training fresh graduates. I hope this will help beginner and intermediate level developers, who are making their mark into the industry, to avoid repeating these mistakes.

The very first mistake that I am going to talk about is, Mistake #1 Code First Approach.

Programming is the process that takes an algorithm and put it into code that computer can understand and execute. We make use of programming languages to make this happen. In the growing world of technology inventions, you can literally automate any manual process.

![oops! where is my image?](https://images.pexels.com/photos/957424/pexels-photo-957424.jpeg?cs=srgb&dl=macbook-pro-programmer-programming-957424.jpg&fm=jpg)

A common mistake that I observed in an entry level programmer is that they don't work through the problem statement manually. This problem statement could be a programming assignment, developing a software application from scratch or adding a new feature to an existing software product. It is important that before you jump into coding, you need to make sure that you understand the requirements.

what sort of input will be required?
what is the expected outcome?
what will be the execution workflow? 

There are dozens of other questions that should pop up in your mind. The very first step is to read and understand the problem statement and ask these questions to yourself, try figuring out answers to these.

You may get to the solution by simply jumping into the code, but remember it may take more iterations to the final solution. Using the right language construct is important, but it is more important that you have understood what you need to implement.

Looking forward to hear your observations on this topic.

> Learning by making mistakes and not duplicating them is what life is about.

Keep learning!
Split, Apply, Merge in D 
Tags: dlang, tutorial
Published: 2019-09-30 13:52:36

I wanted to find Groupby, a means to iterate a list in groups (lists of lists). In that search I came across this article about split, apply, merge for datatables. This looked like what I wanted, but it being specific to data science had me confused.

In D these function are chunkBy, map, joiner. The pattern of consistency continues as we just need to specify what to group on, once our list is sorted. 

```dlang
import std.algorithm;

auto data = [1,1,2,2];
assert(data.chunkBy!((a, b) => a==b)
           .equal!equal([[1,1],[2,2]));
```

Unlike previous lambdas, this one is taking two arguments, this allows for elements to be grouped in interesting ways.


```dlang
import std.algorithm;

auto data = [1,1,2,2,3,3];
auto evenGrouping(int a, int b) {
    if(a%2 == b%2)
        return a < b;
    return a%2 < b%2;
} 

assert(data.sort!evenGrouping
           .chunkBy!((a,b) => a%2==b%2)
           .equal([[2,2],[1,1,3,3]]));
```

As mentioned sorting needs to happen first.


```dlang
import std.algorithm;
import std.range;

auto data = [3,3,1,1,2,2];

assert(data.sort!((a, b) => a%2 < b%2) 
           .chunkBy!((a,b) => a%2==b%2)
           .map!(x => x.array.sort)
           .equal!equal([[2,2],[1,1,3,3]]));
```

In this contrived example I decided it best to run it through a compiler. It was a good thing as I found a difference in behavior. I'll save `map` for another day.

Two types of lambda functions are supplied to these functions. One takes a single argument which gets referred to as unary predicate and one that takes two which gets referred to as binary predicate.

When a unary predicate is supplied to `chunkBy` it returns a tuple of the quality found and the value. This is an interesting optimization but this overload should live with `group` which already has this behavior.
Untitled Developer Game
Tags: discuss, jokes
Published: 2019-09-30 13:28:36

---
title: Untitled Developer Game
published: true
description: 
tags: discuss, jokes
cover_image: https://thepracticaldev.s3.amazonaws.com/i/oj3z2ik2nljmnxxigmx0.jpg
---

Have you seen or played [Untitled Goose Game](https://goose.game/)? It is so much fun being a horrible goose gently messing with people's lives in a quiet village.

It got me thinking, what if you were the goose? What if you just wanted to mess with your colleagues or your office? What would you do?

(Obviously you wouldn't, you're a nice person, not a horrible goose.)

I started some ideas on Twitter:

{% twitter 1178544725374197760 %}

What's on your to-do list?

HONK!
Daily Challenge #79 - Connect Four
Tags: challenge
Published: 2019-09-30 13:22:40

---
title: Daily Challenge #79 - Connect Four
published: true
series: Daily Challenge
description: first player who connects four items of the same color is the winner
tags: challenge
---

Catch up on your Connect Four [here](<https://en.wikipedia.org/wiki/Connect_Four/>) . 

The grid is 6 row by 7 columns, those being named from A to G.

You will receive a list of strings showing the order of the pieces which dropped in columns:

`pieces_position_list = 
["A_Red",
                          "B_Yellow",
                          "A_Red",
                          "B_Yellow",
                          "A_Red",
                          "B_Yellow",
                          "G_Red",
                          "B_Yellow"]`

The list may contain up to 42 moves and shows the order the players are playing.

The first player who connects four items of the same color is the winner.

You should return "Yellow", "Red" or "Draw" accordingly.


***
_This challenge comes from aryan-firouzian at [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!_
SpaceInvaders with only JavaScript and CSS!
Tags: game, javascript, css, spaceinvaders
Published: 2019-09-30 13:18:04

I've created a Javascript + CSS only SpaceInvaders game, to test the performance of a complex HTML management, here there is a video:

[Watch on Loom](https://www.loom.com/share/b9b7a98a2e9f4c93b63802878d0e8fec)

The result is really cool, and the target FPS is pretty high (60fps), without any canvas!

What do you think about this project? Let me know! ^^

Take a look to the repo [here](https://github.com/NicolaLC/spaceinvaders-js)
Picking the first value you find from 2 objects in Rego
Tags: rego, opa, openpolicyagent
Published: 2019-09-30 13:13:15

This post is about "how you can pick the first value you find from 2 objects" in [Rego](https://www.openpolicyagent.org/docs/latest/policy-language/), a query language used in [OPA (Open Policy Agent)](https://www.openpolicyagent.org/).

This use case is a little confusing and you'll probably think "When is this necessary?". One example is shared in ["Merge Objects"](https://www.openpolicyagent.org/docs/latest/policy-cheatsheet/#merge-objects) in the official docs.

When merging multiple objects, you'll definitely need to think about **colliding keys** and how to decide which `key`, `value` to choose. This is where you'll want to use "Pick the first value you find from 2 objects".

Let's dive into details.

## Logical OR in Rego

The function which "Picks the first value it finds from 2 objects" will be called `pick_first`. Here's how the implementation will look like.

```
has_key(x, k) { 
	_ := x[k]
}

pick_first(k, a, b) = a[k]
pick_first(k, a, b) = b[k] { not has_key(a, k) }
```

See how there are 2 definitions of `pick_first(k, a, b)`. This is how you express a [Logical OR](https://www.openpolicyagent.org/docs/latest/#logical-or) in Rego. So the expression above is like saying:

"For key `k`, choose the value from object `a`, **OR**, choose the value from object `b` if object `a` **DOES NOT HAVE** key `k`."

If you feel uncomfortable with the `has_key` function, look at my previous post specifically explaining about it here:

{% link https://dev.to/kenfdev/check-if-key-exists-in-object-in-rego-42pp %}

## Example

Here's a complete example demonstrating the usage of `pick_first`.

```
has_key(x, k) { 
	_ := x[k]
}

pick_first(k, a, b) = a[k]
pick_first(k, a, b) = b[k] { not has_key(a, k) }

x := {"a": true, "b": false}
y := {"b": "foo", "c": 4}

first_values = fv {
	a := pick_first("a", x, y)
   	b := pick_first("b", x, y)
    c := pick_first("c", x, y)
    fv := {
    	"a": a,
        "b": b,
        "c": c
    }
}
```

If you evaluate `first_values`, the result would be:

```json
{
  "a": true,
  "b": false,
  "c": 4
}
```

Notice how key `false` was chosen from object `x`'s key `b`. The only time the values of object `y` are selected are when the key doesn't exist in object `x` (e.g. key `c`).

You can check this out for yourself in the following playground:

https://play.openpolicyagent.org/p/puwMTreKjD

## Reference

* [Logical OR in Rego](https://www.openpolicyagent.org/docs/latest/#logical-or)
* [Negation in Rego](https://www.openpolicyagent.org/docs/latest/policy-language/#negation)
HackerX Event: Is It Worth It?
Tags: discuss, career, jobs, recruiters
Published: 2019-09-30 13:04:08

---
title: HackerX Event: Is It Worth It?
published: true
description: looking for information about the HackerX event.
tags: discuss, career, jobs, recruiters
---

Anybody ever attend a HackerX event? Is it worth going if you're not in the market for a job? From what I gather it's a "by invitation only" recruiting event. I guess it would be good for networking...and there's free food. I suppose it wouldn't hurt to attend. But I don't want to waste my time either. Thanks in advance for any responses.
"UI"​ AND "UX"​ OR "Visual Design"​ AND "Product Design"​ onsite:opportunity
Tags: database, startup, career, design
Published: 2019-09-30 12:54:46


   Or in other words, we are looking for UI and UX (also known as Visual and Product Design) for a full-time opportunity. We are proudly working with one of the fastest-growing start-ups in Silicon Valley. Fortune Magazine mentioned them as being of LinkedIns 'Most Wanted' Startups last year. Wall Street Journal gave acknowledgment to their practiced 'Radical Transparency', and John Chambers agreed when he said they "will be one of the hot stocks of the next decade", on Bloomberg TV.

Their successful growth has created your biggest opportunity as they seek exceptional Visual (UI) and Product Designers (UX). The ideal candidate for UI should have at least 3 years experience, UX candidates will have 4. All designers should have a background with working on web-based products, preferably for an enterprise company. If you are comfortable with startup environments and can push yourself beyond the limits of traditional design, then let's connect!

As mentioned above, this is a full-time onsite opportunity located within the infamous Silicon Valley. They provide a fun environment and offer perks that show their full appreciation for all employees. If you are currently outside of California and are willing to relocate, I encourage you to also connect with me for an additional opportunity. For immediate consideration for all designers, please send your portfolio showcasing you are as a designer, along with an updated resume.

*If know someone who would be a great fit for this position, please send a link to the LinkedIn profile, or have them reach out to me as soon as possible.

Best of Luck in all your journies,

Erica Austin, Technical Sourcer @ Gitty, Inc.
www.linkedin.com/in/ericaraustin
erica.austin@gitty.ai
Hacktoberfest begins in less than 24 hours
Tags: hacktoberfest
Published: 2019-09-30 12:47:41

Follow the Hacktoberfest tag on DEV. Folks have already begun posting there.

{% tag hacktoberfest %}

If you are interested in contributing to DEV itself, we will have an overview post ready to go tomorrow on day one.

In the meantime, feel free to star and follow our repo 🤩

{% github thepracticaldev/dev.to %}

Happy coding!
Prepare for Angular with a quick look at TypeScript

Published: 2019-09-30 12:29:25

When, during the junior phase of the immersive coding program I’m taking, we learned three different frameworks in a week, I questioned why we were learning AngularJS (version 1.7) when there had been so many meaningful updates since. 
In addition to the theory that you learn best by seeing how something works before learning how people have made it work easier, it was assumed that we didn’t learn Angular 2.+ because that was when it switched to TypeScript, and they didn’t want to burden us with learning another language while at the same time trying to wrap our heads around the entirely new concept of MVC. 
And it was at that very moment that TypeScript became some scary mental impediment to learning one of the most popular frameworks out there. 
It wasn’t until I actually had the time to sit and look at what TypeScript is and what it does that I realized that it’s not scary at all. In fact, at its core, it’s just JavaScript with some extras.
<h3>What is it?</h3>
Developed by Microsoft and released in 2012, TypeScript s a superset of JavaScript that compiles down to JavaScript, making it easy to integrate into existing JavaScript projects. It was designed for the development of large apps, and it’s fully compatible with ES6.

<h3>What does it offer?</h3>
Among TypeScript’s most notable features is also where it gets its name — static type checking, meaning that variables and functions can optionally be given “types” to indicate the data type that the programmer expects. If, for instance, you declare a variable like so — let myString: string; — and then try to assign it something other than a string, TypeScript will throw an error when compiling down to ES5, but be aware that it won’t actually stop you from assigning the wrong type, so you have to keep a close eye on the console. Type-checking makes it easier to find and prevent bugs, and it will make your code more readable and descriptive. 
TypeScript types include familiar JavaScript datatypes, such as string, number, boolean, array, and null, but also any, void, tuple, enum, and generics.
With TypeScript, class-based objects provide true object-oriented programming to JavaScript. In lieu of prototypes, subclasses and inheritance keep functionality in order.
Using TypeScript in your JavaScript projects is as easy as compiling the code down by using the tsc prompt in the command line, and in doing so, you can help ensure that your code is more accurate and more readable.
If you're looking to learn about TypeScript and how it can help your code, there are a ton of resources out there, including [this excellent list of tutorials] (https://hackr.io/tutorials/learn-typescript) from the folks at Hakr.io
Introduction to Load Balancing with HAProxy
Tags: haproxy, loadbalancing, ubuntu, linux
Published: 2019-09-30 12:25:29

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

HAProxy is great solution for load balancing as it does not require lots of resources, it is scalable, easy to setup and fairly simple to manage. In this guide, I'll show you how to install and configure HAProxy and load balance 2 Apache Web Servers.

Check out my latest post on the devdojo.com website:

https://devdojo.com/articles/introduction-to-load-balancing-with-haproxy

Let me know if you have any questions, I'll be more than happy to help!
Recursion in a nutshell
Published: 2019-09-30 12:14:21

Recursion in computer science is a sometimes tricky concept to wrap one's head around.

People often say that to understand recursion, one must first understand recursion! But it needn't be as daunting as it seems. Recursion at in its simplest form is simply a function call itself. My instructors have always told me to ignore complexity and let the recursive call do the work for me. Turns out, they're right!

Let's cover the basics first. In order for a function to be a working recursive function, it needs two things: a base case that serves as a stopping condition, and a recursive call that calls the selfsame function again(hopefully with a slightly modified argument).. 

Recursion is great for iterating through lists and trees. It does the heavy lifting of sifting through all of the possibilities for us, and does so quite elegantly might I add. 

I would say that the biggest shortfall of using recursion would be the effect that it can have on time complexity of operations. Using recursion where a simple for loop might have sufficed can cause your code's performance to suffer. One technique to hedge against increased time complexity, is memoization. It's used to store the results of expensive function calls and return the cached result when the same input occurs. Memoization can help a recursive function actually run faster than an iterative function if written correctly.

Be judicious and remember that with great power comes great responsibility, and remember that with great power comes great responsibility, and remember...
Text Based Logo
Tags: logo, css, font, webperf
Published: 2019-09-30 12:09:45

This week on Search Candy we are testing a text/font based logo, not using an image.

https://www.searchcandy.uk/

On hover the logo is given a CSS colour gradient.

There are a few pros of a text/font based logo as opposed to using an image:

* Faster load time / less resources on the page #webperf
* Can change the logo, apply CSS and effects on the fly #style
* Crystal clear rendering of the font at sizes from small to large #style

Cons:

* Reliant on the font being installed or downloaded #webperf
* Could potentially lead to multiple words being split across lines #style

We made use of the Roboto font - which is already cached on pretty much every computer in the world due to being used extensively by Google.

We also added a non-breaking space (nbsp) HTML character entity instead of generic space - which prevents the two words in our logo from being split.
Helical Starter package
Published: 2019-09-30 11:35:53

Get the helical starter package for managing your cybersecurity program. This package is having three essential modules for safeguarding your business. The modules are: 1. Security risk assessment 2. Continous vulnerability scanning and 3. Security training and phishing simulation.

Link for helical starter package: https://helical-inc.com/starter-package/

Link for security risk assessment: https://helical-inc.com/hlcproducts/cybersecurity-risk-assessment/

Link for Continous vulnerability scanning: https://helical-inc.com/hlcproducts/continuous-vulnerability-scanning/

Link for Security training and phishing simulation: https://helical-inc.com/hlcproducts/security-training-phishing-simulation/

Link for Helical Inc. : https://helical-inc.com
Start-up Starts Interview Series. SchedulR — The investor (road)show must go on
Tags: startup
Published: 2019-09-30 11:23:46

*“Start-up Starts” is a mini-interview series with some of the awesome start-ups we`ve worked with throughout the years and their inception. The first few months can make or break a project, so we wanted to dive deeper into these crucial moments for any start-up. We asked everyone the same three questions and … the rest is history. Literally.*

![img1](https://thepracticaldev.s3.amazonaws.com/i/7yxun31xhipdrr41x4d7.png)


[SchedulR](https://www.schedulr.eu/) started out from the desire to help institutional investors and listed companies connect and build trust easier. And disrupt the traditional broker model of corporate access while doing so.

Through the cloud-based platform, investors and companies can schedule meetings and attend events such as roadshows, investor days or conferences. We wanted SchedulR to cover everything you need to set up a meeting, from choosing the participants and sending out invitations to selecting the venue. The platform also comes with a feedback tool for collecting investor opinions and assessing market perception and a CRM.

We were responsible for the entire technical solution, from project planning and management to frontend and backend development. After three product versions, we are currently doing continuous development to streamline the launch and deployment of new features and updates.

Kilian Maier, CEO and founder of Interaction Partners, the Swiss investor relations services & advisory firm behind SchedulR, walks us through the early beginnings.

**1.) What sparked the idea for SchedulR?**
**Kilian**: I was covering banks as an equity analyst at a broker and I observed:
(1) if brokers organize corporate access, there are inherent conflicts of interest that are not really being addressed.
(2) the processes applied by the banks/brokers were very old-school, manual and not digitalized (slow, high risk of mistakes, inconvenient, expensive).
(3) With MiFID2 there was a regulatory ‘trigger’ on the horizon and banks always underestimate the long-term impact of regulatory changes.

**2.) Which were the first three steps you took to get things rolling?**
**Kilian**: (1) Have a rough idea about financials (how much money do you need) and define the things you need to take into account in order to move ahead.
(2) Check if your family and partner support you (and if they are willing to share the pain).
(3) Resign from your cushy, well-paying corporate job :)

**3.) Describe the biggest hurdle you had to overcome in the first 3 months.**
**Kilian**: Everything is new. But the real hurdles are not visible in the first 3 months. They come later, plenty.

If you are a start-up looking for a technical partner to be there along the ride, look no further. At [UPDIVISION](https://updivision.com/) we specialise in helping start-ups validate, launch and refine their MVP, while staying true to their vision. In Eric Ries` words, MVP is a process, not a product, and so is finding the right software development team.
Making a nested params for xxx_tag of View Helper in Rails
Tags: rails
Published: 2019-09-30 11:22:26

---
title: Making a nested params for xxx_tag of View Helper in Rails
tags: rails
published: true
---


## 🤔 Situation
Want to make like this params that have Hash inside an Array at the `award_content`.
​
```ruby
[1] pry> params
=> {"utf8"=>"✓",
 "books"=>
  {"author_name"=>"Minato",
   "book_name"=>"HELLO",
   "category"=>"Fiction",
   "awards"=>[{"award_id"=>"1", "award_title"=>"new", "award_content"=>"award for new people"},
              {"award_id"=>"2", "award_title"=>"movie", "award_content"=>"it becames to movie"}
             ]},
 "action"=>"create",
 "controller"=>"books"}
```
​
## 🦄 How to do it?
### 👍 in erb

```erb
<%= hidden_field_tag 'books[awards][][award_id]', award.id %>
<%= hidden_field_tag 'books[awards][][award_title]', award.title %>
<%= hidden_field_tag 'books[awards][][award_content]', award.content %>
```
​
## 👍 in model
Turn accept nested attribuetes.
​
```ruby
class Author
  has_many :awards
  accepts_nested_attributes_for :awards
  validates_precence_of :awards
end
```
​

---

## 🔗 Parent Note
{% link n350071/my-rails-note-47cj %}