teleren/devto huggingface dataset:
How to Use Bash to Write a Simple Script
Tags: linux, bash
Published: 2021-05-29 14:37:50

Bash is a Unix shell used in Linux and MacOS. We will be using a bash script to make a program that runs in the background. 

You need to know how to open a terminal in your operating system. On Ubuntu, you can press Ctrl+Alt+t . On Mac, you can press Command+Space, then type Terminal and press Enter.

To make bash scripts, you should know Linux commands. To practice the command line, you can use [this site](https://practicelinux.com/)


## What is a bash script?

A Bash script is a text file containing a series of Bash commands. When the file is executed, the commands are executed in sequence as they appear in the text file.

To get started, you can create a new script called my_script.sh. 

A simple script would be:

```
echo "Hello World"
```

Make it executable with the command:

```
chmod +x my_script.sh
```

This script will run when you enter the following command:

```
./my_script.sh
```

You can always stop the script by pressing Ctrl+C.

Any bash [command](https://bsdnerds.org/what-is-linux-shell/) can be inside your bash script. Besides commands, the scripting language also supports for loops and if statements. Variables can be used too.

### Variables

A bash variable is a variable, that stores string values.

For example the following code prints the contents of the variable "friend"

```bash
echo $friend
```

To change the value of a bash variable we use the '=' (or the s equal operator).

For example, to change the value of "user" to "john" we write: user="john"

```bash
user="john"
echo $user
```

### If statements

If statements are a simple tool for logic in bash. If statements can be used in bash.

The syntax is:

```bash
if [ -z "$1" ]; then
fi
```

For example, if your script should only execute the echo hello world command if the script was run on a Mac, you could use the following syntax:

```bash
if [[ $OSTYPE == *"Mac OS X"* ]]; then
echo hello world
fi
```

### For loops

This lets you repeat code. See the following code:

```bash
#!/usr/bin/env bash
for i in {1..10}; do
echo "hello, world $i"
done
```

If you run this program, then it will produce the following output:

```bash
$ ./my_script_with_for.sh
hello, world 1
hello, world 2
hello, world 3
hello, world 4
hello, world 5
hello, world 6
hello, world 7
hello, world 8
hello, world 9
hello, world 10
```

By using the “for” command, you can do something in a loop.
Javascript call(), apply(), bind()
Tags: javascript
Published: 2021-05-29 14:26:02

If you’ve ever Googled Javascript interview questions, you’ve probably come across questions asking the interviewee to discuss the differences between Javascript’s call, apply, and bind functions.

At a first glance, these seem to be very confusing, but if you take the time to really study them, they’re pretty easy to understand.

Before we get started discussing the differences between call, apply, and bind, I’d like to give a shoutout to a course called JavaScript: The Advanced Concepts (2021). The lessons here really helped me increase my Javascript knowledge.

Call, apply, and bind are all centered around the ‘this’ keyword. I’ll write a more in-depth article covering the ‘this’ keyword in Javascript at later date, but you can just remember that ‘this’ refers to the object that calls the function with the ‘this’ keyword.

You might have code that looks like the following.
```javascript
let person = {
  age: 30,
  name: "Josh"
}

person.greet = function() {
  console.log(`My name is ${this.name}.`)

}


person.greet();
```
This would output: “My name is Josh.”

But what if you wanted to call that function, but use something else for ‘this’?

That’s where call and apply come in.

Let’s change our code a bit and add another person so our code looks like the following.
```javascript
let josh = {
  age: 30,
  name: "Josh"
}
 
josh.greet = function() {
  console.log(`My name is ${this.name}.`)
}
 
let frank = {
  age: 25,
  name: "Frank"
}
```
We can “hijack” the greet function from josh and let frank use it by using call or apply.
```javascript
josh.greet.call(frank);

josh.greet.apply(frank);
```
Both of these log “My name is Frank.”

Bind is very similar, but it’s used to store a function and then call at a later time.
```javascript
let frankGreeting = josh.greet.bind(frank);

frankGreeting();
```
We can pass arguments to these if we want. Let’s revise the main function we’re working with to the following.
```javascript
josh.greet = function(lastName) {
   console.log(`My name is ${this.name} ${lastName}.`);
}
```
We can use the call function like this.
```javascript
josh.greet.call(frank, "smith");
```
Or, if we want to use apply, we use an array for the arguments:
```javascript
josh.greet.apply(frank, ["smith"]);
```
And bind works similarly.
```javascript
let frankGreeting = josh.greet.bind(frank);

frankGreeting("Smith");
```
And that’s how call, apply, and bind work in Javascript! I think it’s pretty easy to wrap your head around when you break it down like this.

If you want to learn more about web development, make sure to [follow me on Twitter](https://twitter.com/heyjoshlee).
We are DKFM - Making DevOps things that make DevOps things easier
Tags: devops, automation, tools, cicd
Published: 2021-05-29 14:25:33

DevOps, DevSecOps, Rainbow Monkey Unicorn Pony, it really doesn't matter what you call it but one thing is certain - every one of these practices relies on innovative tooling to shift quality issues left to developers. Innovation is something I needed to turn to as a Security Architect many years ago as I built and deployed DevSecOps practices to a few Fortune 10 healthcare organizations.

When I met Julio Jimenez @juliojimenez we struck up a great friendship built on a shared vision of developing tools that would blur the line between Security and DevOps. We became [Essentialists](https://www.amazon.com/Essentialism-Disciplined-Pursuit-Greg-McKeown/dp/0804137382) and adopted the mantra that security is just an attribute of quality. With that, we focused on developing tools that improve the quality of the code we built.

After Dan Walsh joined DKFM we had our core team and our Open Source collective started gaining industry attention from the tools we were building. Dan brought the business savvy, leadership, product direction, and more Essentialism to our team.

## Dropping the Code Hammer

Now that our core team was put together,Julio and I migrated a number of personal repositories we had been working on for the past few years to our new GitHub organization we named [DKFM](https://github.com/devops-kung-fu). 

The first project we worked on together as DKFM was [SHS](https://github.com/devops-kung-fu/shs), which is a tool that calculates a risk score based on vulnerabilities in source code and infrastructure and presents in the format of a credit score.

Our second project was [domi](https://github.com/devops-kung-fu/domi). domi is one of our flagship codebases. It is a policy-as-code enforcer that analyzes infrastructure as code and configuration for policy violations. It integrates with GitHub and uses [Open Policy Agent](https://www.openpolicyagent.org/) and [conftest](https://github.com/open-policy-agent/conftest) to validate code on a Pull Request.

Other projects followed such as [gardener](https://github.com/devops-kung-fu/gardener) which generates images in markdown from [PlantUML](https://plantuml.com) diagrams, [Hookz](https://github.com/devops-kung-fu/hookz) which generates local action pipelines as git hooks that execute when interacting with the git command, and [Hinge](https://github.com/devops-kung-fu/hinge) that builds dependabot.yaml files for any codebase that is used by GitHub's Dependabot supply chain scanning product. We've started or are working actively on many other projects. All to make DevOps things that make DevOps easier.

## Join the Movement
As an open source collective **anyone** can join DKFM. All you need to do is contribute to any of our [DKFM](https://github.com/devops-kung-fu) projects on GitHub. 

Come and help us make tools that shift left, integrate security as an attribute of quality, and lead by example with  Essentialism and innovation.
JavaScript Data Structures and Algorithms (Search Algorithms, Part 1)
Tags: datastructures, trees, algorithms, javascript
Published: 2021-07-10 20:09:28

---
title: JavaScript Data Structures and Algorithms (Search Algorithms, Part 1)
published: true
date: 2021-05-29 14:25:14 UTC
tags: datastructures,trees,algorithms,javascript
canonical_url: https://medium.com/codex/javascript-algorithms-and-data-structures-search-algorithms-part-1-8270911d5f84
---

[![](https://cdn-images-1.medium.com/max/2600/0*9hnurGbxBf1P4QRM)](https://medium.com/codex/javascript-algorithms-and-data-structures-search-algorithms-part-1-8270911d5f84?source=rss-be00f566a88f------2)

Hello! Today I would like to review what I’ve learned about search algorithms and the importance of each one in computer programming. I’ve…

[Continue reading on CodeX »](https://medium.com/codex/javascript-algorithms-and-data-structures-search-algorithms-part-1-8270911d5f84?source=rss-be00f566a88f------2)
vim vs. emacs
Tags: vim, linux
Published: 2021-05-29 14:05:56

[Vim](https://www.vim.org/) and [emacs](https://www.gnu.org/software/emacs/) are two of the most popular text editors in the world. They are very different, with a different design philosophy.

Vim and Emacs are still used to this day and are both great choices :grin:

Vim's main advantage is that it is very good at being a text editor and that you can do a lot without having to learn anything new.

You can install plugins, change key mappings, etc. either with the builtin scripting language or by sourcing scripts from your .vimrc .

Emacs is a text editor but more than that. It can be used for email, browsing the internet and a lot more.

## What is vim?

Vim is a modal editor. It operates in either the insert mode (where keystrokes are entered and text is composed) or the command mode (where text can be moved and modified). 

It is not until you exit command mode and return to the default, or "normal" mode that the text you have typed will appear on screen :computer:

Entering command mode is simple: hit the esc key. Esc takes you back to normal mode and whatever you typed in command mode will be executed. 

Most of the commands have a corresponding control key, so for example the command to move the cursor forward one word is `w`. 

To practice vim you can use [this site](https://vim.is)

![vim editor](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xbbrkth3q1bxwxcc4pee.gif)

## What is emacs?

The emacs editor is very user friendly and easy to pick up especially if you have used other graphical user interfaces (such as those used on Windows and Mac) before using it. 

It includes a very handy feature called auto-completion. This allows you to start typing a command and the editor will automatically complete it for you after pressing the tab key a couple times.

![emacs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kd70zjostvq7o0yzhd9r.jpeg)

## My choice

I’m a vim user. I used to use emacs but moved to vim a couple years ago. I can never go back. My reasons for switching were:

* Vi/Vim is always installed or available on computers
* In emacs, the keys are not contiguous. In vim, they are.
* In emacs, the keys are not in alphabetical order. In vim, they are.
* I like all my commands to be on a single keystroke (or two). You can get there with a key-chord, but why?
* Vim is minimalist. I want a program to do one thing (Text editing), not be also an email client, browser etc

Both support keyboard macros, which saves a lot of time. 

The design of vim is very simple and extremely efficient, but also very different from what you may expect: there are no appeals to common sense! 

For example, instead of having buttons that say "cut" and "copy", you're expected to remember that "d" means "delete".

That may seem strange, but once you get used to it, you never want to go back.
Why should you switch to a static portfolio website?
Tags: webdev, codenewbie, beginners, devjournal
Published: 2021-05-29 14:04:45

This is often the question I get from people whenever I told them that my website is static, made of HTML/CSS/JS only.

A few years ago, I had a portfolio website where I was showing off my web dev skills and show potential recruiters that I can create a website with complex technical stacks. I was using Django, VueJS, and NuxtJS to achieve the perfect portfolio and to brag about it during my interview.

The problem was that it was incredibly difficult to upgrade since the project was quite complex and I was suffering from a lack of motivation because I had to struggle with server-rendering, routing and it was just way too complex for a simple portfolio. I also needed a pipeline for my GitLab to deploy automatically my website when the build succeeded. 

## Simpler technical stack, same results

Most of the people think that because my website is not using any back-end, it looks like a basic HTML page and I got stuck in 1995 with my website.

The reality is that my website has even more features now that it is static.🤯

Let's compare my old and new technical stacks:

As I said previously I was using VueJS / NuxtJS / Django (and GitLab).
Now I'm using tools that have tighter integration with each other for a more maintainable result.

What I am using now:
VueJS -> Bulma.io for building my front-end. It's a very simple, minimalist front-end library, a successor to the era of Bootstrap, it was just enough for what needed to be done.
Django -> 11ty - My back-end became a static site generator (SSG) since I  found it way easier to manage routing and the little amount of logic that I had on my website.
GitLab -> Netlify for deploying my website, Netlify can fetch, and deploy my website for free, with no pipeline configuration and after 2 minutes I had my website launched.

NuxtJS was simply removed since there was no necessity for it anymore.

## What's the benefit?

The benefit is mainly maintainability, it can also be a financial benefit if, like me, you were hosting your website on a VPS or dedicated server, where I can now post it directly on Github Pages and save 60 bucks per year. 

After refactoring my website so it can be fully static, I manage to create a static blog with little or no effort by integrating Netlify CMS, it allowed me to create an easily customizable administrator panel to manage blog posts and all the generated content of my website.
If you were like me, using the Django admin panel, it's the perfect replacement, and when updating a blog post, it directly updates your GitHub repository.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dqu20y2idzsqdjpxismq.png)

## Conclusion

Updating your website can be difficult and painful depending on your technical stack.
You may want to keep a complex technical stack if your website should operate with APIs or have a complex business logic but if this isn't the case, you may want to consider using a static site generator such as 11ty, Jekyll, or Hugo to create easy to maintain and easy to manage websites.
Diving into Object Detection Basics
Tags: aipool, ai, objectdetection, computervision
Published: 2021-05-29 13:57:47

### Intro
The prospects of Artificial Intelligence (AI) are not just limited to predicting if a person will get a loan or not by giving his credit history, annual income, annual expenses, criminal records, etc. Computer Vision is a trending topic for AI enthusiasts of any experience level.

Let me give you a brief idea about Computer Vision. It is nothing but when a machine identifies an 'object' in an image/video after learning from the data that was fed to it. For example, when we see an object first time, we are mostly aware of it like what it is called. But after getting to know its name, the next time we see it we know exactly what it is. Exactly like our brain, Computer Vision, to be specific Object Detection works.

![intro](https://files.ai-pool.com/a/bcdb850b5e8c7f7082ca5f4857aa6a55.undefined)

### Introduction of Object Detection
Object detection is locating and identifying an object in an image or in a video. Locating an object is nothing but giving the exact position where the object resides in the frame. (Here frame can be a single image or a sequence of frames that is a video). To locate an object, we can either use a bounding box or any other geometrical shape like a circle. The easiest and standard approach is by using the bounding box, where we first obtain the center coordinates (x, y) and the width (w) and height (h) of the box.

To identify an object, the network must be trained on data, for example, images of the person. This step is called the classification of objects and it is very essential for the bounding box to be formed correctly. To ensure the correct training of the network, ensure the data is correct.

![image](https://files.ai-pool.com/a/c933f0514293b8447bb725da690d7eb1.undefined)

### Anchor Boxes
How does the network predict or identify the box?

The network first makes a random guess of the coordinates and assigns them a value w for width and h for height. It assigns (0, 0) for the center of the box (x, y). Of course, this is not the actual prediction. So after every step of training, which is termed as an iteration, the network performs regression to get the correct estimates.

### Datasets to start with
There are many datasets to start training your first object detection model. These datasets are open source meaning anyone is free to use them. These datasets have a large collection of classes of objects to choose from. So have fun while exploring these datasets

* COCO Dataset
* ImageNet
* Open Image Dataset V6
* Labelme
* CelebFaces
* 50 other datasets

You can find more in the [Following Article](https://ai-pool.com/a/s/diving-into-object-detection-basics)

### Other Resources
* [Dropout in Deep Learning](https://ai-pool.com/a/s/dropout-in-deep-learning)
* [Normalization in Deep learning](https://ai-pool.com/a/s/normalization-in-deep-learning)
* [Yolov3 and Yolov4 in Object Detection](https://ai-pool.com/a/s/yolov3-and-yolov4-in-object-detection)
* [How can I find the paper of yolov5?](https://ai-pool.com/d/how-can-i-find-the-paper-of-yolov5)
gpg command examples
Tags: linux, security
Published: 2021-05-29 13:39:07

[gpg](https://gnupg.org/) is a program to encrypt and decrypt files. In other words, it is a program for privacy and security.

Your data is safe if you store it on gpg (i.e. encrypted).
Your data is not safe if you don't encrypt it with gpg (i.e. not encrypted).

So why would you expose your secret information to the threat of being stolen by leaking it to a computer disk?

The only reason is ignorance, because encryption is easy and saves you effort and money in the long run.

Tools like gpg make encryption as easy as saving a file, or even easier.

gpg linux will help you encrypt your e-mails or to encrypt files on your disk so that nobody else can read them without knowing the decryption password which you alone know.

If you are new to the linux command line, you can [practice here](https://www.practicelinux.com/)

## What is encryption?

Encryption is a method for obscuring electronic data from those who should not see it. 

Encrypted data is unreadable by anyone without special knowledge, often referred to as a ‘key’. With most encryption systems, the key needed to decrypt the data is unique to the individual user.

You can use gpg with a single private key or with a key pair.

The gpg program works with separate keys which are required for reading as well as writing. 

The **public key** which is used for reading is distributed in ways that allow others to know that it really belongs to the person named in the user certificate. 

The **private key** must be kept secret, so it is typically stored on a smartcard or similar device.

![sec](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bj8ffyl9vvc5l844rssw.gif)

## What can gpg do?

gpg is a program to encrypt and decrypt files.
gpg is intended to be correctly and completely OpenPGP compliant.

The main features of gpg are:

* Encrypting and decrypting files with the OpenPGP file format.
* Full integration with OpenLDAP and other applications.
* Key generation (prime generation, digest calculation), import/export of keys,
* Creation of revocation certificates, batch key signing, change passphrases,
* Powers for saving private and public keys on smartcards and importing public keys from smartcards.
* Symmetric encryption of data and special files.

![gpg logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cwh47pf3613865kzq4ic.png)

## Symmetric encrpytion

Encrypt a file with a password 

```bash
gpg -c [file]
```

Decrypt a file

```bash
gpg -d [file]
```

## Asymmetric encryption

If you want to use public/private key pairs instead.

Generate a new key pair 

```bash
gpg --gen-key
```

Encrypt a file to a recipient 

```bash
gpg -e -r [recipient key] [file]
```

List keys in local keychain 	

```bash
gpg --list
```

There are also some gui alternatives to [encryption](https://bsdnerds.org/How-to-encrypt-decrypt-files-in-Linux/)  that you can use in your file manager.
GitUI - v0.16 supports merging!
Tags: github, terminal, productivity, rust
Published: 2021-05-29 13:21:45

[GitUI](https://github.com/extrawurst/gitui) is a terminal UI for git written in Rust. We aim to simplify common git tasks in a fast, keyboard-only and cross platform way without leaving your beloved command line.

# Release Highlights

* merge branch, commit merge ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hhcrcjqimfd6n292i8g7.gif)
* list and manage all your tags ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zjoogd35nl2wk3ckt78v.gif)
* file browser (incl. syntax highlighting) ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b453xw804odetiaqzvn3.gif)
* [much more](https://github.com/extrawurst/gitui/releases/tag/v0.16.0)

Thanks for your interest and support!❤️