teleren/devto huggingface dataset:
Setting up your Mac for Machine Learning
Tags: python, productivity, tutorial, machinelearning
Published: 2019-06-17 03:58:37

From zero to running the first Machine Learning and Deep Learning projects within hours using scikit-learn, Keras, and TensorFlow

I bought a new Mac. I need to install everything necessary to build the Machine Learning project on my local machine. I could have copied everything from my old Mac using Time Machine. However, I wanted to start from the scratch so that I can document the steps and I can share with all of those who daily job is not coding but who wants to get hands dirty now and then.

I am not a developer. I am a Product Manager. I don’t code daily, but it’s fun to write some code when necessary. At least, I can clone a project locally in my machine.

1. **Install Python**
Check whether there is Python installed by default. Mac comes with default Python version 2.7.0. I will use Anaconda for Python and different packages for Data Science and Machine Learning.

2. **Install Miniconda**
    I chose Miniconda because I don’t need all the packages right away. I can install those packages in the virtual environments I create on the need basis. I like to isolate dependent packages for different types.
      - [Anaconda vs Miniconda vs Virtual env](http://deeplearning.lipingyang.org/2018/12/23/anaconda-vs-miniconda-vs-virtualenv/)
      - [How to install Miniconda](http://deeplearning.lipingyang.org/2018/12/24/install-miniconda-on-mac/)

3. **Managing environments**
     - [Why you need environments]([https://www.freecodecamp.org/news/why-you-need-python-environments-and-how-to-manage-them-with-conda-85f155f4353c/)
     - [Conda documentation]([https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#removing-an-environment)

4. **Install Jupyter Notebook**
    [Install Jupyter Notebook](https://anaconda.org/anaconda/jupyter)
    How do you install packages in Jupyter notebook? There are complexities we need to be careful. If you are interested, then here is a [good article](https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/).

5. **After you install Jupyter Notebook, you can follow [this notebook](https://github.com/bimalmaharjan/settingupmacforml/blob/master/Helloml.ipynb) to install and check all those packages.**

Hope you find this curation useful!

---

#### Now that your Macbook is ready, want to take the next leap and learn more about integrating AI in your product?

#### [![Lean AI Playbook](https://thepracticaldev.s3.amazonaws.com/i/0n8u8e15v9ephzv6h2eg.jpg)](https://landing.lftechnology.com/ai/?utm_source=devto&utm_medium=blog&utm_campaign=initial_distribution)


This article was first published on [lftechnology blog](https://www.lftechnology.com/blog/setting-mac-machine-learning/)
React: useCallback hooks simple explanation
Tags: react, hooks, javascript
Published: 2019-06-17 03:26:26

```javascript
useCallback(function, [dependecies])
```

useCallback is one of the new features introduced in the react hooks API. Personally the name is quite confusing because callback is usually referred to asynchronous functions, the function that we invoke whenever a certain operation has finished. useCallback however is used for a different purpose.

<br>

So what does it do? According to React official docs, it Returns a memoized callback. In simpler words, it returns a cached version of a function. Basically this hook is mainly use for performance reason (memory-wise).
How does it do that? lets see an example:
<br>

```javascript
const [height, setHeight] = useState(100)
const [age, setAge] = useState(3)

const handleSetHeight = () => setHeight(height + 10)
const handleSetAge = () => setAge(age + 1)
```
We setup two useState hooks & declare two functions to handle state changes. This seems normal. The issue here is that everytime we invoke a function and re-render happens, a new instance of both of these functions will be created. Even if we invoke only one function, the instance of the other function will also be created. Imagine if there are more functions, how many instance have to be created during each re-render. Its redundant & causes performance issues.

<br>

useCallback helps in solving this issue. It will cache/memoized function that we pass to it. For example, lets rewrite both function above like this:

```javascript
const handleSetHeight = useCallback(() => setHeight(height + 10), [height])
const handleSetAge = useCallback(() => setAge(age + 1), [age])
```

By doing this, whenever we invoke a function and re-render happens, a new function instance will only be created for that particular function that is being invoked. No new instance is created for the other function. The second argument passed to useCallback, __the dependecies array plays a major part__. A new function instance will only be generated if any value of the variable inside that array changes between re-rendering. If nothing changes, useCallback will just return the cached version of the function instance. 

<br>

Basically this is what useCallback hook is used for. To prevent unnecessary operation and improve performance.
Rust's `slice::windows` is really cool
Tags: rust, javascript, webdev, productivity
Published: 2019-06-17 02:58:02

_Cover photo by Gordon Williams on Unsplash_

> This post is one of several that outline my perspective on learning Rust as someone who primarily uses JavaScript. You can find the rest [here](https://medium.com/@tindleaj).

Rust has a lot of powerful features associated with its primitives and standard library. A cool one I just came across is the method [`slice::windows`](https://doc.rust-lang.org/std/primitive.slice.html#method.windows). This method returns an iterator over a `slice`. The iterator length can be specified. It lets you iterate over a slice and have a _window_ of a specific size on each pass. For example:

```
// windows.rs

let slice = ['w', 'i', 'n', 'd', 'o', 'w', 's'];

for window in slice.windows(2) {
  &println!{"[{}, {}]", window[0], window[1]};
}

// prints: [w, i] -> [i, n] -> [n, d] -> [d, o] -> [o, w] -> [w, s]
```

This is pretty cool, and doesn't really have a parallel in JavaScript. The closest that I can come up with to achieve the same is this:

```
// windows.js

let slice = ["w", "i", "n", "d", "o", "w", "s"];

slice.forEach((char, index) => {
  if (index === slice.length - 1) return;

  console.log(`[${slice[index]}, ${slice[index + 1]}]`);
});

```

The JavaScript approach is definitely less ergonomic, and I really like the concept of windows as an abstraction for use with iterators. 

Thanks for reading.
Should a button communicate the current state, the intended behavior, or both?
Tags: webdev, ux, css, discuss
Published: 2019-06-17 01:42:39

When I magnify a window in Chrome, I see an icon like this:

![magnify](https://cl.ly/bbba80903198/Image%202019-06-16%20at%209.27.59%20PM.png)

When I reduce the size of a window below it's normal 100% I get this:

![de-magnify](https://cl.ly/db245bd6525e/Image%202019-06-16%20at%209.29.02%20PM.png)

Clicking either of those icons gives me options for modifying the magnification level.

On DEV when I am following someone I see this button. Clicking it makes me "unfollow" them.

![following](https://cl.ly/61b539840d5d/Image%2525202019-06-16%252520at%2525209.30.17%252520PM.png)

We're inconsistent in our UI in that we treat the home page "save" button differently by offering a hover state which indicates the intended action.

![unsave gif](https://im4.ezgif.com/tmp/ezgif-4-b7df09d2da74.gif)

As we seek to make this behavior consistent, I'm curious what you consider to be fundamentally correct behavior. This situation is handled differently across the web but I'm curious if anyone feels like there is a true best practice.

All comments on the subject are super appreciated!
How to use TSDX
Tags: tsdx, react, typescript
Published: 2019-06-17 01:44:38

---
title: How to use TSDX
published: true
tags: tsdx,React,TypeScript
cover_image: https://thepracticaldev.s3.amazonaws.com/i/qljz0a5o2tkwt7cal6bh.jpg
canonical_url: https://www.slightedgecoder.com/2019/06/16/how-to-use-tsdx/
---

## A Zero-configuration CLI (command line interface) for creating a TypeScript library

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_Photo by [solmaz hatamian](https://unsplash.com/@solmaz67?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/search/photos/typescript?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)_

After migrating [react-use-localstorage](https://www.npmjs.com/package/react-use-localstorage) to [TSDX](https://www.npmjs.com/package/tsdx), I wanted to share what TSDX is and how to use it.

It’s pretty cool as it simplified the workflow & scripts within package.json.

Instead of writing a long-@$$ post, I decided to create a video instead.

I’d recommend to watch it at 1.0x+ speed as I was talking very slowly (making funny faces along the way 😨).

{% youtube YfF39o7MR7A %}

You can find the MindMap used to show the steps here – [https://mm.tt/1283868109?t=FOjysY56kp](https://www.youtube.com/redirect?q=https%3A%2F%2Fmm.tt%2F1283868109%3Ft%3DFOjysY56kp&redir_token=8sngKKDyoQyb9khEhfB7Poq8HKR8MTU2MDgyMDU0OUAxNTYwNzM0MTQ5&v=YfF39o7MR7A&event=video_description)

I’d appreciate any feedbacks how I can improve the video recording as I haven’t recorded any videos for years 😉

The post [How to use TSDX](https://www.slightedgecoder.com/2019/06/16/how-to-use-tsdx/) appeared first on [Sung's Technical Blog](https://www.slightedgecoder.com).
New computer
Tags: devops, unity3d, coding, discuss
Published: 2019-06-17 01:24:02

Just dropped a good chunk of change on a new PC. Just wondering what do you use to dev on? I'll soon be running a ryzen 7 2700x with 64gb of ram on a ASUS ROG Strix X470-F with dual ASUS VS248H-P 24" Full HD 1920x1080 2ms HDMI DVI VGA Back-lit LED Monitor
Still a begginer in Javascript 
Tags: javascript, html, css, webdev
Published: 2019-06-17 00:52:27

Hello, first let me say thanks for having me here. I graduated from a bootcsmp last June. Here it is a year later and I'm still a begginer. Coding in gaps hasn't helped at all. Between, being a family man, working a job with OT here and there. Those things have gotten in way of my daily grind. Starting over how many times trying to get the fundamentals of JS down, I've lost count. Like today I planned on coding after getting off work. I get home and
 the realize I need to make a grocery run so I don't spend money at work this week. It seems there's always something. How do I get over these obstacles and code daily without feeling like I'm shaking my wife and son and the world 🌍
Why ZeroMQ
Tags: networking
Published: 2023-01-06 02:01:12

---
title: Why ZeroMQ
published: true
date: 2019-06-16 23:26:50 UTC
tags: Networking
canonical_url: https://brandonrozek.com/blog/whyzeromq/
---

I’ve been playing around with ZeroMQ recently and it’s been really exciting. This blog post is going to outline why I think you should be using ZeroMQ today.

First of all, before you compare this to other products like RabbitMQ, DDS, etc. Realize that this is a static library that you link to in your application as opposed to a broker you run. This means that you can get the benefits with this library for very little overhead.

## Easier Sockets

Instead of talking about how easy ZeroMQ is to use, I’m going to just show you the code to implement a server-client relationship in Python.

**Server.py**

```
import zmq
import time

port = "5556"
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:%s" % port)

while True:
    msg = socket.recv()
    print(msg)
    time.sleep(1)
    socket.send_string("Server Message To Client")

```

**Client.py**

```
import zmq
import time

port = "5556"
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:%s" % port)

while True:
    socket.send_string("client message to server")
    time.sleep(1)
    msg = socket.recv()
    print(msg)

```

And just like that we have a way to transport messages back and forth. No need to make a special header before each message to know the appropriate size of the packets. ZeroMQ abstracts those details from you.

## Different Transports Available

You’re not limited to only `TCP`. You can use `inproc` for thread-to-thread messaging, `ipc` for inter-process communication, and `epgm` or `pgm` for multicast messaging. Most of the time, just changing the connection string in `socket.connect` just works!

## Common Networking Patterns Built In

Sometimes we just want a dumb pipe between two ends (`pipe`) but most of the times we’re writing applications that follow the `server-client` or `publisher-subscriber` architecture. That gets defined in `context.socket`.

Ex: `context.socket(zmq.PAIR)`
Thank Your Favorite Projects
Tags: discuss, opensource
Published: 2019-06-16 22:48:52

Over the years, I have used probably 100's of different open source projects throughout my codebases.  Many of these do not get the thanks the deserve so here is a small shout out to Spatie(https://twitter.com/spatie_be), the provider of my most used open source projects!  Thank you!

Who do you owe a thanks to?
Django user auth
Tags: django, python, webdev
Published: 2019-06-16 22:43:37

Today I've been learning about user authentication with Django. There is quite a bit to it so I figured I'd lay out the code to share.
![](https://thepracticaldev.s3.amazonaws.com/i/08l25ddyhaxmnhmrpsew.png)

Also, here is the form that is used to POST the data as GET is unsafe. A person could just make a username with no constraints and bypass all security. Thank's to Kyle Agronick, he made me aware that it is necessary to show the front end for clarity in the logic. Here is where the user puts in an username and password :
![](https://thepracticaldev.s3.amazonaws.com/i/puvtue1uhcyqh07utts8.png)

As you can see I have gone through and notated almost everything. It is very easy to follow. If you are interested in seeing this code and understanding the steps I went through go check out the repo: https://github.com/wesley-ruede/product-hunt

In the settings you will find the process I have gone through to develop the user authentication. Happy coding everyone and have a good day!
A Long, Strange Trip
Published: 2019-06-16 20:17:13

In 2005, I left my role as a writer and photo editor at IMDb to start my own little web incubator, teaching myself PHP, MySQL, and JavaScript along the way.

In 2007, the incubator not providing enough income, I started contracting. My first contract as a developer was at Microsoft, 12 years ago this month, building this intranet site.

![](https://thepracticaldev.s3.amazonaws.com/i/udr0j908afjrp5a1e7kt.jpg)

I learned C# and ASP.net on the fly to complete it.

Found this image while cleaning up some old files. Back when Vista and IE7 ruled the roost, Firefox had been disruptive but still only had 17ish percent of the market, and Chrome was still a year from being released. Ahh, the memories.
Parents in tech, how do you balance your time between coding and playing with your kids?
Tags: discuss
Published: 2019-06-16 19:32:15

---
title: Parents in tech, how do you balance your time between coding and playing with your kids?
published: true
tags: discuss
---

First off happy Father's Day to all the dad's out there in tech! As far as I am concerned, parenting is the hardest job on the face of the planet. As well as the most rewarding!

I am highly passionate about coding and I have a side project in the works outside of my normal job. I try to spend as much time on it as my family deems fair.

If you are anything like me, how do you balance your time between coding and your family? Do you pull late nights or super early mornings? Do you ever feel guilty about coding when your kids are around? Or do you just code at work and call it a day?
How do you name your tests?
Tags: discuss, testing, unittests
Published: 2019-06-16 19:25:51

---
title: How do you name your tests?
published: true
description: There are so many ways to name your unit tests. Which one do you use?
tags: discuss, testing, unittests 
---

As you might know, I'm a big fan of unit testing and TDD. But I often go back and forth on the naming of my unit tests. There are many popular naming schemes for unit tests. A few of them are:

## [MethodUnderTest]\_[TestedState]\_[ExpectedBehavior]

That's a classical naming scheme.

> `ReadFrom_FileDoesNotExist_ThrowsException`
 
## [MethodUnderTest]\_[ExpectedBehavior]\_[TestedState]

This is pretty similar to the first scheme. Personally, I like this one a little better than the first one. This one reads a little more naturally. For example:

> `ReadFromFile_ThrowsException_FileDoesNotExist`

It reads almost like "WriteToFile throws an exception if file does not exist".

## Should\_[ExpectedBehavior]\_When\_[TestedState]

> `Should_ThrowException_When_FileDoesNotExist`

This also reads almost like a "normal" sentence.

## When\_[TestedState]\_Expect\_[ExpectedBehavior]

> `When_FileDoesNotExist_Expect_WriteToFailToFail`


## Given\_[Preconditions]\_When\_[TestedState]\_Then\_[ExpectedBehavior]

> `Given_ReportIsWrittenToFile_When_FileDoesNotExist_Then_ExceptionIsThrown`

## JustDescribeWhatIsGoingOnAndWhatShouldHappen

This is something I fall back to from time to time. In these cases, my test read something like this:

> `OrderProcessorThrowsAnExceptionInCaseOfMissingCustomer`


These are just a few examples. Feel free to add some more naming schemes in the comments.

Whats your favorite naming scheme? Are there naming schemes you do not like?
Template for creating and developing ZeroNet sites
Tags: webdev, showdev, opensource, javascript
Published: 2019-06-16 18:36:56

[ZeroNet](https://zeronet.io/) is a decentralized web platform. It allows decentralized, open, free and uncensorable websites using [Bitcoin cryptography and BitTorrent network](https://docs.google.com/presentation/d/1_2qK1IuOKJ51pgBvllZ9Yu7Au2l551t3XBgyTSvilew/pub?start=false&loop=false&delayms=3000).

---

Developing of static and simple ZeroNet sites is easy. You just need to create `content.json` as described in ZeroNet documentation and then create and edit files.

But things can get complicated if the site becomes bigger. It can use NPM dependencies, SASS, TypeScript or other NPM tools. It is then hard to maintain all those things and develop the actual site at the same time.

---

Because of that, I created a template that simplifies a process of creating and developing ZeroNet sites. It supports NPM dependencies and it uses Gulp and Browserify for bundling scripts. It also supports SASS and automatic deployments with Travis CI.

It's available on [GitHub](https://github.com/filips123/ZeroTemplate) and [GitCenter](http://127.0.0.1:43110/1Aob9QXahTnn6iBriSSQ6qg8qXkHdkaX2x).
Post about it is also available on [Reddit](https://www.reddit.com/r/zeronet/comments/bcryvu/template_for_creating_and_developing_zeronet_sites/) and [ZeroTalk](http://127.0.0.1:43110/Talk.ZeroNetwork.bit/?Topic:1555000915_1LFu1BTScmY82HHtg3TY2jAuSrCYNsQWEY/Template+for+creating+and+developing+ZeroNet+sites).

{% github https://github.com/filips123/ZeroTemplate %}
It Is YOUR Story - Write The Next Chapter
Tags: nextchapter, college, selfstudy, learning
Published: 2019-06-16 18:04:19

---
title: It Is YOUR Story - Write The Next Chapter
published: True
description: Write your next chapter and tell your tale
tags: nextchapter, college, self-study, learning
---



Your story is one you can write the next chapter all the way to the end. Your story from the beginning to today may or not have been the one you wished. There may have been some twists and turns that were unexpected in terms of loss, unemployment, financial, relationships and overall stability but today is a new day.

A new day brings a new opportunity to write a few lines in your next chapter. Not impulsively, not recklessly but with a goal in mind. A goal to grow and enjoy the reading for the rest of the story that is all about You!

Take a step toward your next great chapter and write the ending you will love.

Read a book that inspires you
Take a class that teaches you
Meet people you can learn from
Find your spark and flame it

Since I'm talking about stories, I want to share a recent blog from Hocking College highlighting one of my students and her journey. Check out her story at https://blog.hocking.edu/stubbornness-persistence-take-student-from-farmer-to-computer-science-major 

As a little addendum to this story, I want to share that she still loves farming and if you have the pleasure of knowing her or follow her on social media you'll see she's still very much about nature, farming and growing her own food. She's writing her chapters after an injury that combines skills that she's learning and a personal passion of hers. She's found her spark. Organizations and companies like Farmers Business Network https://www.fbn.com/ are just one example of combining two worlds to write your story. 

Ask yourself this...What story do you want read on your life?
Bloggerfoo - a Jekyll (Ruby) based blogging theme for Developers
Tags: blogging, ruby, jekyll
Published: 2019-06-16 16:54:14

Hi Folks,

In the process of becoming a theme developer I have started with a developer focussed theme which is simple and mostly shows developer's work.

There are many such developer theme available but I found that the blog post is not as creative.

I really like the [Medium like Blog post](https://medium.com) where it has more creativity as well.

Would really like to get feedback on it so that I could improve it in better way.

Site - https://bloggerfoo.github.io
Source Code - https://github.com/bloggerfoo/bloggerfoo.github.io

*Note*
I have migrated my own personal website to it. Feel free to check this as well https://coolbrg.me

I will be constantly improving it as the time goes.
Its Sunday, are you coding?
Tags: discuss, webdev
Published: 2019-06-16 16:17:09

---
title: Its Sunday, are you coding?
published: true
description: 
tags: discuss, webdev
cover_image: https://thepracticaldev.s3.amazonaws.com/i/3rq2huzwp46gzerlsj4p.png
---

Its Sunday, I get a call. Timelines have changed, new demos are scheduled. Most people are mad when work calls them on the weekend. When I get the call, it feels like the bat signal and I jump into action. 

I code every single day. This works for me because I'm a workaholic. I would be unhappy, not coding.

My question to you, do you normally code on a Sunday?

### Vote and Discuss
I've created two comments which response the Yes and No vote.
React to cast your vote and leave a comment tell us more on why.

Yes https://dev.to/andrewbrown/comment/c160
No https://dev.to/andrewbrown/comment/c161