teleren/devto huggingface dataset:
Short Video: Array Iteration
Tags: javascript, array, functional, video
Published: 2019-01-09 11:32:36

---
title: Short Video: Array Iteration
published: true
description: 
tags: js, array, functional, video
---

JS Nuggets channel is nice with short videos for JS.

{% youtube RD69hYGY-4U %}

Following codes shared with you.

```js
//forEach
[1,2,3].forEach(function(item, index){
  console.log(item, index)
})

//map
const three = [1,2,3]
const doubled = three.map(function(item){
  return item * 2
})
console.log(doubled)

//filter
const ints = [1,2,3]
const evens = ints.filter(function(item){
  return item % 2 === 0
})
console.log(evens)

//reduce
const sum = [1,2,3].reduce(function(result, item){
  return result + item
})
console.log(sum)

//some
const hasNegativeNumbers = [1,2,3,-1,4].some(function(item){
  return item < 0
})
console.log(hasNegativeNumbers)

//every
const allPositiveNumbers = [1,2,3].every(function(item){
  return item > 0
})
console.log(allPositiveNumbers)

//find
const objects = [{id: 'a'}, {id: 'b'}, {id: 'c'}]
const found = objects.find(function(item){
  return item.id === 'b'
})
console.log(found)

//find index
const objects2 = [{id: 'a'}, {id: 'b'}, {id: 'c'}]
const foundIndex = objects2.findIndex(function(item){
  return item.id === 'b'
})
console.log(foundIndex)

```
AI radio control car
Tags: diy, obniz, ai, iot
Published: 2019-01-09 08:26:02

---
title: AI radio control car
published: true
description: Control the car with text detection!
tags: #diy #obniz #ai #iot
---

Control the car with text detection!

[![IMAGE ALT TEXT HERE](http://img.youtube.com/vi/GkxKpqYBtDU/0.jpg)](http://www.youtube.com/watch?v=GkxKpqYBtDU)

## Program
https://obniz.io/explore/34
Remote air conditioner controller
Tags: diy, obniz, ai, iot
Published: 2019-01-09 08:09:55

---
title: Remote air conditioner controller
published: true
description: Home IoT Kit Example
tags: #diy #obniz #ai #IoT
---

![](https://storage.obniz.io/images/6ec3873fa6c11bbd1530774197853)


## What's this
Home IoT Kit Example

Control an air conditioner from your smartphone with obniz!

Put obniz + IR + temp sensor to your home. You can control it from your browser.

## Materials
- obniz * 1
- power supply for an obniz.
- IR module (of Home IoT Kit)
- LM35DZ (of Home IoT Kit)
## Steps
Connect like below. And put it on your home
![](https://storage.obniz.io/images/b56ee6526abc27571530774184044)

Write a program regarding this example.
Change obniz id in the example.

By Pressing "Save&Open", You can see a temperature.
![](https://storage.obniz.io/images/6608f2e237b91b891530774191823)

Record a your air conditioner signal for ON/OFF.

The example contains comment outed code for IR receiver.
Remove the comment out and record your air conditioner's ON/OFF signal. Your signal will be showed in log.

Put it recorded data array into your program.

## Use it !
Just open the HTML, You can control your air conditioner from everywhere in the world!

## Program
https://obniz.io/explore/30
นำแนะแอป “The History of Everything” ที่จะพาเราไปเรียนรู้ประวัติศาสตร์ของโลกใบนี้!
Tags: appreview
Published: 2019-02-06 12:24:06

---
title: นำแนะแอป “The History of Everything” ที่จะพาเราไปเรียนรู้ประวัติศาสตร์ของโลกใบนี้!
published: true
tags: app-review
canonical_url: 
---

สวัสดีครับบบ วันนี้จะพามาแนะนำให้รู้จักแอปสุดเทพในการเล่าเรื่องที่สุดจะสวยงามนะครับบ แอปนี้ชื่อว่า The History of Everything ครับ เป็นที่บอกประวัติในเรื่องต่าง ๆ ตั้งแต่จุดกำเนิดของจักรวาล ยันเรื่องราวในแต่ละยุค โดยมีการแบ่งตามปีอย่างชัดเจน ทำให้เราเห็นภาพ ไทม์ไลน์ที่ผ่านมาของโลกมากขึ้นครับ

![](https://cdn-images-1.medium.com/max/1024/1*EhLtx6Ef9rVBYkU6Cy1BYg.png)<figcaption>รูปที่ 1 หน้าแรกของแอป</figcaption>

จากรูปที่ 1 นะครับคือหน้าแรกของแอป รูปลักษณ์สวยงาม และแบ่งหัวข้อไว้อย่างชัดเจนทำให้หาเรื่องที่ต้องการได้ง่าย หรือจะเลื่อนตามไทม์ไลน์ไปเลยก็ได้ครับ

![](https://cdn-images-1.medium.com/max/1024/1*PLFTPxqUioMNIhAteZ3COw.png)<figcaption>รูปที่ 2 หน้าไทม์เลยของแอป</figcaption>

เมื่อเข้ามาก็จะเป็นแบบนี้ครับ มีไทม์ไลน์ทางด้านซ้ายชัดเจน มีหัวเรื่องแปะตรงที่เกิด บวกกับที่เทพมาก ๆ คือ แอนิเมชันที่เขาทำนี่ ลื่นไหล สวยงาม มาก ๆ ครับ

![](https://cdn-images-1.medium.com/max/1024/1*_j0lHQaDmQZJmkJoisBe6A.png)<figcaption>รูปที่ 3 หน้าอ่านประวัติศาสตร์ในแต่ละเรื่อง</figcaption>

พอเราเลือกหัวข้อเข้ามา เราก็จะเจอหน้าเล่าเรื่องประวัติศาสตร์นะครับ อ่านง่าย แต่ผมคิดว่าอย่างน้อย ๆ น่าจะมี Dark Mode มาให้หน่อย มันช่างแสบตาเหลือเกิน 555

ถ้าใครสนใจสามารถไปดาวน์โหลดได้ทั้ง Android และ iOS เลยนะครับ

**Android**  — [https://play.google.com/store/apps/details?id=com.twodimensions.timeline](https://play.google.com/store/apps/details?id=com.twodimensions.timeline)

iOS — [https://itunes.apple.com/us/app/the-history-of-everything/id1441257460?mt=8](https://itunes.apple.com/us/app/the-history-of-everything/id1441257460?mt=8)
How do you use Night Mode?
Tags: ux, discuss
Published: 2019-01-09 05:00:21

---
title: How do you use Night Mode?
published: true
description: 
tags: ux, discuss
cover_image: https://images.unsplash.com/photo-1544963217-71980dd8f50d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80
---

_Cover: [Patrick Brinksma](https://unsplash.com/photos/kjEev5pYu5E) on Unsplash_

I notice that some sites and apps have night mode as an immediately accessible toggle, some have it on the first level of a popout menu, and others still have it buried a few menus deep in the settings.

Do you find yourself often switching to and from night mode? Do you set it once and use it all the time, day and night? Or do you ignore it?

Personally, I tend to prefer the darker scheme so if there's a night mode I'll leave it on all the time.
ML classification on short strings in Ruby using Smalltext
Tags: ruby
Published: 2019-01-09 04:49:21

---
title: ML classification on short strings in Ruby using Smalltext
published: true
description: Using the Smalltext gem in ruby to classify and categorise short strings
tags: ruby
---

I have a ruby application that pulls in various blog and forum posts from the internet (like a [game dev tracker](https://devtrackers.gg)) and needed a way to classify them. Some simple rules got me 75% of the way there - does it include the word "patch" or "patch notes"? then it's likely a patch notes or announcement post - but that wasn't completely reliable. For example, a post reporting a bug on a patch might be worded as "Empty inventory because of Patch 9.0.0.2076", or a post might be announcing a patch deployment but not include any notes.

Recently I found the gem [smalltext](https://github.com/arjunmenon/smalltext) which has solved most of my problems. It classifies quickly and is pretty simple to train.

I built a training script that hardcodes training data into categories, then trains and saves a model.

#### lib/train_classifier.rb
```ruby
require 'smalltext'

data = {
  patch_notes: [
    "PC Client Update - 12/7/2018",
    "v6.31 Patch Notes",
  ],

  news: [
    "$1,000,000 Winter Royale + Tournament Updates",
    "Pop-Up Cups Update 12/5/2018",
  ],
}


s = Smalltext::Classifier.new
data.each do |classification, titles|
  titles.each do |title|
    s.add_item(classification.to_s, title)
  end
end

s.train
s.save_model("classifications.model")
```

I update this training script with definite examples and incorrectly classified posts as time goes on to improve the model. 

#### app/services/classifier.rb
```ruby
class Classifier
  def self.classify(text, threshold = 0.99)
    
    # Load the classifier and the trained model
    @classifier ||
      ((@classifier = Smalltext::Classifier.new) && @classifier.load_model('classifications.model'))

    classified = @classifier.classify(text).to_h
    # { "patch_notes" => 0.9998900049414214 }

    # Return the first category that meets the threshold
    result = classified.detect {|k,v| v >= threshold }
    result.present? ? result.first : nil
  end
end
```

This class gives my application an entry point to the classifier. I only care about reasonably certain classifications so I built this to only output a classification if the result is above a certain threshold. In my application, I either get a category or nil, which makes it easier for me to handle.

```
> Classifier.classify("V7.00 PATCH NOTES")

sentence: V7.00 PATCH NOTES
classification: [["patch_notes", 0.9998900049414214]]

=> "patch_notes"
```
My Firefox Add-ons in 2019
Tags: firefoxaddons
Published: 2019-01-09 04:40:27

---
title: My Firefox Add-ons in 2019
published: true
description: My list of Firefox Add-ons in 2019
tags: firefox addons
---
This is the current list of Firefox Add-ons that I am using at work. Sharing here out of (possible?) interest (and so I can have a backup). They are all available via <https://addons.mozilla.org/en-US/firefox/>.

- [Auto Tab Discard](https://addons.mozilla.org/en-US/firefox/addon/auto-tab-discard/) - Automatically discard inactive tabs to free up resources

- [Gesturefy](https://addons.mozilla.org/en-US/firefox/addon/gesturefy/) - Mouse gesture addon, which supports over 60 different commands and additional features like rocker and wheel gestures.

- [HTTPS Everywhere](https://addons.mozilla.org/en-US/firefox/addon/https-everywhere/) - encrypts your communications with many major websites, making your browsing more secure.

- [Privacy Badger](https://addons.mozilla.org/en-US/firefox/addon/privacy-badger17/) - automatically learns to block invisible trackers. **Be warned - it's good at breaking sites!**

- [Shorten me - URL Shortener](https://addons.mozilla.org/en-US/firefox/addon/shorten_me/) - shortens links and current tab's url using goo.gl service.

- [Tree Style Tab](https://addons.mozilla.org/en-US/firefox/addon/tree-style-tab/) - provides tree-style tab bar, like a folder tree of Windows Explorer. New tabs opened from links (or etc.) are automatically attached to the parent tab. If you often use many many tabs, it will help your web browsing because you can understand relations of tabs.

- [uBlock Origin](https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/) - an efficient blocker. Easy on CPU and memory.

- [YouTube High Definition](https://addons.mozilla.org/en-US/firefox/addon/youtube-high-definition/) - let's you play all YouTube videos in HD and change video player size automatically.
Git and Other Communication Tools
Tags: git
Published: 2019-01-09 04:22:58

---
title: Git and Other Communication Tools
published: true
description: 
tags: git
canonical_url: https://he-the-great.livejournal.com/60925.html
series: Git Communication
---

My last post on Git tried to focus on an end goal for your history. But I can already hear the nagging reply's "We have other tools which we use to communicate these things."

Most likely you're utilizing some form of bug tracking system, these systems help you to organize what is changing and communicate back what has been completed. These tools are very important as they provide external input, records of future work needed, and facilitate planning efforts. They can also facilitate pretty graphs and development cycles.

In my view, these tools make the reality of clearly communicating changes in your commit history even more important. In all likelihood your git commits can be integrated with your bug tracking system, not only to leave comments on the issue/bug but to cause resolution/closure of them.

If your read my last post, I referenced that during work on one feature some additional bug may be identified and fixed. When you break this fix out into its own commit, you'll start to wonder, "What issue number do I reference in this commit?" The answer to this question will likely result in, "I need a new issue number to assign this commit to." Otherwise if you're doing code reviews, the reviewer will look at your commits and ask, "Where is the record this work was done, I don't see an issue number assigned?"

By communicating we have better checks and balances and expectations on what and where we communicate.
Tweak vs Revamp
Tags: discuss, leadership
Published: 2019-01-09 03:46:44

---
title: Tweak vs Revamp
published: true
description: Taking development practices to the 23rd century. 
tags: discussion, leadership 
---

Here is a hard one, with established software solutions and release processes, how do you fit in a Revamp? 

Docker is taking front stage and with it management software is coming in to complete for mindshare. Developers build many products to help solve a development problem (dev.to advertises some).

Many of these solve real problems and could be beneficial to place into existing and future development but it could be a large undertaking. For my personal projects I likely would avoid buying anything, but if I'm making recommendations to the organization it is important to consider all appropriate options. 

Since I don't reach for these in personal projects, I don't want to waste a trial period on solving a problem and not have approval then loose the solution because I'm not planning my needs far enough ahead of time for finance.

I'm making good choices, but sometimes I wonder if there is an evaluation which should be done, which I don't have time for, at least not yet.
I like to hit vulcanized rubber disks with a stick.
Tags: discuss, hobbies, fun, dev
Published: 2019-01-09 03:17:43

---
title: I like to hit vulcanized rubber disks with a stick.
published: true
description: What do you like to do?
tags: discuss, hobbies, fun, !dev
---

When I'm not sitting in front of the computer I like to play Ice Hockey (still new to it so super bad but its super fun), Workout and/or Ruck, play board games, or shoot.  

When you're not Dev'ing what do you like to do?
Why ReactJS is a Framework, not a Library
Tags: react, coding, programming, webdev
Published: 2019-01-09 02:29:33

---
title: Why ReactJS is a Framework, not a Library
published: true
description: If ReactJS lets you program declaratively, it *must* be a framework
tags: react, coding, programming, webdev
---

####If ReactJS lets you program declaratively, it *must* be a framework

I have read one too many times that React "is a library", presumably by those who have an agenda to make it sound simpler than alternatives, or those who are merely parroting.  But we also always read that React lets you create web UI's "declaratively".  As we will see, these two statements are at odds with one another.

In my immediately previous post, ["Accidentally Declarative"](https://dev.to/dexygen/accidentally-declarative-g37) (which, I'm honored to say, made it "above the fold" as [a most popular dev.to post last week](https://i.imgur.com/Y7kgrH8.png)), I noted that on Wikipedia it is posited that in declarative programming: "the programmer merely declares properties of the desired result, but not how to compute it".  And I argued that implicit in this is the notion that another system *must* do the computation.

As to the difference between a library and a framework, I think this is very well stated in a couple of answers to a particular Stackoverflow question.  The [first of these answers](https://stackoverflow.com/a/148789/34806) states that "A library is a module that you call from your code, and a framework is a module which calls your code.".

The [second answer I like](https://stackoverflow.com/a/233765/34806) is even more succinct, but I like one of the comments in particular: "In Soviet Russia, framework calls you" :)  The logical conclusion then is, that if when you write declarative code another system/framework calls your code, and if React lets you create UI's declaratively, then React is a framework, not a library -- no matter what anybody would have you think, or repeats without themselves thinking.
Setup Custom Domain for S3 Static Website with Cloudflare CDN
Tags: s3, staticwebsite, cloudflare, customdomain
Published: 2019-01-09 02:24:04

---
title: Setup Custom Domain for S3 Static Website with Cloudflare CDN
published: true
description: 
tags: s3, static website, cloudflare, custom domain
---

#Overview
This post briefly describes a little bit of what I learned when looking to setup a custom domain and CDN for a static website hosted on S3.

#TLDR
Bucket name needs to match custom domain. E.g. to setup a custom domain of `wilsonmccoubrey.com`, bucket name must be `wilsonmccoubrey.com`

#Assumptions
This quick guide assumes you have:
- A static website running successfully inside a bucket in S3, accessible via the bucket url e.g. `http://<bucket name>.s3-website-<region>1.amazonaws.com/`
- A domain setup in cloudflare and nameservers setup

#Steps
## Set bucket name correctly
When setting up your bucket, your *bucket name must match the custom domain* which you want to serve the site from. For example, to setup a custom domain of `wilsonmccoubrey.com`, bucket name must be `wilsonmccoubrey.com`. I originally made this mistake and received 'NoSuchBucketException' in the browser after setting up my domain.

## Add CNAME Record to Cloudflare
![](https://thepracticaldev.s3.amazonaws.com/i/8djvu2p5o4kb0unlm7f2.png)

## Enable SSL (Optional, but recommended)
![](https://thepracticaldev.s3.amazonaws.com/i/d7h7q06oaei28mh60vtw.png)
![](https://thepracticaldev.s3.amazonaws.com/i/ugce9rht5vrxx0roab92.png)
Deploy Python-based Azure Functions using Azure DevOps
Tags: azure, devops, serverless, python
Published: 2019-10-23 09:47:53

---
title: Deploy Python-based Azure Functions using Azure DevOps
published: true
tags: Azure, DevOps, Serverless, Python
canonical_url: https://blog.siliconvalve.com/2019/01/09/deploy-python-based-azure-functions-using-azure-devops/
---

In August Microsoft announced that Python support in Azure Functions was Generally Available (GA), meaning it was ready for use for production scenarios.

In this post I'll take a quick look at how you can quickly deploy Python Functions using [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) which is a part of Azure DevOps.

<h4>Build and package</h4>

You now have the choice to package Python Azure Functions using a pre-built template in Azure Pipelines.

<img src="https://siliconvalve.files.wordpress.com/2019/01/2019-10-23_18-48-10.png" alt="Python Functions Build Template" title="Python Functions Build Template" width="831" height="434" />

Once you select this you will have all you need to restore any Python modules you have in your requirements.txt file and ensure any Azure Function Extensions are also installed. The resulting footprint is then zipped for use in a release.

If, like me, you put multiple independent Azure Functions into a single Azure Git Repo then you will need to modify three of the build Tasks to ensure you have the sub-folder selected when running commands.

First we need to ensure we restore the Azure Functions Extensions so we'll add a 'cd' command in and switch into the right folder.

<img src="https://siliconvalve.files.wordpress.com/2019/01/2019-10-23_20-08-09.png?w=1024" alt="Extensions subfolder" title="Extensions subfolder" width="1024" height="545" />

Then we have make sure we restore Python modules based on the `requirements.txt` in the subfolder.

<img src="https://siliconvalve.files.wordpress.com/2019/01/2019-10-23_20-14-25.png?w=1024" alt="Subfolder for requirements.txt" title="Subfolder for requirements.txt" width="1024" height="590" />

Finally we need to edit the Archive Files Task ensure you select the same sub-folder as the previous step.

<img src="https://siliconvalve.files.wordpress.com/2019/01/2019-10-23_19-12-01.png?w=1024" alt="" width="1024" height="553" />

Right, if you run this build you'll end up with a zip file ready to deploy.

<h4>Releasing into Azure</h4>

We can now create an Azure Pipelines Release that uses the standard Azure Function template (shown below). There are no special steps to use as you are deploying into a host environment already setup for Python Functions.

<img src="https://siliconvalve.files.wordpress.com/2019/01/2019-10-23_20-17-31.png" alt="Release Template" width="782" height="411" />

Once you run the Release your Function is deployed! If you need to deploy App Settings at the same time you can use the 'Application and Configuration Settings' section of the 'Deploy Azure Function App' Task to specify the settings to deploy.

That's it - so much easier than when this capability was all in preview!
Visualizing Stocks
Tags: python, datascience
Published: 2019-01-09 00:30:43

---
title: Visualizing Stocks
published: true
description: Visualizing data using `Plotly`
tags: python,data-science
---
Understanding stocks can be hard but In this post, we will be visualizing stocks with the help of `Plotly`(a visualization Library). As we all know Python is really powerful when it comes to handling data. Therefore we will be using modules such as `Pandas` to handle our CSV files and `Plotly` to visualize our data.

#### In order to begin we need to install a few libraries
- Install `Anaconda` Distribution. (This contains all data science related packages/modules) [Installion Link](https://www.anaconda.com/download/#linux).
- Install `Plotly` (This is not included in Anaconda) `pip install plotly`.

If you don't want to install `Anaconda`. You can install the packages you need by following these instructions.

- Install Pandas `pip install pandas`.
- Install Jupyter Notebook `python3 -m pip install jupyter`.
- Install `Plotly` `pip install plotly`.

## Lets Begin
- First, let start jupyter notebook by running the following command 
`jupyter-notebook`.
- Now we have the `jupyter-notebook` running. We will be importing libraries.

```python
import pandas as pd 
# importing Plotly
import plotly.plotly
import plotly.graph_objs as go
```

- Turning on offline mode for `Plotly`

```python
plotly.offline.init_notebook_mode(connected=True)
```


- Lets download stocks data (It can be found on [Yahoo Finance](https://finance.yahoo.com/) Search for your favourite stock). I will be using 
AAPL.

![image](http://i65.tinypic.com/2ps27md.png)

- Now we will be reading stocks csv using pandas.

```python
# read_csv allows us to read csv files
data = pd.read_csv('AAPL.csv')
# few pandas operations.

#This will display first few cells of the CSV files we can always specify how many cells we need by passing a number within those parenthesis data.head(10)
data.head()

# This will tell how many rows and columns are there in our CSV file.
data.shape

# This will describe our data by giving us information like mean, max, min, std and etc
data.describe()
```

- Selecting specific columns using `pandas` to plot them 

```python
# Selecting a specific column from csv file. Note brackets should contain exact name from the csv file.
dates = data['Date']
high = data['High']
```

- Plotting the data using `Plotly`

```python
plotly.offline.iplot({
    "data": [go.Scatter(x=dates ,y=high)],
    "layout": go.Layout(title="AAPL Stocks")
})
```


##### Output
![Image](http://i63.tinypic.com/2nl7jty.png)

And now you have the stocks data represented using Line Graph.



I hope you enjoyed this post if you think I missed anything feel free to comment below.

Feel to share it among your friends and colleagues.

## Note 
This article was posted on [MyBlog](http://muhammadraza.me/2019/Visualizing-Stocks/)



##### Important Links 

- [Pandas CheatSheet](https://s3.amazonaws.com/assets.datacamp.com/blog_assets/PandasPythonForDataScience.pdf)
- [Plotly Docs](https://plot.ly/python/getting-started/#jupyter-setup)
- [Code](https://github.com/mraza007/stocks)
Tea Break Challenge, Day #8
Tags: career, softskills
Published: 2019-01-09 00:07:44

---
title: Tea Break Challenge, Day #8
published: true
description: Finding your own preferences
tags: career, softskills
---

Today, make it a point to notice things that make you feel happy, satisfied, or otherwise positive emotions. Write them down, and put stars next to the things that really stand out to you. Adopting this habit can help you learn about your own preferences and values in an observatory way.