teleren/devto huggingface dataset:
Perl tips I wish I knew as a beginner
Tags: perl, beginners
Published: 2020-12-09 23:10:35

I think the hard part with Perl and other languages, is setting up your environment. As you do more Perl you realize there are better ways to do things that aren't straight forward when you first began the journey.

**Disclaimer:** I use Linux and this will be on a Linux environment, BUT with WSL on windows and with homebrew on mac.

# System Perl and User Perl
On Linux, we have a system Perl. It's great to have but we don't want to mess with it. Lets keep the system Perl for the system. We want a user environment and you really must do this, its way better. We have two tools we can pick from that make it easy to get started.

[Plenv](https://github.com/tokuhirom/plenv) and [Perlbrew](https://perlbrew.pl/). *I started on Perlbrew and moved over to Plenv.*

Plenv allows you to make it so each project you work on has a .plenv file and you can specify the Perl version you want.

Look at the two links, pick one and set it up, pick a perl version and install it. Verify it works with `perl -v`.

You want to install cpanminus.
`plenv install-cpanm` <--plenv
`cpan App-cpanminus`

You are now off system Perl and on your user Perl, its awesome. Cpanminus is installed and you can now install Perl modules for your project.

# The [cpanfile](https://metacpan.org/pod/distribution/Module-CPANfile/lib/cpanfile.pod)
In your project you want to make a cpanfile. Cpanfiles contain a list of Perl modules.

As your project grows, add in the modules to the cpanfile. When you need to distribute it, you can use the below command to install the dependencies. Makes life easier for everyone.
`cpanm --installdeps .`

# [Carton](https://metacpan.org/pod/Carton)
"Perl module dependency manager (aka Bundler for Perl)"
Carton is awesome, with plenv its even more awesome.

This is stolen from metacpan pod:
```perl 
# On your development environment
> cat cpanfile
requires 'Plack', '0.9980';
requires 'Starman', '0.2000';
 
> carton install
> git add cpanfile cpanfile.snapshot
> git commit -m "add Plack and Starman"
 
# Other developer's machine, or on a deployment box
> carton install
> carton exec starman -p 8080 myapp.psgi
```

# [VSCode](https://code.visualstudio.com/)
Before vscode came out, I was living in PHPStorm with a Perl plugin, it worked but it was only okay. Code is awesome with all its plugins, once you get code up, browse the perl plugins. One you will want to have is perltidy and you'll need a `.perltidyrc` in your project, you can find examples on the web, but here is Mojolicoius [perltidyrc](https://github.com/mojolicious/mojo/blob/master/.perltidyrc). I use that one.

This should get you started with Perl.
Who can explain this deceptively simple destructuring assignment?
Tags: javascript, node
Published: 2020-12-10 02:43:53

**Code**
```javascript
var a
[a] = [2]
console.log("a->",a)

var b = {}
[b] = [3]
console.log("b->",b)
```

**Output**
```
a-> 2
b-> [ 3 ]
```

Why is the second output different? How is the assignment working?

Thanks
Array methods: findIndex
Tags: javascript, node, tutorial, programming
Published: 2020-12-10 02:40:07

The **findIndex** receives a function (predicate) that accepts three arguments and returns a value that is coercible to the Boolean value true or false.

The predicate returns true. If such an element is found, findIndex immediately returns the index of the first element value. Otherwise, findIndex returns -1, indicating that no element passed the test.

```
const array = [
    {name: 'Freddy', age: 10}, 
    {name: 'Francisco', age: 3}, 
    {name: 'Emilia', age: 4}
];

const preschoolerIndex = array.findIndex(kid => kid.age < 5);

console.log(preschoolerIndex);
// 1

```

### Parameters

1. **callback**
Testing function to execute on each value in the array, taking 3 arguments:
> **element**
The current element in the array.
 **index** (Optional)
The index (position) of the current element in the array.
 **array** (Optional)
The array that _find_ was called on.

2. **thisArg** (Optional)
Object to use as this inside callback.


The findIndex function is intentionally generic; it does not require that its this value be an Array object. Therefore it can be transferred to other kinds of objects for use as a method.
DWMBackup.sh
Published: 2020-12-10 01:53:26

```
#!/bin/bash                                                                                                                                                 
#
# Daily/Weekly/Monthly Backup
#
PROG_NAME=DWMBackup
source=/etc
dest=/usr/local/backup
DAYOFWEEK_NAME=$(date +"%a")
DAYOFWEEK_NUMERAL_WEEKLY=$(date +"%u")
DAYOFWEEK_NUMERAL_MONTHLY=$(date +"%d")
 
logger Started -t$PROG_NAME $(date "+%m-%d-%Y %r")
 

# Daily Backup START
############################
rsync -avPbu $source/ $dest/Daily/ 2>&1
logger Daily REDBackup Completed -t$PROG_NAME $(date "+%m-%d-%Y %r")
 
# Weekly Sunday Backup START
############################
if [ $DAYOFWEEK_NUMERAL_WEEKLY == 7 ]
then
    rsync -avH --delete --link-dest=$dest/Daily/ $source/ $dest/Weekly/ 2>&1
    logger Weekly REDBackup Completed -t$PROG_NAME $(date "+%m-%d-%Y %r")
fi

# Monthly Backup START
############################
if [ $DAYOFWEEK_NUMERAL_MONTHLY == 1 ]
then
    rsync -avH --delete --link-dest=$dest/Daily/ $source/ $dest/Monthly/ 2>&1
    logger Monthly REDBackup Completed -t$PROG_NAME $(date "+%m-%d-%Y %r")

fi

```
Maven
Published: 2020-12-10 01:17:46

*Official Reference: https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html*

### New a Maven project
```bash
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false
```

### Clean up target folder (build folder)
```bash
mvn clean
```

### Compile the source
```bash
mvn compile
```

### Compile and Pack the compiled source
```bash
mvn package
```

### Test the package
```bash
java -cp target/lt-vaadin-components-1.0-SNAPSHOT.jar <FULL_CLASS_NAME_WITH_PACKAGE>
```

### Install local JAR to local Maven repository
```bash
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version>
```
How to pass an English front end interview
Tags: react, redux, css
Published: 2020-12-10 01:15:16

# here is my situation :
- I am a Chinese front end developer 
- I've worked in China for 7years (major in REACTJS),use my native language Chinese 
- Now I am working in Tokyo Japan for a tiny Chinese-owned Japanese company ,use Chinese 
- I can't speak Japanese 
- My English looks not that bad ,I was in a toeic test(listing and reading ) last Sunday ,and maybe I can get a goal like 800.but I am totally not sure about my oral English ability ,plus ,for some development words,I just know how express in Chinese ,not English ,will that be a problem ?
- I don't like the company and the work environment I'm working for now 

# here is my problem 
- Should I look for a job in English ?
- Or can I even pass a job interview in English  ?
 ## is there anyone who have the similar experience can tell me what to do ,or someone who can help me have a mock-interview in English .

Lastly I'm in Tokyo ,glad to make friends
S3E8 Learn JMeter Series - While Controller
Tags: performance, testing, tutorial, webperf
Published: 2020-12-10 01:13:33

Welcome to Learn JMeter Series!

In this Season 3, Episode 8, you will learn following:

🔹 While Controller

{% youtube h1kQ_g6G1dM %}

☑ Buy me a tea 🍵 : https://www.buymeacoffee.com/qainsights
☑ [My Blog](https://qainsights.com)
☑ [My Udemy Course](https://www.udemy.com/course/performance-testing-using-truweb)

{% github QAInsights/Learn-JMeter-Series%}
Is having 2 jobs worth it? 
Tags: career
Published: 2020-12-10 01:02:54

I've been working the last two years in this insurance company, on the dev department. It was been rough, but full of experiences. 

Now I've been thinking to get a second job, it would be a lot of money, even though I'll be saving the second salary. 

I like the idea of the challenge, but, how is that, do I have to say goodbye to my personal time?
Environment variables in Next.js and Netlify
Tags: nextjs, netlify, blogvent
Published: 2020-12-11 00:32:13

---
title: Environment variables in Next.js and Netlify
published: true
date: 2020-12-10 00:00:00 UTC
tags: nextjs, netlify, blogvent
canonical_url: https://www.netlify.com/blog/2020/12/10/environment-variables-in-next.js-and-netlify/
---

Welcome to Blogvent, day 10!

If you’d like to use environment variables in Next.js, make a `.env.local` file at the root and you can use them all there! It might look something like this:

```bash
// .env.local
SITE_URL=localhost
SITE_KEY=hahabusiness
```

That being said, these variables are only exposed to the Node.js environment like this, not the browser. If you want to use them, you’ll have to use them only in your API routes, or in the data fetching methods like `getStaticProps` in your page components. For example, it might look like this:

```jsx
// pages/index.js

export default function Home(props) {
  return (
    // ...
  )
}

// ...

export async function getStaticProps() {
  const siteData = await someService({
  	  url: process.env.SITE_URL,
    key: process.env.SITE_KEY
  })
  // ...
}
```

If you want your environment variables to be exposed to the browser and be usable in your client-facing components, in your `.env.local` you have to prefix the variable with `NEXT_PUBLIC_`.

```bash
// .env.local
SITE_URL=localhost
SITE_KEY=hahabusiness
NEXT_PUBLIC_PAYMENT_TOKEN=thisispublic // this one is exposed to the browser
```

## Setting environment variables in the Netlify UI

When you’ve deployed your site, you can set your environment variables in the Netlify UI. Head over to the Build & Deploy settings in your Site Settings, and then plug your values in under “Environment variables”:

![Environment Variables in the UI](https://www.netlify.com/img/blog/envnext.png "Environment Variables in the UI")

You can also [use the Netlify CLI](https://docs.netlify.com/cli/get-started/#link-with-an-environment-variable) to use environment variables set in the UI (or even set them from the CLI, too)!

## Is there more?

There’s always more! There’s _so many_ things that you can do with environment variables on Netlify. Here’s some useful docs and guides for how to take full advantage of them:

- [Build environment variables](https://docs.netlify.com/configure-builds/environment-variables/?utm_source=blog&utm_medium=envvars-cs&utm_campaign=devex)
- [Build settings in netlify.toml](https://docs.netlify.com/configure-builds/file-based-configuration/#build-settings?utm_source=blog&utm_medium=envvartoml-cs&utm_campaign=devex)
- [Example of environment variables in use in Next.js](https://github.com/cassidoo/next-adventure/blob/master/functions/get-character.js#L21-L24)
Null Conditional Operator for fallback images
Tags: csharp
Published: 2020-12-11 08:50:35

---
title: Null Conditional Operator for fallback images
published: true
date: 2020-12-10 00:00:00 UTC
tags: csharp
canonical_url: https://www.owain.codes/blog/posts/2020/december/null-conditional-operator-for-fallback-images/
---
![Generic Header image](https://dev-to-uploads.s3.amazonaws.com/i/4t1vobhcjaccdaulmf89.jpg)

Last night when working on my new version of [Owain.Codes](https://www.owain.codes) I managed to blow up the site. 

The reason? 

I hadn't put an image in to the CMS and when I rendered out the image or the lack of an image on the front end, I got a null exception error.

I started to write a bit of code to handle this which looked a bit like

```
@if(Model.Image.Url() == null)
{
  set default image as fallback.jpg
}
else{
  use the image from the CMS
}
```

But then I thought, there must be a nicer way to handle fallbacks, and I believe I have found that nicer option and its by using the [Null Conditional Operator](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/member-access-operators#null-conditional-operators--and-)

So I am now using:

```
 var blogImage = Model.PageBanner?.Url() ?? "assets/images/noImage.jpg";
```

So if the `Model.PageBanner` is null, give me the noImage.jpg fall back string, else give me the `Model.PageBanner.Url()`. I then use the variable blogImage on my page.

I now don't need to worry about whether I set an image for a blog or not. Either way I will have an image on my page.
How to get the full HTML of a website using the fetch() method in JavaScript?
Tags: javascript
Published: 2020-12-10 00:00:00

---
  title: How to get the full HTML of a website using the fetch() method in JavaScript?
  published: true
  tags: JavaScript
  date: Thu Dec 10 2020 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/get-full-html-of-website-using-fetch-javascript
  cover_image: https://melvingeorge.me/_next/static/images/main-d563ed72bec8277214243fa14265237e.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/get-full-html-of-website-using-fetch-javascript)
  
```js
/* Get full HTML from website using fetch() */
fetch(url)
  .then((res) => res.text())
  .then((html) => console.log(html));
```

Let's say we want to get the full HTML document of website `https://google.com`.

```js
// URL
const url = "https://google.com";
```

First of all, We can use the `fetch()` method and pass the `url` as the first argument to the method like this,

```js
// URL
const url = "https://google.com";

// pass url to fetch() method
fetch(url);
```

Since the `fetch()` method returns a [Promise](https://melvingeorge.me/blog/promises-javascript), we can attach a `then()` handler so that when the Promise resolves `then()` handler will be executed and will be passed the buffer response obtained from the website.

Now, this is where we need to convert the buffer response into text so that we can view the HTML as plain text. For that we can use the `text()` method on the response object passed to the `then()` handler.

It can be done like this,

```js
// URL
const url = "https://google.com";

// pass url to fetch() method
// attach a then() handler
fetch(url).then((res) => {
  return res.text(); // using the text() method on the response
});
```

After converting our responce we can attach one more `then()` handler to view the HTML plain text like this,

```js
// URL
const url = "https://google.com";

// pass url to fetch() method
// attach a then() handler
fetch(url)
  .then((res) => {
    return res.text();
  })
  .then((html) => {
    console.log(html); // We will get our converted HTML plain text
  });
```

See this example live in [repl.it](https://repl.it/@melvin2016/Get-full-HTML-from-website-using-fetch).

After getting the HTML plain text, you can do cool stuff like scraping the HTML DOM for data using packages like [cheerio](https://github.com/cheeriojs/cheerio), [Native DOMParser](https://developer.mozilla.org/en-US/docs/Web/API/DOMParser), etc.

### Feel free to share if you found this useful 😃.

---
Downloading your Favorite YouTube Playlist Automatically
Published: 2021-01-12 14:52:49

---
title: Downloading your Favorite YouTube Playlist Automatically
published: true
date: 2020-12-10 00:00:00 UTC
tags: 
canonical_url: https://joshghent.com/youtube-playlist-downloader/
---

In light of Youtube-DL being taken down from GitHub, I decided to give it a go with a use case I happened to have.

Lately, I’ve been listening to lots of concerts/festival sets that are not available for traditional purchase. Although I have listened to them on youtube, I didn’t want to have the webpage open and the auto-play/queuing features are not as fledged out as a proper music player.

I decided to write a quick script that I could run in a cron to pull down the latest version of the playlist I maintain. To keep an eye on it, I included a Slack webhook notification that let’s me know when the playlist has been downloaded.

My first version worked but I quickly realised that the script did not handle updates, only a complete re-download. To resolve this, youtube-dl has a `--download-archive` flag that keeps track of downloaded videos.

Check out the code below and hopefully you find it useful.

```
#!/bin/bash

playlist_url="https://www.youtube.com/playlist?list=ZZZ"

cd ~/Projects/music

youtube-dl --embed-thumbnail --download-archive downloaded.txt --no-post-overwrites --extract-audio --audio-quality 0 --format bestaudio --audio-format mp3 --yes-playlist --output "%(title)s-%(id)s.%(ext)s" $playlist_url

curl -X POST --data-urlencode "payload={\"username\": \"youtubeb0t\", \"text\": \"Completed download of all Music playlist.\", \"icon_emoji\": \":tv:\"}" https://hooks.slack.com/services/ZZZ/YYY
```
How to Repeat the Last Command in Linux
Tags: linux, cli
Published: 2021-03-10 12:58:49

---
title: How to Repeat the Last Command in Linux
published: true
date: 2020-12-10 00:00:00 UTC
tags: linux, cli
canonical_url: https://tech.serhatteker.com/post/2020-12/repeat-last-command-in-linux/
---

You made a *typo* on your command or you got the error `XXX : Permisson denied`.

How will you repeat your last command?

If you are a **Vim** user like me — `h, j, k, l` is the way and hands should be always on the home row, or just don't want to use default `arrow` key to get last command, there is an useful command to execute your last command; just
type:

```bash
$ !!
```

then press `CR | Enter`.

In order to execute your previous command with `sudo` privilege just run:

```bash
$ sudo !!
```

All done!
My first open source library
Tags: java, opensource, webdev, programming
Published: 2020-12-09 23:23:36

I've been working on my first open source java library and few days ago I finished it! It took me around 3 weeks to make it.

It's a library that makes it easy to access Spotify's Web API and fetch all sorts of data within minutes.

You can find the library [here](https://github.com/jzheng2017/spotify-web-api-wrapper)

I've also tried to write some documentation to explain how to use this library.

Please check it out. I'm a third year university student, so I'm still learning, so any feedback is welcome!
Day 273 : Morning Sunrise
Tags: hiphop, code, coding, lifelongdev
Published: 2020-12-09 23:10:22

_liner notes_:
- Professional : Got up early to attend a talk prep session. Got to see the morning sunrise. It was so cold. haha Today was the last day of the conference I was covering. Got to talk to a couple of people and see what they are doing. Helped out on a question a developer was having on our community Slack. Did a pull request for some updates I did to the documentation. Not a bad day at all.

- Personal : Last night, I added some code to my https://otech.events that will archive the livestreams. After that, I watched "Legion" then went to sleep.

![View of mountain ranges from a green field with red and yellow flowers in Wallowa, OR, United States at sunset.](https://dev-to-uploads.s3.amazonaws.com/i/epxux5diagitleolapli.jpg)

So I added a callback / webhook URL to the API so that I can know when the archive is ready to be downloaded. Going to test that out tonight and get that working. Once that is working, I'll maybe go through some tracks for this week's radio show and watch more "Legion".

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube ylHBdhYm-ZE %}
Laravel Cryptocurrency Website
Published: 2020-12-09 23:09:36

Hello guys,im building cool laravel project based on cryptocurrency.If anyone have DOGECOIN please send me some coins,i need it for testing.I dont need soo much,actually i need less then 0.5$ :"D .Website dogecoin address is : A6bNRHrneRLAj4zBMVkt2jZAQ3BQgLBhc1

And take a look how front of welcomepage looks like,its stunning ^_^
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ub0c1zbqvw9xuvy4e0r8.png)
In JS how do you know the right condition to use inside your for loop?
Tags: javascript
Published: 2020-12-09 23:09:03

I'm new to JavaScript and I've been struggling with iterating with for loops. 

The early classes were easy to understand when the condition was simply i < 9 or i > 9. 

The issue I have now is knowing when to use conditions like i < arr.length for example. 

Many times when I do JS challenges and check the solution for challenges I fail, I see these type of conditions and I don't know why one condition is used instead of another. 

Can anyone help me out with this, please?
How I learn
Tags: 100daystooffload
Published: 2020-12-07 22:48:56

It's fair to say that I have an interest in a broad range of topics. It's also fair to say that I don't like to dive down into the detail of any one of them. To find out about something I'm slightly interested in, I'll read the introduction, see some examples and follow a tutorial if it's available. If the tool, language or technology is well documented, I'll usually feel like I know enough about it to have a go at making something. Of course at that point everything falls apart.

## Reading isn't enough

I am quite a fast reader. My job involves reading a lot, and over the years I have developed my ability to scan a document when looking for something specific. Usually, because I understand the subject of what I am reading, I don't need to process every detail that is written to have a good idea of what's going on.

When I read something that is less well known to me (e.g. most of the world of software development), I still read with the confidence that I have with other material. But when it comes to actually trying to _use_ that information, I quickly fail.

This experience was highlighted to me at the weekend when I committed to completing a working version of a Svelte app I had been messing around with. Despite reading a lot, watching a lot, following tutorials and so on, when it came to knowing what to do for myself, I struggled a lot.

## I learn by doing

I had a frustrating time. There were so many aspects I wanted to use and had already played with, but trying to put them together in a way that worked _and_ that did something that I had only the vaguest idea of was a struggle. However, by stripping the project back to its most basic, I was able to focus on one problem at a time. By doing this, not only could I spend more time understanding what was going on, but I benefited from many small (tiny) achievements rather than waiting for one big success.

By the end of the weekend, I had a very simple application that I could run and, more importantly, that I _understood_. I followed this achievement by implementing some tooling to make my development process a bit easier, looking at good practice for git commits, linting etc.

## I learn slowly

Not only to I need to make something in order to really start to understand it, it takes me a very long time. I think this is more to do with wanting to do many things and being impatient than anything else. A learning capacity problem: I can't manage learning Svelte (and therefore JavaScript and/or TypeScript), Tailwind CSS (and design ideas in general), API design, CI principles, etc all at the same time, despite being interested in it all. But if I can focus on one thing at a time, I should hopefully be able to get there.

_I'm publishing this as part of 100 Days to Offload. You can join in yourself by visiting [https://100daystooffload.com.](https://100daystooffload.com)_
Wiprecation
Tags: tdd, testing, webdev
Published: 2020-12-09 22:43:49

🚧 Work in progress

**Wiprecation**: documenting that new code is not ready yet when [Branching by Abstraction](https://paulhammant.com/blog/branch_by_abstraction.html), or using [TCR](https://medium.com/@kentbeck_7670/test-commit-revert-870bbd756864) or Timeboxed TDD.