teleren/devto huggingface dataset:
Using A NodeList as an Array: A Practical Use for Object Composition
Tags: javascript, es6, dom
Published: 2017-08-28 19:43:25

---
title: "Using A NodeList as an Array: A Practical Use for Object Composition"
published: true
description: Using Object Composition to get the best of both worlds.
tags: JavaScript, ES6, DOM
---

#Using A NodeList as an Array

##The Scenario:
I had queried a bunch of tags, using querySelectorAll(), and received a NodeList in return.

##The Problem:
NodeLists are like arrays (i.e. they have a length property, they are accessed by an index in brackets: NodeList[0]) however, try using .map, or .filter, or .forEach on one. 

##The Approach:
The options out there were varied. From looping through and filling an Array to some more clever es6 options like:
```javascript
var elements = [... nodelist]
```
```javascript
var elements = Array.from(nodelist)
```

However, these have a problem... they worked too well. You now had an array INSTEAD of a NodeList. Sure, it had all the data from the NodeList but it no longer identified itself as a NodeList.
**What's the problem with that?**
Try:
```javascript
nodeElementInTheArray.compareDocumentPosition(anotherNodeElementInTheArray)
```
This will error out because the argument is not a true NodeListItem.

###Lets reframe our needs
We don't need our NodeList to be an Array, we just need those properties from Arrays. This is the perfect place for object composition.

##The Solution
```javascript
Object.assign(*NODELIST*, Object.Array)
```
Our NodeList remains a NodeList, and it acquires those Array traits we need while not modifying its prototype. I didn't see this solution anywhere, likely because it's never what is asked for. So instead of asking, how do I make A become B, ask how can I get A to behave like B, and the answer will likely be 'Object Composition'
I switched from software engineering to game development, ask me anything.
Tags: ama
Published: 2017-08-28 17:52:18

---
title: "I switched from software engineering to game development, ask me anything."
published: true
description: 
tags: #ama
---

About a year ago I decided to make one of the biggest choices of my career. I started out as a software egineer working in C# and C++ and now I'm working as a game developer in Java.

Feel free to Ask Me Anything
Obtaining Command Line Input in Java
Tags: java
Published: 2023-01-06 02:48:16

---
title: Obtaining Command Line Input in Java
published: true
date: 2017-08-28 17:37:59 UTC
tags: Java
canonical_url: https://brandonrozek.com/blog/2017-08-28-obtaining-command-line-input-java/
---

To obtain console input for your program you can use the `Scanner` class

First import the relevant library

```
import java.util.Scanner;

```

Then create a variable to hold the `Scanner` object

```
Scanner input;
input = new Scanner(System.in);

```

Inside the parenthesis, the `Scanner` binds to the System input which is by default the console

The new varible `input` now has the ability to obtain input from the console. To do so, use any of the following methods:

| Method | What it Returns |
| --- | --- |
| `next()` | The next space separated string from the console |
| `nextInt()` | An integer if it exists from the console |
| `nextDouble()` | A double if it exists from the console |
| `nextFloat()` | A float if it exists from the console |
| `nextLine()` | A string up to the next newline character from the console |
| `hasNext()` | Returns true if there is another token |
| `close()` | Unbinds the Scanner from the console |

Here is an example program where we get the user’s first name

```
import java.util.Scanner;

public class GetName {
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    System.out.print("Please enter your name: ");
    String firstName = input.next();
    System.out.println("Your first name is " + firstName); 
  }
}

```
The 7 Most Popular DEV Posts from the Past Week
Tags: top7
Published: 2017-08-28 17:13:14

---
title: The 7 Most Popular DEV Posts from the Past Week
published: true
description: A round up of the most-read and most-loved contributions from the community this past week.
tags: icymi
cover_image: https://thepracticaldev.s3.amazonaws.com/i/xsr1z6iqv0pd7p3s6ns3.png
---

Every Monday we round up some of the last week's top posts, comments, and tweets. If you have any feedback, please leave a comment._ :heart:

#1. Beyond loops, functions and callbacks

It becomes clear very quickly when an applicant knows just enough to have scraped by, but doesnâ€™t have a solid understanding the language.

{% link https://dev.to/arnavaggarwal/10-javascript-concepts-you-need-to-know-for-interviews %}

#2. You're a certified genius!
Have you ever seen the internet memes that ask you to solve a problem to prove youâ€re a genius? 
<img src="https://i.imgur.com/l5S2Zsm.jpg" alt="internet-meme">

This article shows you how to use various regression algorithms to solve internet genius memes, how different algorithms can capture different relationships in the data, and how to use grid search to optimize multiple algorithms across a range of different parameters automatically.

{% link https://dev.to/kasperfred/solving-only-2-can-answer-this-question-problems-with-machine-learning %}

#3. JavaScript is eating the world

A list of 5 companies that use JS and NodeJS for their high traffic and high profile production projects.

{% link https://dev.to/anthonydelgado/javascript-is-eating-the-world %}

#4. Because being productive is fun.

A list of command line tips and tricks to make your life more productive.
{% link https://dev.to/sobolevn/instant-100-command-line-productivity-boost %}

#5. Ivy league education, for free. 

Feeling envious or curious about what a top of the line computer science education looks like?
{% link https://dev.to/anthonydelgado/28-free-ivy-league-computer-science-courses %}

#6. Because being productive is _still_ fun.

Productivity seemed to be a theme this week. Here's another list of tools for speed productivity.

{% link https://dev.to/chinchang/tools-that-make-me-fast-and-productive %}

#7. More JS prep.

JavaScript interviews was another theme this week. Here's a list of JS interview exercises, with explanations!

{% link https://dev.to/maxpou/typical-javascript-interview-exercises-explained %}

_That's it for our weekly wrapup! Keep an eye on dev.to this week for daily content and discussions...and if you miss anything, we'll be sure to recap it next Monday!_
Escape Sequences in Java
Tags: java
Published: 2023-01-06 02:48:32

---
title: Escape Sequences in Java
published: true
date: 2017-08-28 17:12:00 UTC
tags: Java
canonical_url: https://brandonrozek.com/blog/2017-08-28-escape-sequences-java/
---

Sometimes you want to format your outputs. This is a quick cheatsheet containing the differerent escape sequences

| Character | Escape Sequence |
| --- | --- |
| Newline | \n |
| Tab | \t |
| Backspace | \b |
| Double Quote | &#8221; |
| Single Quote | &#8217; |
| Backslash | \ |
Is Apple really needed?
Tags: discuss, webdev, mac, linux
Published: 2017-08-28 14:45:02

---
title: Is Apple really needed?
published: true
description: It seems a lot of web development centers around using Apple laptops. Is that truly necessary?
tags: discuss, webdev, mac, linux
---

So it seems that Apple has a large share of use in the web development community, particularly because of it's Unix-like-ness and it's ease of use for the common user. It would seem that would make it a great choice for IT to roll across the company; devs get a Unix-like machine and everyone else gets a simple machine to use.

But for hobby developers, is there anything locking you to Apple? **Any utility or tool that is a _must-have_ that is only available on Mac and not Linux?** Or would it be just fine to get a cheap machine with Linux and call it a day?

Apologies for any platforms wars this erupts...
JavaScript project ideas and practical uses
Tags: javascript, discuss, webdev, tutorials
Published: 2017-08-28 14:20:20

---
title: JavaScript project ideas and practical uses
published: true
description: Perfect for when you know JS but can't think of what to build
tags: javascript, discussion, webdev, tutorials
canonical_url: https://simplestepscode.com/javascript-project-ideas/
cover_image: https://static.pexels.com/photos/35803/robin-bird-on-branch-in-the-garden.jpg
---

*This [article](https://simplestepscode.com/javascript-project-ideas/) originally appeared on [Simple Steps Code](https://simplestepscode.com/) which tries its best to help people [learn JavaScript and actually remember it](https://simplestepscode.com/learn-javascript/).*

Over and over, I hear people want JavaScript project ideas.

I've decided to start an ongoing list, and I'd love for you to jump in and share project ideas. The ideas don't need to be inhumanly creative or anything like that. If possible, I'd prefer plain JS, but don't restrict yourself if some framework or tool is required.

Also, before you attempt JavaScript projects, [read this article](https://simplestepscode.com/dangers-of-projects/) to make sure you don't fall into the trap of attempting something too huge too soon and giving up.

Here's the list of JavaScript projects so far:

## UI stuff
- Autocorrecting text box
- Form validator
- Collapsible navigation menu
- Countdown clock
- Modal dialog box
- A site that lets people design their own UI elements (buttons, mastheads, etc.)
- Customize greeting if people came from a certain site

## E-commerce
- Price estimator
- Front end of an interactive online store
- Shopping cart front end

## Finance
- Tip calculator
- Cost splitter
- Investment calculator
- House or car payment calculator
- Savings calculator

## Tools and utilities
- Page that grabs data from somewhere on the web and puts it in a useful format
- Random name picker
- Unit conversion calculator
- Secret message encoder/decoder

## Fun and games
- Basic quiz
- Rock-paper-scissors game
- Pong game
- Madlibs
- A mario-style game
- A zelda-style game (more likely a 2d one until 3d performance improves on the web)

## Social applications
- Social network front end
- Real time chat app (using socket io)

## API stuff
- Gif search, video search, etc
- Something with maps (like a store locator)
- Something with geolocation (e.g.: find XYZ near you)
- Real-time feed of tweets about a subject of your choice
- Text-to-speech
- Combinations of any of the above

## Console tricks
- Scrape a page through your console and get info easily without having to copy, paste, and format each thing by hand (great for research)
- Change colors of your favorite sites to see what they'd look like


I hope you've enjoyed this, and feel free to let me know if you have other suggestions.
Dealing with NODE_MODULE_VERSION in electron
Tags: electron, node, version, sharp
Published: 2017-08-28 13:36:49

---
title: Dealing with NODE_MODULE_VERSION in electron
published: true
description: 
tags: electron, node, version, sharp
---

Original post https://github.com/onmyway133/blog/issues/69

### NODE_MODULE_VERSION 

Today I was trying to install [sharp](https://github.com/lovell/sharp) with `yarn add sharp` to work in my electron app, but I get the following error

> Uncaught Error: The module '/Users/khoa/MyElectronApp/node_modules/sharp/build/Release/sharp.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 54. Please try re-compiling or re-installing
the module

### Native node module

Searching a bit, it was because `sharp` is a [native node module](https://nodejs.org/api/addons.html) which uses [libvips](https://github.com/jcupitt/libvips) under the hood

> Node.js Addons are dynamically-linked shared objects, written in C++, that can be loaded into Node.js using the require() function, and used just as if they were an ordinary Node.js module. They are used primarily to provide an interface between JavaScript running in Node.js and C/C++ libraries.

More on how to build native node module can be found here https://blog.risingstack.com/writing-native-node-js-modules/

### Node version

I'm using [nvm](https://github.com/creationix/nvm) to manage node version, and `nvm list` shows `8.4.0` as the latest node version I'm using. 

```
v6.10.1
v7.8.0
v7.9.0
v8.0.0
-> v8.4.0
system
```

Searching on [Node releases](https://nodejs.org/en/download/releases/)  reveals that Node 8.4.0 has `NODE_MODULE_VERSION` of 57, so that is the node version npm uses to compile `sharp`

However, I can't seem to find the `NODE_MODULE_VERSION` 54 that `sharp` is using. I tried node `8.0.0` which is believed to have `NODE_MODULE_VERSION` 54 but it didn't work

### Electron version

As the time of this post, `electron` is at version `7.9.0`, you can check here https://github.com/electron/electron/blob/master/.node-version or by running `process.versions` in  Javascript console

### Using electron-rebuild

So after I read this [Using Native Node Modules](https://electron.atom.io/docs/tutorial/using-native-node-modules/), I install `electron-rebuilder` to recompile `sharp`

```
yarn add electron-rebuild --dev
yarn add sharp
./node_modules/.bin/electron-rebuild
```

It works now ðŸŽ‰ 

### Read more

- https://blog.risingstack.com/writing-native-node-js-modules/
How to stop relying on the mouse
Tags: discuss, productivity, devtips
Published: 2017-08-28 10:57:40

---
title: How to stop relying on the mouse
published: true
tags: discuss, productivity, devtips
---

I have recently been looking into keyboards, mechanical and otherwise, and decided that I will most likely upgrade my old Logitech one that I got with my desktop to a nicer one. This is part of my plan to encourage myself to program more at home (my last step was getting a really comfy chair).

Since I'm going to be getting a "high end" keyboard for the first time, I would like to also use it as much as possible. I would like to stop relying on the mouse for most tasks and learn more about keyboard shortcuts as well as get better at touch typing.

Do you have any tips on how to accelerate this process and possibly make it more fun? I am using Windows 10 and Visual Studio Code as my primary tools at the moment.
Meeting old men - Two observations that old beliefs slowly got obsolete
Tags: mindfulness, selfcoaching, coaching, sharing
Published: 2017-08-28 08:30:00


---
title: Meeting old men - Two observations that old beliefs slowly got obsolete
published: true
date: 08:30 28/08/2017
author: Cosima Laube
tags: [mindfulness, self-coaching, coaching, sharing]
cover_image: http://blog.cosima-laube.de/images/1/2/3/b/9/123b9fefaf5eed02f7516540bf0b06865d392343-img20170818134912672hdr.jpeg
---

Today I was running in the woods. I stopped by at my favorite spot which is a small lake. Usually it is calm and quite there - and I am the only person. Today there was an old man with his two dogs. The dogs were enjoying a bath in the lake. No quietness!  

I felt a bit puzzled but... I stopped anyway. After greeting the man he immediately asked me if I had a dog following. Obviously he did not expect people _without_ a dog running through the woods. "No I don't", I said. "Oh, then you're just running? Moving is great" he said.  

We stood a while at the lake. Calm. Watching his dogs. When I was about to leave he added "Keep up moving!". He said it in a friendly, empathic way. Usually a part inside me quickly feels offended. Today I wasn't at all. There was an open and humble older male human being with two dogs enjoying the calm lake in the woods.  
   

I had a similar encounter with another elderly man about two weeks ago which was quite similar. Some years ago I would have felt quite weird. Today I do not any more.


Having leveraged different personality development models during the last years and having worked with systemic therapy approaches almost 15 years ago, I know there was that particular part in me not liking a certain "type" of old men somehow. With "not liking" I mean: there was an instant, emotional and physical reaction of heavy avoidance I was not able to fight against or even to categorize and to work with for years. 

Obsiously working on your personality (or should I say: your mental system) needs not just hard work, but a pile of time, a pinch of patience and a bag of compassion... and new behaviour will have the chance to evolve.


Do you also experience those instant reactions which kick-in from time to time, be it in private life or in business? How do _you_ work with them?

(note: this blogpost first appeared on [blog.cosima-laube.de](http://blog.cosima-laube.de/blog/20170828_oldBeliefsAndNewObservations))
Easy & free automated Database backups
Tags: database, development, backup, programming
Published: 2017-08-28 03:55:10

---
title: Easy & free automated Database backups
published: true
description: How setup free automated database backups in 5 minutes
tags: Database, Development, Backup, Programming
---
So you built something, its running, and now you need to have some kind of automated database backup running.

Wouldn’t it be nice to just be able to implement this with a few lines of code and a git repository ? Rightâ€Š–â€Šthat’s what I thought too.
Lately I’ve been working a lot with sites, servers and users in low-bandwidth areas , and I’ve had to come up with a database backup solution that would run on almost any system, and that would not require much bandwidth.
One solution I’ve found that have worked particularly well for me in these circumstances is a small shell script which dumps the database to a sql file, and then the changes are pushed to a git repository.

This approach has a few benefits:
* Easy to set upâ€Š–â€Šyou only need git repository, a tiny shell script and a cron job
* Low Bandwidthâ€Š–â€ŠBy using git, you will only ever push the changed lines in your sql backupâ€Š–â€Šnot the entire file.
* Easy to track changesâ€Š–â€ŠBy using gitâ€Š–â€Šyou can easily browse the commit’s using your favourite UI to see what changes has actually been made to the database

#How to do it
* Create a git repository that will hold your database backup ( Bitbucket allows free private repositories )
* On your server, clone the git repository into a folder.
`git clone git@bitbucket.org:yourusername/db-backup.git .`

* Create a shell script, lets call it run-db-backup.sh, that will dump your database into this folder, and then add the changes, commit and push to git
```
#!/bin/bash
localPATH=’pwd’
echo “Dump Database”
cd /home/ec2-user/db-backup
mysqldump -u dbusername -p”yourdbpasswordhere db_name > db_backup.sql
echo “Commit changes to git and push”
git add .;git commit -m “Latest Database Snapshot”; git push origin master
echo “Done”
```


* Create a cron job to execute your new shell script at your desired interval
`0 */6 * * * /home/ec2-user/run_db_backup.sh`

Now you can log into your git repository and watch your automated database backups flow in. :)

![Inspect commit changes](https://thepracticaldev.s3.amazonaws.com/i/4ttiolboes5uslb5ktmp.png)
*Bitbucket commit list*

![Inspect commit changes](https://thepracticaldev.s3.amazonaws.com/i/xp8z7xyf3b3yitht3kox.png)
*Inspect commit changes*

#Restore backup
To restore a specific commit from the repository, just reference your commit ID/hash when doing a git checkout:

`git checkout 0d1d7fc32 (where 0d1d7fc32 would be your commit hash)`

Now you can import your db-backup.sql file into your database and have a well deserved cup of coffee.

_This is a cross-post from the [original Medium article](https://medium.com/@ArveSolland/easy-free-automated-database-backups-fc21a18f6b56)_
Easy and powerful reverse proxy and load balancing with Docker
Tags: docker, nginx
Published: 2017-08-27 09:45:13

---
title: Easy and powerful reverse proxy and load balancing with Docker
published: true
description: 
tags: docker, nginx
cover_image: https://thepracticaldev.s3.amazonaws.com/i/dbaegcjjcy6o3ijpcux5.png
---

I build a lot of websites, and I run them in Docker containers. What happens is, I end up with URLs like this `0.0.0.0:1234`. 

This is a problem because, 

1. They are difficult to remember
3. Do not allow sub-domains.
3. Bad for password managers

My initial solution was to add a reverse proxy with Nginx so I have virtual hosts that point to my containers. However, this means I was writing the same Nginx configuration, over and over again, only with different ports.

So as any sane developer will do, I took a couple hours to automate the process once and for all.


![let's do this](https://m.popkey.co/bb9661/7MDOG.gif)

## The solution

I ended up creating a docker image to generate my configuration files and be a proper reverse proxy.
You can find it [here](https://github.com/stephenafamo/docker-nginx-auto-proxy)

### Features

1. Sets up reverse proxies with just a few lines of configuration
2. Can automatically obtain SSL certificates from [let's encrypt](https://letsencrypt.org/)
3. Can be used to set up load balancing between several servers
4. Allows fine tuning of the load balancing configuration.

I'll add more features as I discover more use cases. Let me know if there is anything 

Proper details on how to use are in the `README.md` of the [repository](https://github.com/stephenafamo/docker-nginx-auto-proxy).
If you like it, star on GitHub.
Hi, I'm Carlos Gustavo Ruiz
Tags: introductions
Published: 2017-08-27 01:28:13

---
title: Hi, I'm Carlos Gustavo Ruiz
published: true
description: Introduction to the Dev.to community
tags: #introductions
---

Hello, I'm Carlos Gustavo Ruiz, you can find me as [@carlosgruiz-dev](http://carlosgustavoruiz.me) around the Internet.

I've been coding since I was 8 years old.

I live in Panama City (Panama).

I mostly program in these languages: Python, Javascript, and TypeScript.

I am currently learning more about Functional Programming with Haskell and PureScript.

Nice to meet you.
Accepting a job before finishing engineering?
Tags: discuss, job, developer, experience
Published: 2017-08-26 23:43:11

---
title: Accepting a job before finishing engineering?
published: true
description: What are your thoughts on accepting a developer job before finishing official studies?
tags: #discuss #job #developer #experience
---

Computer engineering and tech industry is huge and competitive. Some people (I'm thinking about some classmates at engineering school, for example) find the job they were looking for before finishing their studies. What are your thoughts, experience and such in this issue? I'm giving a lot of thoughts to this lately, and I'd like to read your advises.