teleren/devto huggingface dataset:
Refactoring If-else statement
Tags: discuss, coding, learning
Published: 2017-11-13 10:17:55

---
title: Refactoring If-else statement
published: true
description: 
tags: #discuss, #coding, #learning
---

Hi everyone! I just want your opinions/thoughts on how to use if-else statements to make it more readable and maintainable or what are the best practices on using if-else statements. So let's start!


###First

*Nested if statements*

```javascript
if(!isEmpty(object))
{
    if(IsString(object.number))
        log("Is a String");	
    else if(IsNumber(object.number))
        log("Is a number");
    else
	log("Is a special character");		
}	
```
or you can have it like this:

```javascript
var bool = !isEmpty(object);
if(bool && IsString(object.number))
{
	log("Is  a String");	
}
else if(bool && IsNumber(object.number))
{
	log("Is a number");
}
else if(bool)
{
	log("Is a special character");
}
```
Which do you think is better? Which one is easy to maintain and read? And what will happen if these *IF statements* get bigger?

###Second

*Ternary operator vs if-else-if statements*
```javascript
var tempVar = 0;
if(number == 1)
    tempVar = 1;
else if(number == 2)
    tempvar = 2;
else
    tempvar = 3;
```
or this one
```javascript
var tempVar = ((number == 1)? 1: (number == 2)? 2:3);
```
Which one is better if we are talking about maintainability?
vimでお手軽にXMLを整形する
Tags: vim
Published: 2017-11-13 08:58:00

---
title: vimでお手軽にXMLを整形する
published: true
tags: Vim
date: 20171113T08:58Z
canonical_url: https://qiita.com/shiena/items/8907c4b42d7958c53ce4
---
開発などで改行がないXMLをvimでお手軽に整形するコマンドです。

```vim:
:%s/></>\r</g | filetype indent on | setf xml | normal gg=G
```

もしくは

```vim:
:%s/></>^M</g | filetype indent on | setf xml | normal gg=G
```

`^M`は`^`と`M`の2文字ではなく、`Ctrl-V`の後に`Enter`を入力した1文字です。

インデント不要だったりXMLが巨大で時間がかかる場合は次のように置換だけにすると高速です。

```vim:
:%s/></>\r</g
```
```vim
:%s/></>^M</g
```

## 整形例

```xml:
<foo><bar><qiita>example</qiita></bar></foo>
```

こんなテキストが

```xml:
<foo>
	<bar>
		<qiita>example</qiita>
	</bar>
</foo>
```

このように整形されます。
Idea for Software Engineering project(Gamification, IOT, Machine Learning)? Should address serious issue. Complex, the beter
Tags: softwareengineering, projectidea, discuss
Published: 2017-11-13 05:48:05

---
title: Idea for Software Engineering project(Gamification, IOT, Machine Learning)? Should address serious issue. Complex, the beter
published: true
description: 
tags: software engineering, project idea, discussion
---
The Progressive JavaScript Framework
Tags: javascript, beginners, webdev, programming
Published: 2017-11-13 05:39:21

---
title: The Progressive JavaScript Framework
published: true
description: 
tags: #javascript, #beginners, #webdev, #programming
---

Vue.js is a javascript framework developed by Evan You. It is a progressive framework for building user interfaces. It focuses on a view layer of the application and it is use to build Single Page Applications(SPA). This framework is like AngularJS but much faster and lighter.

![Vue.js](https://coligo.io/vuejs-the-basics/cover-850x416.jpg)

I'm still studying about this framework and I haven't tried using it in a real project. As what I have learned so far is that it is easier to learn unlike Reactjs and AngularJS 2. And also it is easier to use and integrate with other libraries and frameworks.

Vue.js currently has no stable way to develop mobile applications unlike the other frameworks. But there developers are now working with this two frameworks that could help us build mobile applications. This two frameworks are Weex and NativeScript.

What I like with Vue.js is that it has a small size and it's very easy to integrate in the application just like jQuery. And as a programmer, it also saves a lot of time to build apps because it has a well-written documentation [(Vue.js documentation)](https://vuejs.org/v2/guide/) and has a very simple code structure.

To write applications using Vue.js, you just only have to know some basic Javascript and HTML language.
Self-taught programmers
Tags: discuss
Published: 2017-11-13 02:33:58

---
title: Self-taught programmers
published: true
description: 
tags: #discuss
---


Someone said that self-taught programmers are better than educated programmers. Because they are smarter and good at coding and problem solving. And also they are so passionate on learning new technologies and languages. 

So what do you think? Is it true that self-taught programmers are better?
Оптимизация MySQL: индексы, медленные запросы, конфигурация
Tags: mysql, optimization, index, slowquery
Published: 2018-01-30 14:08:49

---
title: "Оптимизация MySQL: индексы, медленные запросы, конфигурация"
published: true
tags:  MySQL, optimization, index, slow-query
canonical_url: http://phpprofi.ru/blogs/post/76
---

![](https://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2017/10/1509294383superhero-534120_1280.jpg)

MySQL по-прежнему является самой популярной в мире реляционной базой данных, но в то же время и наиболее не оптимизированной. Многие люди остаются с настройками по умолчанию, не "копая" глубже. В этой статье мы рассмотрим некоторые советы по оптимизации MySQL в сочетании с&nbsp;некоторыми новинками, которые вышли относительно недавно.

## Оптимизация конфигурации

Первое, что каждый пользователь MySQL должен сделать для повышения производительности - это настроить конфигурацию. Однако, большинство этот шаг пропускают. В 5.7 (текущая версия) настройки по умолчанию стали намного лучше, чем у её предшественников, но улучшить их по-прежнему можно и несложно.

Читать далее: http://phpprofi.ru/blogs/post/76
When nothing happens
Tags: culture
Published: 2017-11-08 15:24:17

---
title: When nothing happens
published: true
description: Problems suck. But no problems sucks more.
tags: culture
canonical_url: https://listed.standardnotes.org/@mo/309/when-nothing-happens
---

I’ve spent the last week in a buggish sort of hell trying to track down bewildering software issues that made no sense at all. It was, by all definitions, hell. I hated myself for writing bugs. And I hated software for being so sensitive to my human-ness. After spending several days collecting clues and checking the same code over and over again, I concluded there was nothing visibly wrong, and it was time to exile myself to some remote island. 

The issue would later be solved, of course. And it was bewildering for good reason: it had something to do with the timing of the new iPhone release, where people started getting new phones and restoring them from iCloud. Well, it turns out restoring your phone from iCloud will restore your data, but not your keychain. This confused my poor little app. And since I discovered that, the rest is history.

I felt great after fixing this bug that had come to define my life. I was in the best mood I've been in all month. I had big plans now that I was a free man: go on vacation, treat myself to exquisite delicacies, maybe leave the house for the first time and rediscover the sun—oh the heavenly thoughts! After I fixed this bug, released a bunch of new updates, and crossed off my todos, I felt so extremely accomplished.

But the next day, nothing happened.

Sure, less support emails regarding this issue. That should be more peaceful right? But it was a business as usual sort of day. My traffic was the same. Sales were the same. No interesting activity on Twitter. And, I was so exhausted from that week of hell that I just wanted to take one small day off from coding. 

And that became a new sort of hell. And surprisingly, this hell of nothingness was 100x worse than the hell of a software issue you don’t know the cause of. All that to say, be grateful you have problems. Because boredom is the worst problem of all. I can confirm this sentiment dating back to all the many software development jobs I had—being a cog in a wheel sucks, but what sucks more is being a useless cog in a wheel. It sucks the most.

Luckily for wanderers, boredom will only ever be a small window of reprieve from the constant storm. The next day, it was back to the stress of work. And I’m grateful for it.
Moving your workflow to Linux
Tags: linux, workflow, beginners, ubuntu
Published: 2017-11-12 18:12:37

---
title: Moving your workflow to Linux
published: true
description: How to move your workflow to Linux and be free from Windows/Mac
tags: Linux, Workflow, Beginners, Ubuntu
---

Since forever, I've been a Windows user with almost zero knowledge of other Operational Systems. But I always found to develop inside Windows environments to be a little tricky since and if you are out of the Visual Studio environment things are even more complicated.

After a period considering a change to a MacOSX environment, I decided to try Linux, since it's free and work on (most) any hardware that works with Windows.


![Linux TUX](https://upload.wikimedia.org/wikipedia/commons/thumb/6/66/TUX_G2.svg/2000px-TUX_G2.svg.png)

__HOW__:

First, you will need to choose a distribution (flavor) of Linux that will suit your needs. I like to recommend [Ubuntu Mate](https://ubuntu-mate.org/download/) to new users for a couple of reasons:

* It has the support and features of one of the most used distributions on the Linux world plus a great UI (Mate) that have a lot in common with other OS.

Just use [Etcher](https://etcher.io/) to burn the image into a USB stick and plug into the PC before booting it. Your BIOS/UEFI must be set to read from the USB. Follow the instructions on the screen to install the OS (Backup any relevant data first, because this will erase your HD).

__LANGUAGE SUPPORT__:

Most Linux distributions have a large support for programming languages, from C to GO, you will only need to find the correct package for your distribution. To start just run the command `sudo apt install build-essential` to have the most common toolchain for C/C++ compiling that will help to install a lot of other development software like:

* Python: `sudo apt install python2 python3 python3-pip`
* Java: `sudo apt install jdk8-openjdk`
* Javascript/Node: `sudo apt install nodejs npm`

*PS: `apt` is a command line tool to help install packages into the system, like brew for MacOSX or choco for Windows, used by Debian like systems (Debian, Ubuntu, Mint). You can learn more at [`man apt`](http://manpages.ubuntu.com/manpages/zesty/man8/apt.8.html)*




__TEXT EDIT__:

Most common text editors will work without any sweat, like Atom, Visual Studio Code, Sublime. Even some exclusive editors can make your life easier like Kate, Gedit, Geany and KDevelop.

__GIVE IT A TRY__:

If you are not comfortable to move an entire system to a Linux environment, you can still try it using some Virtual Machine environment, like VMWare Workstation or Oracle VirtualBox. You can see for yourself if it suits you and what you can learn from it.

__CONCLUSION__:

Linux systems are very powerful and fully feature to be your next development environment, just remember is not the same thing as Windows or MacOSX and you should approach it with an open mind. 

**And Remember** Google is your friend. Do not be afraid to search for dumb things such: *How to move a file from directory* or *How to install sublime on Linux*. You are learning everything again and some easy things should not stop you.
Hi i'm Ramlev from Copenhagen
Tags: php, introduction
Published: 2017-11-12 13:54:29

---
title: Hi i'm Ramlev from Copenhagen
published: true
description: 
tags: php, introduction
---
I a Drupal developer based in Copenhagen, Denmark. Have worked with Web since the last century. Always a PHP developer.

Have my own little web agency, doing a lot of Drupal and Symfony, working from my Macbook pro.

On [github](https://github.com/ramlev)
Intro & the end for the Dev.To FTUE
Tags: introduction, webdev, career
Published: 2017-11-12 12:35:09

---
title: Intro & the end for the Dev.To FTUE
published: true
description: I need to finish the First Time user Experience tutorial, so I wrote this article.
tags: introduction, webdev, career, 
---

# Hello community
I am Adrian, a Programming-holic, I got this drug since I was a kid (father hobby programmer), I started coding in high school and faculty, and then as a full time job. I develop in my spare time and I'm lucky enough to get payed to practice my hobby during the day.


I had to finish the Dev.To First Time User Experience and also I saw that I have some followers, although I haven't wrote any article, so I feel a pressure to write this.

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


Except for when I'm in a vacation, I cannot stop using the drug, I get itchy fingers, tons of ideas and an increased desire to read what other new shiny blue drugs were invented.

![drugs](https://static.sashe.sk/data/2014/05/11/photos/71554/c/c-N4018648_71554_20140511_69565.jpg)

I'm a web generalist (I think), full stack web developer but I got my hands into other languages and platforms (like mobile, VR, gadgets and toys). I like to help people and teach programming (and related tech fields), mentoring other devs and writing about it. 

Starting this year [I relaunched my blog](https://coder.today/), I'm trying to write generic posts (suited for any developer) and fewer web development stuff. More details [about me](https://coder.today/about-me-software-engineer-5bcd7cf2e054).

I am a pragmatic programmer with a passion for the "right things", I think that our job is a **Craftsmanship**. What does it mean? Well I like to write a clean code, use the best practices, I do not think that  unit tests should be optional, but also I've been into trenches for many years (startups).

I am used to deliver new releases on a daily basis, and know that most of the "right things" cannot be implemented as we learned in the books, at least in the "world outside corporations". So I try to search, develop, [learn and write about techniques that combines](https://coder.today/how-to-maintain-a-clean-code-a-3-step-technique-with-example-477e20c882df) the "real world" (deliver this thing tomorrow) with the "dream world" of best practices.

As a result you will notice that my replies are mixed: I will attack all TDD related articles that treat the technique as a Religion (all time savior, Uncle Bob style), but also I would recommend that Automatic Tests should not be optional and all 3 Clean * Uncle Bob books as a mandatory lecture (for mid-senior devs).  

This concludes the ranting about me, so far I like this website so keep up the good work.
Why all this hate about Python?
Tags: discuss, python
Published: 2017-11-12 10:22:26

---
title: Why all this hate about Python?
published: true
description: On Python's animosity
tags: discuss, python
---

On many forums, discussions between devs and several blogs, I saw a lots of articles in which Python is mentioned as a bad or ugly language; but why is it so?

I find Python awesome: building everything fast, easy to read and to learn the basis, etc.

But whenever I ask to my fellow developers, nobody gives me a constructive answer; so what is your opinion about it?

Happy coding !
Why are global variables bad?
Tags: programming, coding, discuss
Published: 2017-11-12 05:45:54

---
title: Why are global variables bad?
published: true
description: 
tags: #programming, #coding, #discuss
---

Global variables are variables that are declared outside to be accessible by everyone in the application.

But if you search it in goole. The second query result is that global variables are bad. Why?

I think everything has its own pros and cons. And global variables' pros and cons depends on how it is being used. It also depends on how big or small your application is.

For smaller applications, global variables are not a problem. It helps your code to easily pass and access data from other classes and methods. You don't need to pass a variable every time you call a method or class.

Sharing data inside the application using global variables will also help you minimize local variable creation and lesser memory usage.

But for larger applications, using global variables are bad. It will make your application hard to maintain and read. Looking for global variables just to know how they were created or manipulated will take you some time. And in OOP, it destroys the idea of encapsulation. 

But if you do understand what global variables are, then you just have to make your own decision in your implementation. Just code at your risk :D
front end
Tags: learning, discuss, javascript, php
Published: 2017-11-12 03:07:47

---
title: front end
published: true
description: good place to start
tags: #learning #discuss #javascript #php
---

Hi everyone,

Been learning python for about a year and a half and I'm not exactly the fastest learner, but eventually something sinks. Anyway been thinking lately, mainly because living below the line ain't much fun, that maybe I should try and learn front end in the hope of maybe building website and maintenance etc. I really can't afford to pay for Adobe stuff and Microsoft visual studio is slow. Where's a cheap good place to start? And cheap, I mean free lol

Cheers tc
Should students blog?
Tags: blogging, students, studying, writing
Published: 2017-11-14 07:53:28

---
title: "Should students blog?"
published: true
tags: Blogging, Students, Studying, Writing
canonical_url: https://www.samjarman.co.nz/blog/students-blog
---

I recently attended a panel with the ITP at WelTec, and after the event, a student asked me if they should be blogging, even though they "don't know anything".&nbsp;&nbsp;  
  
The answer is HECK YES.

But they were right. Content is the hard part as a student. You're kind right, you dont know much yet, and certainly not at a level that most think they need to be at. But that's not really the reason I'd visit a student's blog?  
  
What I mean is, I want to see your journey. In your blog posts, or vlogs, or tweets, or podcasts, I want to see a few questions answered:

- What are you learning right now?
- What did you find fun?
- What didn't you like, and why?
- What are you struggling to learn or understand, and what are you doing about it?
- What you need help with from the community?

Ultimately, document your journey. Now, these wont be the most mind blowing posts, sure. They won't be on the front page of hacker news, and they wont be shared and viewed countless times. But what it will do is help you more than you think.  
  
It'll help you learn. By writing down and digesting your thoughts into a post, you'll understand the topic better, and therefore remember it better when it comes to exams.&nbsp;  
  
It'll help you learn to communicate. One of the really lacking skills for devs is written communication (and I'm no master myself!), so getting in the habit of writing long form will help.&nbsp;

Finally, it'll set you up for good habits. I believe great developers blog (or something), so making time for this activity will be helpful as you enter your career.&nbsp;  
  
Read more:&nbsp;[Having an Online Presence as a Junior Developer](https://www.samjarman.co.nz/blog/online-presence)  
  
Best of luck!
A fresh coat of paint
Tags: workspace
Published: 2017-11-12 00:00:00


---
Categories:
- Workspace
description: Changing things up
tags: workspace
date: 12/11/2017
published: true
title: A fresh coat of paint
cover_image: https://thepracticaldev.s3.amazonaws.com/i/3f041xcgcu8b491o73nm.jpg 
---

My wife and I recently painted several rooms in our house. The old colors were from the previous owners and we wanted to make the house more our own. It really is surprising how much a new wall color can change the overall vibe of a room. It's quite refreshing and brings a new life to the space.

Similarly, I have now been working at my current company for a little more than four months; and up until recently, had been using the default fonts and colors for Visual Studio. But a couple weeks ago I switched from a light theme to a dark theme, hand selected a few colors for major text editor elements (like keywords, comments, and literals), and switched the font to Inconsolata.

All these changes are very superficial, but they helped usher in a new energy when coding. Furthermore, it encouraged me to treat my code as an art: visually pleasing, easy to read and understand, and structurally consistent.

If you feel like your maybe in a rut with coding, try shaking things up a little. Small changes can help add some excitement from what can easily become a daily grind.
Automating Unity3D Assets Import
Tags: unity3d, gamedev
Published: 2017-11-11 16:53:52

---
title: Automating Unity3D Assets Import
published: true
description: 
tags: Unity3D, gamedev
cover_image: https://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2015/10/1443735529Fotolia_91388525_Subscription_Monthly_M-1024x768.jpg
---

Games aren't always made by a one-man-team but involve several developers, who are people akin to making mistakes,that in turn increase dev cost time. 
Importing assets is no joke, with the default settings and different rules for different parts of your project, let's start with this premise and ask ourselves: "can we write tools to prevent common, costly mistakes ?"

the answer is yes and let's discover one cool Unity3D Class.


**AssetPostprocessor:**

the AssetPostProcessor class receive callbacks on importing something. it implements OnPreProcess* and OnPostProcess* methods and apply your rules to the assetImporter instance.
therefore we can write rules that prevent some common mistakes, let's take textures for instance, we can ensure:
- setting the texture type (deault, sprite, etc..)
- making sure Read/Write is disabled.
- disabling mipmaps for anything that is 2D or UI (it is enabled by default).
- forcing a max texture size

```C#
public class AssetImportSample : AssetPostprocessor {

    void OnPreprocessTexture()
    {
        if (assetPath.Contains("_UI") || assetPath.Contains("_Sprite"))
        {
            TextureImporter textureImporter = (TextureImporter)assetImporter;
            textureImporter.textureType = TextureImporterType.Sprite;
            textureImporter.spriteImportMode = SpriteImportMode.Multiple;
            textureImporter.mipmapEnabled = false; // we don't need mipmaps for 2D/UI Atlases

            if (textureImporter.isReadable)
            {
                textureImporter.isReadable = false; // make sure Read/Write is disabled
            }
            textureImporter.maxTextureSize = 1024; // force a max texture size
            Debug.Log("UI/Sprite Audit Complete");
        }
    }
}

```
Now with the above script, is it easier for the team to comply to naming conventions rather than cherrypick settings for different parts of a project.

we can also implement the same OnPreprocessModel() method for meshes to audit some common errors:

• Make sure Read/Write is disabled
• Disabling rig on non-character models (it fixes the auto added Animator component)
• Copy avatars for characters with shared rigs
• Enable mesh compression

and of course, also applies for Audio.
A Collection of AWS Related Plugins From SparrowHub
Tags: aws, cli, linux, raku
Published: 2017-11-11 15:54:16

---
title: A Collection of AWS Related Plugins From SparrowHub
published: true
description: For those who need ready to use aws utilities
tags: aws, cli, Linux, raku 
---

Here is a small, but useful [set of cli utilities](https://sparrowhub.io/search?q=aws) for aws related tasks:

- Print ec2 instance CPU utilization for a period of time.
- Run ec2 instance with users input parameters.
- List tagged ec2 instances.

And so on.  

[SparrowHub](https://sparrowhub.io) - is a repository of tools ( in terms of SparrowHub they are called plugins ) for a wide range of uses.