teleren/devto huggingface dataset:
Merging piped `stdin` with command-line arguments within Bash
Tags: bash
Published: 2019-04-29 18:59:04

---
title: Merging piped `stdin` with command-line arguments within Bash
published: false
tags: 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/9rapgw69nvli5qptx7wd.jpg
canonical_url: https://fortes.com/2019/bash-script-args-and-stdin
published: true
tags: bash
---

I am computer nerd who is easily seduced by [automation](https://xkcd.com/1319/), which means I end up writing a fair number of shell scripts. Even though I’ve written my fair share of Bash, my small primate brain never quite grasps the language and I always copy-paste my way through the task at hand, absorb nothing, and then pat myself on the back for being such a _1337 h4x0r_.

Typically my needs are quite pedestrian, and I can immediately find an answer to plagiarize. My latest script, however, wasn’t solved within seconds so I’ve written up the solution for my very handsome future self.

## The “Problem”

My script takes one or more command-line parameters, which is straightforward to invoke when you know the values:

```sh
# Called via command-line arguments
my_script item_one item_two

```

In other cases, the values I’m passing in are the output of some other command. As a [godly Unix user](https://linux.die.net/Linux-CLI/c1089.htm), my instinct is to pipe the output (`printf` just for illustration):

```sh
# Called with piped input, one argument per line
printf "item_one\nitem_two" | my_script

```

The argument-handling Bash code I copy-paste every time only handles command-line arguments, and completely ignores any piped input. Here’s code that will read in the piped input and convert to command-line arguments, one per line:

```sh
# Copy command-line arguments over to new array
ARGS=( $@ )

# Read in from piped input, if present, and append to newly-created array
if [! -t 0]; then
  readarray STDIN_ARGS < /dev/stdin
  ARGS=( $@ ${STDIN_ARGS[@]} )
fi

# Single loop to process all arguments
for ARG in "${ARGS[@]}"; do
  echo "$ARG"
done

```

I’ve already forgotten I wrote this code, so don’t ask me what it does. I’m just gonna copy-paste it again in a few months, leave me alone!

Note that you can get around supporting piped input if you’re just willing to use `xargs` (which I also make sure to regularly forget how to use):

```sh
# This is way easier than what I just showed you
printf "item_one\nitem_two" | xargs my_script

```

Farewell, future self. Be glad that your tiny brain retains the vital lyrics to _Ice Ice Baby_ instead of something as useless as `xargs` and Bash arrays.
Introducing Agenty "Agents for Machine Intelligence"
Tags: webscraping, machineintelligence, ocr, showdev
Published: 2019-04-02 15:33:06

---
title: Introducing Agenty "Agents for Machine Intelligence"
published: true
description: Introducing Agenty's Cloud-based agents for data scraping, text extraction, ocr, change tracking and more
tags: web scraping, machine intelligence, OCR, showdev
---

Hi, Dev Community!

We have been working on [Agenty](https://www.agenty.com/) from a long time, and today I am so excited to show it to the Dev community.

We are launching 4 agents today :

- **Scraping agents** : Point-and-Click web scraping agent to extract data from websites of choices. Convert websites into api in lass then 2 minutes (see my video https://www.agenty.com/docs/video-tutorials.aspx ) or install the extension from Chrome store - https://chrome.google.com/webstore/detail/agenty-advanced-web-scrap/gpolcofcjjiooogejfbaamdgmgfehgff

- **Textract agents** : Extract text and metadata from almost any documents in batch

- **OCR agents** : Extract text from images and pdfs.

- **Bar code recognition agent** - Recognize the bar code number and it's type from products photo captured by mobile or cameras.

All agents are API ready, see the documentation - https://www.agenty.com/docs/api

Go to our website and signup to get 100 pages credit free to try any agent you like. And you can go PRO anytime if you like it, the [pricing plans](https://www.agenty.com/pricing/) just starts from $29 per month (10x lower then import.io for web scraping whose plans starts from $299)

I’ll keeps checking this page today to answer any comments, feedback you have, really looking forward to it :)
Use $ & $$ Instead of document.querySelector/All in JavaScript without jQuery
Tags: javascript, onedevminute
Published: 2019-04-02 15:19:44

---
title: Use $ & $$ Instead of document.querySelector/All in JavaScript without jQuery
published: true
description: Yes, the good old jQuery tricks that still work in JavaScript without having to use jQuery.
tags: JavaScript, OneDevMinute
---

I started writing JavaScript code because of WordPress back in 2007. JavaScript was not what it is today. It would behave differently on different browsers and there were too many hacks around basic stuff to keep up with all the changes all the time.

So, many of us decided to rely on jQuery — a simple JavaScript library with one single form of syntax that just worked everywhere in all the browsers.

Fast forward to 2019, as a full-time JavaScript Developer Advocate — I advocate modern JavaScript. Because it's super awesome. Though at times I miss the simplicity of jQuery in things like you'd just need a `$` sign to pick up an element and do stuff to it.

Now with JavaScript, I find myself doing `document.querySelector` multiple times in an application. Well, guess what, there's an easy way to just bind that `$` sign to your document's `document.querySelector`.

![gif](https://thepracticaldev.s3.amazonaws.com/i/se386yy0s87edjw2z38k.gif)

Here's how you go about it. 

```js
const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document);
```

Now you can use the following:

```js

// Change the background color of a class.
$('.class').style.background="#BADA55";

// Change the inner HTML of an ID.
$('#id').innerHTML="<span>Cool beans!</span>";

// Select all images on the webpage.
$$('img')

// Print the image addresses for all the images on a webpage.
$$('img').forEach(img => console.log(img.src))
```

{%tweet 1113094169025708033 %}

Use your code for good and have fun! :)
Peace! ✌️
What is the history of npm?
Tags: npm, javascript, node
Published: 2019-04-02 15:07:16

---
title: What is the history of npm?
published: true
description: I have some questions I'm hoping someone with context can answer for me
tags: npm, javascript, node.js
---

I didn't get into JavaScript development until about 2016-ish. Therefore, I missed a lot of the early stages of Node.js (and the io.js fork), `npm`, the rise of all of the frontend frameworks, etc. 

To my surprise, I learned recently that `npm`, the package manager that ships by default with Node.js, is actually controlled by a for-profit company and it is not open source. 

Python's `pip` and Java's Maven are both open source, and that seems to be the default for other programming language's package managers. 

There has been a lot of chatter and concern on Twitter about:

- moving the registry to the JS Foundation
- making it decentralized
- contingency plans should the company sell to a bad actor.

I have some questions I'm hoping someone with context can answer for me:

- Was `npm` always a for-profit company or did it start open source and eventually incorporate?
- How did Node.js decide to partner and ship with `npm`?
Top 5 DEV Comments from the Past Week
Tags: bestofdev
Published: 2019-04-02 14:39:17

---
title: Top 5 DEV Comments from the Past Week
published: true
description: Highlighting some of the best DEV comments from the past week.
tags: bestofdev
cover_image: https://res.cloudinary.com/practicaldev/image/fetch/s--7VrAA2ln--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://thepracticaldev.s3.amazonaws.com/i/qmb5wkoeywj06pd7p8ku.png
---

This is a weekly roundup of awesome DEV comments that you may have missed.  You are welcome and encouraged to boost posts and comments yourself using the **[#bestofdev](/t/bestofdev)** tag.

Answering **[Have you ever quit a job without anything else lined up?](https://dev.to/ben/have-you-ever-quit-a-job-without-anything-else-lined-up-e43)**, @gypsydave5 how they got into software development in the first place:
{% devcomment 9kao %}

@yechielk shared an awesome achievement in **[What was your win this week?](https://dev.to/jess/what-was-your-win-this-week-onl)**:
{% devcomment 9m6j %}

The **[What's your type?](https://dev.to/helenanders26/do-you-have-a-type-4jp1)** thread discussed different types of managerial styles.  @thorstenhirsch chimed in with their nightmare manager story:
{% devcomment 9mjb %}

Yesterday, we had an April Fool's related goof:

{% twitter 1112759560547258368 %}

In response, people started telling their own stories in **[Tell me about a time you messed up](https://dev.to/ben/tell-me-about-a-time-you-messed-up-47an)**.  None more beloved than the mistake shared by @jrtibbetts:
{% devcomment 9ng8 %}

Finally, it's always so cool when a community resource is visited by a true authority on the subject.  In the **[You've been doing mapDispatchToProps wrong this entire time ](https://dev.to/mcrowder65/you-ve-been-doing-mapdispatchtoprops-wrong-this-entire-time-582m)**, @markerikson pops in to offer confirmation and additional context:
{% devcomment 9mm6 %}

See you next week for more great comments ✌
Week of April 02 - Top 3 React articles from around the web
Tags: react
Published: 2019-04-02 14:32:33

---
title: Week of April 02 - Top 3 React articles from around the web
published: true
description: Short and sweet. No spam.
tags: reactjs
---

#### 1. [How to Avoid the Boolean Trap When Designing React Components](https://spicefactory.co/blog/2019/03/26/how-to-avoid-the-boolean-trap-when-designing-react-components) by Filip Danić

Using CSS conventions from Bootstrap for the API design of your React components can lead to bad decisions. Here's what you can learn from "The Clean Code" by Robert C. Martin in the context of React.

#### 2. [Building a Componentized and Reusable Scroll to Top Feature in React](https://levelup.gitconnected.com/building-a-componentized-and-reusable-scroll-to-top-feature-in-react-7fa5ac8d4c2d) by Sarah Sweat
 
One of the main considerations in creating this component was that I needed it to be reusable on multiple pages of the site, so my goal was to create something that could be imported and utilized in other react components in order to add to a div which had content that would need to be scrolled through.

#### 3. [react-frontload](https://github.com/davnicwil/react-frontload) (library) by Dave Williams

Load data asynchronously into your React components. Works on both client and server render.

[Get emails like this in your inbox, every Tuesday](https://tinyreact.email) . Short and sweet. No spam.
Which do you prefer?: DSL or a well-designed Library?
Tags: discuss, api, library, dsl
Published: 2019-04-02 14:26:15

---
title: Which do you prefer?: DSL or a well-designed Library?
published: true
description: 
tags: discuss, api, library, dsl
---

Lately, I am preferring libraries over DSLs more and more.  As I have ventured into learning Rust, it seems that all too many Crate authors abuse the (otherwise awesome) macro-system to create their own DSL.  If more library-developers spent their time on designing a well-put-together API, then I would have the benefit of everything else my IDE supports:

* Syntax I am familiar with: nothing else to learn besides the API surface
* Autocomplete for discovery! (instead of switching between a Docs page and my text-editor)
* Inline documentation, if methods were documented
* etc.

The epitome of this philosophy would be [RethinkDB's query language](https://rethinkdb.com/docs/introduction-to-reql/), which is actually an API, and not its own query language!

What do you all prefer?
Bug on Timbu.com
Published: 2019-04-02 14:10:39

---
title: Bug on Timbu.com
published: true
description: 
tags: 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/wv1vbnuwgfge6dxhkdn9.png
---
[Timbu](https://timbu.com/#) is a travel site that helps travellers plan their trips. It has database for all top travel destinations, homes and hotels. 

However, the site has a bug in the ![Exclusive offers](https://thepracticaldev.s3.amazonaws.com/i/whrojeslxffkiw5729ty.png) section of the site. As you can see in the picture the section doesn't display properly on mobile. You can check out [Timbu](https://timbu.com/#) yourself.
Lazy Type (custom-abbreviation)
Tags: python, keyboard, typing, lazy
Published: 2019-04-02 14:06:53

---
title: Lazy Type (custom-abbreviation)
published: true
description: create your own abbreviation for quick typing
tags: python,keyboard,typing,lazy
---

this (<a href="https://gitlab.com/hhypnos/custom-abbreviation" target="_blank">link</a>) mini script gives you chance to write everyday text with simple abbreviations.

you should add
<code>keyboard.add_abbreviation('Abbreviation','value')</code>in config.py
and start the script with <code>sudo python3 abbr.py</code>

<h2>Example of config.py:</h2>
<code>settings=[
    keyboard.add_abbreviation('@@', 'example@email.com'),
    keyboard.add_abbreviation('HH', 'SecondAbbreviation'),
   ]
</code>

<h2>Usage:</h2>
write your abbreviation anywhere and press space
Show some 🖤 to Node.js process errors
Tags: node, javascript, debugging, testing
Published: 2019-04-02 14:04:11

---
title: Show some 🖤 to Node.js process errors
published: true
description: Show some 🖤 to Node.js process errors
tags: [nodejs, javascript, debugging, testing]
---

Node.js prints process errors (`uncaughtException`, `warning`, `unhandledRejection`, `rejectionHandled`) on the console which is very useful. Unfortunately those errors:

  - do not show stack traces for `warning` and `rejectionHandled` making them hard to debug.
  - do not include `multipleResolves` errors (when a promise is resolved/rejected twice).
  - are inconvenient to log to an external service.
  - are hard to test.
  - cannot be conditionally skipped.
  - are printed each time an error is repeated (except for `warning`).
  - are not human-friendly.

I have created a library that fixes all those issues: [`log-process-errors`](https://github.com/ehmicky/log-process-errors).

Feel free to check it out at https://github.com/ehmicky/log-process-errors. Any feedback is welcome!
What makes dev.to popular?
Tags: devto
Published: 2019-04-02 13:01:41

---
title: What makes dev.to popular?
published: true
description: Hi everyone, I was wondering what makes dev.to this popular? I've seen a post at some point talking about it but can't find it anymore. Why not use medium for example? Can the same idea be applied to other communities? Cheers!
tags: dev.to
---

Hi everyone, I was wondering what makes dev.to this popular? I've seen a post at some point talking about it but can't find it anymore. Why not use medium for example? Can the same idea be applied to other communities? Cheers!
Java Inheritance Puzzle
Tags: java, challenge, inheritance, oop
Published: 2019-04-02 12:38:49

---
title: Java Inheritance Puzzle
published: true
description: Java puzzle about inheritance
tags: java, challenge, inheritance, oop
---

Imagine we have one interface and these classes:

```java
interface SuperType {
    void test();
}


class DefaultSuperType implements SuperType{
    @Override
    void test(){
        System.out.println("0")
    }
}

class ChildOfSuperType extends DefaultSuperType{
    @Override
    void test(){
        System.out.println("1")
    }
}
```

And then we execute this piece of code
```
SuperType superType = new ChildOfSuperType();
DefaultSuperType defaultSuperType = (DefaultSuperType) superType;
defaultSuperType.test()
```

Do you know what will be printed?
My HNG Chronicles- Debugging Timbu.com
Published: 2019-04-02 12:04:20

---
title: My HNG Chronicles- Debugging Timbu.com 
published: true
description: 
tags: 
---
https://timbu.com/

Today we were instructed to look for bugs on the Timbu website as the first part of this week’s challenge to get promoted to stage two. I found the following

While on the Flights page, https://timbu.com/flights I discovered that under the “Explore the World” Category that the “See More” links that where supposed to link to a page with more detailed information about the categories were non-functioning.
![Screenshot of Bug](https://thepracticaldev.s3.amazonaws.com/i/j7vuooz386ne0sbuv4xk.jpg)

Also, just below this category there was a random, out-of-place letter “n”..
![Screenshot of Bug](https://thepracticaldev.s3.amazonaws.com/i/qpivj3alzfshufvzl9ji.png)
The About Us links at the footer of the same page were non-functioning
![Screenshot of Bug](https://thepracticaldev.s3.amazonaws.com/i/9wucqepehzvqsih4broi.png)
Neat-RTC: WebRTC wrapper for React and Vue
Tags: webrtc, react, javascript, showdev
Published: 2019-04-02 11:53:42

---
title: Neat-RTC: WebRTC wrapper for React and Vue
published: true
description: WebRTC wrapper for React and Vue
tags: webrtc, react, javascript, showdev
---
**Welcome**, this is my recently created module, it makes WebRTC easier to use with features like:

 - Built-in signaling
 - Simplified mediastream, datachannel usage
 - Ready to use React, Vue examples
 - Detailed description

[Try the package at NPM](https://www.npmjs.com/package/neat-rtc)
[Check browser compatibility](https://caniuse.com/#feat=rtcpeerconnection)

###What is WebRTC?
[WebRTC](https://webrtc.org/) is an HTML5 specification that you can use to add encrypted, real-time media/data communications directly between browsers or devices.

###Have a nice day!

{% github tamasszoke/neat-rtc %}
The 7 Most Popular DEV Posts from the Past Week
Tags: top7
Published: 2019-04-02 11:43:39

---
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/sfwcvweirpf2qka2lg2b.png
---
This is a round up of last week's top posts based on traffic, engagement, and a hint of editorial curation. The typical week starts on Monday and ends on Sunday, but don't worry, we take into account posts that are published later in the week. ❤️

#1. Starting From Zero

Ali explains what computers are and teaches us some programming fundamentals. This is the perfect post to forward to all your friends Interested In Programming or anyone who is curious about what programmers do!

{% link https://dev.to/aspittel/a-complete-beginner-s-guide-to-programming-2ni4 %}

#2. "Dust Off Your Ternary Expressions"

Andrew shares a collection of terse solutions -- which is your favorite?! 

{% link https://dev.to/healeycodes/javascript-one-liners-that-make-me-excited-56aj %}

#3. Story Time

Nikita shares their approach to writing user stories. Their post discusses everything from the default user story format to behavior driven development to how it all ties together with tests, source code, and documentation.

{% link https://dev.to/wemake-services/engineering-guide-to-writing-correct-user-stories-1i7f %}

#4. Secure Your Server

Vitaliy's server was hacked. In this post, they share what they did to research, clean, and secure their server. 

{% link https://dev.to/vkolesov/how-to-protect-your-server-from-hackers-4j6l %}

#5. Simple To Start

All you need to know to get started with Cube.js, an open source framework for building analytical web applications. 

{% link https://dev.to/cubejs/cube-js-the-open-source-dashboard-framework-ultimate-guide-53be %}

#6. Git Mastery

Fifteen git tricks that'll help you along your coding journey. Did you know all of these?!

{% link https://dev.to/zaiste/15-git-commands-you-may-not-know-4a8j %}

#7. Freebies

Who doesn't love a good listicle? Sarthak shares a list of awesome dev resources they've discovered in the past month. 

{% link https://dev.to/teamxenox/-ultra-list-one-list-to-rule-them-all-march-19-4p4f %}


_That's it for our weekly wrap up! 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!_
JetBrains gave me 1 year license for all products
Tags: opensource, vue, discuss
Published: 2019-04-02 11:35:14

---
title: JetBrains gave me 1 year license for all products
published: true
description: JetBrains gave me 1 year license for all products
tags: opensource, vue, discuss
---

A week ago I chatted to colleague about JetBrains products. We tolked about this and that. And then the colleague told me: do you know that JetBrains give an annual license if you are an open source developer?

I didn't know about this opportunity. It getting interesting :) I read in the requirements that for the approval of the application is necessary to have the project more than 3 months old and it has to be in active development. I filled out the form indicating:

{% github antonreshetov/mysigmail %}

and sent it.

A few days later I received a reply in which I got approved 1 year license for all products. I was delighted!

It's great that the big company support open source development.

Try your luck!
Pushing Left, Like a Boss! -- Part 2: Security Requirements
Tags: tutorial, beginners, security, requirements
Published: 2019-04-02 08:57:39

---
title: Pushing Left, Like a Boss! -- Part 2: Security Requirements
published: true
description: Part 2 of the "Pushing Left, Like a Boss" series discusses security requirements for software development projects.
series: Pushing Left Like a Boss
tags: tutorial, beginners, security, requirements
---
###This series, and my blog, have moved! [Check it out](https://wehackpurple.com/pushing-left-like-a-boss-part-2-security-requirements/)!

In the previous article in this series we discussed why ensuring the security of software is an elusive task; application security is hard to achieve with how the InfoSec and software development industries and education system(s) currently work. We talked about the importance of starting security actives early in the SDLC and formalizing them as part of your process. But what ARE these actives? How do they work, and when do we do what? That, dear reader, is what this article is about.

As you recall from the previous article, the system development life cycle generally looks like the image below:

![The System Development Life Cycle - SDLC](https://thepracticaldev.s3.amazonaws.com/i/y02hdgzvifmhra9nppqq.png)

####System Development Life Cycle (SDLC)

Whether you are doing Agile, Waterfall, or if you have a DevOps culture at your office, you always need to know what you are building (requirements), you need a plan (design), you need to code it (the fun part), testing is obviously a must, and then you release it out into the wild (hopefully you also maintain and monitor it as well, which is all part of the “release” phase). Each one of these phases should involve security activities. Let’s look a little deeper, shall we?



###[Read the rest on my NEW blog!](https://wehackpurple.com/pushing-left-like-a-boss-part-2-security-requirements/)!
Serverless and SPA, a perfect match in heaven
Tags: serverless, spa, javascript
Published: 2019-04-02 08:43:14

---
title: Serverless and SPA, a perfect match in heaven
published: true
description: Serverless and SPA, a perfect match in heaven
tags: serverless, spa, javascript
---

Recently, Next.JS V8 allows you to build each endpoint into a serverless function.
It's one of the coolest thing that happens to frontend team.

Now, they not only can split frontend in a SPA, they can split backends, too.

NextJS was and is truly an inspiration. 

What can frameworks learn from it ?

Now you know, let's just kill the big, monothlic backend server. And please, please seriously split it for fun and profit.

2019 will be a big milestone in technology for us, universal developers.

I'm happy for this transition, and how about you ?