teleren/devto huggingface dataset:
understanding 'this'
Tags: javascript, beginners
Published: 2018-12-27 07:33:33

---
title: understanding 'this'
published: true
description: 
tags: javascript, beginners
---

# What is 'this'?

In short, `this` in JavaScript references the object that is executing the current function.

## How then do we determine the object being referenced?

#### (#1.) If the function is part of an object (ie. a method), `this` references the object.

```javascript
const bird = {
  name: "Tweety",
  printThis() {
    console.log(this); // `this` references `bird`
  }
};

bird.printThis(); // { name: 'Tweety', printThis: ƒ }
```

#### (#2.) If the function is a regular function (not part of an object), `this` references the global object in the running environment (ie. window in browsers and global in node)

```javascript
function bird() {
  console.log(this);
}

// If called in browser:

bird(); // Window {stop: ƒ, open: ƒ, alert: ƒ, ...}
```

Note: if a method has a callback function, `this` in the callback function references the global object.

```javascript
const bird = {
  birdName: "tweety",
  sounds: ["chirp", "quack", "tweet"],
  printBirdSounds() {
    this.sounds.forEach(function(sound) {
      console.log(this.birdName, sound);
    });
  }
};

bird.printBirdSounds(); // undefined 'chirp'
// undefined 'quack'
// undefined 'tweet'
```

In the above example, `this.sounds` in the `printBirdSounds()` method correctly references the `bird` object as it follows rule 1 above.

However, as the line logging `this.birdName` is inside a regular function, `this` now follows rule 2 and references the global object. Since there is no `birdName` property on the global object, it prints `undefined`.

To fix this, see rule 4 below.

#### (#3.) If the function is called using the `new` keyword in the case of constructor functions, `this` references a new empty object.

```javascript
function Bird() {
  console.log(this);
  this.name = "tweety";
  console.log(this);
}

new Bird();
// {}
// { name: 'tweety' }
```

#### (#4.) If `this` is used in an arrow function, the value of this is inherited from its enclosing scope (ie. follow lexical scoping rules).

This is because arrow functions do not have their own `this` value.

Rewriting the second example in rule 2 using arrow functions,

```javascript
const bird = {
  birdName: "tweety",
  sounds: ["chirp", "quack", "tweet"],
  printBirdSounds() {
    this.sounds.forEach(sound => console.log(this.birdName, sound));
  }
};

bird.printBirdSounds(); // tweety 'chirp'
// tweety 'quack'
// tweety 'tweet'
```

With arrow functions, the line logging `this.birdName` now follows rule 1 and references the bird object!

#### (#5.) If `bind`, `call`, `apply` are used to call a function, `this` inside the function is the object that is passed in as the argument.

```javascript
function bird() {
  console.log(this);
}

const tweety = {
  sound: "tweet"
};

const bindTweety = bird.bind(tweety);
bindTweety(); // { sound: 'tweet' }
bird.call(tweety); // { sound: 'tweet' }
bird.apply(tweety); // { sound: 'tweet' }
```
norris-cli
Tags: showdev, beginners, python, cli
Published: 2018-12-27 06:16:59

---
title: norris-cli
published: true
description: A simple python cli app that brightens up your day with Chuck Norris jokes from chucknorris.io
tags: showdev, beginners, python, cli
cover_image: https://thepracticaldev.s3.amazonaws.com/i/2apznh1ejsu1nmnt6c9p.jpg
---
Best feeling I've had this year: seeing something I did listed on PyPi 😊 🎉

It's a really simple cli app that get's a random joke from [chucknorris.io](https://api.chucknorris.io/) every time you run it. I made it with [Click](https://click.palletsprojects.com/en/7.x/)

## Install it
```
pip3 install norris-cli
```
**Make sure you install the pip3 version.**

## How to use
```
$ norris-cli --help
Usage: norris-cli [OPTIONS]

  If I had a nickel for every Chuck Norris joke out there...

Options:
  -c, --category [dev|movie|food|celebrity|science|sport|political|religion|animal|history|music|travel|career|money|fashion]
  --help                          Show this message and exit.

```

### Get a random joke
```
$ norris-cli
Chuck Norris doesn't call the wrong number. You answer the wrong phone.
```

### Specify a category
_You can see all available categories by running `norris-cli --help`_
```
$ norris-cli -c dev
Chuck Norris can't test for equality because he has no equal.
```

```
$ norris-cli -c food
Chuck Norris' favorite cereal is Kellogg's Nails 'N' Gravel.
```

Enjoy!

![approval](https://media.giphy.com/media/3hvmlYNsOTFWE/giphy.gif)
React: React Redux 6.0がリリース
Tags: javascript, react, programming, webdeb
Published: 2018-12-27 01:37:44

---
title: React: React Redux 6.0がリリース
published: true
description: React Reduxのv6.0.0が2018年12月5日にリリースされました。リリース情報にもとづいてその内容をご紹介します。
tags: #javascript, #react, #programming, #webdeb
---

[React Redux](https://react-redux.js.org/)のv6.0.0が2018年12月5日にリリースされました。本稿は[リリース情報](https://github.com/reduxjs/react-redux/releases/tag/v6.0.0)にもとづいてその内容をご紹介します。

React Redux 6.0は、React 16.4から新たに備わった[Context](https://reactjs.org/docs/context.html) APIをサポートするはじめてのリリースです。したがって、React 16.4以降が必要です。v6の詳しい変更点や、React Reduxのこれまでの実装の変遷については「[Idiomatic Redux: The History and Implementation of React-Redux](https://blog.isquaredsoftware.com/2018/11/react-redux-history-implementation/)」をご参照ください。


# 互換性を破る変更
React Redux 6.0に加えられた、後方互換性を破る変更はつぎのふたつです。

- [`connect`](https://react-redux.js.org/api#connect)の[`withRef`](https://react-redux.js.org/api#arguments-1)オプションは、`forwardRef`に置き替えられました。`connect`に`{forwardRef : true}`が渡されると、接続したラッパーコンポーネントに参照を加えれば、そのコンポーネントのインスタンスが返されます。

- 接続したコンポーネントにプロパティとして`store`は渡せなくなりました。替わりに、カスタムのプロパティ`context={MyContext}`が、`<Provider>`と`<ConnectedComponent>`のどちらも受け取れます。また、`connect`のオプションとして渡せるのは`{context : MyContext}`です。


# 変更された動作
React Redux 6.0で、これまでと動きが変わるのはつぎのふたつです。

- 従来のコンテキストから`Store`インスタンスを参照しようとするライブラリは動作しなくなります。`Store`の状態は、`<Context.Provider>`に納められるようになったからです。これによって動きが変わるのは、たとえば`connected-react-router`や`react-redux-subspace`です。(現在の実装では、`Store`はそのコンテキストにも加えられます。けれど、コンテキストの`Store`を参照する公開のAPIはありません。他のライブラリから参照できるようにしたものです。ただし、廃止される場合があります。)

- `componentWillMount`でコンストラクタから送出する`Action`に関わる動きが変わります。これまで、親コンポーネントのコンストラクタからの送出により、子はマウントされていればただちに更新された状態が使えました。コンポーネントがそれぞれ`Store`から個別に読み取るためです。React Redux 6.0では、すべてのコンポーネントがコンテクストから同じ現行の`Store`状態の値を得ます。ですから、ツリーの一貫性が保たれ、分裂することはありません。これは全体としては改善です。けれど、これまでの動作に依存するアプリケーションに影響する場合があります。


# その他の変更
- `React.createContext()`の使用(「[Use React.createContext()](https://github.com/reduxjs/react-redux/pull/1000)」)
- Prettierの使用(「[Use Prettier](https://github.com/reduxjs/react-redux/pull/1071)」)
- `isValidElementType`を開発ビルドでのみ実行(「[remove react-is/isValidElementType from production builds](https://github.com/reduxjs/react-redux/pull/1069)」)
- `isPlainObject()`で`null`をプレーンなオブジェクトのプロトタイプとして扱う(「[Treat `null` as a valid plain object prototype in `isPlainObject()`](https://github.com/reduxjs/react-redux/pull/1075)」)
- `connectAdvanced`はプロパティに変更が加えられたときのみ再描画する(「[Add connectAdvanced() tests](https://github.com/reduxjs/react-redux/pull/1079)」)
Looking back at 2018
Published: 2022-04-10 17:04:23

---
title: Looking back at 2018
published: true 
date: 2018-12-27 00:00:00 UTC
tags: 
canonical_url: https://www.funkysi1701.com/posts/2018/looking-back-at-2018/
---

As 2018 starts to draw to a close let’s look at some of the highlights from the past year.

1. New Home - I started 2018 with the goal of buying my own home and I managed it. At the end of October I actually moved in but it was months of looking at houses, speaking to estate agents, saving, packing and unpacking. There is more I want to do to my home in 2019 so this is only really the beginning.
2. New Job - Another goal was to kick my career up a notch and this happened in June. It has been great working as part of a large team and I have learnt loads, there is much more I want to learn and contribute to so 2019 should be great on that front.
3. New Car - Not a goal that I achieved as unfortunately in October I was involved in a car accident, no one was seriously hurt but this was a horrible experience to go through. My car was written off which gave me an excuse to buy a new car.
4. See more of family was a goal, I am not sure if I really achieved this. However family have been around loads for us during our move and we do live closer so hopefully I can work on this some more.
5. Celebrate 5 years of marriage. It hasn’t been an easy year for me and the wife due to moving house and all the stress that involved plus with two children she was diagnosed with Postnatal Depression which as a family we are still dealing with. All that said we had a fab weekend away and we so need to do something similar again soon.
6. Family. 2018 has included many great times with my two boys. It’s been amazing seeing them grow, in September we had a thanksgiving service for them and in July we had our annual holiday.
7. Lightning Talk. This is the only thing I mentioned as a goal that didn’t happen, it’s on my 2019 list so hopefully I can kick myself into action but with everything else I achieved something had to slip.
Resources.js.org - A curated list of #NodeJS & #Javascript tutorials, books, resources and shiny 💎 things.
Tags: beginners, javascript, codenewbie, node
Published: 2018-12-26 23:40:43

https://resources.js.org - A curated list of #NodeJS & #Javascript tutorials, books, resources and shiny 💎 things.

Powered by Github Pages, so everyone can contribute to the resource list and the repo. 

All data is saved in .json ( https://github.com/MrDatastorage/resources.js/blob/master/data/resources.json )

What do you think ? You love it ? Some improvements ? maybe some GitHub star 😉
Looking for feedback/help on locopy
Tags: python, opensource, contributorswanted, data
Published: 2018-12-26 16:17:53

---
title: Looking for feedback/help on locopy
published: true
description: A open source ETL package to help Load/Unload from Amazon Redshift.
tags: python, opensource, contributorswanted, data
---

Hi all, 

First post here. Some how I stumbled upon dev.to and this seems like a great spot to learn and collaborate! Wanted to share a project I've been working on. It isn't anything fancy but would love any feedback/help as this is my real first foray into maintaining a package.

`locopy` helps abstract some of the tedious work of getting data in and out of Amazon Redshift. It helps with getting data in/out of S3, and building the `COPY`/ `UNLOAD` to execute. It lets the user chose their DBAPI package (`psycopg2`, `pg8000`, etc.) vs forcing one on them.

I'm currently doing some refactoring, and also hoping to add more databases which I can support (Snowflake, Postgres, etc.)

https://github.com/capitalone/Data-Load-and-Copy-using-Python

Appreciate any thoughts, or help!
Kotlin for Android    
Tags: kotlin, android, java, tutorials
Published: 2018-12-26 21:35:49

---
title: Kotlin for Android    
published: true    
description: Kotlin for Android for absolute beginners   
tags: kotlin, android, java, tutorials
---

Hey Guys, 

My name is Amir and I want to learn Kotlin for Android. Unfortunately I don't have any background knowledge in Java, so I wonder if it is possible to learn Kotlin for Android without having a basic understanding of Java. 

If this is possible please give me some links to tutorials for absolute beginners, otherwise please do tell me how I should start learning Kotlin for Android. Do I have to first start with Kotlin itself as a whole and then move to Kotlin for Android or do I have to learn some basics in Java first and move to Kotlin for building Android applications. 

Thanks millions times, in advance.
What is a code review?
Tags: codenewbie, beginners, webdev, productivity
Published: 2018-12-26 21:29:02

---
cover_image: https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQezNA5efK7oX4o4JNa0oLf7vdRq1LtpuU-_6YafLo78o5wBGxT
title: What is a code review?
published: true
description: A brief explanation of the code review process and benefits. 
tags: #codenewbie #beginners #webdev #productivity
---
Have you ever worked on a project and became so hyper focused the world around you could fall apart and you wouldn't notice?  I love those moments and as a new web developer it's when I feel everything coming together and I make a significant amount of progress on a project or a piece of functionality.  The downside is of course when something breaks or just doesn't work the way its intended and despite my best efforts of concentration my eyes can no longer decipher the difference between a comma and a period.  That's when code review come into play!

Code review is the process of reviewing and approving code changes for collaborators, someone other than the author of the pushed changes.  It's basically code inspections conducted by peers working on the same project with a protected `master` branch. 

Code review *needs* to be taken seriously.  Don't treated it like it's depicted in this cartoon! 
![Code Review](https://cdn-images-1.medium.com/max/1200/1*uDyb9W5jE0sVDHjPkG_o7w.png)

There are tremendous benefits of code reviews. For one, code reviews save time and help to streamline the development process up front.  Ultimately the upfront time saved reduces the amount of work for the Quality Assurance teams later.  A second set of eyes to review something you've stared at for days can quickly identify simple errors and even catch bugs that might have slipped undetected through testing or production.  We all know time is money and time saved is money saved too.  

In my opinion the code review process also fosters collaboration. The more I collaborate with others the more I learn too.  To me, it's fascinating to watch someone code, troubleshoot and do a code review.  It provides an opportunity to witness someone else's approach to coding and their thought process.  It's a priceless opportunity for anyone to learn ways to identify common problems or write cleaner code along with useful shortcuts. 

For more information checkout the posts in my Reference Guide series:  [Conducting a Code Review](https://dev.to/kymiddleton/reference-guide-conducting-a-code-review-k6m) and [Complete and Merge a Pull Request](https://dev.to/kymiddleton/reference-guide-complete-and-merge-a-pull-request--12n4).
My website design is not like others
Tags: webdev, beginners, discuss
Published: 2018-12-26 20:30:15

---
title: My website design is not like others
published: true
description: 
tags: productivity, webdev, beginners, discuss
---
When I create a website or something such as small scripts always I ask my self if this website's code is good or just I imagine. my website looks good and amazing for me like I have thought before I created it but I always think that is other websites are so good exactly their codes...
sometimes when i see a design in a website I know I can do it but when i see their code... it is so different from my code, they write class divs and other elements in another way.
How can I know that is my code is good ? it must be like their codes ?
I can do a lot of things when i am practicing but I have problem with my self when I saw a website coding with another way and a lot of details...
What courses would you recommend for learning Front End Development? 
Tags: beginners, help, selftaught, frontend
Published: 2018-12-26 18:14:30

---
title: What courses would you recommend for learning Front End Development? 
published: true
description: 
tags: beginner, help, selftaught, frontend
---

Hi guys 

What courses would you recommend for learning Front End Development? 
What would the learning path be in that case and which courses to take to learn it?

Thanks
understanding closures in javascript
Tags: javascript, beginners
Published: 2018-12-26 18:02:17

---
title: understanding closures in javascript
published: true
description: an attempt at a short and simple explanation of closures
tags: javascript, beginners
---

## Closures

Closures are created when you define a function. A closure encompasses everything that a function can access.

```javascript
var g = "G";

function functionA() {
  var a = "A";

  function functionB() {
    var b = "B";
    console.log(a, b, g);
  }

  functionB(); // prints A, B, G

  a = "Batman";
  functionB(); // prints Batman, B, G
}

functionA();
```

In the above example, when functionB is defined, its created closure gives it access to the global variable 'g', the variable 'a' and the variable 'b'.

Note that the closure gives a reference to the variable and not a copy of the variable. Hence, if the value of variable 'a' is changed and functionB is called again, the new value of 'a' will be printed instead of the old one.

Closure is a very important concept in functional programming paradigm. It allows a function to remember its context where it's defined.

When a function returns another function, the concept of closures becomes more relevant. The returned function has access to variables that are not in the global scope, but solely exist in its closure ie. private variables.

In the above example, the variable 'a' is considered private in the function and only accessible by functionB.

In functional programming, closures are also frequently used for partial application and currying.

![alt text](https://ichef.bbci.co.uk/food/ic/food_16x9_832/recipes/fish_curry_09718_16x9.jpg "random curry photo")

> Partial Application: The process of applying a function to some of its arguments. (ie. a function that takes a function with multiple parameters and returns a function with fewer parameters.)

> Currying: A function that takes a function with multiple parameters as input and returns a function with exactly one parameter.

Here is another example:

```javascript
function adder(a) {
  function add(b) {
    return a + b;
  }

  return add;
}
```

```javascript
var addOne = adder(1); // a is 1, addOne has a reference to add(b)
var addTen = adder(10); // a is 10

addOne(5); // 1 (a) + 5 (b) = 6
addTen(5); // 10 (a) + 5 (b) = 15
```

In C and most other common languages, after a function returns, the local variables are no longer accessible because the stack-frame is destroyed.

In JavaScript, if you declare a function within another function, the inner function can remember and access variables and arguments of its outer function, even after the outer function has returned.

#### For further reading...

<sub>https://medium.com/javascript-scene/master-the-javascript-interview-what-is-a-closure-b2f0d2152b36</sub>
<sub>https://medium.com/dailyjs/i-never-understood-javascript-closures-9663703368e8</sub>
<sub>https://medium.freecodecamp.org/whats-a-javascript-closure-in-plain-english-please-6a1fc1d2ff1c</sub>
JMQT (JSON Message Queuing and Transfer) - a new IoT and messaging protocol
Tags: iot, networking, python, pubsub
Published: 2018-12-26 17:35:27

---
title: JMQT (JSON Message Queuing and Transfer) - a new IoT and messaging protocol
published: true
description: 
tags: iot,networking,python,pubsub
---
Dear fellow developers,

After using MQTT in many of my IoT projects in last few years, I have realized that there is a huge learning curve for the beginners to understand and implement MQTT in their projects. MQTT has a complex packet structure and customizing the open source MQTT brokers for a specific need is also difficult for the beginners, and sometimes even for the experts.

I have developed an IoT and messaging protocol called JMQT (JSON Message Queuing and Transfer), which minimizes the learning curve for the developers and can speed up the development cycle. The key features of this protocol goes as follows :
1. It is JSON based and much less complex than the available IoT protocols (such as MQTT). JSON is natively supported on most of the major programming and scripting languages.
2. JMQT has modernized the authentication system using Authentication Token on the contrary to the other IoT protocols (like MQTT) which use conventional user id and password.
3. JMQT is perfect for the beginners to understand the basics of pub-sub protocols.
4. JMQT can easily be expanded and customized. Adding a new parameter to a JMQT packet is pretty easy as it uses JSON.
5. JMQT has Point to Point messaging support. This allows the programmers to develop robust solutions (for example, IoT or messenger applications) which needs point to point communication between the clients.

I have also developed an open source project which implements the JMQT protocol. This project includes a python Socket & WebSocket server with SSL support, a python load balancer, a python client and a Javascript client. The initial code is ready, tested and released. 

To know more about JMQT, please visit http://jmqt.org. JMQT open source project can be found at https://github.com/shubhadeepb14/jmqt. 

If you get interest in JMQT and in its open source implementation, please let me know. Collaborators are welcome. For any query, you can comment in this post or directly message me.

Thank you for your patience in reading this long post. Happy programming!
Most Popular Development Posts Of The Week (26 December 2018)
Tags: webdev, vscode, productivity, javascript
Published: 2018-12-27 15:25:37

---
title: Most Popular Development Posts Of The Week (26 December 2018)
published: true
tags: webdev,vscode,productivity,javascript
canonical_url: https://medium.com/daily-now/most-popular-development-posts-of-the-week-26-december-2018-f76b776a505e
cover_image: https://cdn-images-1.medium.com/max/1024/1*6C-9NnZPaWVbTQZKZIJC3Q.jpeg
---

Wonder what your customer really wants? Ask. Don’t tell.

- [What’s New in JavaScript Frameworks in 2019](https://app.dailynow.co/r/489036240f60554a758115089cb850b3)
- [Creative Login Screen Designs](https://app.dailynow.co/r/9c57c698a7cfcdbeb8fe6d8c9565fc65)
- [5 Ways To Improve Development With Visual Studio Code](https://app.dailynow.co/r/95534b7609139c8a5e1e8beb3b61f352)
- [6 Simple Steps to Make Money Online During the First Month of 2019](https://app.dailynow.co/r/1e41085c9234249dc2659a5043934910) by [Jon Brosio](https://medium.com/u/619b53ccda0)
- [The Pros and Cons of Node.js Web Application Development](https://app.dailynow.co/r/fafc4ba7ac0afc99b4058fbbfeae3d10)
- [Do We Need A Better Calendar?](https://app.dailynow.co/r/d4415893d7dde7cfd0dbb3b441f1df80) by [Zi Wang](https://medium.com/u/97e6c507f0ea)
- [Essential Software Developer Skills, Technologies & Languages for 2019](https://app.dailynow.co/r/a3e6f0e5ab833d404f69a6b4be55a6f4) by [The Martec](https://medium.com/u/539352acfbd0)
- [If You Work Very Hard for Something but Don’t Get It, Read This.](https://app.dailynow.co/r/1b10ddbb64a7170354e2a0cfb69253a5) by [Tiffany Sun](https://medium.com/u/168304bc5c01)
- [How REST Apis Make the Difference in programming field?](https://app.dailynow.co/r/3a34b4bd8ca3c359f04318de3d5eaac6)
- [What’s New in React v16.7](https://app.dailynow.co/r/bf156fcdf5ea629143dab2bc1ca95dd5) by [Josh Sherman](https://medium.com/u/56a91edb2bbb)

* * *

[_Thanks to Daily_](https://www.dailynow.co/) _developers can focus on code instead of searching for news. Get immediate access to all these posts and much more just by opening a new tab._

![](https://cdn-images-1.medium.com/max/1024/1*m8Uf-6F4Q5AOp_wW6tbKSQ.jpeg)
Hello, I am Chidinma (cheedeema)
Tags: introductions
Published: 2018-12-26 13:35:22

---
title: Hello, I am Chidinma (cheedeema)
published: true
description: introductions
tags: introductions
---
Hello! 
One of my new year resolutions is to write. I have always been scared of writing for quite a number of reasons. I decided to start by introducing myself here.

I am a Nigerian living in the Netherlands. 

I work as a frontend developer and I am self-taught. Although I mostly program in Javascript and React, I have some experience in Angular, SQL, and Nodejs. I do enjoy mathematics, even though it drives me crazy sometimes, more than I let on.

I am currently immersing myself in Python, learning and understanding data structures and algorithms.

I am also currently looking to get into Open Source Contribution (really don't know where to start from), teaching, contributing and doing more for the community than just existing!
 
You can find me on [Github](http://github.com/ChidinmaKO) and [Twitter](http://twitter.com/ChidinmaKO).

Nice to meet you! ❤️