teleren/devto huggingface dataset:
A cautionary note about use of Javascript's Set and Map objects
Tags: javascript
Published: 2019-06-12 14:50:51

---
title: A cautionary note about use of Javascript's Set and Map objects
published: true
description: Be careful not to assume Set and Map act just like Array and Object.
tags: Javascript
---

A few weeks ago I was working on a really odd bug. An object was being assembled that contained some user data, and when we went to send that object up to the server as JSON, it was always incomplete -- it was missing data in one of the properties.

I tried all kinds of things to track down what was causing this: was an object merge acting unexpectedly? Was there an event somewhere that removed this data that I didn't know about?

It was actually much simpler than this. The problem, was `JSON.stringify()` and a `Set` contained within the object being stringified.

For an example, I'll create a user with some "lucky numbers", which I'm just making up as an example where the entries should be unique, so a `Set` would (in theory) be better than an `Array`.

```js
const userData = {
    name: 'Haleema Greer',
    id: 7252,
    luckyNumbers: new Set([55, 45, 62, 21])
};
```

Looks good enough. Now, let's convert to JSON so we can send this to a server.

```js
JSON.stringify(userData);

// > "{\"name\":\"Haleema Greer\",\"id\":7252,\"luckyNumbers\":{}}"
```

Wait, what just ate our `luckyNumbers`?

Apparently `Set` data just isn't in a format that can convert to JSON without some extra work.

One good solution is presented on [Stack Overflow](https://stackoverflow.com/a/46491780/325674).

```js
function Set_toJSON(key, value) {
  if (typeof value === 'object' && value instanceof Set) {
    return [...value];
  }
  return value;
}


JSON.stringify(userData, Set_toJSON);

// > "{\"name\":\"Haleema Greer\",\"id\":7252,\"luckyNumbers\":[55,45,62,21]}"
```

Much better!

Many guides will either state or imply `Set` can be used as a drop-in for `Array`, but they do not act the same and can have some unexpected consequences if you treat them the same. 

Be aware these two types are different, and what works for one, may not work for the other.

`Map` also shares this issue as well.

```js
const userDataMap = {
    name: 'Haleema Greer',
    id: 7252,
    luckyNumbers: new Map([
        [1, 55],
        [2, 45],
        [3, 62],
        [4, 21]
    ])
};

JSON.stringify(userDataMap);

// > "{\"name\":\"Haleema Greer\",\"id\":7252,\"luckyNumbers\":{}}"
```

Fixing this isn't as straight-forward, because `Map`'s structure doesn't directly translate to JSON. It will be a matter of how you prefer to solve the problem.

For various solutions to converting `Map` to JSON, see this [Stack Overflow discussion](https://stackoverflow.com/questions/29085197/how-do-you-json-stringify-an-es6-map).
Hoisting in JS: The Quick and Dirty
Tags: javascript, beginners, webdev
Published: 2019-06-12 14:32:26

---
title: Hoisting in JS: The Quick and Dirty
published: true
description: A super quick overview of what hoisting is.
tags: #javascript #beginners #webdev 
---

Before reading this, check out: [Var and Function Scope](https://dev.to/steelvoltage/var-and-function-scope-in-javascript-3k4p)

```javascript
console.log(hoistAndRun()) // returns 'also hoisted and can be ran'
console.log(hoistMe) // returns undefined

var hoistMe = 'hoisted, but undefined'

function hoistAndRun() {
  return 'also hoisted and can be ran'
}
```

The first thing to understand about hoisting is that it's a feature of Javascript. (I think some other languages have it too, like Python, but not all use it.) You'll see a lot of people explain it as variables (declared with `var`) and functions (using the `function` keyword) being "lifted" to the top of the code.

That's not accurate. Javascript doesn't do that, at least not physically. It's more of an analogy or conceptual way of thinking of it. Instead, Javascript creates space in memory for the variables and functions. Think of it as the programming equivalent of making a dinner reservation.

Hoisted `var` variables will return `undefined`. Because, you haven't assigned them a value (until you actually do with `=`). Functions can be ran immediately, because they are fully placed in memory before the code is ran.

Function expressions using `var` are *are* hoisted, but cannot be called right away.

```javascript
console.log(hoistAndRunAgain()) // TypeError: hoistAndRunAgain is not a function

var hoistAndRunAgain = function() {
  return 'hoisted, but undefined as well'
}
```

Variables and function expressions assigned with `const` and `let` are not hoisted, as they use block scope.

```javascript
console.log(hoistConstant) // ReferenceError: hoistContant is not defined
console.log(hoistLet) //ReferenceError: hoistLet is not defined

const hoistConstant = 'not hoisted'
let hoistLet = 'not hoisted'
```

That's the quick and dirty of hoisting as I understand it. There is probably more nuance and detail that could be provided about hoisting, but hopefully this is enough to get you started, or at least to jog your memory.
Pushing Left, Like a Boss — Part 5.4 — Session Management
Tags: programming, tutorial, beginners, security
Published: 2019-06-12 14:26:06

---
title: Pushing Left, Like a Boss — Part 5.4 — Session Management
published: true
description: The 5th section of this series details various examples of secure coding.
series: Pushing Left Like a Boss
tags: programming, tutorial, beginners, security
---

###[This series, and my blog, have moved!](https://wehackpurple.com/pushing-left-like-a-boss-part-5-4-session-management/)

It is my firm opinion that only the session management features in your framework should be used to manage identity or a user session. The HTTP 1.1 protocol was never designed to manage these concepts and thus there is no default way to do this built into it. When you choose a framework, such as [.Net](https://docs.microsoft.com/aspnet/core/?view=aspnetcore-2.2&WT.mc_id=devto-blog-tajanca), Ruby or Spring, they have built in features to handle this, and you should always use those features. Don’t be tempted to think you can do better on your own, let the experts handle this for you.

![As an ex-dev, I know the temptation to write your own. Trust me, don’t.](https://thepracticaldev.s3.amazonaws.com/i/11ucokpbxb4yifg4begh.jpeg "As an ex-dev, I know the temptation to write your own. Trust me, don’t.") As an ex-dev, *I know the temptation to write your own*. Trust me, don’t.

Much of the information in this section was learned from the [OWASP Cheat Sheet — Session Management](http://OWASP%20Cheat%20Sheet%0A-%0ASession%20Management), as written by Raul Siles. For a much more in-depth look on this topic, check it out.

Below is general guidance on session management. Again, always use the features in your framework and otherwise use the advice below...

###[Read the rest of this article on my NEW blog!](https://wehackpurple.com/pushing-left-like-a-boss-part-5-4-session-management/)
Structured Programming Paradigm
Tags: cs, mindmap
Published: 2019-06-12 15:52:49

---
title: Structured Programming Paradigm
published: true
tags: cs, mindmap
canonical_url: https://vorakl.com/articles/goto/
cover_image: https://vorakl.com/files/goto/goto.png
---

There was the time when computer programs were so much long and unstructured that some times just a few people managed to logically navigate source code in huge software projects. Having low-level programming languages, programmers used various equivalents of "goto statements" for conditional branching that often led to decreasing readability and difficulties in keeping a logical context, especially jumping too far to another subroutine.

A few things happened on the way to a solution that eventually appeared in the form of [Structured Programming Paradigm](https://en.wikipedia.org/wiki/Structured_programming). In 1966, _Corrado Böhm_ and _Guiseppe Jacopini_ proved a [theorem](https://en.wikipedia.org/wiki/Structured_program_theorem) that any computer program which might be represented as a flow diagram can be rewritten using only 3 control structures (sequence, selection, iteration).

In 1968, _Edsger W. Dijkstra_ published the influential article "[Go To Statement Considered Harmful](https://vorakl.com/files/goto/Dijkstra68.pdf)" where he pointed out that using too many **goto** statements has a negative effect on the readability and understanding of computer programs. Though, his intention was, unfortunately, misunderstood and misused by the almost complete abandoning of using "goto" in high-level programming languages, even at the cost of less readable and vague code.

As a result of working on the improvement of the ALGOL, _Niklaus Wirth_ designed a new imperative programming language, [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language)), which was released in 1970. It was widely used for teaching students the Structured Programming Design for a few decades since then.

![PNG](https://vorakl.com/files/goto/goto.png)

Other formats: [PDF](https://vorakl.com/files/goto/goto.pdf), [PNG](https://vorakl.com/files/goto/goto.png), [TXT](https://vorakl.com/files/goto/goto.txt)
Is Docker an overkill during development?
Tags: python, docker
Published: 2019-06-12 14:08:11

I am a newbie learning python. Earlier I used virtualenv and I screwed up managing it. Then I tried Docker and each project with its own seems fine, but my 16gb i5 X220's fan was not. Chrome, VS code & docker seems too much to handle for a laptop.

I think more power aka Xeon processor, will fix my issue(Newbie alert!). I have read about pros using VIM+ZSH+TMUX+SSH, I struggled to just figure my way out of Vim. I realized that I am taking on too much and vim+tmux seems an overkill for me. I am now focusing on python with vscode & bash. Now I read about vscode supporting SSH. So, I am starting reconsider the idea of a remote dev setup again.

I know a HP z400 that I can get for $100. So, I am considering the option. But then I read about the developement with Pipenv and heard of other options like pyenv & conda.

So, assuming that pipenv, pyenv & conda are far less resource intensive than docker. I am reconsidering the wisdom in using docker for development.
Test-Driven Meetings
Tags: organization, productivity, psychology
Published: 2019-06-12 13:54:18

---
title: Test-Driven Meetings
published: true
description: You're not alone in your frustration with meetings. But meetings don't have to drain your energy, time, and productivity!
tags: organization, productivity, psychology
---

Write a test, make it fail. Write the code to make it work. Refactor.

This "red-green" cycle is something most modern developers understand. Many of us have built our whole workflow with this concept in front and center.

We also identify with each other's pain when it comes to meetings.

_Why are we meeting again? Why does this meeting have to last 2 hours? Doesn't everyone already have this information? Wouldn't it be better if we would all just go back to our work? This isn't real work... it's just making us feel like we're working._

Some meetings feel more productive than others. Maybe you really enjoy daily standup meetings, but can hardly tolerate "town hall" meetings.

Wherever you are in your career, you can make meetings drastically more useful by applying the test-driven model of thinking to your meeting schedule.

Let's break it down!

## 1. Look at your calendar and identify all events that are meetings.

Not every event is a meeting. Make a calendar specific for your meeting events. If you have informal meetings, put them on the calendar too.

## 2. In the calendar event, write out the _expected output_ of the meeting.
Arguably, great functions always produce output. What will you take away from this meeting? Here are some types of output:

- Tasks - is your meeting intended to generate work to be completed?
- "Decision record" - wherever you keep documentation of your work in progress, the output of a meeting might be as simple as making a decision about something and documenting it.
- Notes - At the very least, your meeting should be able to output a simple summary about what was discussed.

## 3. In the calendar event, also write out the desired _side effects_ of the meeting.

While most of your meetings should produce functional output, you will also have meetings intended to produce side effects. Here's a list of side effects you may care about.

- Camaraderie - Does your team feel closer to each other after a meeting?
- Belonging / in-the-know - does your team feel like they are included on important information?
- Emotional support and expression - do your team members feel emotionally supported? Has everyone had a chance to express their opinions?

### Don't fly blindly into a meeting.

It's easy to ignore meeting prep as a practice. It's difficult to immediately see the value in _stopping_ the "important" work you are doing for something seemingly less important.

Make your meetings matter by creating these expectations, and testing against them. If a meeting is failing to produce expectations, do what a good developer does when tests fail: refactor the meeting!
what would you build if you won the lottery and never had to work again.
Tags: discuss
Published: 2019-06-12 13:38:38

---
title: what would you build if you won the lottery and never had to work again. 
published: true
description: if you were lucky enough to have all the money you ever needed, what would you spend your time building
tags: discuss
---

I’ve always dreamed of the day I was wealthy enough that I could just not have to work, other than on my own projects. 

Mine is two part. 

One, I would build tools for non-profit companies. Helping make people’s lives better. 

The other part of that, I would start my own company and go through all of my old ideas and make them live products. I have over a hundred ideas from all the years. I managed to get one live this last year [https://gidgitz.com](https://gidgitz.com) 

What would you do? Feel free to be as specific as you want. Even share your product you might be already working on and wish was your full time project.
What keeps you from trying out new tech?
Tags: discuss, technology, products
Published: 2019-06-12 13:13:38

As a developer my goal is to create software that people use, (specifially [Mint](https://www.mint-lang.com)) but as I see, it's really hard for people to take the leap and try something new.

For example, I started to learn Elm 4-5 times before I could actually took the time to understand it and make progress.
 
I'm curious, what is it that keeps you from trying out new libraries and technologies? and in the end what is the thing that makes you do it?
Weekly Picks #79 — Development Posts
Tags: typescript, angular, vscode, webdev
Published: 2019-06-14 07:41:11

---
title: Weekly Picks #79 — Development Posts
published: true
tags: typescript,angular,vscode,webdev
cover_image: https://cdn-images-1.medium.com/max/1024/1*GgRYanLCXd2y9l0Rcz30ZA.jpeg
canonical_url: https://medium.com/daily-now/weekly-picks-79-development-posts-8fc633c491c9
---

> A goal without a plan is just a wish

- [7 FrontEnd JavaScript Trends and Tools You Should Know for 2020](https://app.dailynow.co/r/ead59da9ff37a67d1edc903a448b0e26) by [Jonathan Saring](https://medium.com/u/c9a6ef212193)
- [Saving Data in JavaScript Without a Database](https://app.dailynow.co/r/75d39d4d365e28be8c038972a326c7de)
- [Top 5 skills to learn as a junior JavaScript developer](https://app.dailynow.co/r/4feb4fef2b08b7dec0ba9486477ffda0) by [Kevin Ball](https://medium.com/u/af637b4461bb)
- [60 Extensions to Supercharge Visual Studio Code](https://app.dailynow.co/r/5e3c2de1309ebf8d8d8108b1d0d87eb5) by [Brandon Burrus](https://medium.com/u/3146d6dce9f3)
- [Top Five YouTube Channels for Web Developers](https://app.dailynow.co/r/5db57529443b4eccbea4bb39388ac77c) by [CodeDraken](https://medium.com/u/79e2592263f8)
- [Best Web Development Practices You Need to Know in 2019](https://app.dailynow.co/r/2285f1aee95e39a5bdd101d9245b660f)
- [How to Design for the Web in 2019](https://app.dailynow.co/r/515959e8995ffc2e641f5aae6e29cfe2) by [Casper Beyer](https://medium.com/u/3ed1af08209)
- [10 easy ways for programmers to hate you](https://app.dailynow.co/r/9984e8fde80ec94d5baf46c836a63ff1) by [Michail Athanassiadis](https://medium.com/u/4f239d7d14ec)
- [I’m a Fan of TypeScript, but Please Be Careful!](https://app.dailynow.co/r/33a8c02bd83aa91cd2d6e166e806ba0c) by [Dor Moshe](https://medium.com/u/6107923b20dc)
- [Nebular 4 — UI kit & Design System for web with light/dark mode support](https://app.dailynow.co/r/c465b914622f768e06aa04e4136037d9)

* * *

[_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*7bwIhcH467BKX5Ni8XWpQg.jpeg)](https://www.dailynow.co/)
List of useful gems to build Ruby on Rails app
Tags: rails
Published: 2019-06-12 13:32:26

---
title: List of useful gems to build Ruby on Rails app
published: true
tags: Ruby on Rails, ruby on rails
canonical_url: https://kevinhq.com/list-of-useful-gems-to-build-ruby-on-rails-app/
cover_image: https://i2.wp.com/kevinhq.com/wp-content/uploads/2019/06/List-of-useful-gems-to-build-Ruby-on-Rails-app.png
---

List of useful gems to build Ruby on Rails app. This list may help you to start with a new Rails app. I used most

[Continue reading List of useful gems to build Ruby on Rails app](https://kevinhq.com/list-of-useful-gems-to-build-ruby-on-rails-app/)

The post [List of useful gems to build Ruby on Rails app](https://kevinhq.com/list-of-useful-gems-to-build-ruby-on-rails-app/) appeared first on [kevin's tech blog](https://kevinhq.com).
Java VS Go
Tags: discuss, go, java, spring
Published: 2019-06-12 12:43:51

---
title: Java VS Go
published: true
description: Java vs Go for big projects
tags: discuss, go, java, spring
---
![](https://thepracticaldev.s3.amazonaws.com/i/ttqkzbnztfcvcjl1343e.png)
At my current job we are going to make a big project that will have a lot of requests from all the country. We don't know if Go is better than Java with Spring for this case. Don't think about knowledge of programmers or experience with that techologies, just think on performance and development speed.
The "Boring Software" manifesto
Tags: webdev, discuss
Published: 2019-06-12 12:38:05

As software developers we are tired of the false claims made by evangelists of the latest and greatest technology. We will no longer confront them with their lack of understanding of computer science fundamentals, nor will we defend our lack of knowledge of their hyped and volatile technologies. The state of industry is forcing us to value:

   - Not only working software,
      - but also well-crafted software,
      - built exclusively with popular and proven tools.
   - Not only responding to change,
      - but also steadily adding value,
      - while reducing the dependencies and complexity.
   - Not only individuals and interactions,
      - but also a community of professionals,
      - that share best practices with verifiable claims.
   - Not only customer collaboration,
      - but also productive partnerships,
      - to reduce the scope of the software we build.

That is, in pursuit of "agility and craftsmanship" we have found "boring software" to be indispensable.

### Some examples

The things on the left that are well-understood and proven, while the things on the right are hyped and volatile.

   - 3-tier applications vs. micro services
   - relational database vs. NoSQL
   - page reloads vs. single page applications

There are many other examples, but this should get the idea across.

Happy coding!

### Links:

  - [Agile Manifesto](http://agilemanifesto.org/)
  - [Manifesto for Software Craftsmanship](http://manifesto.softwarecraftsmanship.org/)

NB: This post originally appeared on [TQdev.com](https://tqdev.com/2018-the-boring-software-manifesto) (my blog).
Can someone ELI5 the difference UI and UX
Tags: help
Published: 2019-06-12 12:35:46

---
title: Can someone ELI5 the difference UI and UX
published: true
tags: help
---
I thought I knew the difference between UI and UX. That is why I planned and started writing a blog about it. But then I started researching it, and I ended up confused.
For me, UI is the platform and UI designer is focused on it. UX, on the other hand, is about the user. And UX designer focuses on the user and his/her experience. 
But when I look up what a UX designer does it involves wireframing and prototyping, that doesn't add up to me. I believe UI designer should do that.
Am I missing something here? Can you guys help?
Writing a dev.to blog post with VSCode
Tags: vscode, writing, showdev, blogging
Published: 2019-06-12 12:33:29

Today, I present you [📝 New Blog Post](https://marketplace.visualstudio.com/items?itemName=timdeschryver.new-blog-post) a simple way to create and publish [dev.to](https://dev.to) blog posts from within Visual Studio Code.

## Installation

To install the or search for `📝 New Blog Post` in the extensions go to the marketplace https://marketplace.visualstudio.com/items?itemName=timdeschryver.new-blog-post.

## Writing a dev.to post

The default template of this extension is the `dev.to` template. To create create a new blog post, right click in the explorer or use the command palette and select `📝 New Blog Post`

![Gif on how to create a new blog post](https://raw.githubusercontent.com/timdeschryver/new-blog-post/master/other/new-blog-post.gif)

## Publishing to dev.to

In order to be able to publish your post to `dev.to`, you have to first create an API access token.
You can create one at [https://dev.to/settings/account](https://dev.to/settings/account). Once you have your token copy paste the token in your VSCode settings with the `post.publishToken` setting:

```json
{
  "post.publishToken": "jbVJ8mwfY2WrPUGfDWjx4xxB"
}
```

> To add this to your config, search via the command palette for settings

When you have added the token to your settings, go back to your post and you can use the `🚀 Publish to dev.to` command in the command palette.

![Image showing how to publish to dev.to](https://raw.githubusercontent.com/timdeschryver/new-blog-post/master/other/publish-dev-to.png)

## Why

I created this extension to get familiar with VSCode extensions.

Also, my workflow to write my blog posts is to:

- write them within VSCode
- publish them to GitHub
- there's a [now](https://zeit.co/now) trigger that automatically deploys a new version to [timdeschryver.dev](https://timdeschryver.dev)
- manually cross-post on dev.to

To make it a little bit easier to myself, I think this extension is a good addition to save a few minutes 🙂.

## More info

For more info and the source code of this extension, go to the [GitHub repo](https://github.com/timdeschryver/new-blog-post)
#CodepenChallenge Noodles: Restaurant Home Page Layout Concept
Tags: codepen, vue, html, css
Published: 2019-06-12 12:24:22

<p>My CodepenChallenge for this week.</p>

<p>This week's challenge is about noodle. I couldn't think of any fancy CSS art this week, so I just thought of making an example home page for a restaurant.</p>

<p>Its functionality is written in VueJS.</p>

<p>Design is inspired by many restaurant websites on the internet.</p>

<p>The header part is just a simple slider. You may be able to see the images that are featured on the website.<p>

<p>Technology used:<br>
VueJS<br>
FontAwesome<br>

<p>Google Fonts:<br>
<a href="https://fonts.google.com/specimen/Lobster+Two" target="_blank">https://fonts.google.com/specimen/Lobster+Two</a><br>
<a href="https://fonts.google.com/specimen/Fredoka+One" target="_blank">https://fonts.google.com/specimen/Fredoka+One</a></p>

{% codepen https://codepen.io/takaneichinose/pen/ydyMqy %}