teleren/devto huggingface dataset:
Use webmock for stubbing multiple body parameters with the same name
Tags: faraday, webmock, queryvaluesnotation, flatparamsencoder
Published: 2019-02-05 07:24:00

---
title: Use webmock for stubbing multiple body parameters with the same name
published: true
description: 
tags: faraday, webmock, query_values_notation, FlatParamsEncoder
---

If you use Faraday to perform requests it's likely you'll have to use the `Faraday::FlatParamsEncoder`. 

```ruby
Faraday.new(url: base_url) do |faraday|
  faraday.request :url_encoded # form-encode POST params
  faraday.options.params_encoder = Faraday::FlatParamsEncoder
  ...
end
```

It converts the JSON parameters to query string removing square brackets, so instead of converting `{ key: ['value1', 'value2'] }` to `key[]=value1&key[]=value2` it will convert it to `key=value1&key=value2` instead. This approach is used in many services, for example, in Twilio API.

The problem happens when you try to stub that API using `webmock`. By default `webmock` does not support multiple parameters with the same name in url encoded body. So the `key=value1&key=value2` will become `key=value1`. Here are the related issues:
- https://github.com/bblimke/webmock/issues/227
- https://github.com/bblimke/webmock/issues/490
- https://github.com/bblimke/webmock/issues/584

The basic suggestion in the webmock repo is to use: `WebMock::Config.instance.query_values_notation = :flat_array` option. I prefered the different approach though.

As Faraday encodes the body with `Faraday::FlatParamsEncoder` we can manually encode the body and pass the result to webmock.

```ruby
stub_request(:post, twilio_api_url("Accounts/#{subaccount_sid}/Calls.json"))
  .with(body: Faraday::FlatParamsEncoder.encode(request_params))
  .to_return(body: response_body)
```

The following code block also works, but for consistency with the faraday behavior, I used the above one.

```ruby
stub_request(:post, twilio_api_url("Accounts/#{subaccount_sid}/Calls.json"))
  .with(body: URI.encode_www_form(request_params))
  .to_return(body: response_body)
```

I hope this will help someone or at least save some time.
What do you do at the end of the workday?
Tags: discuss
Published: 2019-02-05 06:14:20

---
title: What do you do at the end of the workday?
published: true
description: 
tags: discuss
---

As a Software Engineer what do you do at the end of the day?
I want to start writing a summary about what I worked to document what I did well and what I can improve on such as responding to emails, communicating ideas, getting into the zone, etc...

Do any of you have end-of-day habits/rituals that made you better at your craft?
Binary tree in Javascript
Tags: javascript, datastructure, binary, graph
Published: 2019-02-05 05:44:28

---
title: Binary tree in Javascript
published: true
description: What is Binary tree and how to implement it in Javascript      
tags: #javascript #data structure #binary #graph    
---
Let’s take a look at how a Binary Search Tree works and how they are implemented in Javascript.
<img src="https://thepracticaldev.s3.amazonaws.com/i/s3h65yq1qwkciff5nwf1.png"/>

<h2><b>Basics of tree structure</b></h2>
<h3>In a Binary tree there are three things one should know first:</h3>

<b>Root :</b> This is the top node of a tree structure and it does not have a parent. In the example image above, 8 is a Root node.
<b>Parent :</b> It’s a predecessor node, of a node. In the above example 3, 10, 6, 14 are parent nodes.
<b>Child :</b> It’s a successors of a parent node. In the above example 1 and 6 are children of 3 and so on.
<h2><b>Binary tree</b></h2>
In binary tree structure each node can have maximum of two children. Child on left subtree is called left child and child on right subtree is called right child.

<h2><b>Binary search tree</b></h2>
<h3>BST is a binary tree but with a few conditions:</h3>

<b>1)</b> All the keys (data inside the node) are distinct.
<b>2)</b> In every parent node, the left child key value is smaller than the parent node key value.
<b>3)</b> In every parent node, the right child key value is larger than the parent node key value.

<h2><b>Insertion of a node</b></h2>
For insertion of a new node with key value , a program will find the right place and it will create a new empty node for data. If the key value already exists, insertion will be declined and the insertion operation terminates immediately without insertion — as a BST is not allowed to have duplicate keys.

<h2><b>Binary Search Tree implementation in Javascript</b></h2>

{% gist https://gist.github.com/thevenice/ffb32f4fab3a53ba65bf348fc646a236 %}

<h2><b>And that’s it! 🎉</b></h2>
If you like this article let me know in comments or tweet about it.
<h5>(you can also read this on <a src="https://medium.com/javascript-in-plain-english/binary-search-tree-in-javascript-ca5aa7ba05de">Medium</a> )</h5>
How to make a website
Tags: html, websitedevelopment, css
Published: 2019-02-05 03:28:36

---
title: How to make a website
published: true
description: How to make a website within 6 min.
tags: html5,website development,html,css
canonical_url: https://www.linkedin.com/pulse/how-make-website-steffan-jensen/
cover_image: http://www.milevdesigns.com/blog/wp-content/uploads/2017/11/Shopify-Shoes-V1-1000x420.jpg
---

First you gonna need a text editor, if you use windows, you can use notepad or if you wanna go pro search for sublime text, in Linux go with vim or another editor, and mac... figure it out yourself

Now you have the text editor open, you should start typing.


```html
<html>
<title>
My websites title
</title>
<body>
<h1>This is my website headline</h1>
Welcome to my website
<img src="https://markmanson.net/wp-content/uploads/2010/09/stones.jpg">
</body>
</html>
```
Example: https://jsfiddle.net/58ngefro/1/

Now click Save and save the file as mywebsite.html, now open the mywebsite.html file with your mouse in your directory.

Always when you create statements you should remember to use the <> and close it again with </> this is a way for the code to know the difference between when to open and close new statements.

Now we have a basic website. If you learn these 3 commands which is <html>, <title> and <body>. You will be able to understand every HTML line in the matter of a few seconds.

Now we have the basic we should be moving on to add different stuff to your new website, like images and different text.

```
<html>
<title>
My websites title
</title>
<body>
<h1>This is my website headline</h1>
Welcome to my website
<img src="https://markmanson.net/wp-content/uploads/2010/09/stones.jpg">
</body>
</html>
```
Example: https://jsfiddle.net/xo981m4s/

Save the file and open it.

Now you have created your first website with both a title,headline,text and image. There are thousands of more commands you can use in HTML. But with this tutorial we just covered the basic.

My Instagram Scraper Website:
https://instascraper.github.io

Download My Instagram Bot:
https://github.com/instagrambot/Instagram-scraper-with-autopost


Follow me:
https://www.linkedin.com/in/steffan-jensen/
https://github.com/reliefs/
https://dev.to/reliefs/
https://fiverrdiscountcode.com
JIRA Workflow task from YAML files
Tags: jira, task, workflow, agile
Published: 2019-02-05 01:36:49

---
title: JIRA Workflow task from YAML files
published: true
description: Create a set of task to your JIRA Workflow
tags: jira, task, workflow, agile
---

Use Case:

In our company we have different areas that work across JIRA tasks and Confluence.

Sometime we need to set around 20 tasks for a common target. This tasks are for example to get up and running some customizations from our customers.

In the example that i'm going to use we need:

1. [1] Epic Task
2. [4-5] Main Tasks for the different areas
3. [4-5] Sub-tasks from each main task
4. Relate the task to labels
5. Relate the tasks between them
6. Attach links (Zendesk, Confluence, docs, etc)

This actions at this moment are executed by one person, but sometimes you forget to do a task, or may be creation the relations between tasks (blocks, relates to). With this we avoid human mistakes, we set the structure and then the script auto-generates all the tasks.


{% github https://github.com/diegonalvarez/jira-workflow-tasks %}

So with this we can set many templates in the projects folder and run automated workflows.
In programming, is it better to have many small files or one large file?
Tags: explainlikeimfive, beginners, discuss
Published: 2019-02-05 01:13:27

---
title: In programming, is it better to have many small files or one large file?
published: true
description: The title says it all. In general, is it better to have multiple small files linked together, or one large file?
tags: explainlikeimfive, beginners, discuss
cover_image: https://images.unsplash.com/photo-1493217465235-252dd9c0d632?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80
---

The title says it all. In general, is it better to have multiple small files linked together, or one large file?

At least in the web, I know that you should have one or very few CSS stylesheets, to better control the style across different pages and all. As for HTML, it's pretty logically one per page. But what about JS?

And most importantly, the main point of my question is, what about other environments and other languages? Does this depend on the language or the goal? If so, what are some examples or cases where one method is better than the other?

Regardless of which is better, is it defined just by convention, or is it because of performance?

*BTW, this is first post, so I'm sorry if I missed something, and please let me know!*
Learn React and Redux by building a real-world app
Tags: react, javascript, redux
Published: 2019-02-05 00:10:54

---
title: Learn React and Redux by building a real-world app
published: true
description: Learn by building a full-stack production app. Concepts include React, Redux, Styled Components, Server-side rendering, search, authentication, payments.
tags: react, javascript, redux
---

It's too long (and evolving) to paste the full markdown here, but here's the Medium link to it - https://medium.appbase.io/build-an-end-to-end-movies-store-app-with-react-redux-appbase-a8622f7e0c7a.

This is a new form of content we're trying out and are really excited to see the initial reception. Out of 10 posts, we are putting out the first three today that teach React, Styled Components, and using them to create the landing page of the Movie Store app!
Take your first step towards Business digitalization with DevOps and cloud
Published: 2019-02-13 07:29:49

---
title: Take your first step towards Business digitalization with DevOps and cloud
published: true
tags: 
canonical_url: https://www.cswebsolutions.ca/blog/digital-transformation-devops-and-cloud
---

The technological advancement has revolutionized the concept of running a business enterprise. The term refers to utilizing digital technology into every aspect of the business, starting from the way you operate to adding value to your clients. Now the question arises why your business needs a digital transformation?[...]

Full post here: https://www.cswebsolutions.ca/blog/digital-transformation-devops-and-cloud
Build people, not tech
Tags: business, organizations, agile
Published: 2019-11-11 17:32:00

---
title: Build people, not tech
published: true
tags: business, organizations, agile
canonical_url: https://guifroes.com/build-people-not-tech/
---

Retrospectives, build-measure-learn and continuous improvement are all activities and practices that companies and their agile teams do to support project delivery and product development.

I think this is wrong.

These things are way too important to be only supporting the business.

Not long ago, businesses used technology to accelerate, to automate, to improve themselves somehow. Teams would form, the technological product would be built, and the business would cary on with its life.

It is different now. **The business is the technology.** The very existence of the business depends on the continuous production and operation of technology.

Because of that, companies should focus not on producing technology but on continuously cultivating people’s capabilities.

Retrospectives, build-measure-learn and continuous improvement must abandon the position of supporting activities and occupy business’ center of attention. Teams and their learning capabilities – not their products – are business’ competitive advantage. And this should reflect on investments, recruiting and promotions.

Technology companies must transform into knowledge and skills companies.

The post [Build people, not tech](https://guifroes.com/build-people-not-tech/) appeared first on [Gui Froes](https://guifroes.com).
What’s my skill set worth?  
Tags: discuss, career
Published: 2019-02-04 23:26:34

---
title: What’s my skill set worth?  
published: true
description: what’s my skill set work, how to ask for a raise and/or a pronation 
tags: discuss, career
---

Help!  I am the sole programmer/developer/sql admin etc for a small company, compared to what I was hired to do vs. what I now do 4 years laters have vastly change.  My skill set has expand a great deal as well to move the company forward.

I would like to get a gauge of what my skills are worth to see if it’s worth wild to ask for a rise.

Any kind of input would be great!
Install and Setup Gatsby
Tags: javascript, gatsby, tutorial
Published: 2019-02-04 22:59:19

---
title: Install and Setup Gatsby
published: true
description: In this video, I walk through what Gatsby is and how to install it, then generate your first site. This is for those that know nothing about Gatsby
tags: JavaScript, Gatsby, Tutorial
---

I put this first part of a series together for those that have no idea how to get Gatsby downloaded and running on their machine. Whilst the instructions for installing apply for a Mac, they should work just fine for other platforms.

As a newbie to Gatsby, I thought...as I learn, why not share the highs and lows of getting a site up.

{% youtube dpiV15xNcBQ %}
Your Mate
Tags: beginer
Published: 2019-02-04 22:40:58

---
title: Your Mate
published: true
description: A short personal motivation.
tags: #beginer 
---

"Your Mate"
that statement crushed a lot of souls and will still continue to do so, but it shouldn't crush you. When people closer to you utter that statement and tell you your mates are these and that never let it get to you and have this in you: you're nobody's mate and no one is your mate, we all have our different working time. Trust your process and be persistent. 😎
Is collage underrated in our industry?
Tags: discuss
Published: 2019-02-04 21:38:41

---
title: Is collage underrated in our industry?
published: true
tags: discuss
---


I'm a Software Engineer, graduate in my birth country Venezuela. I have to say, as collage is free (since 1960), was an advantage to choose to do the studies, but even if it was paid, I would probably end up studying anyway. I have no regrets about it, as I learned so much things outside the programming itself, that I did not learn that much as I learned by myself. But, the other subjects, that many may find unrelated, and insufficient to justify the cost of a collage, did make a different for me. 

What do you think? Is collage underrated? Can you truly self learn every there is needed to be a good professional?
Who's looking for open source contributors? (Feb 4th edition)
Tags: discuss, opensource, contributorswanted
Published: 2019-02-04 21:22:56

---
title: Who's looking for open source contributors? (Feb 4th edition)
published: true
description: 
tags: discuss, opensource, contributorswanted
---

Find something to work on or promote your project here.

Please shamelessly promote your project. Everyone who posted in previous weeks is welcome back this week, as always. 😄

Additionally, all are welcome to also create a standalone post in this tag:

{% tag contributorswanted %}

Follow the tag for more posts like this one.

Happy coding!
How do you refer to the reader?
Tags: discuss
Published: 2019-02-04 19:13:35

---
title: How do you refer to the reader?
published: true
description: 
tags: discuss
cover_image: https://thepracticaldev.s3.amazonaws.com/i/ovcv2fuvdzxw9uj9i79x.jpg
---

###### Photo by Toa Heftiba on Unsplash

Had this thought, I have always written anything I learn as a, "hey let's do this together" sort of post.

{% twitter 1092308129218510848  %}

If you write a guide do you do it the same way or as a direct got to a, do b sort of thing?

I have been going through a lot of the DigitialOcean documentation which is beautufully written and now I'n not sure I'm going about writing guides the right way.
Day 008: Making a TODO list
Tags: ios, swift, iosdevelopment
Published: 2019-02-04 18:36:05

---
title: Day 008: Making a TODO list
published: true
description: Slide to delete is here!
tags: iOS, swift, iOS development
---

[GitHub Repo](https://github.com/maeganjwilson/todo_list)

**Question**: Where are days 6 and 7?

**Answer**: I didn't do any coding since it was the
weekend, and I was busy.

## Things I want to accomplish
- Slide to delete

## Things I accomplished

- Slide to delete

## Things I learned

### The function needed to add "Slide to delete".

The function needed is this one

```swift
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
        // CODE GOES HERE
    }
```

The way I chose to implement the function is checking if the
`editingStyle` is equal to `.delete` and inside that check, I do the following:

- Delete the todo
- Delete the row from the table view

Here is the final code

```swift
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
        if editingStyle == .delete {
            todos.deleteTodo(index: indexPath.row)
        }
        tableView.deleteRows(at: [indexPath], with: .left)
    }
```

If you have any questions about what I did or how I implemented anything, let me know! If you have any suggestions or other comments, let me know as well!
Removing duplicates in an Array of Objects in JS with Sets
Tags: javascript, array, tip
Published: 2019-02-04 17:54:40

The other day at work I was faced with what I think is a rather common problem when dealing with data coming from an API.

I was getting from my async http call an `array of objects` (addresses in this case), but for _unimportant reasons_ this array was returning objects that could be duplicate (so two identical `id`s).

My first instinct was to make a new array, and loop through the addresses' array and do a `.findIndex` on each for my "copy". If the "copy" didn't have the address, then I would push it. In the end the code was readable, but I wanted a simpler more straightforward way.

**There are many ways to solve this particular problem!**

Now that we got that out of the way 😋, I wanted to show this solution that uses the power of [JavaScript `Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set).

```js
const addresses = [...]; // Some array I got from async call

const uniqueAddresses = Array.from(new Set(addresses.map(a => a.id)))
 .map(id => {
   return addresses.find(a => a.id === id)
 })
```

Let's dissect this mess:
1. `Array.from(new Set())` I'm going to make a new set, and I want to turn it back into an array with `Array.from` so that I can later re-map it.
2. `new Set(addresses.map(a => a.id))` Set will only allow **unique** values in it, so i'm going to pass it the ids of each object. If the loop tries to add the same value again, it'll get ignored for free.
3. `.map(id => [...])` With the array of ids I got on step 1, I run a map function on it and return the actual address from the original address array

That's it! Simple, clear, and I had fun learning about/using `Set` 😎

--- 

Huge shout out to my bae [Natalia Tepluhina](https://twitter.com/N_Tepluhina) who endured and helped me come up with crazy ideas for this, and her awesome solution to do it with `Array.reduce` showcased below ❤️👩‍💻

```js
const arr = [
  { id: 1, name: "test1" },
  { id: 2, name: "test2" },
  { id: 2, name: "test3" },
  { id: 3, name: "test4" },
  { id: 4, name: "test5" },
  { id: 5, name: "test6" },
  { id: 5, name: "test7" },
  { id: 6, name: "test8" }
];

const filteredArr = arr.reduce((acc, current) => {
  const x = acc.find(item => item.id === current.id);
  if (!x) {
    return acc.concat([current]);
  } else {
    return acc;
  }
}, []);
```
Introducing our February 2019 sponsors
Tags: meta
Published: 2019-02-04 17:41:15

---
title: Introducing our February 2019 sponsors
published: true
description: Our wonderful sponsors are vital to the health of dev.to and it is great to work with companies contributing so much to the ecosystem.
tags: meta
cover_image: https://thepracticaldev.s3.amazonaws.com/i/hip5esqvc5secxlf4wb7.png
---

As we roll into February, we have a couple returning sponsors and one first-time DEV Community partner.

Please take a few minutes to check out their offerings and consider them for your company or next project.


## DigitalOcean

[DigitalOcean](https://try.digitalocean.com/performance/?utm_source=devto&utm_medium=display&utm_campaign=Devto_2018_Brand) is a much-loved cloud computing platform. I'm always impressed by how well-built _and well-documented_ the DigitalOcean core products are. It's easier said than done, and they've been able to stay ahead of the curve.

DigitalOcean has been our longest-running supporter to date, and we're extremely thankful for their consistent support.  Their commitment to the developer ecosystem is crystal clear.

## GoCD

[GoCD](https://www.gocd.org/?utm_campaign=dev_to&utm_medium=dev_homepage&utm_source=logo_link&utm_content=gocd_homepage&utm_term=) is a continuous delivery tool built by Thoughtworks, one of the most reputable software development firms we've ever dealt with.

This is a feature-rich tool with some really fabulous visualization. Definitely worth considering for your organization or project. The product is very well supported through documentation, resources, and of course, the open source community. Very much worth checking out.

## Triplebyte

[Triplebyte](https://triplebyte.com/a/YU8fSn0/recognition) allows developers to take one quiz and immediately get into the interview process with top tech companies if you qualify. It should be a part of any developer's job search process.

I personally took the Triplebyte quiz and the questions felt like a genuine test of real world software development principles. I'm spoken for in terms of work and you may be as well, but I'd suggest giving the quiz a spin either way.


***

These organizations are helping us build the best community we can. I urge you to check out their offerings if you are in the market for their services.

Happy coding ❤️