teleren/devto huggingface dataset:
Using Array prototypes in strange ways #2
Tags: javascript
Published: 2019-07-22 08:53:32

---
title: Using Array prototypes in strange ways #2
published: true
description: filling an array with changing data
tags: javascript
---

Usually one uses `.fill()` to fill with a simple value. However, you can fill with other things, like records and even function references.

Here we pre-fill a 100 element array with random numbers:
```
const LIM = 1000;
const arrayOfRandomIntegers = new Array(LIM)
  .fill(function () {
    return Math.floor(Math.random() * LIM)
  })
  .map(function (item) {
    return item();
  });
```
Granted, it's not quite as simple as a the value fill -- one still has to evaluate each of the function references in each of the cells -- however, it is another way of creating an array, and one which dispenses with obvious `for(...;...;...)` code.

The function reference approach allows for some interesting things. Below we preload a character array, first by filling with an object's method reference, and then with the function itself. 

First the object itself:
```
function Generator(init) {
  var stuff,
  index;
  var that = this;
  if (init) {
    stuff = init;
    index = 0;
  }
  that.next = function () {
    return stuff.charAt(index++);
  }
  that.eod = function () {
    return index >= stuff.length;
  }
  return that;
}
```
The example object exposes two methods: `next()` and `eod()` (end of data). When we instantiate the object we provide some data for it to work on. Every call to `next()` returns the next character. `eod()` is provided to check if we've run out of data. In this implementation the object will return an empty string if it does run out.

So, first instantiation and use:
```
const string = "lewd did i live - evil i did dwel";

const H = new Generator(string);
const arrayFromH = new Array(string.length)
  .fill(H.next)
  .map(function (item) {
    return item();
  });
```
Here we fill with a reference to `.next()` and trust that the `Generator` object will fail politely if we ask for more data than it has to offer. As it is, because we've told `Array` only to allocate space for `string.length`, we're never going to find out if `Generator` is polite or otherwise.

Second go:
```
const G = new Generator(string);
const arrayFromG = new Array(string.length)
  .fill(G)
  .map(function (item) {
    return item.eod() ? "*" : item.next();
  });
```
Here we store the reference to the function and then check with `.eod()` in the body of the `.map()`, storing an asterisk if we go too far.



By the way, the history of the "lewd ... dwel" thing can be found [here](https://en.wikiquote.org/wiki/John_Taylor_(1578%E2%80%931653))

P.S. There are generators in ES6 and this isn't them.
Linux by example - Building make and a couple of common languages
Tags: linux
Published: 2019-07-22 08:32:47

---
title: Linux by example - Building make and a couple of common languages
published: true
description: We talk about building language compilers and their usages within linux.
tags: linux
cover_image: https://thepracticaldev.s3.amazonaws.com/i/0jxlrtwyduqcegmu0ui5.jpg
---

{% youtube hxMWvvCdg08 %}
Learn JavaScript Basics with These 10 Free Resources
Tags: javascript
Published: 2019-07-22 07:20:28

This is the first post of a series called ‘Learn JavaScript for Free’ – in these chapters you will find excellent materials and a roadmap for learning JS from scratch. As the JavaScript community is one of the best out there, the series will entirely rely on free JavaScript resources

If you are looking to learn JavaScript, or just want to brush up on the JavaScript basics, then you are in luck. There are currently some amazing resources available online to help you understand and get to grips with JavaScript. And even better, most of the are free.

In this article, I have put together a variety of free resources (in no particular order) that you can easily access to help you learn the JavaScript basics. From courses and videos, to written guides and blogs, there is something here for everyone. Enjoy…
Why Learn JavaScript Now?

JavaScript is almost everywhere: in your browser, web apps, mobile apps, cloud services, even IoT devices. It’s easy to get started with it as all you need is a plain text editor and a browser. It is a beginner friendly language, with an awesome community around it.

You can code both frontend and backend with JavaScript, which makes it extremely useful.

Click here to continue: https://simpliv.wordpress.com/2019/07/22/learn-javascript-basics-with-these-10-free-resources/
BETA testing of Utopia decentralized ecosystem is now LIVE!
Tags: testing
Published: 2019-07-22 07:18:31

We live in a world of total surveillance, where a lack of privacy is becoming a norm and confidentiality is a thing of the past. We, a group of networking technology enthusiasts, feel that such a state of affairs cannot continue for long, and our answer is Utopia! Get ready for the future where Big brother is no longer watching you.

We are looking for the  beta testers to take part in closed testing of a new decentralized peer-to-peer network. The network is supported by users and offers high-quality features as well as a smooth user interface. The main functions are confidential communication and secure financial transactions. All information is impossible to steal, and all conversations stay private. With our ecosystem, you will be able to send instant text and voice messages, exchange files, create group chats and channels, view news feeds, conduct private discussions.   Moreover, our network has an inbuilt browser , API and financial functionality.    Join us https://beta.u.is/

The project is absolutely unique!

The problem of security and privacy has been bothering us for long years. That’s why we gathered the best team of specialists to produce such a place for everyone.  Experienced developers were consulted by the top experts of data security sphere from around the globe. We spent more than five years secretly working on the development together to make the world better.

What we expect from you:

During the registration on the beta portal, you can choose one of three available roles: a tester, a promoter, an assistant, or all three at once: 
- actively use the ecosystem
- search for bugs and report them
- suggest improvements for the software 
- give feedback with an assessment of the system
- promote our software
-  provide assistance to other users

Benefits:

- an opportunity to be the first to test this unique software
- crypto bonuses (paid in BTC)
- lifelong access to all the features of the ecosystem 
- additional rewards in BTC for promotion and bringing new beta testers
- additional bonuses for bugs reporting 
To learn more about Utopia and to sign up for its beta please visit https://beta.u.is 

P.S. If you are a blogger, a journalist, or an owner of a YouTube channel, your offers for collaboration and promotion are welcomed.
React tldr; Styled-components v5
Tags: react, styledcomponents, devtools
Published: 2019-07-22 07:10:34

- Major improvements:
31% smaller bundle size
22% faster client-side mounting
26% faster updating of dynamic styles
45% faster server-side rendering

- All of your styled components are now fully hooks-powered
- Fully automatic RTL support for your styles

Source: https://medium.com/styled-components/announcing-styled-components-v5-beast-mode-389747abd987
Multiple MongoDB database Connections in NodeJS
Tags: mongodb, node, mongoose
Published: 2019-07-22 06:59:57

---
title: Multiple MongoDB database Connections in NodeJS
published: true
description: Create Read Only database connection along side default database connection in NodeJS. 
tags: MongoDB, NodeJS, Mongoose
---
MongoDB allows configuring a secondary replica node to be hidden. It means that the secondary replica node will not be elected as Primary in case of primary node failure. Wait… But why we need such a replica node? The answer is that the application can transfer its analytics(read heavy) queries to this node so the primary node will not suffer any hiccup because of heavy read analytics queries. 
Read More...
 
https://medium.com/@abhi11210646/multiple-mongodb-database-connections-in-nodejs-ee4b75cc70e3
Call for Speakers - Cloud Data Summit - 100% Web-based conference. Fall 2019
Tags: dataops, bigdata, datascience
Published: 2019-07-22 06:40:13

Call for speakers

Oct 16-17, 2019. See conference presentations and case studies from prominent experts in cloud data warehousing, Data Science, AI, Streaming Data, Elastic Compute, Data Visualization, and more.

We are organizing a new online summit for Cloud data technology called Cloud Data Summit. It will be a 2-day 100% web-based conference on an incredible new web summit platform on October 16-17. Over 1000 tech and non-tech leaders, data scientists, and data engineers at large companies will be in attendance.

We are looking for a few more technology leaders who would like to speak

Primary Topics

How you designed elastic cloud systems at your organization
How you optimized your elastic cloud infrastructure
How you evaluated and selected technology platforms
Elastic cloud databases or data warehouses (SQL or NoSQL)
Data Integration/Preparation
Data Visualization
Microservices
AI and Machine Learning
IoT in the cloud (even if you have edge processing)
Streaming Data
Distributed applications
Blockchain
ERP in the cloud
Automation in the cloud
Data Governance
Data Quality
All presentations should be related to cloud data technology in some way, even if they aren't directly affected by it.

The audience has asked to see 
-Business cases 
-Success stories 
-Failures 
-Lessons learned 
-Light technical presentations 
-High level systems architecture slides

The attendees are a mix of managers, architects, data scientists, and data/cloud engineers so the Main Stage topics shouldn't be technically deep. Technical topics and deep dives will be held for roundtables.

https://www.clouddatasummit.com/
Day Two - Rendering Elements
Tags: react, reactjavascript, javascript, webdev
Published: 2019-07-22 06:38:50

---
title: Day Two - Rendering Elements
published: true
description: A series of my learning of the React Concepts
tags: react, ReactJavaScript, javascript, webdev
series: React Concepts Series
---

In my previous posts, I have written about JSX and few of its concepts. This post will include the rendering of elements in React.



Elements are the smallest building blocks of React apps. It is the smallest renderable unit in React. These elements can be rendered using the *ReactDOM*. React Elements are plain objects which are easy to render. React Elements and Components are two different terms. 


In order to get React elements rendered, they must be enclosed in the div element with id="root" or "app". React elements are _immutable_ i.e. once an element is created it is impossible to update its children or attribute. Hence, to update the element, its render method is to be called several times. React render is quite efficient by using virtual DOM and efficient differentiating algorithm. The algorithm checks the rendered data and the updated data and only re-renders the data that needs an update, instead of rendering all data.

In the next post, I'll be writing about Components and Props in react.
Anyone need help for developing oss project in reactjs and php/symfony framework?
Tags: react, php, symfony4, javascript
Published: 2019-07-22 05:29:30

---
title: Anyone need help for developing oss project in reactjs and php/symfony framework?

published: true
description: 
tags: #Reactjs, #PHP, #symfony4. #javascript
---
Anyone need help for developing oss project in reactjs and php/symfony framework?
How many use Github Actions and Why?
Tags: help
Published: 2019-07-22 04:52:55

I am really curious to know if devs and QA engineers like to create functional and executable code blocks in a web app versus writing it as a python script? 

For example, if I was a developer using GCP-APJ and AWS-US-east for storing images, then I will have to create a script internally that hooks into both these cloud vendor APIs to perform similar functional things like uploading new content, deleting images, etc. 

Question for the group here:
a) As a developer would you use a system like Github Actions to do this? if yes, why?
b) if you don't intend to use Github Actions, then what other use-cases would you use Github actions for?
Top Python Posts from July 15 week
Tags: python, bestofdev
Published: 2019-07-22 03:14:26

Hi! I'm Vicente, your friendly Filipino mod for the python tag. Today, I'll be starting a Top Python Posts from the past week!

Hope you'll follow along!

On the first article, Mischa Spiegelmock talks about their stack and how they don't overcomplicate things at JetBridge.

{% link https://dev.to/cybermischa/web-application-software-stack-2019-edition-3c30 %}

Next would be an article from Gajesh Bhat, who talks about the importance of having a virtual environment for each of your project.

{% link https://dev.to/gajesh/all-you-need-to-know-about-python-virtual-environments-29l8 %}

On this article, Nina 𝚉𝚊𝚔𝚑𝚊𝚛𝚎𝚗𝚔𝚘 shares three things you should know about coding with Python in VS Code!

{% link https://dev.to/nnja/three-things-you-should-know-about-visual-studio-code-1pnn %}

Anurag Rana, starts a series of articles in Programming on Raspberry Pi with Python.

{% link https://dev.to/anuragrana/programming-on-raspberry-pi-with-python-raspberry-pi-setup-58lg %}

Lastly, petercour walks us through on how to grab satelite data with Python. 

{% link https://dev.to/petercour/grab-satellite-data-with-python-a5c %}

That's it for this week! Stay tuned for more!
A Whiteboard Summary of Dave Alger
Published: 2019-07-22 03:02:30

Let the Power of JavaScript consume you!
![vader](https://thepracticaldev.s3.amazonaws.com/i/7inw1ws0jhv9m0k20393.jpeg)

Do or Do Not there is no try.
![yoda](https://thepracticaldev.s3.amazonaws.com/i/np4rv5ahfcxdv788ew6y.png)

Not the "droid" you’re looking for...
![r2d2](https://thepracticaldev.s3.amazonaws.com/i/rulvdqgiwmszfcauoghn.jpeg)
What got you into dev?
Tags: discuss, productivity
Published: 2019-07-22 03:01:43

What made you get into your field? Was it a game you played? Maybe a show you watched on TV? Or some career payroll chart in highschool. For me it was a online game. Late 1990's early 2000's. The game was RuneScape. Back then it was super simple and the graphics couldn't get any more basic. I seen the way people reacted and the unlimited possibilities for growth in the game and with programming. Still to this day if I hit a road block or I get frustrated I log in and play for a few days. It always reminds me of what a simple and basic idea can become with enough work and a strong dedication.
My First Development Job
Tags: discuss
Published: 2019-07-22 02:48:40

---
title: My First Development Job
published: true
tags: discuss
canonical_url: https://blog.ryan.devportfol.io/my-first-development-job/
description: Just a quick catch up on what I am doing - new job!
---

I recently started my first job in the development world.  I am a Junior Apprentice at Maxx Potential.  While we have many different types of projects in the technology field, I have been primarily working on development and code maintenance projects.

So far I have worked with Docker Compose, Docker Swarm, and Vagrant for development environments.  They are definitely interesting.  If you ever really want to learn Docker, convert a custom Docker Compose setup to be Docker Swarm friendly.  

As far as languages are concerned, I have been working primarily with PHP for an extension of the WordPress plugin Elementor.  Elementor is extremely powerful, however it is rather under documented, so it has also been a pretty solid learning experience.  Along with learning Elementor, I was also required to learn PHPUnit unit testing.  This was without a doubt the most difficult part of the process, however it forced me to learn that I need to be able to test my own code.

This post has been more of an update regarding what I am doing right now and unfortunately does not really cover any interesting code work.  So I think I'll just mark it as discuss and ask if anyone else just started their first job in the industry and would like to talk about it a bit.  Expect more from me soon, still figuring this blogging thing out.
Spring Boot Tutorial: Complete guide from development to deployment
Tags: java, webdev, microservices, tutorial
Published: 2019-07-22 01:49:55

In this course we will start from basics and learn all key features of Spring boot from development to deployment.

Some of the major topic that we will cover this would be
- Development environment setup
- Demo application overview for the course
- Creation the rest web-services
- Creation of sample web-application
- Profiles and properties
- Logging
- Security
- Production grade feature like actuator.
- Deployment

What you'll learn
- Learn how to built micro-service application using Spring boot

{% youtube qY1d1DRh2a0 %}
Design Patterns Discussion
Tags: patterns, mvc, adr, discuss
Published: 2019-07-22 01:38:25

---
title: Design Patterns Discussion
published: true
description: A start of a general discussion of design patterns
tags: patterns,mvc,adr,discuss
---

# Preface

It's been a while since I've written a post, but I figured I'd ask about something I don't remember learning in college (and also because I've only encountered it while learning Laravel).

Laravel implements a flavor of a design pattern called MVC (at least, its own flavor of the one common in the PHP world from my basic understanding). I had sort of been following this early on learning Laravel. But when asking for help with part of it (just for the sake of sticking to the pattern), it was mentioned to me that what's called "MVC" typically in PHP projects isn't *really* MVC.

At this point, I was recommended to learn the Action-Domain-Responder pattern instead and pointed to [this reading material][1].

## To the point...

I'm planning to look into ADR again this week and wanted to ask others for input.

So what design patterns are you familiar with, and which do you prefer?

### P.S. (not to be confused with PowerShell)

The [reading material][1] I mentioned earlier links to some MVC history, including how today's "MVC" came about. This definitely was interesting to read for a design patterns newbie like me (that and I just like learning about software development in general).

----

Discuss away! 

[1]: https://github.com/pmjones/adr
SFTP to S3 Backup
Tags: aws, sftp, go, github
Published: 2019-07-15 17:05:18

In our company, we had a simple SFTP Server where third parties used to supply us with reports, files etc. In order to backup the information onto S3 where we could start processing the files, I wrote a simple utility in `Go` to achieve the same [sftp-s3-backup](https://github.com/babbarshaer/sftp-s3-backup).

The purpose of this article is to walk through a simple process of backing up the files present in SFTP onto S3.

# S3 Login Credentials

In order to backup onto S3 our system needs to be able to login to the platform. Below environment variables needs to be set for the program to automatically pick them up. The variables are as follows:

1. `AWS_ACCESS_KEY_ID`
2. `AWS_SECRET_ACCESS_KEY`
3. `AWS_REGION`
4. `AWS_SESSION_TOKEN` // In case you have 2 factor auth enabled.


# Simple Backup

```
package main

import (
  "log",
  backup "github.com/babbarshaer/sftp-s3-backup"
)

func main() {

  config := backup.Config{
    User:              "user",
    Address:           "address",
    Port:              22,
    PublicKeyLocation: "/home/user/.ssh/id_rsa.pub",
  }

  client := backup.Client(config)
  err = client.Init()
  if err != nil {
    log.Fatalf("Unable to initialize the client: %s", err.Error())
  }
  
  defer client.Close()

  err := client.Backup(
    "/data/user/uploads",
    "aws.bucket",
    backup.DefaultPathTransformer)

  // If we don't want the default path transformer
  // we can override it with our own implementation.

  if err != nil {
    log.Fatalf("Unable to backup, err: %s", err.Error())
  }
```


We will go through each part of the program step by step:

We start by creating a `config` object which mainly contains the credentials of the sftp server who's directory we need to backup onto S3.

```
config := backup.Config{
    User:              "user",
    Address:           "address",
    Port:              22,
    PublicKeyLocation: "/home/user/.ssh/id_rsa.pub",
  }
```

We then create a new backup `client` object by supplying in the config. We initialize the client by calling the `Init()` method.

```
client := backup.Client(config)
client.Init()
```

If everything goes smoothly, we should be able to establish a sftp connection after this point. Otherwise, it would return an error. Handling of error depends upon the user at this point.

We should always remember to free up the client connection.
```
defer client.Close()
```


Finally, we can now perform a directory backup. This method will backup all the files in the directory to the corresponding bucket in s3. We supply an additional `transformer` variable which dictates how the path needs to be transformed when storing the object from sftp onto s3. 

```
directoryToBackup := "/data/user/uploads"
awsBucket := "aws.bucket"
transformer := backup.DefaultPathTransformer

err := client.Backup(
    directoryToBackup,
    awsBucket,
    transformer)

```

A user can supply there own `transformer function` as follows:

```
func MyTransformer(path string) string {
  newPath := path
  // computation ...
  return newPath
}

```


******
Diagramming your AWS VPC & IAM structure
Tags: aws, iam, vpc, topology
Published: 2019-07-22 00:52:01

The snowball effect for organizations & startups using AWS is a real thing. You may start experimenting with using one of the cloud platforms (AWS in this article) and soon to find out you have *quite the labyrinth* of policies, groups, users, access keys and more. This handy tool developed by the security company DUO (now owned by Cisco) will help you untangle the ball of yarn that started with a back & forth between you and the developers.

**[DUO CloudMapper](https://github.com/duo-labs/cloudmapper)** is a tool that has grown from originally diagramming your AWS *Virtual Private Cloud* to now including IAM reports and much more.

A few examples of my personal favorite components of the CloudMapper tool are the [resource aggregation](https://raw.githubusercontent.com/duo-labs/cloudmapper/master/docs/images/report_resources.png) along with the IAM reporting for identifying [policy best-practices and potential](https://raw.githubusercontent.com/duo-labs/cloudmapper/master/docs/images/report_findings.png) problems.

Here are a few screenshots from the tool and it's components:

![principals](https://www.troydieter.com/static/duo-cloudmapper/thumbnail/iam_report-inactive_and_detail.jpg)  
![layout](https://www.troydieter.com/static/duo-cloudmapper/thumbnail/ideal_layout.jpg)  
![report findings](https://www.troydieter.com/static/duo-cloudmapper/thumbnail/report_findings.jpg)  
![report findings summary](https://www.troydieter.com/static/duo-cloudmapper/thumbnail/report_findings_summary.jpg)  
![report resources](https://www.troydieter.com/static/duo-cloudmapper/thumbnail/report_resources.jpg)

For installation, code repository and more [visit the official DUO CloudMapper GitHub page](https://github.com/duo-labs/cloudmapper). Cheers!
JavaScript Events: Bubbling, Capturing, and Propagation
Tags: javascript, javascriptevents
Published: 2020-09-21 07:16:43

---
title: JavaScript Events: Bubbling, Capturing, and Propagation
published: true
date: 2019-07-22 00:00:00 UTC
tags: JavaScript,JavaScriptEvents
canonical_url: https://www.loginradius.com/engineering/blog/javascript-events-bubbling-capturing-and-propagation/
---

A basic example of a JavaScript event Events, in JavaScript, are occurrences that can trigger certain functionality and can result in certain behaviour. A common example of an event is a “click”, or a “hover”. You can set listeners to watch for these events that will trigger…

   
[Read On](https://www.loginradius.com/engineering/blog/javascript-events-bubbling-capturing-and-propagation/)