teleren/devto huggingface dataset:
Design Patterns to a beginner developer
Tags: designpatterns, softskills, softwaredevelopment, beginners
Published: 2019-12-14 19:01:56

As a beginner developer and fresh graduated boy I’ve started to look into some base concepts of programming in order to keep growing up as a professional. I realized that there are dozens of concepts that students usually take for granted and are really important in “real life”. One of them is Design Patterns.

# Design Patterns
Design Patterns aren’t the silver bullet that solve all your problems. After years of programming languages been used in the world, software developers noticed that some logical solutions have been used repeatedly over and over again. In 1995, four developers published Design Patterns: Elements of Reusable Object-Oriented Software with 23 patterns solving various problems of object-oriented design and became a best-seller very quickly. Nowadays it’s known by the GoF book. GoF = Gang of Four.

That’s what make Design Patterns really important, they’re manuals of how to deal with logical problems in programming. If you’re a developer you should know and study about it because during your carrer you will face this problems every day.

Every design pattern can be described in terms of three aspects:

* Intent briefly describes both the problem and the solution.
* Motivation explains the problem and the solution the pattern makes possible.
* Structure shows each part of the pattern and how they are related.

Patterns also can be classified into groups of intents

* Creational patterns provide object creation mechanisms that increase flexibility and reuse of existing code.
* Structural patterns explain how to assemble objects and classes into larger structures, while keeping the structures flexible and efficient.
* Behavioral patterns take care of effective communication and the assignment of responsibilities between objects.

References:

https://refactoring.guru/

Any hints or comments are welcome, as many information and discussion better :)
Máy cwau xích Vinafarm
Published: 2019-12-14 18:39:53

https://maycuaxichvinafarm.com/ -Máy cưa xích Vinafarm là nhà cung cấp hàng đầu hiện nay các dòng máy cưa chạy xăng và chạy điện với giá thành hết sức phải chăng, xem thêm tại https://maycuaxichvinafarm.com/may-cua-xich. Ngoài ra hãng còn cung cấp nhiều loại máy nông nghiệp khác như bình phun thuốc sâu https://maycuaxichvinafarm.com/binh-phun-thuoc-sau. Đến với Vinafarm khách hàng sẽ được tư vấn 1 cách tận tình nhất để có thể lựa chọn sản phẩm đáp ứng yêu cầu sử dụng. Và với hơn 21+ mẫu máy cưa xích Vinafarm tự tin có thể làm hài lòng và đem đến những trải nghiệm tuyệt vời nhất cho khách hàng. 

> Profile Máy cưa xích Vinafarm:
https://buddypress.org/members/maycuaxichvinafarm/profile/
https://www.instapaper.com/p/maycuavinafarm
https://www.wantedly.com/users/125834497
Koji
Tags: javascript, node
Published: 2019-12-14 18:26:42

Hey all!

I'm Diddy, a Senior Dev at [Koji](https://withkoji.com), a platform that is changing the way that we think about software development.

While our aim has always been to democratize the creation of interactive content, in the process of doing that, we've also built a pretty amazing developer experience:

- Cloud-based editor based on Monaco
- Containerized development with access to the command line
- Scoped database, with a package that abstracts away the auth and gives you a simple API
- Streaming debug logs (no more ADB/Safari to see device logs!)
- Auto-scaling deployments
- Embeddable/shareable out of the box


The platform is free to use, and the easiest way to get started is to just find an interesting project and "Remix" it, which will clone the template and give you your own copy to start from.

Three's a ton more I'll try to share in some follow up posts, just thought the dev community may find some cool uses for this =)

Any feedback about the platform or experience is appreciated!
🎄 How to decorate a Christmas tree like a programmer 🎄
Tags: watercooler, android, arcore
Published: 2019-12-14 18:26:06

---
title: 🎄 How to decorate a Christmas tree like a programmer 🎄
published: true
description: how to build an android app using ArCore
tags: watercooler, android, arcore
---

#**Xmas** is around the corner! 🎁🎅
I know that not everyone celebrates Christmas, but for those that do or for those that just love Christmas I did an **Android application** to make this Christmas **devtastic**!  

Why not start and build something using your skills? There are lots and lots of programming languages so why to stick to a single one?


#Stack
ArCore for Android. I started with the Sceneform sample found [here] (https://developers.google.com/ar/develop/java/quickstart).
Going through the sample you will learn how to display an arSceneView and how do you detect a plane in order to place different virtual objects. 

The next step is to add a bunch of models from [poly](https://poly.google.com/). Notice that those are published under a CC-BY license. You're free to use them as long as you credit the author.


#Compatibility
Android devices with Android version > 7.0

#The Outcome

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

## How do you decorate your Christmas tree?
Go ahead and post your Christmas tree! 🎄🎄🎄
How to write functions in Kotlin? (Basic syntax)
Tags: kotlin, android, beginners, dev
Published: 2019-12-14 18:25:38

Functions are the building block of any programming language. They allow us to write DRY (Don't Repeat Yourself) code.

Let's continue our Kotlin tutorial by exploring the elements of a function.

We will start with a function that prints the current year. So it won't return anything.

<code>
 fun printYear(): Unit {
	println(2019)    
}
</code>

Let's examine each part:
1. fun - the keyword that tells us that we are about to write a function
2. printYear() - the name of the function
3. : Unit - the return type. Unit is the equivalent of void in Java.
4. { } - the body of the function

NOTE: Unit is not required. Kotlin will allow us to write this function as:
<code>
 fun printYear() {
	println(2019)    
}
</code>

Now let's write a basic function that generates a team name based on the names of the players that compose that team. For example, if the players are named Adrian and Jacob, the name of the team will be AdrianJacobTeam.

<code>fun generateTeamName(firstName: String, secondName: String): String {
    return firstName + secondName + "Team"
}</code>

Let's see what we have in addition to the previous function:
1. (firstName: String, secondName: String) - The parameters needed to call the function. We declare them without var or val.
2. return firstName + secondName + "Team" - if our function is not void it will have to contain the return statement (same type as the one declared)

Actually there also other types of functions, but we will analyze them one at a time.

Photo by [basitixustito](https://pixabay.com/users/basitixustito-14594756/)
Is it possible to browse multiple tags?
Tags: help, meta
Published: 2019-12-14 18:17:50

---
title: Is it possible to browse multiple tags?
published: true
description: 
tags: help,meta
---

I know you can browse by single tags, like https://dev.to/t/javascript for example, but is it possible to browse both `javascript` and `react` for example? Not valid obviously, but something like this: https://dev.to/t/javascript,react
What's Good?
Published: 2019-12-14 17:12:15

Hi there, I've come to join the DEV community because I want to help people out, share my progress and learn. The DEV community's values align with my own and the platform is only going to grow in popularity, making this a great environment to publish my content. 

###Overview of my coding journey

I stumbled into the coding world in November 2018, I used to play around with websites on Squarespace. One day, I wanted to make a project that I couldn't with the traditional website builder - I soon found out I would have to code it. A few weeks later I was on [Codewars](https://www.codewars.com/) preparing for an entry test to a bootcamp, [Northcoders](https://northcoders.com/). I started in June and finished in August(2019). I landed a front-end role at a data analytics startup in October. I was leading a small project for O2Wifi. I was let go 3 weeks later because the company lost too many clients. On December 2nd, I started my new role as a consultant for a company called Ricoh. It's been great.


### What tech I'm paying attention too:

I'm been working on two apps, one for a client and one internal project. Both are written using Flutter (an open-source UI sdk). I started by learning Dart on [Codewars](https://www.codewars.com/) and then picked up a [Flutter course I recommend](https://www.udemy.com/course/flutter-bootcamp-with-dart/). Next on my list to learn:

* Angular
* Docker
* Kubernetes 


#### Thanks for reading

I plan to post weekly, please feel free to reach out - I would love to chat.
PHP form 71: complete upload
Tags: php, form, complete, upload
Published: 2019-12-14 16:58:32

<hr />

<center>Happy Coding</center>

<hr />

index.php

		<form method="post" action="process.php" enctype="multipart/form-data" >

			Firstname: <input type="text" name="firstname" />
			<br />

			Lastname: <input type="text" name="lastname" />
			<br />

			Description: <textarea name="description" rows="10" cols="50"></textarea>
			<br />

			Gender:
			<input type="radio" name="gender" value="male" checked /> Male
			<input type="radio" name="gender" value="female" /> Female
			<br />

			Programming Language (single):
			<select name="language" >
				<option value="c" >C</option>
				<option value="c++" >C++</option>
				<option value="java" >Java</option>
				<option value="javascript" >Javascript</option>
				<option value="php" selected >PHP</option>
			</select>
			<br />

			Programming Languages (multiple):
			<select name="languages[]" multiple >
				<option value="c" >C</option>
				<option value="c++" >C++</option>
				<option value="java" >Java</option>
				<option value="javascript" selected >Javascript</option>
				<option value="php" selected >PHP</option>
			</select>
			<br />

			Hobbies (single): <input type="checkbox" name="hobby" value="studying" /> Studying
			<br />

			Hobbies (multiple):
			<input type="checkbox" name="hobbies[]" value="studying" /> Studying
			<input type="checkbox" name="hobbies[]" value="reading" checked  /> Reading
			<input type="checkbox" name="hobbies[]" value="writing" /> Writing
			<input type="checkbox" name="hobbies[]" value="sleeping" checked /> Sleeping
			<br />

			File Upload: <input type="file" name="upload" /><br />
			Preview: <img src="#" /> <br />

			<hr />

			<input type="submit" name="submit" value="Submit" />

		</form>

<hr />

process.php

    $data = array(
        "post"  => $_POST,
        "files" => $_FILES
    );

    echo "<pre>";

    // echo json_encode($data);

    var_dump($data);

<hr />

Output

<img src="https://thepracticaldev.s3.amazonaws.com/i/rcp3l42pb237ln7739jt.JPG" width="100%" />

<hr />

Demo <a href="https://repl.it" >repl.it</a>

<ul>
  <li><a href="https://repl.it/@antelove19/PHP-form-71" >Editor</a></li>
  <li><a href="https://PHP-form-71.antelove19.repl.co" >Live</a></li>
</ul>

<hr/>

<center>Thank for reading :)</center>

<hr/>
The best text editor/IDE for beginners (and pros)
Tags: react, javascript, beginners, tutorial
Published: 2019-12-14 16:57:46

So you just thought out a new project or you want to start coding, after you have chosen your preferred choice of language and frameworks, the next question is what text editors do you use to write out your codes?

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

Visual Studio Code is arguable the best free text editor out there, here are a few points to support my argument
 autocomplete: have you ever had to rewrite the same code over and over again? (You should probably copy and paste) but with VS Code, you get suggestions on auto fill properties be it values or functions, as long as they are in the scope of the file, you are good to go
 indenting: ive used quite a number of text editors and i have to say VS Code has the best auto indentation system. You dont have to worry about formatting your codes to make them clearer, just save your file and VS Code does all the magic for you
 debugger: whilst most ides have good debuggers, VS Code's debugger is the easier to understand and work with
 there are so much more add benefits of using VS Code like extensions, language adaptation etc, a very long list. 
You can get started with VS Code in the link below

https://code.visualstudio.com/  :)
Architectural Patterns vs Design Patterns
Tags: architecture, design, software, development
Published: 2019-12-14 16:41:35

###Architectural Patterns vs Design Patterns

Generally, the architecture and design both explain the idea but architecture focus on the abstract view of an idea while design focus on the implementation view of the idea.

###Design Patterns:
#####Design patterns - It solves reoccurring problems in the software Design.

###Architectural Patterns:
#####Architectural patterns - It serves as a blueprint for the software systems.


Read Complete Article [Architectural Patterns vs Design Patterns](https://www.fullstacktutorials.com/architectural-patterns-vs-design-patterns-57.html)
Cannot add class but elements are already added to the DOM
Tags: javascript, css, html, vscode
Published: 2019-12-14 16:40:25

Hey I am trying to add an active class to searchResult HTML using Javascript.

I try to search for recipe in search bar and results are displayed as it is shown in image.

Search Result
https://i.stack.imgur.com/vWj4m.jpg

When I click on a recipe from the search list I want to add a background color to the currently selected recipe(click on the recipe) using function resultHighlight()

function resultHighlight() is being called in the controller and produces an error. Since the HTML is already added(after a search query is fired) by function renderRecipe() then why it is unable to find href id and producing error ?

//Function to add background color 

export const resultHighlight = id => {
  document
    .querySelector(`a[href="#${id}"]`)
    .classList.add("results__link--active");
};

Error Image
https://i.stack.imgur.com/m372A.jpg

NOTE: I tried console logging follwoing part and it returns null.

document.querySelector(`a[href="#${id}"]`)

//OUTPUT: null

JavaScript has already added HTML by a function (Search result)

//Function to add search result on UI

const renderRecipe = recipe => {
      const markup = `
      <li>
        <a class="results__link results__link--active"  href="#${recipe.recipe_id}">
          <figure class="results__fig">
          <img src="${recipe.image_url}" alt="${recipe.title}">
          </figure>
            <div class="results__data">
             <h4 class="results__name">${reduceRecipeTitle(recipe.title)}</h4>
                 <p class="results__author">${recipe.publisher}</p>
            </div>
          </a>
       </li>`;

      elements.searchResList.insertAdjacentHTML("beforeend", markup);
    };
PHP form 70: complete
Tags: php, form, complete
Published: 2019-12-14 16:25:20

<hr />

<center>Happy Coding</center>

<hr />

index.php

		<form method="post" action="process.php" enctype="multipart/form-data" >

			Firstname: <input type="text" name="firstname" />
			<br />

			Lastname: <input type="text" name="lastname" />
			<br />

			Description: <textarea name="description" rows="10" cols="50"></textarea>
			<br />

			Gender:
			<input type="radio" name="gender" value="male" checked /> Male
			<input type="radio" name="gender" value="female" /> Female
			<br />

			Programming Language (single):
			<select name="language" >
				<option value="c" >C</option>
				<option value="c++" >C++</option>
				<option value="java" >Java</option>
				<option value="javascript" >Javascript</option>
				<option value="php" selected >PHP</option>
			</select>
			<br />

			Programming Languages (multiple):
			<select name="languages[]" multiple >
				<option value="c" >C</option>
				<option value="c++" >C++</option>
				<option value="java" >Java</option>
				<option value="javascript" selected >Javascript</option>
				<option value="php" selected >PHP</option>
			</select>
			<br />

			Hobbies (single): <input type="checkbox" name="hobby" value="studying" /> Studying
			<br />

			Hobbies (multiple):
			<input type="checkbox" name="hobbies[]" value="studying" /> Studying
			<input type="checkbox" name="hobbies[]" value="reading" checked /> Reading
			<input type="checkbox" name="hobbies[]" value="writing" /> Writing
			<input type="checkbox" name="hobbies[]" value="sleeping" checked /> Sleeping
			<br />

			File Upload: <input type="file" name="upload" /><br />
			Preview: <img src="#" /> <br />

			<hr />

			<input type="submit" name="submit" value="Submit" />

		</form>

<hr />

process.php

    $data = array(
        "post"  => $_POST,
        "files" => $_FILES
    );

    echo "<pre>";

    // echo json_encode($data);

    var_dump($data);

<hr />

Output

<img src="https://thepracticaldev.s3.amazonaws.com/i/dp7d682s5saytn2alm26.JPG" width="100%" />

<hr />

Demo <a href="https://repl.it" >repl.it</a>

<ul>
  <li><a href="https://repl.it/@antelove19/PHP-form-70" >Editor</a></li>
  <li><a href="https://PHP-form-70.antelove19.repl.co" >Live</a></li>
</ul>

<hr/>

<center>Thank for reading :)</center>

<hr/>
What are the most common mistakes you make as a programmer?
Tags: discuss
Published: 2019-12-14 16:06:19

We all make mistakes from time to time. Most of the times we learn from it, to avoid making it again in the future.

But in some cases, we just can't learn the lesson, and we keep making the same stupid mistakes over and over again.

For you, what are those mistakes you keep making, be that typo, not calling a function or anything else.
Don't Trust the Cops: Sometimes Rubocop is Wrong
Tags: ruby, linting, rubocop, rails
Published: 2019-12-16 10:51:14

---
title: Don't Trust the Cops: Sometimes Rubocop is Wrong
published: true
date: 2019-12-14 15:22:00 UTC
tags:
 - ruby
 - linting
 - rubocop
 - rails
canonical_url: https://cassidy.codes/blog/2019-12-14-rubo-cop-is-wrong/
---

My team at work recently upgraded our version of [Rubocop](https://github.com/rubocop-hq/rubocop), the popular linter used to enforce good Ruby code style. With the upgrade we got a whole bunch of new suggestions and warnings about style violations.

One of them that tripped us up was the [Performance/Count](https://github.com/rubocop-hq/rubocop-performance/blob/master/lib/rubocop/cop/performance/count.rb) rule.

According to the Rubocop docs:

> This cop is used to identify usages of `count` on an `Enumerable` that follow calls to `select` or `reject`. Querying logic can instead be passed to the `count` call.

So in plain Ruby, the cop sees that you are filtering an array with `select` or `reject` and _then_ calling `count` on it. This is inefficient because `count` can actually do all this work for you.

But! What if you're in a Rails project and you have some code that looks like this?

```ruby
@users.select { |u| u.admin? }.count
```

Rubocop will autocorrect this to:

```ruby
@users.count { |u| u.admin? }
```

Looks okay? Well, this will likely execute a SQL count that ignores the block!!! Rubocop incorrectly assumes that `@users` is an `Array`. Why else would you be calling `select` on it, right?

In our case, though, `@users` was actually an ActiveRecord object that hadn't been loaded yet! Since ActiveRecord lazy-loads things, sending count to this object executes an SQL `COUNT` that ignores the block passed in!

Here's what it looks like in action:

```ruby
User.count { |u| u.admin? }
# (0.4ms)  SELECT COUNT(*) FROM "users"
# => 320
User.count
# (0.6ms)  SELECT COUNT(*) FROM "users"
# => 320
```

See how we got the same number each time here? This is because ActiveRecord ignores the block passed into count without raising an error and counts _all_ users!.

The correct thing to do here is to pass your filter parameters into a `where` _and then_ do a `count`.

```ruby
User.where(type: 'admin').count
# (0.3ms)  SELECT COUNT(*) FROM "users" WHERE "users"."type" = $1  [["type", "Admin"]]
# => 10
```

## TL;DR
* ActiveRecord count works like this: https://devdocs.io/rails~4.2/activerecord/calculations#method-i-count
* Ruby count works like this: https://devdocs.io/ruby~2.3/enumerable#method-i-count
* These are two different count methods that can be called on objects that look similar.
* Passing a block to an ActiveRecord count will not raise an error, but will return inaccurate results.
PHP form 61: input text textarea file upload
Tags: php, form, file, upload
Published: 2019-12-14 15:04:34

<hr />

<center>Happy Coding</center>

<hr />

index.php

		<form method="post" action="process.php" enctype="multipart/form-data" >

			Firstname: <input type="text" name="firstname" />
			<br />

			Lastname: <input type="text" name="lastname" />
			<br />

			Description: <textarea name="description" rows="10" cols="50"></textarea>
			<br />

			File Upload: <input type="file" name="upload" /><br />
			Preview: <img src="#" /> <br />

			<hr />

			<input type="submit" name="submit" value="Submit" />

		</form>

<hr />

process.php

    $data = array(
        "post"  => $_POST,
        "files" => $_FILES
    );

    echo "<pre>";

    // echo json_encode($data);

    var_dump($data);


<hr />

Output

<img src="https://thepracticaldev.s3.amazonaws.com/i/l9em1yk4t7t2ioamylix.JPG" width="100%" />

<hr />

Demo <a href="https://repl.it" >repl.it</a>

<ul>
  <li><a href="https://repl.it/@antelove19/PHP-form-61" >Editor</a></li>
  <li><a href="https://PHP-form-61.antelove19.repl.co" >Live</a></li>
</ul>

<hr/>

<center>Thank for reading :)</center>

<hr/>
PHP form 60: input text textarea file
Tags: php, form, file
Published: 2019-12-14 14:56:28

<hr />

<center>Happy Coding</center>

<hr />

index.php

		<form method="post" action="process.php" >

			Firstname: <input type="text" name="firstname" />
			<br />

			Lastname: <input type="text" name="lastname" />
			<br />

			Description: <textarea name="description" rows="10" cols="50"></textarea>
			<br />

			File Upload: <input type="file" name="upload" /><br />
			Preview: <img src="#" /> <br />

			<hr />

			<input type="submit" name="submit" value="Submit" />

		</form>

<hr />

process.php

    $data = array(
        "post"  => $_POST,
        "files" => $_FILES
    );

    echo "<pre>";

    // echo json_encode($data);

    var_dump($data);

<hr />

Demo <a href="https://repl.it" >repl.it</a>

<ul>
  <li><a href="https://repl.it/@antelove19/PHP-form-60" >Editor</a></li>
  <li><a href="https://PHP-form-60.antelove19.repl.co" >Live</a></li>
</ul>

<hr/>

<center>Thank for reading :)</center>

<hr/>