teleren/devto huggingface dataset:
What’s your alternative solution? Challenge #24
Tags: challenge, javascript, codenewbie, learntocode
Published: 2020-04-16 21:03:53

# About this series

This is series of daily JavaScript coding challenges... for both beginners and advanced users.

Each day I’m gone present you a very simple coding challenge, together with the solution. The solution is intentionally written in a didactic way using classic JavaScript syntax in order to be accessible to coders of all levels.

Solutions are designed with increase level of complexity.

## Today’s coding challenge

```
Reverse an array

```

(scroll down for solution)

## Code newbies

If you are a code newbie, try to work on the solution on your own. After you finish it, or if you need help, please consult the provided solution.

## Advanced developers

Please provide alternative solutions in the comments below. 

You can solve it using functional concepts or solve it using a different algorithm... or just solve it using the latest ES innovations.

By providing a new solution you can show code newbies different ways to solve the same problem.

## Solution

```javascript
// Solution for challenge22

var ar = [1, 2, 3];
var ar2 = reverseArray(ar);
println(ar2);

function reverseArray(ar)
{
    var ar2 = [];
    
    for(var i = ar.length - 1; i >= 0; i--)
    {
        ar2.push(ar[i]);
    }
    
    return ar2;
}

```


To quickly verify this solution, copy the code above in this coding [editor](https://codeguppy.com/code.html) and press "Run".

> Note: The solution was originally designed for [codeguppy.com](https://codeguppy.com) environment, and therefore is making use of `println`. This is the almost equivalent of `console.log` in other environments. Please feel free to use your preferred coding playground / environment when implementing your solution.
Constants & Variables: SSTNPL's new Integer Constants
Tags: ternary, sstnpl, tutorial
Published: 2020-04-16 20:35:46

---
title: Constants & Variables: SSTNPL's new Integer Constants
published: true
description: We look at SSTNPL's new constants, and how they can be used.
tags: ternary,sstnpl,tutorial
---

# Part 1: SSTNPL Integer background

SSTNPL _(A Programming Language for my Balanced Ternary VM: SBTCVM)_, f has always had integer variables, as they were part of its original design. creating & using integer variables in SSTNPL is easy enough:

```
#create 3 variables using: decimal, ternary, & a character value.
var bob=@11
var bob2=*+0-
var bob3=:L
#dump the decimal values of each variable to SBTCVM's Terminal
dumpd bob
dumpd bob2
dumpd bob3
```
# Part 2: The Integer Literal Syntax

However, we can also just use SSTNPL's 'literal' syntax, that's supported on most integer input arguments:

```
#same as above, just using the 'literal' syntax
dumpd @11
dumpd *+0-
dumpd :L
```
# Part 3: The builtin constants

Whats changed in SSTNPL, is the introduction of a special, forth 'literal' syntax: the constant. Currently, SSTNPL has 2 of them builtin:

```
#$true=1, $false=0
dumpd $true
dumpd $false
```

# Part 4: Use a custom constant to store a module's version number.

while there are still some holes _(you can't use constants in var & val statements yet for example)_, We can use constants to provide static values that when not used, don't use up Memory:

for example, in an SSTNPL module called 'bob':
```
const version=@15
```
That way we could write an SSTNPL program like this:
```
#print version of bob module
prline Bob version:
dumpd $b.version

#wait for keystroke, then power-off the VM
keyprompt
stop

include bob as b
```

# Conclusion

While SSTNPL & SBTCVM are still _technically_ in alpha, and aren't that useful for practical purposes, I've put a lot of work into both, & hope others find programming a Balanced Ternary VM as interesting as I do.

SBTCVM Gen2-9 On github: https://github.com/SBTCVM/SBTCVM-Gen2-9
SSTNPL Language docs: https://github.com/SBTCVM/SBTCVM-Gen2-9/tree/master/textdocs/SSTNPL
Vue 3.0 Beta released
Tags: vue
Published: 2020-04-16 20:02:15

Today the Vue Team released the beta for the 3.0 version, you can check out the release changelog here:

https://github.com/vuejs/vue-next/releases/tag/v3.0.0-beta.1

Note: Evan remarked to don't use this version in production or critical apps yet!

{% twitter 1250875642830303233 %}
Explain Standard and Quirks Mode.
Tags: html, webdev, todayilearned, codenewbie
Published: 2020-04-16 19:50:07

*This post first appeared on [hackinbits.com](https://hackinbits.com/practice/html-interview-questions/explain-standard-and-quirks-mode).*

In the old days, pages were written separately for supporting different browsers. It means that if you were developing a website in the early days of the internet, you would have written code separately for chrome and firefox. 

To solve this problem, standards were developed by W3C but browsers could not have started supporting the new standards at once as it would have broken most of the websites at that time. Therefore, different rendering modes were developed for supporting new standard-compliant sites as well as old legacy sites.

Layout Engine now uses three different rendering modes in web browsers:

- **Quirks modes:** Layout emulates non-standard behavior as supported by old browsers.
- **Almost standard modes:** A small number of quirks/old behavior are supported while rendering the layout.
- **Full standard modes:** Layout emulates standard behavior as described by HTML and CSS specifications.
How to back-up Postgres database on Linux using cronjob
Tags: devops, programming, linux, cronjob
Published: 2020-04-18 16:52:17

---
title: How to back-up Postgres database on Linux using cronjob
published: true
date: 2020-04-16 19:49:22 UTC
tags: DevOps, programming, linux, cronjob
canonical_url: https://boobo94.xyz/devops/back-up-postgres-linux-cronjob/?utm_source=rss&utm_medium=rss&utm_campaign=back-up-postgres-linux-cronjob
---

Learn how to backup Postgres database on Linux, using cronjobs. Very simple and very straight forward guide step by step using only scripts.

1. Make new .pgpass file in the root folder

```
$ vi .pgpass
```

And paste the content from `/root/.pgpass`

1. Create new file `/root/pg_backup.sh` and paste the content
2. Change permissions

```
$ chmod 700 /root/pg_backup.sh
```

1. Add new cron

```
$ crontab -e
```

Add at the end of the file the content:

```
0 0 * * * /root/pg_backup.sh
```

## .pgpass

```
localhost:5432:DATABASE:USER:PASSWORD
```

## pg\_backup.sh

```
#!/bin/bash
# This script will backup the postgresql database
# and store it in a specified directory

# Constants

USER="user_name_of_db"
DATABASE="name"
HOST="localhost"
BACKUP_DIRECTORY="/root/backup_db"

# Date stamp (formated YYYYMMDD)
# just used in file name
CURRENT_DATE=$(date "+%Y%m%d")
 
# Database named (command line argument) use pg_dump for targed backup
pg_dump -U $USER $DATABASE -h $HOST | gzip - > $BACKUP_DIRECTORY/$DATABASE\_$CURRENT_DATE.sql.gz

# Cleanup old backups

find $BACKUP_DIRECTORY/* -mtime +7 -exec rm {} \;
```

The post [How to back-up Postgres database on Linux using cronjob](https://boobo94.xyz/devops/back-up-postgres-linux-cronjob/) appeared first on [boobo94](https://boobo94.xyz).
The difference between block and inline elements
Tags: todayilearned, html, 100daysofcode, codenewbie
Published: 2020-04-16 19:46:12

I work for [Feldroy](https://www.feldroy.com/), which is a cool little tech company. My job is Director of Customer Success and while I don't code yet, I want to learn. This is the beginning of my journey to become a programmer. I am learning HTML since it might be useful in my job. This is something I learned from my first lesson in [Mozilla's HTML class](https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Getting_started). 

So, in my job, I use Slack a lot. What I realized was that when I want to highlight part of a single line, I use single backticks. This would be an `inline` element as the lesson described. To highlight a number of sentences, I use three backticks and it puts a `block` around the text. 

Examples:

In this `example`, the word "example" is decorated with an inline element.

```
In this example, the entire sentence is in a block element.
```
What I realized after I completed the lesson, was that I had already been using a version of block and inline elements! How cool!
What is the purpose of the <main> tag in HTML?
Tags: html, webdev, todayilearned
Published: 2020-04-16 19:45:05

*This post first appeared on [hackinbits.com](https://hackinbits.com/practice/html-interview-questions/what-is-the-purpose-of-the-main-tag-in-html).*

> The main element represents the main content of the body of a document or application. -w3c

The <main> tag in HTML represents the central topic or core content of the document body. It is a semantic and structural element introduced in HTML5.

```html
<body>
  <!-- Other content such as header, nav -->
  <main>
    <!-- main content of the document body -->
  </main>
  <!-- Other content such as footer -->
</body>
```

The <main> element is also useful for screen readers to skip the navigation and other irrelevant content and jump directly to the core content of the document.

**A document should only contain a single \<main\> element.**
What is the purpose of <!DOCTYPE html> at starting of an HTML document?
Tags: html, webdev, todayilearned
Published: 2020-04-16 19:40:08

*This post is first published on [hackinbits.com](https://hackinbits.com/practice/html-interview-questions/what-is-the-purpose-of-doctype-html-at-starting-of-an-html-document).*

Doctype is required in HTML document for legacy reasons. Its main purpose is to prevent the browser from entering 'Quirks Mode' while rendering the document.

Including the DOCTYPE in a document ensures that the browser makes the best-effort to follow standard specifications. The doctype should be included at the beginning of the HTML document as shown in the example, below.

```html
<!DOCTYPE html>
<html>
  <head>
    <title>Including Doctype in HTML Document</title>
  </head>
  <body>
    <h1>
      Including Doctype in HTML Document
    </h1>
    <p>
      Welcome to hackinbits.com
    </p>
   </body>
</html>
```

> In HTML5, Doctype's only purpose is to activate the full standard mode.
Run Java tests against the Firestore emulator
Tags: firestore, java, firebase
Published: 2020-04-16 19:39:35

It's not widely documented how to do this, right? You have a test suite that you want to run against Firestore emulator, which should get started and stopped automatically while the tests are running. In this case, we will be using Java.

Connecting to local Firestore is quite straightforward, though poorly documented:

```Java
var options = FirestoreOptions.getDefaultInstance()
  .toBuilder()
  .setProjectId("my_project_id");
var firestoreUrl = System.getenv("FIRESTORE_URL");
if (!Strings.isNullOrEmpty(firestoreUrl) {
  options.setHost(firestoreUrl);
  options.setCredentialsProvider(null);
} else {
  options.setCredentials(GoogleCredentials.getApplicationDefault());
}
Firestore instance = options.build().getService();
```

This will connect Firestore to your local environment if you pass an environment variable named `FIRESTORE_URL`, and if not defined it will try to connect to the real service using the default Service Account for Compute Engine (if the code is running on a CI/CD environment, or just fail noisily if it's your local laptop). You can configure gradle to launch the emulator before your tests.

**bin/start-firestore-emulator** will launch the emulator on port 9000:

```bash
#!/bin/bash
# Launch firestore emulator on port 9000

waitport() {
  while ! nc -z localhost $1; do 
    sleep 1 
  done
}

PID=$(lsof -t -i :9000 -s tcp:LISTEN)
if [ -z "$PID" ]; then
  echo "Starting mock Firestore server on port 9000"
  nohup gcloud beta emulators firestore start \
    --host-port=127.0.0.1:9000 \
    > /tmp/mock-firestore-logs &
  waitport 9000
else
  echo "There is an instance of Firestore already running on port 9000"
fi
```

**bin/stop-firestore-emulator** will kill whatever is running on port 9000, so better it be your emulator:

```bash
#!/bin/bash
# Stop mock firestore 

PID=$(lsof -t -i :9000 -s tcp:LISTEN)
if [ ! -z "$PID" ]; then
  echo "Stopping mock Firestore server"
  kill "$PID"
fi
```

These two scripts will start and stop Firestore locally on port 9000. Now we need to trigger them before and after launching our tests in **build.gradle**:

```groovy
task startMockFirestore {
  doFirst {
    ext.process = new ProcessBuilder()
      .directory(projectDir)
      .inheritIO()
      .command("bin/start-firestore-emulator")
      .start()
      .waitFor()
    }
}
tasks.test.dependsOn(startMockFirestore)

task stopMockFirestore(type: Exec) {
  executable "bin/stop-firestore-emulator"
}
test.finalizedBy(stopMockFirestore)
```

As bonus points, IntelliJ will automatically use these tasks when launching individual tests, which is nice. One last note: remember that the Firestore emulator will not persist anything between executions – once you kill the server, you lose the data.

Hope this is useful! For more tips on testing, code and cute animal pictures, follow us [on Twitter](https://twitter.com/koliseoapi).

(Photo courtesy of [Phil Hearing](https://unsplash.com/photos/YbT8wrbPMug) on Unsplash)
Placeholder title
Tags: twiliohackathon
Published: 2020-04-16 19:34:57

[Comment]: # (All of this is placeholder text. Use this format or any other format of your choosing to best describe your project.)

[Reminder]: # (Make sure you've submitted the Twilio CodeExchange agreement: https://ahoy.twilio.com/code-exchange-community)

[Important]: # (By making a submission, you agree to the competition's terms: https://www.twilio.com/legal/twilio-dev-hackathon-terms)


## What I built
#### Category Submission: 


## Demo Link
 

## Link to Code


## How I built it (what's the stack? did I run into issues or discover something new along the way?)


## Additional Resources/Info
Admin page coming along, but still looking.
Tags: wordpress, php, career
Published: 2020-04-16 19:31:03

Hey everyone,

I am creating a WordPress theme and want show what I have done so far. I already have the design mock of the theme so I decided to work on the backend portion. I am working on the Advanced admin page for personal information that will work in a sidebar and shows a preview in the admin section. 

[Check it out](https://i.imgur.com/FOLdes3.png)

Have if work ahead of me with this theme, trying to find a job, school work, and overall family matters. 

On that note,

If anyone has any remote job suggestions for an intermediate Frontend, UI Dev, Web Developer/Designer with a small amount of experience let me know. Even internships are cool. Just trying to get more experience and not feel like an impostor. 

Merci beaucoup!
How to get started with VIM efficiently!
Tags: vim
Published: 2020-04-16 19:23:43

First, open your terminal app. If you are on MacOS, I highly recommend using [iTerm2](https://www.iterm2.com/).

Then, type the *vimtutor* command.

```bash
vimtutor
```

Finally, start reading and follow the instructions.

vimtutor has 7 lessons. Try to complete at least 2 lessons a day.

That's all!
What style have you picked up from another developer that you are still using?
Tags: styleguide, javascript, productivity
Published: 2020-04-16 19:06:02

Good coding style is like correct punctuation: you can manage without it, butitsuremakesthingseasiertoread. – The Tidyverse Style Guide by Hadley Wickham

What style have you picked up from another developer that you are still using?


I picked up a style for renaming a thing that I want to archive such as a file, a folder, a database file, etc.


This pattern is zxYYYYMMDD_name

it starts with zx so that when I order the list alphabetically it will always appear at the bottom.


Yes, I have been brainwashed, so now everything I manually archive starts off that way.


------------------------

For example, I have an Oracle MySQL database called example_db that I want to make major changes. Before I mess with it I copy it, then label the copy.


zx20200416_example_db

--------------------------------
Chances are that if you have ever asked me to help you with code and I have had to touch your files, you have seen me do this. 

And another thing: how often do you randomly read style guides on the internet to improve the quality of your code?

Here are some fun ones:
Google JavaScript Style Guide: https://google.github.io/styleguide/jsguide.html#file-name

Sql Style Guide : https://www.sqlstyle.guide/

 #codingstorytime
Do not use CFMailPart "WrapText" with HTML
Tags: coldfusion, cfml
Published: 2020-04-16 17:46:07

We encountered a strange issue this week where client-provided HTML wasn't being displayed consistently in all email clients. Some of the received message text was being displayed incorrectly, but it appeared correct when previewed prior to being sent.

After reviewing their HTML and experimenting with a global email handler that we've used for years, we determined it was due to using a `WRAPTEXT` parameter on the [CFMailPart](https://cfdocs.org/cfmailpart) tag.  One example was an inline CSS rule that used the font "Times Roman". The wraptext option would occasionally insert a line break in the midst of the font name due to the context-insensitive wordwrap logic.

I'm not sure if this is a bug, but it seems like one. (I've reported it. [Bug CF-4208015](https://tracker.adobe.com/#/view/CF-4208015)) We've used this parameter for years under the assumption that it would correctly wrap long HTML to ensure that it's compliant.  We incorrectly assumed that adding `wraptext="900"` would help ensure that long HTML lines would be safely wrapped.  I'm pretty sure that this was tested a one point in the past, but we've been using Coldfusion since v3 and we keep discovering built-in functions behaving a little differently (ie, incorrectly) in newer versions.

> The Internet Message Format RFC [5322](http://www.rfc-editor.org/rfc/rfc5322.txt)
> **_2.1.1. Line Length Limits_**
> There are two limits that this standard places on the number of characters in a line. Each line of characters MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF.

## Comparison of Generated HTML Screenshot

Here's what the resultant HTML looks like when delivered to a Gmail address. _(NOTE: The right-side is supposed to indicate "900 characters".  I used the VSCode [Render Line Endings](https://marketplace.visualstudio.com/items?itemName=medo64.render-crlf) extension so that the end-of-line characters would be visible.)_

![CFMailPart using WrapText parameter](https://dev-to-uploads.s3.amazonaws.com/i/nlp1zpsqtx2prs3o1wq9.png)

## Solution / Work-Around

The MailPart tag should probably be updated to ignore the `wraptext` parameter if the type is "HTML".  Since it's not ignoring the value and using it negatively impacts the resultant HTML, we highly recommend checking your CFML code to ensure that this option is not used for HTML content within the CFMAILPART tag.

```html
<!--- HTML wrapped correctly; short 76 character lines delimited with "=" --->
<cfmailpart type="html" charset="utf-8">#myHTML#</cfmailpart>

<!--- HTML wrapped incorrectly; long ~900 character lines --->
<cfmailpart type="html" wraptext="900" charset="utf-8">#myHTML#</cfmailpart>
```
Unconventional hobbies during quarantine!
Tags: hobbies, fun, quarantine
Published: 2020-04-16 18:52:54

# With the world on lockdown:
* Comment something (***unconventional***) worth learning/exploring/killing-time **(non-dev related)**:
  * Origami
  * Card stacking
  * Type racing
  * ...


######Note:
* I will try to keep this list as up-to date as possible with comments below :+1:
Day 6 - 100 days of Coding - Vs Code Extension - add restart feature
Tags: 100daysofcode, javascript, learning, vscode
Published: 2020-04-16 18:48:22

---
title: Day 6 - 100 days of Coding - Vs Code Extension - add restart feature 
published: true
description: A simple Pomodoro Timer extension for VS Code built using Javascript
tags: #100daysofcode, #JavaScript, #Learning, #vscode
cover_image: https://github.com/ganeshraja10/static_files/raw/master/6.jpeg
series: 100 Days of Code
---
So it's day 6 of 100 days of coding

## Today's Objectives
####   1)Add Restart Functionality
####   2)Update the Format of the Data


### Add Restart Functionality
To do this, I added a new command that will call the storeDate Method to make sure it stores the Data into File if it's a restarting Pomodoro.
Then it resets the value to default. Later it moves to the Start Timer Method to trigger new Pomodoro

```javascript
  restartTimer() {
    if (this.tick >= 0) this.storeStatusToFile(); //Update File with Previous Pomodo Data
    this.resetPomodoTimer();
    this.startTimer();
  }
```
### Update the Format of the Data
Here we store the ISO String of Date & time the Pomodoro was started. If it's fully completed. We trigger completed. Else store as canceled

```javascript

  storeStatusToFile() {
    let status = this.tick <= 0 && this.currentAction == POMODO_TIMER ? COMPLETED : CANCELED;
    let data = [this.startedTime.toISOString(), status].join(",");
    fs.appendFile(this.fileName, data + "\n", (err) => console.log(err));
  }
```

Tomorrow I will be working on custom values for the PomodoTimer. 

You can check the full code in my repo [simple-pomodoro-timer](https://github.com/ganeshraja10/simple-pomodoro-timer)
How to Create Requirement Traceability Matrix?
Tags: testing, webdev, beginners, tutorial
Published: 2020-04-16 18:34:53

In this tutorial, We are going to learn about the Requirement Traceability Matrix, what is it and Why we need the requirement traceability matrix.

➡️ RTM is usually referred to as the Requirement Traceability Matrix.

It a matrix that gives a clear idea about
requirements and test cases relation. In simple words, it is mapping of the requirement, test cases, defects in the simple document.

There are about two types of traceability matrix

- Forward traceability matrix
- Backward traceability matrix
- Bi-directional matrix.

> In Forward Traceability Matrix, We have a single direction related to the requirement to test cases.
e.g What requirements are mapped to test cases in left in the right direction.

``` Whereas in backward traceability, we have left to right, the relation of test cases to requirement direction relation. ```

> Good requirement traceability is when we have both ways of relation with each other, knows as bi-directional traceability matrix.

[![Requirement Traceability Matrix )
](https://i.imgur.com/km1ehU9.png)](https://youtu.be/A1rF0BhcddQ "Requirement Traceability Matrix ")

> 👉 You can download the Sample Requirement t traceability matrix at 
https://bit.ly/rtm-templte.

👉 Learn Software Testing Concepts:  https://scrolltest.com
🙏 Learn Cypress Tutorial:  https://cypresstutorial.com.
👔 Learn API Testing: https://www.learnapitesting.com
👮🏻‍♀️ Automation Tester Training: https://thetestingacademy.com

--
Be sure to subscribe for more videos like this!

[![ TheTestingAcademy](https://dev-to-uploads.s3.amazonaws.com/i/r7vcy6wbvyjbk1y1uu0o.png
)](https://www.youtube.com/TheTestingAcademy?sub_confirmation=1 "TheTestingAcademy")