teleren/devto huggingface dataset:
フロントエンジニアのリーダブルコード #2 コードの美しさ
Tags: javascript, jquery, readablecode
Published: 2019-09-14 08:56:23


この記事では、コードの美しさの２つを紹介します。「可動性」と「最短処理」です。可動性は、コードの見た目を意識し、開発者が読みやすいコードを書くことです。最短処理は、無駄な処理、同じ処理(二重化の過ち)を書かないようにすることです。「[DRY原則](https://ja.wikipedia.org/wiki/Don't_repeat_yourself)」という哲学を意識していきましょう。

#### #2 コードの美しさ

可動性を高めるには、インデントとスペースに頼ることになります。可動性のほとんどは、自動整列機能で解決できます。エディタのSublimeTextはHTML-CSS-JS Prettify、Atomでは標準のAuto indentが付いています。サイトのソース確認に、Google Chrome デベロッパーツールのsourcesタブにも自動整列機能が付いています。

しかし、ほとんどの開発者は、自分でネストを調整していきます。ネストは、深くなるほど可動性は下がります。ネストが深くなる前に、処理の答え(リターン)を返してあげるようにしましょう。

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

ネストは深くなるほど、開発者にストレスを与えます。なぜなら、覚えていられないからです。条件分岐が5重6重となると、最初の条件分岐を忘れてしまいます。リターンが遠いコードは、読む気が起きません。

コードの縦の線も意識していきましょう。３つの引数の文字数が異なっていても、カンマの位置の縦線を意識することによってコードが読みやすくなっています。

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

マークアップ言語のHTMLは、ソースの順番の入れ替えを行うことが出来ません。JavaScriptとCSSは、HTMLの順番に合わせるようにしましょう。

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

実際は、もっと複雑です。例では、同じHTMLに記述してありますが、実際は別々のファイルです。またひとつひとつのクリックイベントは、一行では収まりません。順番を意識することで、二重化を防ぎ見やすいコードになるでしょう。

上記のクリックイベントは、二重化になりやすいコードです。順番を工夫することで、イベント自体の二重化を防げましたが、イベント内で二重化が発生する場合があります。ボタンを押すと、サイトの背景色が変更します。各イベントの違いは、**色だけ**です。

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

ボタンを作成するJavaScriptのコードです。作成するボタンの違いは、テキストとクラス名です。呼び出しのときに、(関数の引数に)テキストとクラス名を与えることで、それぞれのボタンを作成することできます。違う点を把握し、同じような処理を書かないようにしましょう。同じ処理をまとめることは、コードの修正点も１つにまとめることができます。

最後に無駄なコードです。配列から値を削除する関数です。第1引数に配列を入れ、第2引数に配列内の削除したい要素を入れます。

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

removeIndexは無駄な変数です。for文内で、変数に格納するのではなく、spliceで直接削除するのが良いでしょう。タスクは早く完了するようにしましょう。

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

コードの美しさの「可動性」と「最短処理」を紹介しました。いろいろ紹介しましたが、環境によっては二重化を要求する場合もあります。やむ得ない「二重化の過ち」については、参考書籍「[達人のプログラマー](https://www.amazon.co.jp/%E6%96%B0%E8%A3%85%E7%89%88-%E9%81%94%E4%BA%BA%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9E%E3%83%BC-%E8%81%B7%E4%BA%BA%E3%81%8B%E3%82%89%E5%90%8D%E5%8C%A0%E3%81%B8%E3%81%AE%E9%81%93-Andrew-Hunt/dp/427421933X)」をご覧下さい。コードを主観的ではなく、客観的に見るようにしましょう。

※前回のフロントエンジニアのリーダブルコードは、「フロントエンジニアのリーダブルコード #1 変数名で情報を伝える」です。ぜひ、そちらも読んで見てください。
{% link https://dev.to/shibandd/-3a40 %}
※参考書籍「[達人のプログラマー](https://www.amazon.co.jp/%E6%96%B0%E8%A3%85%E7%89%88-%E9%81%94%E4%BA%BA%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9E%E3%83%BC-%E8%81%B7%E4%BA%BA%E3%81%8B%E3%82%89%E5%90%8D%E5%8C%A0%E3%81%B8%E3%81%AE%E9%81%93-Andrew-Hunt/dp/427421933X)」
※参考書籍「[リーダブルコード ―より良いコードを書くためのシンプルで実践的なテクニック](https://www.oreilly.co.jp/books/9784873115658/)」
Custom Linux Command
Tags: linux, terminal, ashstudios
Published: 2019-09-14 08:47:21

You can also watch this video on my [channel](http://www.youtube.com/ashstudios)

In this video, I'll teach you how to create your own custom Linux terminal command. Which means that you can merge more than one commands into 1 or shorten a really long command!

Sorry for the background noise :(
Today I Learned!?
Tags: webdev, php, html, javascript
Published: 2019-09-14 08:01:48

So, I had a new year's resolution that I want to **learn something new everyday**. 
For tracking if I learned something, I use an app called [Habit](https://github.com/iSoron/uhabits)
But up until now, I had no way of knowing what I learned previously on a particular day...
So, inspired by [Bhupesh Varshney](https://dev.to/bhupesh)'s [til](https://github.com/Bhupesh-V/til) I decided to create something like that.

Finally, I ended up using PHP and MySQL to store my data.

- I created a simple HTML form ( template picked up from colorlib )
- Created inputs - title, date ( today's date (not editable) ) & description
- Then I sent a post request using JQuery to my til.php file
- In the til.php, I validated the input and inserted it into the DB

Later, I want to include this section in my [new website](http://harshsaglani.byethost13.com/new/?i=1) (currently under construction 'cuz imma buzy with some app development)
So, I'll be having an admin panel via which I will update the til everyday and it will be shown on my website too!!

If you have some thoughts, please share them! Let me know if you have some ideas!
Django tutorial
Tags: pythondjango, djangopython, pythondjangotutorial, djangotutorial
Published: 2019-09-14 07:50:44


You can learn Django much faster than any other programming language and this Django tutorial helps you do just that. Our Django tutorial has been created with extensive inputs from the industry so that you can learn Django and apply it for real world scenarios.

Watch Now: https://www.youtube.com/watch?v=E-uFDJOnMuw&t=821s
Todo List App Using Flask and SQL-Alchemy
Tags: python, sql, flaskapp, tutorial
Published: 2019-09-14 07:39:56

https://youtu.be/MWVViGmxTJg

Todo List App With Flask Python and SQL Database

In this video we'll be looking into a Todo list app using python flask & sql database and performing some basic CRUD operation's like delete,create,update and read etc.
We'll also see POST and GET request while getting and creating new task.
Friday Blast #78
Tags: fridayblast, links, post
Published: 2019-09-15 15:03:22

---
title: Friday Blast #78
published: true
tags: friday_blast,links,post
canonical_url: https://horia141.com/friday-blast-78.html
series: "Friday Blast"
---

[Building and motivating engineering teams (2016)](http://www.elidedbranches.com/2016/11/building-and-motivating-engineering.html) - from the author of “The Manager’s Path”, but before the book. There’s something in here for anybody - for ICs it’s a handy reminder of what you can or could expect from a company. For managers it’s more _practical_. While founders or higher-up types can actually influence things like salaries or purpose, line managers can work within what they can control - respect for example - to create better teams and orgs.

[The hopeless task of the Unicode Consortium (2019)](https://www.johndcook.com/blog/2019/08/31/hopeless-task-of-unicode/) - musings on Unicode. Modeling any concept where humans have had a big say - time, calendars, borders, language is a huge task, and often the simple solution is plain wrong.

[Incrementally migrating over one million lines of code from Python 2 to Python 3 (2019)](https://blogs.dropbox.com/tech/2019/02/incrementally-migrating-over-one-million-lines-of-code-from-python-2-to-python-3/) - war stories from Dropbox’s migration of their desktop client. Interesting that it _could_ happen without massive massive re-engineering efforts. Relevant in the wake of Python 2 EoL.

[Machine Learning powered search ranking of Airbnb Experiences (2019)](https://medium.com/airbnb-engineering/machine-learning-powered-search-ranking-of-airbnb-experiences-110b4b1a0789) - this was a fun one about how the Airbnb “experiences” feature basically evolved it’s recommendation system from “basic” to “advanced”. A good guide for anyone trying to build such features - start out simple, provide value, then iterate!

[Details on Tesla’s new big beefy chips (2019)](https://om.co/2019/08/23/details-on-teslas-new-big-beefy-chips/) - one of the results of the end of Moore’s law is that we aren’t getting general purpose chips which are more powerful year over year. More power efficient yes, more cores yes(ish), but not “free lunch” more powerful like before. So if you’re a big company and you have a bunch of compute that’s really important to you - ML training/inference, image processing, computational photography, object detection etc. one solution is building custom chips for that problem. We’re very far from taping out “this” market!
Decision Tree Machine Learning
Tags: decisiontreetutorial, decisiontreeindatamining, decisiontreepython, decisiontreemachinelearning
Published: 2019-09-14 06:34:01

Data Science is taking over each and every industry domain. Machine Learning and especially Deep Learning are the most important aspects of Data Science that are being deployed everywhere from search engines to online movie recommendations. Taking the Intellipaat Data Science training & Data Science Course can help professionals to build a solid career in a rising technology domain and get the best jobs in top organizations.

Watch Now: https://www.youtube.com/watch?reload=9&v=98qV-L6DW8M
Python vs Go
Tags: golanguagevspython, govspython, pythonvsgolang, pythonvsgo
Published: 2019-09-14 06:24:25

python and go are one of the trending buzz in the IT industry. Python is very popular in the IT industry on the other hand Golang's popularity is continuously increasing. Seeing the demand for Python and the increasing demand for Golang, there might be a question in your mind like which one of them is better - python or go? or which one should I learn first - python vs go? If these question have popped in your head too then this video is definitely for you.

Watch Now: https://www.youtube.com/watch?v=MZFs3LSlakc
Sentiment Analysis Python
Tags: sentimentanalysis, sentimentanalysisinpython, sentimentanalysistwitter, sentimentanalysispython
Published: 2019-09-14 06:13:19

You can learn Python much faster than any other programming language and this Python tutorial helps you do just that. Python programming is one of the best languages that is finding increased applications for machine learning. Our Python tutorial has been created with extensive inputs from the industry so that you can learn Python Programming and apply it for real world scenarios like machine learning and data science.

Watch Now: https://www.youtube.com/watch?v=WGf7gXbCTp4
Do Good Daily Day 2
Tags: swift, swiftui, ios
Published: 2019-09-14 06:04:40

📅 09/13/2019
🔥 2 day streak
📱 Do Good Daily
💰 $0.99 price
🤑 0 sales
⌚️ 2 hours spent
💻 12 files changed, 693 insertions(+), 0 deletions(-)
✅ Today's goal: Add a swiftUI view that lets people set the first daily push notification time

## Captain's Log: 🤦‍♂️
You know that feeling when you start a new side project and you're full of optimism and everything is going well?
That's a great feeling and you can hold on to that by never starting that side project.

Things went from great to good to bad for me really quickly. I don't know where start. Yes I do: xcode.

![family guy peter griffin grinds my gears](https://thepracticaldev.s3.amazonaws.com/i/fwvarxmss4osf422q35r.jpeg)

Ah xcode, the editor everybody loves to hate, but with good reason. It's horrible. The beta is especially bad this year with the introduction of swiftUI. Everything goes smoothly until you add any `ObservableObject` into your app. Then the preview starts failing and never recovers. Eventually I learned that the preview is only good for quick visual tweaks and leave it off now.

There's one more thing that really grinds my gears and that's a rogue swift process spinning up my CPU fan like it's an effin' apache helicopter. Closing xcode doesn't even put a stop to it, no this process needs [Rey](https://en.wikipedia.org/wiki/Rey_(Star_Wars)) because I had to FORCE QUIT it.

## Progress Still Happened
Learning any new thing is going to cause some grumpy cat moments, but swiftUI really takes the cake. Maybe I should focus on the positive. I did get a picker working and I serialized app state to a json file, I’ll get into the nitty gritty tech stuff tomorrow
Hive Tutorial 
Tags: hivetutorialforbeginners, hivearchitecture, hivecourseforbeginners, hivetutorial
Published: 2019-09-14 05:40:54

Data is being generated hugely in each and every industry domain and to process and distribute effectively hadoop is being deployed everywhere and in every industry. Taking the Intellipaat big data hadoop training can help professionals to build a solid career in a rising technology domain and get the best jobs in top organizations.

Watch Now: https://www.youtube.com/watch?v=nVI4xEH7yU8&t=13s
How to ensure that two separate copies of same file on client and server side always be in sync?
Tags: dnsserver, networking, python, discuss
Published: 2019-09-14 04:32:27

Actually I have made a dns server in python using dnslib. The dns server first checks for the domain in its own dictionary ,if domain is found it returns the IP Address, if it is not found it fetches the ip address from an external dns. 


I have also built a portal using which people can register their own domains with the dns server. 
For this the domain and ip address are entered into the copy of the dictionary which is with the dns server. 

Now using a TCP connection I am thinking of sending the changes made in the dictionary with the portal to the dictionary with the dns server. 

But I am concerned that if for some time the data from client dictionary can't reach data to host dictionary then the two would be left async. 

What can be the most efficient way to tackle this problem?
Ghostbusters Challenge/JavaScript Challenge
Tags: discuss, javascript, learning, silly
Published: 2019-09-14 03:58:21

Okay,

I thought of this stupid little snippet of JS that has been cracking me up all day. I wanted to create a snippet of JS code that would emulate the line from the Ghostbusters theme song: <em> "If there's something strange in your neighborhood, who you gonna call? Ghostbusters" </em> 

So this is what I came up with:

<pre>
{
let somethingStrange = 1;
let neighborhood = 1;

function whoYouGonnaCall() {
if (somethingStrange === neighborhood) {
whoYouGonnaCall = 'Gohstbusters';
console.log(whoYouGonnaCall);
} else {
console.log('I ain\'t afraid of no ghost');
}
}
whoYouGonnaCall();

}
</pre>

This prints <strong>Ghostbusters</strong> to the console. 

I thought this would be a great learning exercise for me and others to learn something from other JS devs. I know there are more experienced JS devs out there who can put together a more creative JS snippet that expresses this same line in a different way, and I would love if you would take a crack at it. 

<strong>Challenge:</strong>
Please show us how you would use JS to express:
<em>"If there's something strange in your neighborhood, who you gonna call? Gostbusters"</em>

<strong>Rules are:</strong>
1.) it has to work.
2.) it would be great if you explained why you chose the snippet you chose
3.) Please share an explanation of it's result.


Thanks!!
Schedule your Netlify build with GitHub Actions
Tags: netlify, github, serverless, jamstack
Published: 2019-09-14 03:49:54

---
title: Schedule your Netlify build with GitHub Actions
published: true
canonical_url: https://ericjinks.com/blog/2019/netlify-scheduled-build/
description: If your build process is pulling in content from third-party services (e.g. Instagram, Youtube), scheduling a daily build & deploy can be an easy way to keep this content fresh.
tags: netlify, github, serverless, jamstack
---

If you host a site on Netlify, you may know about [Build Hooks](https://www.netlify.com/docs/webhooks/#incoming-webhooks). By creating a build hook and sending a `POST` request to it, you trigger a new build & deploy for your site. If your build process is pulling in content from third-party services (e.g. Instagram, Youtube), scheduling a daily build & deploy can be an easy way to keep this content fresh.

The easiest way to setup a scheduled build hook trigger that I have come across is to use [GitHub Actions](https://github.com/features/actions). Setting this up is completely free if your repository if public. If your repository if private, you will most likely remain in their free tier, see pricing [here](https://github.com/features/actions).

## Creating a scheduled Netlify build trigger GitHub Action

1 – Add a Build hook to your site using the [Netlify Dashboard](https://app.netlify.com)

   > (Settings > Build & Deploy > Continuous Deployment > Build hooks)

2 – In your GitHub repo, create a `main.yml` file in a `.github/workflows` directory:

   ```yaml
   # .github/workflows/main.yml

   name: Trigger Netlify Build
   on:
     schedule:
       # Run at 0815 daily
       - cron: '15 8 * * *'
   jobs:
     build:
       name: Request Netlify Webhook
       runs-on: ubuntu-latest
       steps:
         - name: Curl request
           run: curl -X POST -d {} YOUR_BUILD_HOOK
   ```

   > Replace **YOUR_BUILD_HOOK** with the build hook url you just created.  
   > You can use [crontab.guru](https://crontab.guru) to easily generate your cron schedule.

3 – Open the Actions tab in you GitHub repo to watch the workflow trigger as per your cron schedule. 🎉

I hope this is useful to you! If you have any questions, I've created an example repository that uses GitHub Actions to build every 15mins: 

{% github Jinksi/netlify-build-github-actions %}
Cuban Opensource
Tags: cuba, github
Published: 2019-09-14 03:05:34

So, this is just to share a list of Cuban Opensource projects: https://github.com/cuban-opensourcers/cuban-opensource
And to remember: a couple of months ago Github started to block private repos and accounts of Cuban developers. 
In our case it wasn't a problem, but some fellow devs were affected by this. Why? Because they still live in our country. Not cool!
Newbie notes while learning rails
Tags: rails, heroku
Published: 2019-09-14 02:56:18

This a small diary...📓
If you are using heroku to deploy your app and a database, don’t forget to run <code>heroku run rails db:migrate</code> after <code>git push heroku master</code>.

You can use multiple rails version, useful if you are following a tutorial from a previous version than the current version. Just don’t forget <strong>underscores</strong> while <code>rails _5.1.6_ new app_title</code> where 5.1.6 can be another version.

If you modify your <strong>Gemfile</strong> don’t forget to <code>bundle install</code> after the changes.

Always check if at some point of the code the <strong>colon</strong> is in front of the variable like <code>name:</code> or if it’s in back <code>:name</code>, this always put me in trouble while learning rails.


This are things happening right now to me while learning and if you feel like sharing your experience while you were learning rails please add a comment 😋
Laravel Redirect HTTP to HTTPS via .htaccess
Tags: laravel
Published: 2019-09-14 02:06:47

Today, i share with you, redirect http to Https in laravel
You create file .htaccess in root laravel
```
RewriteEngine On
RewriteRule ^(.*)$ public/ [L]
```
Way code above it redirect to http, if you want http to https, you can using following code above

```
<IfModule mod_rewrite.c>
    RewriteEngine On        
  RewriteCond %{HTTPS} !=on    
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  RewriteRule ^(.*)$ public/ [L]
</IfModule>
```
Post:[Laravel Redirect HTTP to HTTPS via .htaccess](https://hoanguyenit.com/laravel-redirect-http-to-https-via-htaccess.html)
How to start building career?
Tags: career, discuss, help
Published: 2019-09-14 00:35:22

Hi everyone , This is my first post in this website ( I liked it so much ) .
First, I'm in my last year of engineering degree in CS( 5/6 years in university),
I studied many things in computer science from C/C++ to VB.net/C#, Java/J2EE, Matlab, Photoshop, Illustrator, Flash/3ds max,PHP,HTML,CSS,JS and more ( wow ! ).
Each year i study a different thing so i hesitate between the path i should take i feel like i love everything i study but from the beginning i love so much web development. During this years i created many projects but all of them are academic so i don't care too much for code quality or UI/UX so i didn't showed it in my portfolio , neither upload source code to github , I don't wont to share something ugly even if it is functional.
I will graduate after 1 year so i must start thinking of my career (Thinking now -lol- ) . I don't say that i'm not good in development ( software or web) , No ! I can build awesome stuffs if I take the time needed :D 
So now , I want to start to rearrange thinks , I'm focusing on the field I liked : Front End development with some Back-end development ( Full stack oh !) .
I studied Angular and i really enjoyed it and the community using it , I have already good knowledge in PHP with MySql, but I think of the MEAN stack instead .

I have some questions :
I will soon upload my source codes ( after code reviews :D ) , what is the best place to host the front end (Angular) and the back-end (PHP && J2EE) the projects  will be seen by normal people not necessary developers . Do I need to upload only complete projects worked or i can add examples of functionality .
As i have worked in some projects i can share informations , It's better to create my own blog or share it in websites like dev.to or medium ?

I want to get advices for a fresh person who will graduate in a year . 
Thank you . I appreciate every comment :)
Reset root or user password of linux (Ubuntu/debian) OS
Tags: linux
Published: 2019-09-19 15:50:31

---
title: Reset root or user password of linux (Ubuntu/debian) OS
published: true
tags: linux
canonical_url: https://thecodersblog.com/reset-linux-password-from-termnial/
---

If you accidentals locked-out or want to change the root/user password at any cost - you can reset it.

> Side effect & Note: Previous users `login.keyring` will not work. Hence, you will loss all previously saved wifi/network drives as well as Google Chrome profile settings (until you remember the old password and unlock it).

### To reset follow the following steps.

1. Reboot pc
2. Hold _SHIFT_ during boot to start _GRUB_ menu
3. Highlight your image and press _E_ to edit _GRUB_ config (change will reset after reboot)
4. Find the line starting with “linux”
5. Append `rw init=/bin/bash` at the end of that line
6. Press _CTRL + X_ to continue the boot
7. Change password with command `passwd USERNAME`
8. Reboot with CTRL+ALT+DEL
9. Log in using the new password

If you want to backup your keyring file to try unlocking it later save the following file:

```
/home/user/.local/share/keyrings/login.keyring
```